From f14805e9e9550bb11e1f79bdbdec574237e92893 Mon Sep 17 00:00:00 2001
From: 石广澎 <shiguangpeng@163.com>
Date: 星期四, 12 九月 2024 10:41:51 +0800
Subject: [PATCH] feat(支付): 修改键盘组件

---
 common/http.interceptor.js |  148 ++++++++++++++++++++++++-------------------------
 1 files changed, 73 insertions(+), 75 deletions(-)

diff --git a/common/http.interceptor.js b/common/http.interceptor.js
index 16bdfd5..364454d 100644
--- a/common/http.interceptor.js
+++ b/common/http.interceptor.js
@@ -1,79 +1,77 @@
 import {
-	ACCESSTOKEN,
-	config,
-	DEBUG
+    ACCESSTOKEN,
+    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
-}
+import {
+    getPlat
+} from 'common/util.js';
+
 module.exports = (vm) => {
-	uni.$u.http.setConfig((x) => {
-		return x = {
-			// baseURL: config.baseURL,
-			dataType: 'json',
-			timeout: 60000,
-			showLoading: false, //鏄惁鏄剧ず鍏ㄥ眬loading
-			timer: null,
-			loadingTime: 800, //澶氬皯绉掓棤杩斿洖鍐嶆樉绀簂oading
-			header: {
-				'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
-				'Access-Control-Allow-Origin': '*'
-			}
-		}
-	})
-	// 璇锋眰鎷︽埅
-	uni.$u.http.interceptors.request.use((x) => {
-		DEBUG && console.log('璇锋眰鍙傛暟', x);
-		// 寮曠敤token
-		const TOKEN = uni.getStorageSync(ACCESSTOKEN);
-		if (TOKEN) {
-			x.header[ACCESSTOKEN] = 'Bearer ' + TOKEN;
-		}
-		x.header['CLIENT-TYPE'] = appType()
-		return x;
-	}, x => {
-		return Promise.reject(x)
-	})
-	// 鍝嶅簲鎷︽埅
-	uni.$u.http.interceptors.response.use((x) => {
-		DEBUG && console.log('杩斿洖缁撴灉', x);
-		let res = x.data
-		if (res.code == 10000) {
-			return res.data;
-		} else if (res.code == 401) {
-			const cid = uni.getStorageSync('CID')
-			uni.removeStorageSync(ACCESSTOKEN)
-			vm.$u.toast("鎺堟潈杩囨湡,璇烽噸鏂扮櫥褰�");
-			setTimeout(() => {
-				uni.reLaunch({
-					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 || res.msg ||res.info ||"璇锋眰寮傚父锛�"); //閿欒鎻愮ず淇℃伅
-			return Promise.reject(res)
-		}
-	}, (response) => {
-		vm.$u.toast("璇锋眰寮傚父锛�"); //閿欒鎻愮ず淇℃伅
-		return Promise.reject(response)
-	})
+    uni.$u.http.setConfig((x) => {
+        return x = {
+            // baseURL: config.baseURL,
+            dataType: 'json',
+            timeout: 60000,
+            showLoading: false, //鏄惁鏄剧ず鍏ㄥ眬loading
+            timer: null,
+            loadingTime: 800, //澶氬皯绉掓棤杩斿洖鍐嶆樉绀簂oading
+            header: {
+                'Clientid': '944c6aade52ebbffc015478e6ce51b5a',
+                'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
+                'Access-Control-Allow-Origin': '*'
+            }
+        }
+    })
+    // 璇锋眰鎷︽埅
+    uni.$u.http.interceptors.request.use((x) => {
+        DEBUG && console.log('璇锋眰鍙傛暟', x);
+        // 寮曠敤token
+        const TOKEN = uni.getStorageSync(ACCESSTOKEN);
+        if (TOKEN) {
+            x.header[ACCESSTOKEN] = 'Bearer ' + TOKEN;
+        }
+        const plat = getPlat()
+        if (plat == 2) { //寰俊
+            const OPENID = uni.getStorageSync('OPENID') || null
+            const UNIONID = uni.getStorageSync('UNIONID') || null
+            if (OPENID) {
+                x.header['Openid'] = OPENID;
+            }
+            if (UNIONID) {
+                x.header['Unionid'] = UNIONID;
+            }
+        }
+        if (plat == 5) { //鏀粯瀹�
+            const ALIUSERID = uni.getStorageSync('ALIUSERID') || null
+            if (ALIUSERID) {
+                x.header['Aliuserid'] = ALIUSERID;
+            }
+        }
+        if (plat == 15) { //浜戦棯浠�
+            const UNIONPAYID = uni.getStorageSync('UNIONPAYID') || null
+            if (UNIONPAYID) {
+                x.header['Unionpayid '] = UNIONPAYID;
+            }
+        }
+        return x;
+    }, x => {
+        return Promise.reject(x)
+    })
+    // 鍝嶅簲鎷︽埅
+    uni.$u.http.interceptors.response.use((x) => {
+        DEBUG && console.log('杩斿洖缁撴灉', x);
+        let res = x.data
+        if (res.code == 10000) {
+            return res.data;
+        } else if (res.code == 10002) {
+            return Promise.reject(res)
+        } else {
+            vm.$u.toast(res.description || res.msg || res.info || "璇锋眰寮傚父锛�"); //閿欒鎻愮ず淇℃伅
+            return Promise.reject(res)
+        }
+    }, (response) => {
+        vm.$u.toast("璇锋眰寮傚父锛�"); //閿欒鎻愮ず淇℃伅
+        return Promise.reject(response)
+    })
 }

--
Gitblit v1.9.1