Silent há 6 anos atrás
pai
commit
487c292a6f
3 ficheiros alterados com 11 adições e 5 exclusões
  1. 4 2
      wechat/app.js
  2. 4 3
      wechat/pages/index/index.js
  3. 3 0
      wechat/pages/login/index.js

+ 4 - 2
wechat/app.js

xqd xqd
@@ -25,7 +25,8 @@ App({
   },
 
   globalData: {
-    userInfo: null
+    userInfo: null,
+    ptStudent: null
   },
   login: function (info) {
     wx.login({
@@ -41,7 +42,8 @@ App({
           success: info => {
             console.log(info);
             if (info.data.status == 'success') {
-              wx.setStorageSync('pt_student_id', info.data.id);
+              wx.setStorageSync('pt_student', info.data.data);
+              getApp().globalData.ptStudent = info.data.data;
             }
           }
         });

+ 4 - 3
wechat/pages/index/index.js

xqd
@@ -13,12 +13,13 @@ Page({
         })
       }
     })
-
-    var pt_student_id = wx.getStorageSync('pt_student_id')
-    if (!pt_student_id) {
+    var pt_student = wx.getStorageSync('pt_student')
+    if (!pt_student) {
       wx.redirectTo({
         url: '/pages/login/index',
       })
+    } else {
+      app.globalData.ptStudent = pt_student;
     }
   }
 })

+ 3 - 0
wechat/pages/login/index.js

xqd
@@ -19,6 +19,9 @@ Page({
   bindGetUserInfo: function (e) {
     if(e.detail.errMsg == 'getUserInfo:ok') {
       app.login(e.detail)
+      wx.redirectTo({
+        url: '/pages/index/index',
+      })
     }
   },