소스 검색

fix 授权登录

stanley-king 4 년 전
부모
커밋
7c5935f8ba
1개의 변경된 파일24개의 추가작업 그리고 2개의 파일을 삭제
  1. 24 2
      app.js

+ 24 - 2
app.js

@@ -6,7 +6,16 @@ App({
         let self = this;
         // 登录
         new WxAuthor(self)
-    },
+        const dirs = ['addAddress','address','myhome','confirmOrder','confirmVOrder',
+        'order_tabs','orderPaySn','person','postageDetail','postageManage','shopCart'];
+
+        let pages = new Set()
+        dirs.forEach(dir => {
+            let page = `/pages/${dir}/${dir}`   
+            pages.add(page)
+        });
+        this.globalData.authPages = pages    
+    },    
     globalData: {
         userId: {
             openid: '',
@@ -20,8 +29,10 @@ App({
         fromSource: '',
         channel: '欧耶商城',
         record: null,
-        card_type: ''
+        card_type: '',
+        authPages: null
     },
+
     setFromSource(fromSource) {
         this.globalData.fromSource = fromSource
     },
@@ -56,6 +67,17 @@ App({
     },
     navigateto(page) 
     {
+        this.globalData.authPages.forEach(prefix => {
+            if(page.indexOf(prefix) == 0) {
+                if(!this.globalData.userInfo) {
+                    wx.navigateTo({
+                        url: '/pages/auth/auth',
+                    })
+                    return;
+                }                
+            }            
+        });
+        
         wx.navigateTo({
             url: page,
         })