From 6a0f844cfd92ace03de38df7bc1f72d276a953bd Mon Sep 17 00:00:00 2001
From: 石广澎 <shiguangpeng@163.com>
Date: 星期二, 23 七月 2024 16:11:50 +0800
Subject: [PATCH] feat(支付): 去除无用api
---
common/http.interceptor.js | 30 ++++++++++++++++++++++++------
1 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/common/http.interceptor.js b/common/http.interceptor.js
index 5371580..2ebb5dd 100644
--- a/common/http.interceptor.js
+++ b/common/http.interceptor.js
@@ -3,6 +3,25 @@
config,
DEBUG
} from '@/common/config.js';
+function appType() {
+ let appType = 0
+ // #ifdef MP-WEIXIN
+ appType = 3 // 寰俊灏忕▼搴�
+ // #endif
+ // #ifdef MP-ALIPAY
+ appType = 1 // 鏀粯瀹濆皬绋嬪簭
+ // #endif
+ // #ifdef H5
+ var ua = window.navigator.userAgent.toLowerCase();
+ if (ua.match(/MicroMessenger/i) == 'micromessenger') {
+ appType = 4; //鏄井淇″叕浼楀彿
+ }
+ if (ua.match(/AlipayClient/i) == 'alipayclient') {
+ appType = 2; //鏀粯瀹濈敓娲诲彿
+ }
+ // #endif
+ return appType
+}
module.exports = (vm) => {
uni.$u.http.setConfig((x) => {
return x = {
@@ -24,10 +43,9 @@
// 寮曠敤token
const TOKEN = uni.getStorageSync(ACCESSTOKEN);
if (TOKEN) {
- x.header[ACCESSTOKEN] = TOKEN;
- } else {
- delete x.header[ACCESSTOKEN]
+ x.header[ACCESSTOKEN] = 'Bearer ' + TOKEN;
}
+ x.header['CLIENT-TYPE'] = appType()
return x;
}, x => {
return Promise.reject(x)
@@ -38,20 +56,20 @@
let res = x.data
if (res.code == 10000) {
return res.data;
- } else if (res.code == 20002) {
+ } else if (res.code == 401) {
const cid = uni.getStorageSync('CID')
uni.removeStorageSync(ACCESSTOKEN)
vm.$u.toast("鎺堟潈杩囨湡,璇烽噸鏂扮櫥褰�");
setTimeout(() => {
uni.reLaunch({
- url: "/pages/pay/scanpay?cid=" + cid
+ url: "/pay/login?cid=" + cid
})
}, 800);
return Promise.reject(res)
} else if (res.code == 10002) {
return Promise.reject(res)
} else {
- vm.$u.toast(res.description || "璇锋眰寮傚父锛�"); //閿欒鎻愮ず淇℃伅
+ vm.$u.toast(res.description || res.msg ||res.info ||"璇锋眰寮傚父锛�"); //閿欒鎻愮ず淇℃伅
return Promise.reject(res)
}
}, (response) => {
--
Gitblit v1.9.1