Selaa lähdekoodia

修改登录扫一扫tabbar

roose 4 vuotta sitten
vanhempi
commit
ceac6faccf

+ 28 - 22
pages/index/index.js

@@ -67,25 +67,31 @@ Page({
   },
   goSaoMa() {
     console.log("扫阿");
-    // 允许从相机和相册扫码
-    wx.scanCode({
-      onlyFromCamera: true,
-      success: (res) => {
-        console.log(res, "打印锕");
-        let length = res.result.substring(res.result.lastIndexOf('/') + 1, res.result.length)
-        wx.navigateTo({
-          url: '/pages/love/love?id=' + length,
-        })
-      },
-      fail: (res) => {
-        console.log(res, "假的");
-        wx.showToast({
-          title: '扫码失败',
-          icon: 'none',
-          duration: 2000,
-        })
-      }
-    })
+    if (wx.getStorageSync('user') == '') {
+      wx.redirectTo({
+        url: '/pages/login/login',
+      })
+    } else {
+      wx.scanCode({
+        onlyFromCamera: true,
+        success: (res) => {
+          console.log(res, "打印锕");
+          let length = res.result.substring(res.result.lastIndexOf('/') + 1, res.result.length)
+          wx.navigateTo({
+            url: '/pages/love/love?id=' + length,
+          })
+        },
+        fail: (res) => {
+          console.log(res, "假的");
+          wx.showToast({
+            title: '扫码失败',
+            icon: 'none',
+            duration: 2000,
+          })
+        }
+      })
+    }
+
   },
   depts() {
     console.log("打印走了么的接口呢");
@@ -118,7 +124,7 @@ Page({
         success: (res) => {
           if (res.data.code == 0) {
             console.log(res);
-            if(res.data.data.length!=0){
+            if (res.data.data.length != 0) {
               let result = res.data.data[0].title
               this.data.msgList.push({
                 title: result
@@ -173,7 +179,7 @@ Page({
     console.log("onshowssshshshhshshshss");
     this.depts();
     this.welcomeMessage();
-    
+
   },
   onLoad: function () {
     console.log("onload11111111111111111111111");
@@ -186,5 +192,5 @@ Page({
 
   }
 
-  
+
 })

+ 11 - 1
pages/login/login.js

@@ -25,6 +25,9 @@ Page({
     var password = e.detail.value.pwd;
     if (e.detail.value.name) {
       if (e.detail.value.pwd) {
+        wx.showLoading({
+          title: '加载中',
+        })
         wx.request({
           url: app.globalData.publicUrl + '/applet/bing',
           method: "GET",
@@ -35,7 +38,6 @@ Page({
           },
           success: (res) => {
             console.log(res, "777777");
-
             if (res.data.code == 0) {
               Notify({
                 type: 'success',
@@ -51,6 +53,9 @@ Page({
                 message: res.data.message
               });
             }
+          },
+          complete:(res) => {
+            wx.hideLoading()
           }
         })
       } else {
@@ -69,6 +74,11 @@ Page({
     }
 
 
+  },
+  goHome() {
+    wx.switchTab({
+      url: '/pages/index/index',
+    })
   },
   onLoad: function () {
     var that = this;

+ 3 - 0
pages/login/login.wxml

@@ -17,6 +17,9 @@
 			<view class="register">
 				<button formType="submit">登录并绑定微信号</button>
 			</view>
+			<view class="register" style=" margin-top: 20rpx;">
+				<button bindtap="goHome" >返回首页</button>
+			</view>
 		</view>
 	</form>
 

+ 8 - 8
pages/personInfo/personInfo.js

@@ -71,13 +71,7 @@ Page({
 
   },
   onShow() {
-    console.log(wx.getStorageSync('user'), "打印");
-    if (wx.getStorageSync('user') == '') {
-      wx.redirectTo({
-        url: '/pages/login/login',
-      })
-    }
-
+  
     wx.request({
       url: app.globalData.publicUrl + '/applet/findUserInfo',
       method: "GET",
@@ -93,6 +87,12 @@ Page({
     })
   },
   onLoad() {
-
+    console.log( "onload .......................");
+    if (wx.getStorageSync('user') == '') {
+      wx.redirectTo({
+        url: '/pages/login/login',
+      })
+      return
+    }
   }
 })

+ 45 - 38
pages/visitandinfo/visitandinfo.js

@@ -355,6 +355,12 @@ Page({
   },
 
   onLoad() {
+    if (wx.getStorageSync('user') == '') {
+      wx.redirectTo({
+        url: '/pages/login/login',
+      })
+      return
+    }
     this.oldInfo();
     this.visitInfo();
     this.computeScrollViewHeight();
@@ -366,45 +372,46 @@ Page({
       wx.redirectTo({
         url: '/pages/login/login',
       })
-    };
-    this.setData({
-      isAllTrue: false,
-      select_all: false
-    })
-    switch (this.data.number) {
-      case 0:
-        this.openIdInfo();
-        break;
-      case 1:
-        this.openIdInfo({
-          status: "1"
-        });
-        break;
-      case 2:
-        this.openIdInfo({
-          status: "0"
-        });
-        break;
-      case 3:
-        this.openIdInfo({
-          status: "2"
-        });
-        break;
-      case 4:
-        this.openIdInfo({
-          status: "3"
-        });
-        break;
-      case 5:
-        this.openIdInfo({
-          status: "4"
-        });
-        break;
-      default:
-        this.openIdInfo();
-        break;
+    }else {
+      this.setData({
+        isAllTrue: false,
+        select_all: false
+      })
+      switch (this.data.number) {
+        case 0:
+          this.openIdInfo();
+          break;
+        case 1:
+          this.openIdInfo({
+            status: "1"
+          });
+          break;
+        case 2:
+          this.openIdInfo({
+            status: "0"
+          });
+          break;
+        case 3:
+          this.openIdInfo({
+            status: "2"
+          });
+          break;
+        case 4:
+          this.openIdInfo({
+            status: "3"
+          });
+          break;
+        case 5:
+          this.openIdInfo({
+            status: "4"
+          });
+          break;
+        default:
+          this.openIdInfo();
+          break;
+      }
+      this.visitInfo();
     }
-    this.visitInfo();
   },
   onHide(){
     this.setData({