C端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

134 lines
2.6 KiB

  1. const navigationBarHeight = (getApp().statusBarHeight + 44) + 'px'
  2. const Http = require("../../utils/HttpBasics");
  3. const config = require("../../config/config");
  4. let app = getApp();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. navigationBarHeight,
  11. activityStyle: '',//选中当前日历样式
  12. hideFlag:false,//遮罩成
  13. childUrl: config.api.signDey,
  14. continueSign:'',//连续签到天数
  15. signInDay:'',//0能签到 1是不能签到
  16. rules:[],//积分规则
  17. },
  18. getSignRule(){//查询签到规则
  19. Http.get({
  20. url: config.api.signRule
  21. }).then(res=>{
  22. let {code ,data}=res
  23. if(code==200){
  24. let tempArr = []
  25. JSON.parse(data.rules).map(item=>{
  26. if (item.id == 17 || item.id == 18 || item.id == 19 || item.id == 20){
  27. tempArr.push(item)
  28. }
  29. if (this.data.continueSign>7){
  30. tempArr[1].activity=1
  31. if (this.data.continueSign > 14){
  32. tempArr[2].activity = 1
  33. if (tempArr[1].activity = 28){
  34. tempArr[3].activity = 1
  35. }
  36. }
  37. }
  38. })
  39. this.setData({
  40. rules: tempArr
  41. })
  42. }
  43. })
  44. },
  45. setContinuousDye(){//获取连续签到天数
  46. Http.get({
  47. url: config.api.continuousDye
  48. }).then(res=>{
  49. let{code ,data}=res
  50. if(code==200){
  51. this.setData({
  52. continueSign: data.continueSign,
  53. signInDay: data.signInDay
  54. })
  55. }
  56. })
  57. },
  58. setHide(){//设置遮罩成
  59. this.setData({
  60. hideFlag:!this.data.hideFlag
  61. })
  62. },
  63. setSign(){//点击签到
  64. Http.post({
  65. url: config.api.userSign,
  66. data:{type:"1"}
  67. }).then(res=>{
  68. let{code}=res
  69. if(code==200){
  70. this.setContinuousDye()
  71. this.setHide()
  72. }
  73. })
  74. },
  75. /**
  76. * 生命周期函数--监听页面加载
  77. */
  78. onLoad: function (options) {
  79. this.setContinuousDye()
  80. this.getSignRule()
  81. },
  82. /**
  83. * 生命周期函数--监听页面初次渲染完成
  84. */
  85. onReady: function () {
  86. },
  87. /**
  88. * 生命周期函数--监听页面显示
  89. */
  90. onShow: function () {
  91. },
  92. /**
  93. * 生命周期函数--监听页面隐藏
  94. */
  95. onHide: function () {
  96. },
  97. /**
  98. * 生命周期函数--监听页面卸载
  99. */
  100. onUnload: function () {
  101. },
  102. /**
  103. * 页面相关事件处理函数--监听用户下拉动作
  104. */
  105. onPullDownRefresh: function () {
  106. },
  107. /**
  108. * 页面上拉触底事件的处理函数
  109. */
  110. onReachBottom: function () {
  111. },
  112. /**
  113. * 用户点击右上角分享
  114. */
  115. onShareAppMessage: function () {
  116. }
  117. })