From a18c3f127247dad2b9650fc457d136c39c03a3cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=98=8A=E5=A4=A9?= <442384644@qq.com> Date: Thu, 8 Oct 2026 14:24:07 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E8=90=A5=E9=94=80=E9=A1=B5):=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E7=A7=92=E6=9D=80/=E7=A0=8D=E4=BB=B7=E9=A1=B5?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E6=9C=AA=E8=A3=85=E6=97=B6=E7=99=BD=E5=B1=8F?= =?UTF-8?q?=E4=B8=8E=20colorStatus=20=E6=9C=AA=E5=AE=9A=E4=B9=89=E5=B4=A9?= =?UTF-8?q?=E6=BA=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 秒杀页 getSeckillIndexTime 无 catch,接口 400(插件未装)时页面 空白无提示,补 catch 并 toast 后端错误信息 - 砍价两页从 useColorTheme 解构 colorStatus,但该 composable 只返回 colorStyle,onLoad 读取 undefined.value 抛错导致标题停留在加载中、 列表与主题接口均不加载;改为页面级 ref + color_status 缓存, 命中缓存直接套用背景图,失败兜底默认背景 - 砍价列表接口失败同样补 toast 提示 --- .../src/pages/activity/goods_bargain/index.vue | 18 +++++++++++++++++- .../activity/goods_bargain_details/index.vue | 11 ++++++++++- .../src/pages/activity/goods_seckill/index.vue | 9 +++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/frontend/uni-app/src/pages/activity/goods_bargain/index.vue b/frontend/uni-app/src/pages/activity/goods_bargain/index.vue index 5287c5d16..a3d1b259f 100644 --- a/frontend/uni-app/src/pages/activity/goods_bargain/index.vue +++ b/frontend/uni-app/src/pages/activity/goods_bargain/index.vue @@ -58,7 +58,9 @@ import { HTTP_REQUEST_URL } from '@/config/app.js'; import i18n from '@/utils/lang.js'; import { onLoad, onReachBottom } from '@dcloudio/uni-app'; -const { colorStyle, colorStatus } = useColorTheme(); +const { colorStyle } = useColorTheme(); +// useColorTheme 不提供 colorStatus(主题档位),读缓存并在 colorChange 成功后更新 +const colorStatus = ref(uni.getStorageSync('color_status') || 0); const appStore = useAppStore(); const { isLogin } = storeToRefs(appStore); @@ -196,6 +198,12 @@ function getBargainList() { }) .catch((res) => { loading.value = false; + // 砍价插件未安装/未启用等场景给出提示,避免页面空白无反馈 + uni.showToast({ + title: typeof res === 'string' ? res : (res && res.msg) || i18n.t(`请求失败`), + icon: 'none', + duration: 2500 + }); }); } @@ -203,8 +211,16 @@ function getBargainList() { onLoad((options) => { if (!colorStatus.value) { colorChange('color_change').then((res) => { + uni.setStorageSync('color_status', res.data.status); + colorStatus.value = res.data.status; colorShow(res.data.status); + }).catch(() => { + // 主题档位接口失败时兜底默认背景,不阻断列表加载 + colorShow(1); }); + } else { + // 已有缓存档位时直接套用背景图(初始值不触发 watch) + colorShow(colorStatus.value); } var pages = getCurrentPages(); returnShow.value = pages.length === 1 ? false : true; diff --git a/frontend/uni-app/src/pages/activity/goods_bargain_details/index.vue b/frontend/uni-app/src/pages/activity/goods_bargain_details/index.vue index 63801787e..588d72a41 100644 --- a/frontend/uni-app/src/pages/activity/goods_bargain_details/index.vue +++ b/frontend/uni-app/src/pages/activity/goods_bargain_details/index.vue @@ -295,7 +295,9 @@ import { ref, watch } from 'vue'; import { storeToRefs } from 'pinia'; import { onLoad, onHide, onUnload, onShareAppMessage } from '@dcloudio/uni-app'; -const { colorStyle, colorStatus } = useColorTheme(); +const { colorStyle } = useColorTheme(); +// useColorTheme 不提供 colorStatus(主题档位),读缓存并在 colorChange 成功后更新 +const colorStatus = ref(uni.getStorageSync('color_status') || 0); const appStore = useAppStore(); const { isLogin } = storeToRefs(appStore); @@ -801,8 +803,15 @@ onLoad((options) => { // #endif if (!colorStatus.value) { colorChange('color_change').then((res) => { + uni.setStorageSync('color_status', res.data.status); + colorStatus.value = res.data.status; colorShow(res.data.status); + }).catch(() => { + colorShow(1); }); + } else { + // 已有缓存档位时直接套用背景图(初始值不触发 watch) + colorShow(colorStatus.value); } // #ifdef MP uni.getSystemInfo({ diff --git a/frontend/uni-app/src/pages/activity/goods_seckill/index.vue b/frontend/uni-app/src/pages/activity/goods_seckill/index.vue index 139c33a6f..03abd9417 100644 --- a/frontend/uni-app/src/pages/activity/goods_seckill/index.vue +++ b/frontend/uni-app/src/pages/activity/goods_seckill/index.vue @@ -70,6 +70,7 @@