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.

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