From 1fb498c5d63850cb63163ca295954f86459e4612 Mon Sep 17 00:00:00 2001
From: 石广澎 <shiguangpeng@163.com>
Date: 星期四, 27 六月 2024 15:26:31 +0800
Subject: [PATCH] feat(支付):

---
 common/http.interceptor.js |   26 ++++++++++++++++++++++----
 1 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/common/http.interceptor.js b/common/http.interceptor.js
index 5371580..77fa8f2 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)
@@ -58,4 +76,4 @@
 		vm.$u.toast("璇锋眰寮傚父锛�"); //閿欒鎻愮ず淇℃伅
 		return Promise.reject(response)
 	})
-}
+}
\ No newline at end of file

--
Gitblit v1.9.1