From fabaab15854e84a21bef0d7a8300a133fd7b6508 Mon Sep 17 00:00:00 2001 From: taiyuan Date: Fri, 26 Feb 2021 11:19:27 +0800 Subject: [PATCH] 签到前检测是否登录 --- packageA/pages/checkin/checkin.js | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------- packageA/pages/checkin/checkin.wxml | 7 +++++-- 2 files changed, 55 insertions(+), 73 deletions(-) diff --git a/packageA/pages/checkin/checkin.js b/packageA/pages/checkin/checkin.js index 10ea4fa..37ed28e 100644 --- a/packageA/pages/checkin/checkin.js +++ b/packageA/pages/checkin/checkin.js @@ -1,6 +1,6 @@ // packageA//pages/checkin/checkin.js const app = getApp(); - +let self; Page({ /** @@ -25,12 +25,12 @@ Page({ checkInNums: 0, //补签次数 isCheckInDay: '', - flag: true, + isLogin: false, + }, loadQd(callback) { - let self = this; app.request.get('/api/weshop/qdrecord/getUser/'+ app.globalData.setting.stoid + '/' + app.globalData.user_id, { success: function (res) { if(callback) callback(); @@ -46,17 +46,62 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad: function(options) { - let self = this; + console.log('执行onload'); + self = this; this.getDate(); this.setDate(); var res = wx.getSystemInfoSync(); this.setData({ param: res.windowHeight / 12, + }) + + + // 判断会员是否授权登录, + // 没有登录则跳转到登录页, + // 已登录则设置已登录状态,请求加载签到数据 + this.isLogin().then(function() { + console.log('loginnnn',app.globalData.userInfo); + self.setData({ + isLogin: true + }); + self.loadQd(); + }); - this.loadQd(); }, + + onShow() { + if(app.globalData.userInfo instanceof Object) { + if(this.data.isLogin) { + return; + } else { + this.setData({ + isLogin: true + }); + this.loadQd(); + }; + } + }, + + onHide() { + console.log('执行onHide'); + }, + + // 是否登录 + isLogin() { + return new Promise(function(resolve, reject) { + let user_info = getApp().globalData.userInfo; + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { + wx.navigateTo({ + url: '/pages/togoin/togoin', + }) + return false; + } else { + resolve(); + }; + }); + }, // 点击"我的积分"和"去购物"进行跳转 @@ -219,73 +264,7 @@ Page({ } this.setData({ dateArr: this.data.dateArr, - // firstDay: this.data.firstDay }); }, - // prevMonth: function() { //上一月 - // var months = ""; - // var years = ""; - // if (this.data.month == 1) { - // years = this.data.year - 1 - // this.data.month = 12; - // months = this.data.month; - // } else { - // years = this.data.year; - // months = this.data.month - 1; - // } - - // var first = new Date(years, months - 1, 1); - // this.data.firstDay = first.getDay(); - // var last = new Date(years, months, 0); - // this.data.lastDay = last.getDate(); - - // this.setData({ - // month: months, - // year: years, - // firstDay: this.data.firstDay, - // lastDay: this.data.lastDay - // }) - - // this.data.dateArr = []; - // for (var i = 1; i < this.data.lastDay + 1; i++) { - // this.data.dateArr.push(i); - // } - // this.setData({ - // dateArr: this.data.dateArr - // }) - // }, - - // nextMonth: function() { //下一月 - // var months = ""; - // var years = ""; - // if (this.data.month == 12) { - // this.data.month = 0; - // months = this.data.month; - // years = this.data.year + 1; - // } else { - // months = this.data.month + 1; - // years = this.data.year; - // } - // var months = this.data.month + 1; - // var first = new Date(years, months - 1, 1); - // this.data.firstDay = first.getDay(); - // var last = new Date(years, months, 0); - // this.data.lastDay = last.getDate(); - // this.setData({ - // month: months, - // year: years, - // firstDay: this.data.firstDay, - // lastDay: this.data.lastDay - // }) - - // this.data.dateArr = []; - // for (var i = 1; i < this.data.lastDay + 1; i++) { - // this.data.dateArr.push(i); - // } - // this.setData({ - // dateArr: this.data.dateArr - // }) - // }, - }) diff --git a/packageA/pages/checkin/checkin.wxml b/packageA/pages/checkin/checkin.wxml index a155ed9..d297782 100644 --- a/packageA/pages/checkin/checkin.wxml +++ b/packageA/pages/checkin/checkin.wxml @@ -38,9 +38,12 @@ - + {{!dateArr[day-1].isCheckIn ? '立即签到':'今日已签到'}} + + 签到请登录 + 补签(-10分) @@ -103,7 +106,7 @@ 签到规则 - 1.每日签到领积分 + {{res.qdrules}} X -- libgit2 0.21.4