Browse Source

服务端手机校验

lucheng 1 năm trước cách đây
mục cha
commit
b8dd6d3ed4

+ 20 - 1
pages/scan_result/scan_result.js

@@ -115,7 +115,26 @@ Page({
           });
           console.info("sssssss   " + data.repaidbalance)
           //开始充电
-          if (!data.repaidbalance || data.repaidbalance <= 0) {
+          if(data.bindingPhone==0){
+            wx.showModal({
+              title: '提示',
+              content: '您未绑定手机号,请重新登录后自动刷新绑定信息',
+              confirmText: '去登录',
+              showCancel:false,
+              confirmColor:'#00aadd',
+              success: function (res1) {
+                if (res1.confirm) {
+                  wx.removeStorageSync('userInfo');
+                  wx.removeStorageSync('isLogin');
+                  let url = '/pages/login/phone_login/phone_login';
+                  wx.redirectTo({
+                    url
+                  })
+                }
+              }
+            });
+            log.info('[扫码]', '[同步用户数据]', '[未绑定手机号]', data);
+          }else if (!data.repaidbalance || data.repaidbalance <= 0) {
             wx.showModal({
               showCancel: false,
               content: '余额不足,请充值!',

+ 2 - 2
pages/ucenter/accountsecurity/checkphonesecuirty/checkphonesecruity.js

@@ -151,12 +151,12 @@ Page({
         } else {
           if(that.data.scene==that.data.reviserPasswordScene){
             let url = `/pages/ucenter/accountsecurity/mdfpassword/mdfpassword`;
-            wx.navigateTo({
+            wx.redirectTo({
               url
             });
           }else if(that.data.scene==that.data.unbindPhoneScene){
             let url = `/pages/ucenter/accountsecurity/unbindphone/unbindphone`;
-            wx.navigateTo({
+            wx.redirectTo({
               url
             });
           }

+ 29 - 6
pages/ucenter/accountsecurity/index/index.js

@@ -5,12 +5,20 @@ Page({
    * 页面的初始数据
    */
   data: {
+    isLogin: false,
     isBindPhone: 0,
     reviserPasswordScene: 'MDF_PWD',
     unbindPhoneScene: 'UN_PHONE'
   },
 
   goModifuPassword(e) {
+    if (!this.data.isLogin) {
+      let url = `/pages/login/phone_login/phone_login`;
+      wx.navigateTo({
+        url
+      });
+      return;
+    }
     if(this.phoneCheck()){
       let url = '/pages/ucenter/accountsecurity/checkphonesecuirty/checkphonesecruity?scene='+this.data.reviserPasswordScene;
       wx.navigateTo({
@@ -20,6 +28,13 @@ Page({
   },
 
   goModifyPhone(e) {
+    if (!this.data.isLogin) {
+      let url = `/pages/login/phone_login/phone_login`;
+      wx.navigateTo({
+        url
+      });
+      return;
+    }
     if(this.phoneCheck()){
       let url = '/pages/ucenter/accountsecurity/checkphonesecuirty/checkphonesecruity?scene='+this.data.unbindPhoneScene;
       wx.navigateTo({
@@ -53,11 +68,7 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad(options) {
-    
-    let userInfo = wx.getStorageSync('userInfo');
-    this.setData({
-      isBindPhone: userInfo.bindingPhone
-    });
+  
   },
 
   /**
@@ -71,7 +82,19 @@ Page({
    * 生命周期函数--监听页面显示
    */
   onShow() {
-
+    let userInfo = wx.getStorageSync('userInfo');
+    let isLogin = wx.getStorageSync('isLogin');
+    if (userInfo && isLogin) {
+      this.setData({
+        isLogin,
+        isBindPhone: userInfo.bindingPhone
+      });
+    }else{
+      this.setData({
+        isLogin: false,
+        isBindPhone: 0
+      });
+    }
   },
 
   /**

+ 18 - 0
pages/ucenter/accountsecurity/mdfpassword/mdfpassword.js

@@ -33,6 +33,24 @@ Page({
             showCancel: false,
             confirmColor: '#4359b5'
           });
+        }else if (res.data.code == 2) {
+          wx.showModal({
+            title: '提示',
+            content: '您未绑定手机号,请重新登录后自动刷新绑定信息',
+            confirmText: '去登录',
+            showCancel:false,
+            confirmColor:'#00aadd',
+            success: function (res1) {
+              if (res1.confirm) {
+                wx.removeStorageSync('userInfo');
+                wx.removeStorageSync('isLogin');
+                let url = '/pages/login/phone_login/phone_login';
+                wx.redirectTo({
+                  url
+                })
+              }
+            }
+          });
         } else {
           let url = `/pages/ucenter/index/index`;
           wx.redirectTo({

+ 20 - 1
pages/ucenter/accountsecurity/unbindphone/unbindphone.js

@@ -200,7 +200,26 @@ Page({
             confirmColor:'#4359b5'
           });
           log.info('[绑定手机号]', '[绑定手机号]', '[失败code==1]', res.data);
-        } else {
+        }else if (res.data.code == 2) {
+          wx.showModal({
+            title: '提示',
+            content: '您未绑定手机号,请重新登录后自动刷新绑定信息',
+            confirmText: '去登录',
+            showCancel:false,
+            confirmColor:'#00aadd',
+            success: function (res1) {
+              if (res1.confirm) {
+                wx.removeStorageSync('userInfo');
+                wx.removeStorageSync('isLogin');
+                let url = '/pages/login/phone_login/phone_login';
+                wx.redirectTo({
+                  url
+                })
+              }
+            }
+          });
+          log.info('[绑定手机号]', '[绑定手机号]', '[失败code==2]', res.data);
+        }  else {
           //跳转到上一页
           wx.setStorageSync("userInfo", res.data);
           wx.setStorageSync("isLogin", true);

+ 18 - 0
pages/ucenter/center/center.js

@@ -162,6 +162,24 @@ Page({
           that.setData({
             errorMsg: res1.data.msg
           })
+        }else if (res1.data.code == 2) {
+          wx.showModal({
+            title: '提示',
+            content: '您未绑定手机号,请重新登录后自动刷新绑定信息',
+            confirmText: '去登录',
+            showCancel:false,
+            confirmColor:'#00aadd',
+            success: function (res1) {
+              if (res1.confirm) {
+                wx.removeStorageSync('userInfo');
+                wx.removeStorageSync('isLogin');
+                let url = '/pages/login/phone_login/phone_login';
+                wx.redirectTo({
+                  url
+                })
+              }
+            }
+          });
         } else {
           //返回该用户
           //跳转到上一页

+ 9 - 6
pages/ucenter/index/index.js

@@ -81,7 +81,7 @@ Page({
   onShow: function() {
     let userInfo = wx.getStorageSync('userInfo');
     let isLogin = wx.getStorageSync('isLogin');
-    //console.log(userInfo);
+    // console.log(userInfo.flag);
     // 页面显示
     if (userInfo && isLogin) {
       //userInfo.flag = true;
@@ -92,7 +92,8 @@ Page({
     } else {
       //未登录信息
       this.setData({
-        userInfo: {}
+        userInfo: {},
+        isLogin: false
       });
     }
   },
@@ -196,10 +197,12 @@ Page({
       });
       return;
     }
-    let url = '/pages/ucenter/accountsecurity/index/index'
-    wx.navigateTo({
-      url
-    });
+    if (this.phoneCheck()) {
+      let url = '/pages/ucenter/accountsecurity/index/index'
+      wx.navigateTo({
+        url
+      });
+    }
   },
   goHelp(){
     // wx.downloadFile({

+ 1 - 1
pages/ucenter/index/index.wxml

@@ -126,7 +126,7 @@
           <image src='/images/enter.png'></image>
         </view>
       </view>
-      <view class="zan-cell"  wx:if='{{userInfo.flag}}' hover-class="active" bindtap="goAccountSecrity">
+      <view class="zan-cell"  wx:if='{{userInfo.flag==null?1:!userInfo.flag}}' hover-class="active" bindtap="goAccountSecrity">
         <view class="zan-icon">
           <image src='/images/column.png'></image>
         </view>