feat: banner跳转ai店铺判断
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user