From 915424730f27445da2e8de13b62e77179cc1a15a Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期一, 18 八月 2025 17:07:39 +0800
Subject: [PATCH] fix: 关闭移动充值渠道,打开电信充值渠道
---
apps/taro/src/utils/request/index.ts | 32 +++++++++++++++++++++++++++-----
1 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/apps/taro/src/utils/request/index.ts b/apps/taro/src/utils/request/index.ts
index 5842e65..cae3512 100644
--- a/apps/taro/src/utils/request/index.ts
+++ b/apps/taro/src/utils/request/index.ts
@@ -1,8 +1,9 @@
import { type IRequestOptions, Request, type RequestConfig } from 'senior-request';
-import { type AxiosRequestConfig, type AxiosError } from 'axios';
+import axios, { type AxiosRequestConfig, type AxiosError } from 'axios';
import qs from 'qs';
import Taro from '@tarojs/taro';
import { getToken, Message } from '@/utils';
+import { isWeb, isWeChat } from '@/utils/env';
import { tokenIsExpired, SensitiveManage } from '@life-payment/utils';
import { useUserStoreWithOut } from '@/stores/modules/user';
@@ -23,7 +24,9 @@
}
export function endLoading() {
- Taro.hideNavigationBarLoading();
+ if (isWeChat) {
+ Taro.hideNavigationBarLoading();
+ }
Taro.hideLoading();
}
@@ -46,7 +49,7 @@
REDIRECT = 9,
}
// 涓庡悗绔害瀹氱殑鍝嶅簲鏁版嵁鏍煎紡
-interface ResponseStructure {
+export interface ResponseStructure {
success: boolean;
data: any;
/**
@@ -76,7 +79,7 @@
}
const AxiosOptions: AxiosRequestConfig = {
- baseURL: process.env.BASE_URL,
+ baseURL: isWeb ? process.env.BASE_URL_H5 : process.env.BASE_URL,
timeout: 10 * 1000,
headers: {
Accept: 'application/json, text/plain, */*',
@@ -91,13 +94,20 @@
withCredentials: true,
};
-const config: RequestConfig<ResponseStructure, IRequestOptions> = {
+export const config: RequestConfig<ResponseStructure, IRequestOptions> = {
...AxiosOptions,
errorConfig: {
// 閿欒鎺ユ敹鍙婂鐞�
errorHandler: (error, opts) => {
console.log('error: ', error);
+ const userStore = useUserStoreWithOut();
+ logFront({
+ url: opts.url,
+ message: JSON.stringify(error),
+ requestTime: new Date().toLocaleString(),
+ userId: userStore.virtualUserId,
+ });
if (opts?.skipErrorHandler) throw error;
if (opts?.customErrorHandler) {
@@ -286,3 +296,15 @@
}
export const request = Request.create(config);
+
+function logFront(body: API.LogFrontInput) {
+ return axios.request({
+ baseURL: AxiosOptions.baseURL,
+ url: '/api/Log/LogFront',
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ data: body,
+ });
+}
--
Gitblit v1.9.1