From f00c1cca98455a036548672d28e7e8ad13729a21 Mon Sep 17 00:00:00 2001
From: litian <C21AF165>
Date: 星期四, 11 四月 2024 21:57:27 +0800
Subject: [PATCH] 问题修改

---
 pages/bindInfo/index.js |   41 +++++++++++++++++++++++++++--------------
 1 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/pages/bindInfo/index.js b/pages/bindInfo/index.js
index 7e317c7..1fcccf6 100644
--- a/pages/bindInfo/index.js
+++ b/pages/bindInfo/index.js
@@ -1,4 +1,7 @@
 // pages/index/bindInfo/index.js
+import {
+  setSessionGuid
+} from "../../assets/js/userAction"
 const app = getApp();
 Page({
 
@@ -8,7 +11,7 @@
   data: {
     avatarUrl: "https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0",
     nickName: "",
-    wxCode: null,
+    redirectPage: ""
   },
 
   onChooseAvatar(res) {
@@ -46,15 +49,24 @@
             app.MG.identity.loginByWeChatAppCode({
               code: res.code,
               appRefCode: app.config.appRefCode,
-              platform: "weChatApp",
+              platform: "WeChatAppCustom",
               icon: this.data.avatarUrl,
               encryptedData: infoRes.encryptedData,
               iv: infoRes.iv,
               name: this.data.nickName,
             }).then(res => {
               if (res && res.status == "Ok") {
+                // 鍌ㄥ瓨token
                 wx.setStorageSync(app.config.tokenKey, res.token);
+                // 鑾峰彇鐢ㄦ埛淇℃伅
                 this.getUserInfo()
+                // 璁板綍鐧诲綍缁熻
+                setSessionGuid()
+              } else {
+                wx.showToast({
+                  icon: "error",
+                  title: res.message,
+                });
               }
             })
           },
@@ -64,12 +76,11 @@
   },
   // 鑾峰彇鐧诲綍鐢ㄦ埛韬唤
   getUserInfo() {
+    let that = this;
     app.MG.identity.getCurrentAppUser().then(res => {
-      // console.log(res, "userInfo");
       // 鐢ㄦ埛淇℃伅浼樺厛绾э細鏁欏笀璁よ瘉 > 寰俊 > 瀛︾敓锛堟敞鍐屾椂榛樿锛�
       if (res) {
         let defaultUser = {};
-        // let secretData = res.secretList.find(i => i.type == 'LoginNameAndPassword')
         let WeChatInfo = res.infoList.find((item) => item.type === "WeChat");
         let phoneNumber = res.secretList.find(i => i.type == 'MobilePhone')
 
@@ -80,19 +91,20 @@
             weChatId: WeChatInfo.id
           }
         }
-
         if (phoneNumber) {
           defaultUser.phoneNumber = phoneNumber.credential
         }
-        this.setData({
-          userInfo: defaultUser,
-          loading: false
-        })
-        wx.setStorageSync(app.config.userInfoKey, JSON.stringify(this.data.userInfo));
+        wx.setStorageSync(app.config.userInfoKey, JSON.stringify(defaultUser));
       }
-      wx.switchTab({
-        url: '/pages/index/index'
-      })
+      if (that.data.redirectPage == "" || that.data.redirectPage == "/pages/home/home" || that.data.redirectPage == "/pages/bookServices/assort/index" || that.data.redirectPage == "/pages/study/index" || that.data.redirectPage == "/pages/cart/index" || that.data.redirectPage == "/pages/personalCenter/index") {
+        wx.switchTab({
+          url: that.data.redirectPage != "" ? that.data.redirectPage : '/pages/home/home'
+        })
+      } else {
+        wx.navigateTo({
+          url: that.data.redirectPage
+        })
+      }
     });
   },
 
@@ -101,8 +113,9 @@
    */
   onLoad(options) {
     console.log(options, "options");
+    console.log(decodeURIComponent(options.page));
     this.setData({
-      wxCode: options.code
+      redirectPage: decodeURIComponent(options.page)
     })
   },
 

--
Gitblit v1.9.1