C端小程序
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

192 Zeilen
3.9 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: 1, //0能签到 1是不能签到
  16. rules: [], //积分规则
  17. rewardPoints: "", //记录签到后的奖励积分
  18. },
  19. getSignRule() { //查询签到规则
  20. Http.get({
  21. url: config.api.signRule
  22. }).then(res => {
  23. let {
  24. code,
  25. data
  26. } = res
  27. if (code == 200) {
  28. let tempArr = []
  29. JSON.parse(data.rules).map(item => {
  30. if (item.id == 17 || item.id == 18 || item.id == 19 || item.id == 20) {
  31. tempArr.push(item)
  32. }
  33. })
  34. // if (tempArr[0].score == 0 && tempArr[1].score == 0 && tempArr[2].score == 0 && tempArr[3].score == 0) {
  35. // this.setData({
  36. // signInDay: 1
  37. // })
  38. // }
  39. if (this.data.continueSign >= 7) {
  40. tempArr[1].activity = 1
  41. if (this.data.continueSign >= 14) {
  42. tempArr[2].activity = 1
  43. if (this.data.continueSign >= 28) {
  44. tempArr[3].activity = 1
  45. }
  46. }
  47. }
  48. console.log(tempArr, "tempArr")
  49. this.setData({
  50. rules: tempArr
  51. })
  52. }
  53. }).catch(err => {
  54. wx.showToast({
  55. title: err.errMsg,
  56. icon: 'none',
  57. duration: 2000,
  58. mask: false
  59. });
  60. })
  61. },
  62. setContinuousDye() { //获取连续签到天数
  63. Http.get({
  64. url: config.api.continuousDye
  65. }).then(res => {
  66. let {
  67. code,
  68. data
  69. } = res
  70. if (code == 200) {
  71. this.setData({
  72. continueSign: data.continueSign,
  73. signInDay: data.signInDay
  74. })
  75. }
  76. }).catch(err => {
  77. if (err.code == 1989) {
  78. app.globalData.type = "qd"
  79. wx.navigateTo({
  80. url: '/pages/getuserinfo/index',
  81. })
  82. }else{
  83. wx.showToast({
  84. title: err.errMsg,
  85. icon: 'none',
  86. duration: 2000,
  87. mask: false
  88. });
  89. }
  90. })
  91. // .catch(err => {
  92. // wx.showToast({
  93. // title: err.errMsg,
  94. // icon: 'none',
  95. // duration: 2000,
  96. // mask: false
  97. // });
  98. // })
  99. },
  100. setHide() { //设置遮罩成
  101. this.setData({
  102. hideFlag: !this.data.hideFlag
  103. })
  104. },
  105. setSign() { //点击签到
  106. Http.post({
  107. url: config.api.userSign,
  108. data: {
  109. type: "1"
  110. }
  111. }).then(res => {
  112. let {
  113. code
  114. } = res
  115. if (code == 200) {
  116. this.setData({
  117. rewardPoints: res.data.credit
  118. })
  119. this.setContinuousDye()
  120. this.getSignRule()
  121. this.setHide()
  122. }
  123. }).catch(err => {
  124. wx.showToast({
  125. title: err.errMsg,
  126. icon: 'none',
  127. duration: 2000,
  128. mask: false
  129. });
  130. })
  131. },
  132. /**
  133. * 生命周期函数--监听页面加载
  134. */
  135. onLoad: function(options) {
  136. this.setContinuousDye()
  137. this.getSignRule()
  138. },
  139. /**
  140. * 生命周期函数--监听页面初次渲染完成
  141. */
  142. onReady: function() {
  143. },
  144. /**
  145. * 生命周期函数--监听页面显示
  146. */
  147. onShow: function() {
  148. },
  149. /**
  150. * 生命周期函数--监听页面隐藏
  151. */
  152. onHide: function() {
  153. },
  154. /**
  155. * 生命周期函数--监听页面卸载
  156. */
  157. onUnload: function() {
  158. },
  159. /**
  160. * 页面相关事件处理函数--监听用户下拉动作
  161. */
  162. onPullDownRefresh: function() {
  163. },
  164. /**
  165. * 页面上拉触底事件的处理函数
  166. */
  167. onReachBottom: function() {
  168. },
  169. /**
  170. * 用户点击右上角分享
  171. */
  172. // onShareAppMessage: function() {
  173. // }
  174. })