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
+52 -6
View File
@@ -37,8 +37,9 @@
</uni-swiper-dot>
</template>
<script setup lang="ts">
<script setup>
import { ref } from 'vue';
import * as AiApi from '@/sheep/api/ai/index';
let current = ref(0);
// 轮播图
const props = defineProps({
@@ -62,14 +63,59 @@
current.value = e.detail.current;
};
const go = (url, obj = {}) => {
const HOME_DEFAULT_TAB_STORAGE_KEY = 'home.goods.defaultTabName';
const parsePath = (raw) => {
const s = typeof raw === 'string' ? raw : '';
const [p] = s.split('?');
return p;
};
const go = async (url, obj = {}) => {
if (!url) {
uni.showToast({
title: '功能开发中, 敬请期待',
icon: 'none',
});
// uni.showToast({
// title: '功能开发中, 敬请期待',
// icon: 'none',
// });
return;
}
const path = parsePath(url);
if (path === '/pages/index/aiStore') {
try {
const res = await AiApi.checkShopStatus({});
const opened = res?.code === 0 ? Boolean(res?.data) : false;
if (!opened) {
const message =
'您尚未开通AI店铺,无法查看购物车。请先开通AI店铺后再进行购买。';
uni.setStorageSync(HOME_DEFAULT_TAB_STORAGE_KEY, '会员优选');
uni.showToast({
title: message,
icon: 'none',
duration: 2500,
});
setTimeout(() => {
uni.switchTab({
url: '/pages/index/index',
fail: () => {
uni.reLaunch({ url: '/pages/index/index' });
},
});
}, 1000);
return;
}
} catch (e) {
uni.showToast({
title: '系统繁忙,请稍后重试',
icon: 'none',
});
return;
}
uni.switchTab({ url: '/pages/index/aiStore' });
return;
}
uni.navigateTo({
url: url,
data: obj,