From e4f61bb43673d0934b549fc865f228188aa03528 Mon Sep 17 00:00:00 2001
From: YM <479443481@qq.com>
Date: 星期三, 27 三月 2024 15:59:30 +0800
Subject: [PATCH] 调整登录

---
 pages/bindInfo/index.js |   28 ++++++++++++++++------------
 1 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/pages/bindInfo/index.js b/pages/bindInfo/index.js
index 7e317c7..897d56c 100644
--- a/pages/bindInfo/index.js
+++ b/pages/bindInfo/index.js
@@ -1,4 +1,5 @@
 // pages/index/bindInfo/index.js
+import { setSessionGuid } from "../../assets/js/userAction"
 const app = getApp();
 Page({
 
@@ -8,7 +9,7 @@
   data: {
     avatarUrl: "https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0",
     nickName: "",
-    wxCode: null,
+    redirectPage: ""
   },
 
   onChooseAvatar(res) {
@@ -46,15 +47,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);
+                // 璁板綍鐧诲綍缁熻
+                setSessionGuid()
+                // 鑾峰彇鐢ㄦ埛淇℃伅
                 this.getUserInfo()
+              } else {
+                wx.showToast({
+                  icon: "error",
+                  title: res.message,
+                });
               }
             })
           },
@@ -65,11 +75,9 @@
   // 鑾峰彇鐧诲綍鐢ㄦ埛韬唤
   getUserInfo() {
     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,18 +88,13 @@
             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'
+        url: this.data.redirectPage ? this.data.redirectPage : '/pages/home/home'
       })
     });
   },
@@ -101,8 +104,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