Commit fabaab15854e84a21bef0d7a8300a133fd7b6508

Authored by 后端研发-倪永富
1 parent e7c9b7c6

签到前检测是否登录

packageA/pages/checkin/checkin.js
1 // packageA//pages/checkin/checkin.js 1 // packageA//pages/checkin/checkin.js
2 const app = getApp(); 2 const app = getApp();
3 - 3 +let self;
4 Page({ 4 Page({
5 5
6 /** 6 /**
@@ -25,12 +25,12 @@ Page({ @@ -25,12 +25,12 @@ Page({
25 checkInNums: 0, //补签次数 25 checkInNums: 0, //补签次数
26 isCheckInDay: '', 26 isCheckInDay: '',
27 27
28 -  
29 flag: true, 28 flag: true,
  29 + isLogin: false,
  30 +
30 }, 31 },
31 32
32 loadQd(callback) { 33 loadQd(callback) {
33 - let self = this;  
34 app.request.get('/api/weshop/qdrecord/getUser/'+ app.globalData.setting.stoid + '/' + app.globalData.user_id, { 34 app.request.get('/api/weshop/qdrecord/getUser/'+ app.globalData.setting.stoid + '/' + app.globalData.user_id, {
35 success: function (res) { 35 success: function (res) {
36 if(callback) callback(); 36 if(callback) callback();
@@ -46,17 +46,62 @@ Page({ @@ -46,17 +46,62 @@ Page({
46 * 生命周期函数--监听页面加载 46 * 生命周期函数--监听页面加载
47 */ 47 */
48 onLoad: function(options) { 48 onLoad: function(options) {
49 - let self = this; 49 + console.log('执行onload');
  50 + self = this;
50 this.getDate(); 51 this.getDate();
51 this.setDate(); 52 this.setDate();
52 var res = wx.getSystemInfoSync(); 53 var res = wx.getSystemInfoSync();
53 this.setData({ 54 this.setData({
54 param: res.windowHeight / 12, 55 param: res.windowHeight / 12,
  56 +
55 }) 57 })
  58 +
  59 +
  60 + // 判断会员是否授权登录,
  61 + // 没有登录则跳转到登录页,
  62 + // 已登录则设置已登录状态,请求加载签到数据
  63 + this.isLogin().then(function() {
  64 + console.log('loginnnn',app.globalData.userInfo);
  65 + self.setData({
  66 + isLogin: true
  67 + });
  68 + self.loadQd();
  69 + });
56 70
57 - this.loadQd();  
58 71
59 }, 72 },
  73 +
  74 + onShow() {
  75 + if(app.globalData.userInfo instanceof Object) {
  76 + if(this.data.isLogin) {
  77 + return;
  78 + } else {
  79 + this.setData({
  80 + isLogin: true
  81 + });
  82 + this.loadQd();
  83 + };
  84 + }
  85 + },
  86 +
  87 + onHide() {
  88 + console.log('执行onHide');
  89 + },
  90 +
  91 + // 是否登录
  92 + isLogin() {
  93 + return new Promise(function(resolve, reject) {
  94 + let user_info = getApp().globalData.userInfo;
  95 + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
  96 + wx.navigateTo({
  97 + url: '/pages/togoin/togoin',
  98 + })
  99 + return false;
  100 + } else {
  101 + resolve();
  102 + };
  103 + });
  104 + },
60 105
61 106
62 // 点击"我的积分"和"去购物"进行跳转 107 // 点击"我的积分"和"去购物"进行跳转
@@ -219,73 +264,7 @@ Page({ @@ -219,73 +264,7 @@ Page({
219 } 264 }
220 this.setData({ 265 this.setData({
221 dateArr: this.data.dateArr, 266 dateArr: this.data.dateArr,
222 - // firstDay: this.data.firstDay  
223 }); 267 });
224 }, 268 },
225 269
226 - // prevMonth: function() { //上一月  
227 - // var months = "";  
228 - // var years = "";  
229 - // if (this.data.month == 1) {  
230 - // years = this.data.year - 1  
231 - // this.data.month = 12;  
232 - // months = this.data.month;  
233 - // } else {  
234 - // years = this.data.year;  
235 - // months = this.data.month - 1;  
236 - // }  
237 -  
238 - // var first = new Date(years, months - 1, 1);  
239 - // this.data.firstDay = first.getDay();  
240 - // var last = new Date(years, months, 0);  
241 - // this.data.lastDay = last.getDate();  
242 -  
243 - // this.setData({  
244 - // month: months,  
245 - // year: years,  
246 - // firstDay: this.data.firstDay,  
247 - // lastDay: this.data.lastDay  
248 - // })  
249 -  
250 - // this.data.dateArr = [];  
251 - // for (var i = 1; i < this.data.lastDay + 1; i++) {  
252 - // this.data.dateArr.push(i);  
253 - // }  
254 - // this.setData({  
255 - // dateArr: this.data.dateArr  
256 - // })  
257 - // },  
258 -  
259 - // nextMonth: function() { //下一月  
260 - // var months = "";  
261 - // var years = "";  
262 - // if (this.data.month == 12) {  
263 - // this.data.month = 0;  
264 - // months = this.data.month;  
265 - // years = this.data.year + 1;  
266 - // } else {  
267 - // months = this.data.month + 1;  
268 - // years = this.data.year;  
269 - // }  
270 - // var months = this.data.month + 1;  
271 - // var first = new Date(years, months - 1, 1);  
272 - // this.data.firstDay = first.getDay();  
273 - // var last = new Date(years, months, 0);  
274 - // this.data.lastDay = last.getDate();  
275 - // this.setData({  
276 - // month: months,  
277 - // year: years,  
278 - // firstDay: this.data.firstDay,  
279 - // lastDay: this.data.lastDay  
280 - // })  
281 -  
282 - // this.data.dateArr = [];  
283 - // for (var i = 1; i < this.data.lastDay + 1; i++) {  
284 - // this.data.dateArr.push(i);  
285 - // }  
286 - // this.setData({  
287 - // dateArr: this.data.dateArr  
288 - // })  
289 - // },  
290 -  
291 }) 270 })
packageA/pages/checkin/checkin.wxml
@@ -38,9 +38,12 @@ @@ -38,9 +38,12 @@
38 </view> 38 </view>
39 39
40 <view class="btn-container"> 40 <view class="btn-container">
41 - <view class="btn" bindtap="checkInToday"> 41 + <view class="btn" bindtap="checkInToday" wx:if="{{isLogin}}">
42 <text class="iconfont icon-rili"></text>{{!dateArr[day-1].isCheckIn ? '立即签到':'今日已签到'}} 42 <text class="iconfont icon-rili"></text>{{!dateArr[day-1].isCheckIn ? '立即签到':'今日已签到'}}
43 </view> 43 </view>
  44 + <view class="btn" bindtap="isLogin" wx:else>
  45 + <text class="iconfont icon-rili"></text>签到请登录
  46 + </view>
44 <view class="btn" wx:if="{{res.curbqdaynum}}" bindtap="reCheckIn"><text class="iconfont icon-buqian"></text>补签(-10分)</view> 47 <view class="btn" wx:if="{{res.curbqdaynum}}" bindtap="reCheckIn"><text class="iconfont icon-buqian"></text>补签(-10分)</view>
45 </view> 48 </view>
46 49
@@ -103,7 +106,7 @@ @@ -103,7 +106,7 @@
103 <view class="popup-wrapper"> 106 <view class="popup-wrapper">
104 <view class="popup"> 107 <view class="popup">
105 <view class="popup-title">签到规则</view> 108 <view class="popup-title">签到规则</view>
106 - <view class="popup-content">1.每日签到领积分</view> 109 + <view class="popup-content">{{res.qdrules}}</view>
107 </view> 110 </view>
108 <view class="popup-close"> 111 <view class="popup-close">
109 <text class="btn-close" bindtap="showRules">X</text> 112 <text class="btn-close" bindtap="showRules">X</text>