feat: banner跳转ai店铺判断

This commit is contained in:
2026-06-08 17:34:23 +08:00
parent 7752c4efa5
commit 5551b08d5a
7 changed files with 186 additions and 17 deletions
+88 -1
View File
@@ -176,6 +176,30 @@
import aistore_tab1 from './components/aistore_tab1.vue';
import aistore_tab2 from './components/aistore_tab2.vue';
const HOME_DEFAULT_TAB_STORAGE_KEY = 'home.goods.defaultTabName';
const aiShopStatus = ref({
value: null,
checkedAt: 0,
});
const ensureAiShopOpened = async () => {
const now = Date.now();
if (aiShopStatus.value.value !== null && now - aiShopStatus.value.checkedAt < 60 * 1000) {
return Boolean(aiShopStatus.value.value);
}
const res = await api.checkShopStatus({});
if (res?.code !== 0) {
throw new Error('checkShopStatus_failed');
}
const opened = Boolean(res?.data);
aiShopStatus.value = {
value: opened ? 1 : 0,
checkedAt: now,
};
return opened;
};
const searchText = ref('');
const search = () => {
@@ -232,7 +256,70 @@
}
});
onShow(() => {
onShow(async () => {
try {
const opened = await ensureAiShopOpened();
if (!opened) {
const message = '您尚未开通AI店铺,无法查看购物车。请先开通AI店铺后再进行购买。';
uni.setStorageSync(HOME_DEFAULT_TAB_STORAGE_KEY, '会员优选');
uni.switchTab({
url: '/pages/index/index',
success: () => {
setTimeout(() => {
uni.showToast({
title: message,
icon: 'none',
duration: 2500,
});
}, 50);
},
fail: () => {
uni.reLaunch({
url: '/pages/index/index',
success: () => {
setTimeout(() => {
uni.showToast({
title: message,
icon: 'none',
duration: 2500,
});
}, 50);
},
});
},
});
return;
}
} catch (e) {
const message = '系统繁忙,请稍后重试';
uni.switchTab({
url: '/pages/index/index',
success: () => {
setTimeout(() => {
uni.showToast({
title: message,
icon: 'none',
duration: 2500,
});
}, 50);
},
fail: () => {
uni.reLaunch({
url: '/pages/index/index',
success: () => {
setTimeout(() => {
uni.showToast({
title: message,
icon: 'none',
duration: 2500,
});
}, 50);
},
});
},
});
return;
}
getSpuTimeList();
getCartList();
getMessageList();