From 3274209ee74929dfbced4827efa76c4dd50a5085 Mon Sep 17 00:00:00 2001 From: YeMingfei666 <1619116647@qq.com> Date: Wed, 12 Nov 2025 10:10:04 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=99=90=E6=97=B6?= =?UTF-8?q?=E6=8A=98=E6=89=A3=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 8 ++++---- src/store/modules/carts.ts | 6 +++--- src/views/tool/Instead/util.js | 5 ++++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.env.development b/.env.development index 34d306e..bf19431 100644 --- a/.env.development +++ b/.env.development @@ -7,14 +7,14 @@ VITE_APP_BASE_API=/dev-api # 接口地址 # VITE_APP_API_URL=https://tapi.cashier.sxczgkj.cn/ # 测试 -# VITE_APP_API_URL=https://cashier.sxczgkj.com/ # 正式 - VITE_APP_API_URL=http://192.168.1.42/ # 本地 +VITE_APP_API_URL=https://cashier.sxczgkj.com/ # 正式 +# VITE_APP_API_URL=http://192.168.1.42/ # 本地 # WebSocket 端点(不配置则关闭),线上 ws://api.youlai.tech/ws ,本地 ws://localhost:8989/ws # VITE_APP_WS_ENDPOINT=wss://sockets.sxczgkj.com/wss -# VITE_APP_WS_ENDPOINT=wss://czgeatws.sxczgkj.com/wss # 正式 -VITE_APP_WS_ENDPOINT=ws://192.168.1.42:2348 # 本地 +VITE_APP_WS_ENDPOINT=wss://czgeatws.sxczgkj.com/wss # 正式 +# VITE_APP_WS_ENDPOINT=ws://192.168.1.42:2348 # 本地 # 启用 Mock 服务 diff --git a/src/store/modules/carts.ts b/src/store/modules/carts.ts index 2490523..e5c9cec 100644 --- a/src/store/modules/carts.ts +++ b/src/store/modules/carts.ts @@ -198,8 +198,8 @@ export const useCartsStore = defineStore("carts", () => { goods.value = res.records.map(item => { return { ...item, - isLimitDiscount: limitDiscountRes.value !== null && canUseLimitTimeDiscount(item, limitDiscountRes.value, shopInfo, shopUser.userInfo), - limitDiscountPrice: limitDiscountRes.value !== null && returnPrice({ goods: { ...item, memberPrice: item.lowMemberPrice, salePrice: item.lowPrice }, shopInfo: shopInfo, limitTimeDiscountRes: limitDiscountRes.value, shopUserInfo: shopUser.userInfo, idKey: 'id' }) + isLimitDiscount: limitDiscountRes.value !== null && canUseLimitTimeDiscount(item, limitDiscountRes.value, shopInfo, vipUser.value), + limitDiscountPrice: limitDiscountRes.value !== null && returnPrice({ goods: { ...item, memberPrice: item.lowMemberPrice, salePrice: item.lowPrice }, shopInfo: shopInfo, limitTimeDiscountRes: limitDiscountRes.value, shopUserInfo: vipUser.value, idKey: 'id' }) } }); @@ -314,7 +314,7 @@ export const useCartsStore = defineStore("carts", () => { fullReductionActivities: fullReductionActivities.value, currentDinnerType: dinnerType.value, limitTimeDiscount: limitDiscountRes.value, - shopUserInfo: shopUser.userInfo, + shopUserInfo: vipUser.value, newUserDiscount: newUserDiscount.value })); diff --git a/src/views/tool/Instead/util.js b/src/views/tool/Instead/util.js index 79aea6a..b4c08a5 100644 --- a/src/views/tool/Instead/util.js +++ b/src/views/tool/Instead/util.js @@ -128,7 +128,7 @@ export function returnIsSeatFee(item) { /** * 计算购物车会员优惠价格 */ -export function returnVipDiscountPrice() {} +export function returnVipDiscountPrice() { } //计算商品券优惠价格 export function returnProductCouponPrice(coup, goodsArr, vipUser) { @@ -243,6 +243,9 @@ export function returnCartPrice(goods, vipUser) { // 价格保留两位小数不四舍五入 export function customTruncateToTwoDecimals(number) { + if (!number) { + return 0; + } let stringNumber = number.toString(); let dotIndex = stringNumber.indexOf("."); if (dotIndex === -1) { From 7ef27a41811d72011ea2de3eaa07795035a0a6b2 Mon Sep 17 00:00:00 2001 From: YeMingfei666 <1619116647@qq.com> Date: Wed, 12 Nov 2025 10:23:33 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E4=BF=A1=E6=81=AF=E6=A0=BC=E5=BC=8F=E5=8C=96?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/request.ts | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/utils/request.ts b/src/utils/request.ts index dca818b..651dc5e 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -12,6 +12,30 @@ const service = axios.create({ paramsSerializer: (params) => qs.stringify(params), }); +/** + * 格式化错误信息msg + */ +function formatErrorMsg(error: string) { + // 1. 获取原始提示文本(兜底空字符串避免报错) + const originMsg = error + // 2. 定义要匹配的前缀 + const exceptionPrefix = "Exception:"; + // 3. 判断是否包含目标前缀 + if (originMsg.includes(exceptionPrefix)) { + // 截取前缀后的内容 → 去除首尾空格 → 限制最大20个字符 + return originMsg + .slice( + originMsg.indexOf(exceptionPrefix) + + exceptionPrefix.length + ) + .trim() + .slice(0, 20); + } else { + // 不包含则按原逻辑截取前20个字符 + return originMsg.slice(0, 20); + } +} + // 请求拦截器 service.interceptors.request.use( (config: InternalAxiosRequestConfig) => { @@ -66,10 +90,11 @@ service.interceptors.response.use( }); return; } - ElMessage.error(msg || "系统出错"); - return Promise.reject(new Error(msg || "Error")); + ElMessage.error(formatErrorMsg(msg || "Error")); + return Promise.reject(new Error(formatErrorMsg(msg || "Error"))); }, async (error: any) => { + // 非 2xx 状态码处理 401、403、500 等 const { config, response } = error; if (response) {