const navigationBarHeight = (getApp().statusBarHeight + 44) + 'px' const Http = require("../../utils/HttpBasics"); const config = require("../../config/config"); let app = getApp(); Page({ /** * 页面的初始数据 */ data: { navigationBarHeight, activityStyle: '',//选中当前日历样式 hideFlag:false,//遮罩成 childUrl: config.api.signDey, continueSign:'',//连续签到天数 signInDay:'',//0能签到 1是不能签到 rules:[],//积分规则 rewardPoints:"",//记录签到后的奖励积分 }, getSignRule(){//查询签到规则 Http.get({ url: config.api.signRule }).then(res=>{ let {code ,data}=res if(code==200){ let tempArr = [] JSON.parse(data.rules).map(item=>{ if (item.id == 17 || item.id == 18 || item.id == 19 || item.id == 20){ tempArr.push(item) } }) if (this.data.continueSign>=7){ tempArr[1].activity=1 if (this.data.continueSign >= 14){ tempArr[2].activity = 1 if (tempArr[1].activity >= 28){ tempArr[3].activity = 1 } } } this.setData({ rules: tempArr }) } }) }, setContinuousDye(){//获取连续签到天数 Http.get({ url: config.api.continuousDye }).then(res=>{ let{code ,data}=res if(code==200){ this.setData({ continueSign: data.continueSign, signInDay: data.signInDay }) } }) }, setHide(){//设置遮罩成 this.setData({ hideFlag:!this.data.hideFlag }) }, setSign(){//点击签到 Http.post({ url: config.api.userSign, data:{type:"1"} }).then(res=>{ let{code}=res if(code==200){ this.setData({ rewardPoints: res.data.credit }) this.setContinuousDye() this.setHide() } }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.setContinuousDye() this.getSignRule() }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })