From 17efddc6a667670dca682bf36b51a43e99615e6d Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期三, 16 十月 2024 15:59:38 +0800
Subject: [PATCH] 代码初始化
---
h5/utils/service.js | 27 ++++++++++++++++-----------
1 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/h5/utils/service.js b/h5/utils/service.js
index bcc3d22..a6791d1 100644
--- a/h5/utils/service.js
+++ b/h5/utils/service.js
@@ -2,7 +2,7 @@
export const http = function (options) {
{
return new Promise((resolve, reject) => {
- let token = uni.getStorageSync('token')
+ let token = uni.getStorageSync('token') || ''
// 鍦ㄧ櫥褰曠殑鏃跺�欓渶瑕佸偍瀛� token uni.setStorageSync("authorization","杩欓噷鏄櫥褰曡幏鍙栫殑token鍊�")
// uni.showLoading({
@@ -18,7 +18,7 @@
method: options.method || 'GET',
header: options.header || {
// 鏍规嵁瀹為檯鎺ュ彛璁捐 key 鍙� token 鎴栬�� authorization
- token: token,
+ dm_user_token: token,
"content-type": 'application/json'
},
success: (res) => {
@@ -26,17 +26,21 @@
// 鎺у埗鍙版樉绀烘暟鎹俊鎭�
uni.hideLoading()
// 鐧诲綍杩囨湡
- if (data.code === 401) {
- uni.navigateTo({
- url: '/packageA/loginAgain/loginAgain'
- })
- }
if (data.code !== 200) {
- uni.showToast({
- title: data.message,
- icon: "none",
- duration: 2000
+ setTimeout(() => {
+ uni.showToast({
+ title: data.message,
+ icon: "none",
+ duration: 2000
+ })
})
+ if (data.code === 500) {
+ uni.clearStorageSync()
+ return uni.navigateTo({
+ url: '/pages/login/login'
+ })
+ }
+ return
}
resolve(data)
// return response.data
@@ -46,6 +50,7 @@
uni.showToast({
title: '璇锋眰鎺ュ彛澶辫触'
})
+
// 杩斿洖閿欒娑堟伅
reject(err)
uni.hideLoading()
--
Gitblit v1.9.3