|
- 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: 1, //0能签到 1是不能签到
- rules: [], //积分规则
- rewardPoints: "", //记录签到后的奖励积分
- isPhone: false
- },
- 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 (tempArr[0].score == 0 && tempArr[1].score == 0 && tempArr[2].score == 0 && tempArr[3].score == 0) {
- // this.setData({
- // signInDay: 1
- // })
- // }
- if (this.data.continueSign >= 7) {
- tempArr[1].activity = 1
- if (this.data.continueSign >= 14) {
- tempArr[2].activity = 1
- if (this.data.continueSign >= 28) {
- tempArr[3].activity = 1
- }
- }
- }
- console.log(tempArr, "tempArr")
- this.setData({
- rules: tempArr
- })
- }
- }).catch(err => {
- wx.showToast({
- title: err.errMsg,
- icon: 'none',
- duration: 2000,
- mask: false
- });
- })
- },
- setContinuousDye() { //获取连续签到天数
- const that = this
- Http.get({
- url: config.api.continuousDye
- }).then(res => {
- let {
- code,
- data
- } = res
- if (code == 200) {
- this.setData({
- continueSign: data.continueSign,
- signInDay: data.signInDay
- })
- }
- }).catch(err => {
- if (err.code == 1989) {
- that.setData({
- continueSign: 0,
- signInDay: 2,
- isPhone: false
- })
- // app.globalData.type = "qd"
- // wx.navigateTo({
- // url: '/pages/getuserinfo/index',
- // })
- } else {
- wx.showToast({
- title: err.errMsg,
- icon: 'none',
- duration: 2000,
- mask: false
- });
- }
- })
- // .catch(err => {
- // wx.showToast({
- // title: err.errMsg,
- // icon: 'none',
- // duration: 2000,
- // mask: false
- // });
- // })
- },
-
- setHide() { //设置遮罩成
- this.setData({
- hideFlag: !this.data.hideFlag
- })
- },
-
- goSetPhone() {
- wx.navigateTo({
- url: `/pages/getphoneInfo/index?path=activityCalendar`,
- })
- },
-
- 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.getSignRule()
- this.setHide()
- }
- }).catch(err => {
- wx.showToast({
- title: err.errMsg,
- icon: 'none',
- duration: 2000,
- mask: false
- });
- })
- },
-
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.setContinuousDye()
- this.getSignRule()
- },
-
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- this.setContinuousDye()
- this.getSignRule()
- },
-
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
- },
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
-
- },
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- },
-
- /**
- * 用户点击右上角分享
- */
- // onShareAppMessage: function() {
-
- // }
- })
|