mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-10-28 13:31:04 +00:00
fix(营销页): 修复秒杀/砍价页插件未装时白屏与 colorStatus 未定义崩溃
- 秒杀页 getSeckillIndexTime 无 catch,接口 400(插件未装)时页面 空白无提示,补 catch 并 toast 后端错误信息 - 砍价两页从 useColorTheme 解构 colorStatus,但该 composable 只返回 colorStyle,onLoad 读取 undefined.value 抛错导致标题停留在加载中、 列表与主题接口均不加载;改为页面级 ref + color_status 缓存, 命中缓存直接套用背景图,失败兜底默认背景 - 砍价列表接口失败同样补 toast 提示
This commit is contained in:
parent
b552e925ed
commit
a18c3f1272
@ -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;
|
||||
|
||||
@ -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({
|
||||
|
||||
@ -70,6 +70,7 @@
|
||||
|
||||
<script setup>
|
||||
import { getSeckillIndexTime, getSeckillList as getSeckillListApi } from '../../../api/activity.js';
|
||||
import i18n from '@/utils/lang.js';
|
||||
import home from '@/components/home/index.vue';
|
||||
import { useColorTheme } from '@/composables/useColorTheme';
|
||||
import { HTTP_REQUEST_URL } from '@/config/app';
|
||||
@ -117,6 +118,14 @@ function getSeckillConfig() {
|
||||
status.value = timeList.value[active.value].status;
|
||||
getSeckillList();
|
||||
}
|
||||
}).catch((err) => {
|
||||
// 秒杀插件未安装/未启用时接口报错,给出提示并结束 loading,避免页面空白
|
||||
uni.showToast({
|
||||
title: typeof err === 'string' ? err : (err && err.msg) || i18n.t(`请求失败`),
|
||||
icon: 'none',
|
||||
duration: 2500
|
||||
});
|
||||
loading.value = true;
|
||||
});
|
||||
}
|
||||
function getSeckillList() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user