From f64693c0da5483d8670220bf3a5bf89a32e94a20 Mon Sep 17 00:00:00 2001
From: peng <peng.com>
Date: 星期五, 07 十一月 2025 10:34:21 +0800
Subject: [PATCH] 解决线上打包问题
---
wx/pages/profile/personal-info.js | 94 +++++++++++++++++++++++++++++++++++++++-------
1 files changed, 79 insertions(+), 15 deletions(-)
diff --git a/wx/pages/profile/personal-info.js b/wx/pages/profile/personal-info.js
index 1fbdb5f..b9f5f07 100644
--- a/wx/pages/profile/personal-info.js
+++ b/wx/pages/profile/personal-info.js
@@ -157,10 +157,17 @@
title: '鑾峰彇涓�...'
})
- // TODO: 璋冪敤鍚庣API瑙e瘑鎵嬫満鍙�
+ // 璋冪敤鍚庣API瑙e瘑鎵嬫満鍙�
+ const app = getApp()
+ const sessionKey = app.globalData.sessionKey
+
+ if (!sessionKey) {
+ throw new Error('SessionKey涓嶅瓨鍦紝璇烽噸鏂扮櫥褰�')
+ }
+
const mutation = `
- mutation DecryptPhoneNumber($encryptedData: String!, $iv: String!) {
- decryptPhoneNumber(encryptedData: $encryptedData, iv: $iv) {
+ mutation DecryptPhoneNumber($encryptedData: String!, $iv: String!, $sessionKey: String!) {
+ decryptPhoneNumber(encryptedData: $encryptedData, iv: $iv, sessionKey: $sessionKey) {
phoneNumber
}
}
@@ -168,7 +175,8 @@
const variables = {
encryptedData: e.detail.encryptedData,
- iv: e.detail.iv
+ iv: e.detail.iv,
+ sessionKey: sessionKey
}
const result = await graphqlRequest(mutation, variables)
@@ -229,10 +237,13 @@
return
}
- if (!userInfo.phone) {
- wx.showToast({
- title: '璇疯幏鍙栨墜鏈哄彿',
- icon: 'none'
+ // 寮哄埗瑕佹眰鎺堟潈鐢佃瘽鍙风爜
+ if (!userInfo.phone || userInfo.phone.trim() === '') {
+ wx.showModal({
+ title: '闇�瑕佹巿鏉冩墜鏈哄彿',
+ content: '鏍规嵁骞冲彴瑙勫畾锛屽繀椤绘巿鏉冩墜鏈哄彿鐮佹墠鑳戒繚瀛樼敤鎴蜂俊鎭�傝鍏堣幏鍙栨墜鏈哄彿鐮佹巿鏉冦��',
+ showCancel: false,
+ confirmText: '鎴戠煡閬撲簡'
})
return
}
@@ -284,15 +295,17 @@
// 淇濆瓨鍒版湰鍦板瓨鍌�
wx.setStorageSync('userInfo', app.globalData.userInfo)
- wx.showToast({
+ // 鏄剧ず淇濆瓨鎴愬姛鎻愮ず锛屽苟鎻愰啋闇�瑕侀噸鏂扮櫥褰�
+ wx.showModal({
title: '淇濆瓨鎴愬姛',
- icon: 'success'
+ content: '鐢ㄦ埛淇℃伅宸蹭繚瀛樻垚鍔熴�備负浜嗚幏鍙栨渶鏂扮殑鍏宠仈淇℃伅锛堝鍙傝禌鑰呫�佽瘎濮斻�佸憳宸ヨ韩浠斤級锛岀郴缁熷皢閲嶆柊鐧诲綍銆�',
+ showCancel: false,
+ confirmText: '纭畾',
+ success: () => {
+ // 寮哄埗閲嶆柊鐧诲綍浠ヨ幏鍙栨渶鏂扮殑鐢ㄦ埛鍏宠仈淇℃伅
+ this.forceRelogin()
+ }
})
-
- // 寤惰繜杩斿洖涓婁竴椤�
- setTimeout(() => {
- wx.navigateBack()
- }, 1500)
} else {
throw new Error('淇濆瓨澶辫触')
}
@@ -385,5 +398,56 @@
// 鑾峰彇鏂囦欢鎵╁睍鍚�
getFileExtension(fileName) {
return fileName.split('.').pop().toLowerCase()
+ },
+
+ // 寮哄埗閲嶆柊鐧诲綍
+ forceRelogin() {
+ wx.showLoading({
+ title: '閲嶆柊鐧诲綍涓�...'
+ })
+
+ try {
+ // 娓呴櫎鏈湴瀛樺偍鐨勭櫥褰曚俊鎭�
+ wx.removeStorageSync('token')
+ wx.removeStorageSync('userInfo')
+ wx.removeStorageSync('sessionKey')
+
+ // 娓呴櫎鍏ㄥ眬鏁版嵁
+ app.globalData.token = null
+ app.globalData.userInfo = null
+ app.globalData.sessionKey = null
+
+ console.log('宸叉竻闄ゆ湰鍦扮櫥褰曚俊鎭紝鍑嗗閲嶆柊鐧诲綍')
+
+ // 閲嶆柊璋冪敤鐧诲綍娴佺▼
+ app.login()
+
+ // 寤惰繜涓�娈垫椂闂村悗闅愯棌loading骞惰繑鍥炰笂涓�椤�
+ setTimeout(() => {
+ wx.hideLoading()
+ wx.showToast({
+ title: '閲嶆柊鐧诲綍瀹屾垚',
+ icon: 'success'
+ })
+
+ // 杩斿洖涓婁竴椤�
+ setTimeout(() => {
+ wx.navigateBack()
+ }, 1000)
+ }, 2000)
+
+ } catch (error) {
+ console.error('寮哄埗閲嶆柊鐧诲綍澶辫触:', error)
+ wx.hideLoading()
+ wx.showToast({
+ title: '閲嶆柊鐧诲綍澶辫触',
+ icon: 'none'
+ })
+
+ // 鍗充娇澶辫触涔熻繑鍥炰笂涓�椤�
+ setTimeout(() => {
+ wx.navigateBack()
+ }, 1500)
+ }
}
})
\ No newline at end of file
--
Gitblit v1.8.0