C端小程序
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

138 wiersze
2.7 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. rewardPoints:"",//记录签到后的奖励积分
  18. },
  19. getSignRule(){//查询签到规则
  20. Http.get({
  21. url: config.api.signRule
  22. }).then(res=>{
  23. let {code ,data}=res
  24. if(code==200){
  25. let tempArr = []
  26. JSON.parse(data.rules).map(item=>{
  27. if (item.id == 17 || item.id == 18 || item.id == 19 || item.id == 20){
  28. tempArr.push(item)
  29. }
  30. })
  31. if (this.data.continueSign>=7){
  32. tempArr[1].activity=1
  33. if (this.data.continueSign >= 14){
  34. tempArr[2].activity = 1
  35. if (tempArr[1].activity >= 28){
  36. tempArr[3].activity = 1
  37. }
  38. }
  39. }
  40. this.setData({
  41. rules: tempArr
  42. })
  43. }
  44. })
  45. },
  46. setContinuousDye(){//获取连续签到天数
  47. Http.get({
  48. url: config.api.continuousDye
  49. }).then(res=>{
  50. let{code ,data}=res
  51. if(code==200){
  52. this.setData({
  53. continueSign: data.continueSign,
  54. signInDay: data.signInDay
  55. })
  56. }
  57. })
  58. },
  59. setHide(){//设置遮罩成
  60. this.setData({
  61. hideFlag:!this.data.hideFlag
  62. })
  63. },
  64. setSign(){//点击签到
  65. Http.post({
  66. url: config.api.userSign,
  67. data:{type:"1"}
  68. }).then(res=>{
  69. let{code}=res
  70. if(code==200){
  71. this.setData({
  72. rewardPoints: res.data.credit
  73. })
  74. this.setContinuousDye()
  75. this.setHide()
  76. }
  77. })
  78. },
  79. /**
  80. * 生命周期函数--监听页面加载
  81. */
  82. onLoad: function (options) {
  83. this.setContinuousDye()
  84. this.getSignRule()
  85. },
  86. /**
  87. * 生命周期函数--监听页面初次渲染完成
  88. */
  89. onReady: function () {
  90. },
  91. /**
  92. * 生命周期函数--监听页面显示
  93. */
  94. onShow: function () {
  95. },
  96. /**
  97. * 生命周期函数--监听页面隐藏
  98. */
  99. onHide: function () {
  100. },
  101. /**
  102. * 生命周期函数--监听页面卸载
  103. */
  104. onUnload: function () {
  105. },
  106. /**
  107. * 页面相关事件处理函数--监听用户下拉动作
  108. */
  109. onPullDownRefresh: function () {
  110. },
  111. /**
  112. * 页面上拉触底事件的处理函数
  113. */
  114. onReachBottom: function () {
  115. },
  116. /**
  117. * 用户点击右上角分享
  118. */
  119. onShareAppMessage: function () {
  120. }
  121. })