From b920b4a7e70ffdeb7308131cb3d6a10dff9e3451 Mon Sep 17 00:00:00 2001
From: 石广澎 <shiguangpeng@163.com>
Date: 星期三, 08 五月 2024 11:22:08 +0800
Subject: [PATCH] feat(支付): 请求头内放置客户端类型
---
common/http.interceptor.js | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/common/http.interceptor.js b/common/http.interceptor.js
index 5371580..f12595f 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 = {
@@ -28,6 +47,7 @@
} else {
delete x.header[ACCESSTOKEN]
}
+ x.header['CLIENT-TYPE'] = appType()
return x;
}, x => {
return Promise.reject(x)
--
Gitblit v1.9.1