From 05db93c48c69b1fc5db8bb2fce4c37014e92e450 Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期二, 19 八月 2025 10:01:30 +0800
Subject: [PATCH] 代码初始化
---
h5/utils/http.interceptor.js | 65 +++++++++++++++++---------------
1 files changed, 35 insertions(+), 30 deletions(-)
diff --git a/h5/utils/http.interceptor.js b/h5/utils/http.interceptor.js
index 0c2a36c..9e914a5 100644
--- a/h5/utils/http.interceptor.js
+++ b/h5/utils/http.interceptor.js
@@ -1,3 +1,4 @@
+import { decryptedData } from '@/utils/decryption.js'
const install = (Vue, vm) => {
// 鏄惁姝e湪鍒锋柊鐨勬爣璁�
let isRefreshing = false
@@ -9,9 +10,13 @@
// if (!['mobile/chatLog/unReadMessageNum', 'mobile/Message/messageList'].includes(config.url)) {
// uni.showLoading({ title: '璇锋眰涓�' });
// }
- const Headtoken = vm.$store.state.token
+ uni.showLoading({ title: '璇锋眰涓�' });
+ let Headtoken
+ if (vm.$store.state.userInfo) {
+ Headtoken = vm.$store.state.userInfo.token
+ }
if (Headtoken) {
- config.header['eva-auth-token'] = Headtoken;
+ config.header['web-token'] = Headtoken;
}
return config
}, config => {
@@ -20,37 +25,37 @@
// 鍝嶅簲鎷︽埅鍣�
uni.$u.http.interceptors.response.use((response) => {
+ console.log(location.href.split('#')[1])
+ let pageUrl = location.href.split('#')[1]
uni.hideLoading();
// 鐧诲綍杩囨湡
- if (response.data.code === 401) {
- if (!isRefreshing) { // 鏄惁宸茬粡鎵ц鍒锋柊
- isRefreshing = true
- uni.login({
- provider: 'weixin',
- success: async function (loginRes) {
- let { code } = loginRes;
- uni.request({
- url: vm.$baseUrl + 'mobile/system/login',
- method: "GET",
- data: { code },
- success: (res) => {
- isRefreshing = false
- vm.$store.commit('setToken', res.data.data)
- // 宸茬粡鍒锋柊浜唗oken锛屽皢鎵�鏈夐槦鍒椾腑鐨勮姹傝繘琛岄噸璇�
- requests.forEach(item => item(res.data.data))
- requests = []
- }
- });
- }
- });
- }
- return new Promise((resolve) => {
- // 灏唕esolve鏀捐繘闃熷垪锛岀敤涓�涓嚱鏁板舰寮忔潵淇濆瓨锛岀瓑token鍒锋柊鍚庣洿鎺ユ墽琛�
- requests.push(token => {
- response.config.header['eva-auth-token'] = token
- resolve(uni.$u.http.request(response.config));
- })
+ if (response.data.code === 5112) {
+ uni.showToast({
+ title: '鐧诲綍杩囨湡锛屾鍦ㄩ噸鏂拌烦杞巿鏉�',
+ icon: 'none',
+ duration: 2000,
+ success() {
+ setTimeout(() => {
+ let loc_href = encodeURIComponent("https://lkshereporting.unilever-china.com/lianhelihua_web/")
+ let corpId = 'ww08b163f924524474';
+ let agentId = '1000165';
+ let wxUrl = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${corpId}&redirect_uri=${loc_href}&response_type=code&scope=snsapi_base&state=p_${pageUrl}#wechat_redirect`
+ location.href = wxUrl;
+ }, 1500)
+ }
})
+ return
+ }
+ if (response.data.message) {
+ const tm = response.data.message
+ const list = tm.split(' ')
+ let msg = list[0]
+ if (list.length > 1 && response.data.data) {
+ msg = decryptedData(list[1], list[0])
+ response.data.data = decryptedData(list[1], response.data.data)
+ console.log(response.data.data)
+ response.data.message = msg
+ }
}
if (response.data.code !== 200) {
uni.showToast({
--
Gitblit v1.9.3