feat:性能优化

This commit is contained in:
2026-07-25 09:12:36 +08:00
parent 3eba959b48
commit 9ab39d2aec
138 changed files with 232 additions and 1511 deletions
-10
View File
@@ -1,10 +0,0 @@
/**
* 订单的状态 状态:1-待支付,2-支付处理中,3-已支付,4-待评价
*/
export const ORDER_STATUS_CSS={
1:"#5486FF",//待支付,不管
2:"#FF0050",//待发货
3:"#FF0050",//待收货
4:"#999999",//待评价
}
+2 -2
View File
@@ -167,13 +167,13 @@ export const WAY_LIST = [
disabled: false,
id: PAYMENT_WAY.WECHAT,
name: "微信支付",
path: "/static/product/way_wx.png",
path: "/pages/other_package/static/product/way_wx.png",
},
{
disabled: false,
id: PAYMENT_WAY.ALIPAY,
name: "支付宝支付",
path: "/static/product/way_zfb.png",
path: "/pages/other_package/static/product/way_zfb.png",
},
]
+27 -15
View File
@@ -4,6 +4,27 @@ import { BASE_URL, Authorization } from "@/utils/config.js";
// utils/http.js (修改后的版本)
// const baseUrl = 'http://192.168.0.108:8087';
let requestCount = 0;
function showLoading() {
if (requestCount === 0) {
uni.showLoading({
title: "加载中...",
mask: false
});
}
requestCount++;
}
function hideLoading() {
if (requestCount > 0) {
requestCount--;
}
if (requestCount === 0) {
uni.hideLoading();
}
}
function request(options) {
const {
url,
@@ -13,11 +34,10 @@ function request(options) {
isShowLoading = true,
} = options;
// const token = uni.getStorageSync(tokenKey); // 获取token, 根据实际情况调整获取方式
const token = getStorageFun(TOKEN_NAME); // 获取token, 根据实际情况调整获取方式
const token = getStorageFun(TOKEN_NAME);
let defaultHeaders = {
Authorization: Authorization,
"HSM-AUTH": token ? token : "", // 如果存在token, 则添加到请求头中
"HSM-AUTH": token ? token : "",
"content-type": ["post", "POST"].includes(method)
? "application/x-www-form-urlencoded"
: "application/json",
@@ -30,13 +50,7 @@ function request(options) {
}
return new Promise((resolve, reject) => {
if (isShowLoading) {
// 请求之前做一些事
uni.showToast({
title: "加载中...",
image: "https://static.tbmall.xin/static/loading.gif",
// image: "/static/common/loading.gif", // 本地图片路径
position: "middle", // 可选:top/middle/bottom
});
showLoading();
}
uni.request({
url: BASE_URL + url,
@@ -44,12 +58,11 @@ function request(options) {
data,
header: {
...defaultHeaders,
...headers, // 使用展开运算符合并默认头和自定义头
...headers,
},
success: (res) => {
if (isShowLoading) {
// 请求之前做一些事
uni.hideToast();
hideLoading();
}
let data = res.data;
@@ -114,8 +127,7 @@ function request(options) {
fail: (error) => {
console.log("错误-2", url);
if (isShowLoading) {
// 请求之前做一些事
uni.hideToast();
hideLoading();
}
uni.showToast({
title: "服务器异常,稍后再试",