feat: 点底部 tab 的“AI店铺”时没开通就不跳转并提示
This commit is contained in:
@@ -12,3 +12,4 @@
|
|||||||
- 我的社员ui重构
|
- 我的社员ui重构
|
||||||
- 粉色卡默认false所有页面统一调整
|
- 粉色卡默认false所有页面统一调整
|
||||||
- 选品广场结算返回到我的店铺页
|
- 选品广场结算返回到我的店铺页
|
||||||
|
- 点底部 tab 的“AI店铺”时没开通就不跳转并提示
|
||||||
@@ -31,6 +31,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { computed, ref, watch } from 'vue';
|
import { computed, ref, watch } from 'vue';
|
||||||
import { onShow } from '@dcloudio/uni-app';
|
import { onShow } from '@dcloudio/uni-app';
|
||||||
|
import * as AiApi from '@/sheep/api/ai/index';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
path: {
|
path: {
|
||||||
@@ -120,13 +121,56 @@
|
|||||||
return isActive(item) ? item.selectedIconPath : item.iconPath;
|
return isActive(item) ? item.selectedIconPath : item.iconPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
const onTap = (item) => {
|
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 AiApi.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 onTap = async (item) => {
|
||||||
if (item.isMid) {
|
if (item.isMid) {
|
||||||
hideNativeTabBar();
|
hideNativeTabBar();
|
||||||
uni.navigateTo({ url: item.pagePath });
|
uni.navigateTo({ url: item.pagePath });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isActive(item)) return;
|
if (isActive(item)) return;
|
||||||
|
|
||||||
|
if (normalizePath(item.pagePath) === '/pages/index/aiStore') {
|
||||||
|
try {
|
||||||
|
const opened = await ensureAiShopOpened();
|
||||||
|
if (!opened) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '您尚未开通AI店铺,无法查看购物车。请先开通AI店铺后再进行购买。',
|
||||||
|
icon: 'none',
|
||||||
|
duration: 2500,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '系统繁忙,请稍后重试',
|
||||||
|
icon: 'none',
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
hideNativeTabBar();
|
hideNativeTabBar();
|
||||||
uni.switchTab({
|
uni.switchTab({
|
||||||
url: item.pagePath,
|
url: item.pagePath,
|
||||||
|
|||||||
+14
-4
@@ -41,7 +41,11 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="notice-card" v-if="mesArr.length && index === 0">
|
<view class="notice-card" v-if="mesArr.length && index === 0">
|
||||||
<view class="notice-marquee-viewport">
|
<view class="notice-marquee-viewport">
|
||||||
<view class="notice-marquee-track" :class="{ 'is-scroll': mesArr.length > 1 }">
|
<view
|
||||||
|
class="notice-marquee-track"
|
||||||
|
:class="{ 'is-scroll': mesArr.length > 1 }"
|
||||||
|
:style="mesArr.length > 1 ? { '--marquee-duration': marqueeDuration } : {}"
|
||||||
|
>
|
||||||
<view class="notice-marquee-content">
|
<view class="notice-marquee-content">
|
||||||
<view
|
<view
|
||||||
v-for="(line, i) in mesArr"
|
v-for="(line, i) in mesArr"
|
||||||
@@ -164,7 +168,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, watch } from 'vue';
|
import { ref, watch, computed } from 'vue';
|
||||||
import { onLoad, onShow } from '@dcloudio/uni-app';
|
import { onLoad, onShow } from '@dcloudio/uni-app';
|
||||||
import * as api from '@/sheep/api/ai/index';
|
import * as api from '@/sheep/api/ai/index';
|
||||||
import card_pages from '@/components/card_pages/card_pages';
|
import card_pages from '@/components/card_pages/card_pages';
|
||||||
@@ -187,6 +191,11 @@
|
|||||||
const selectedTimeId = ref(null);
|
const selectedTimeId = ref(null);
|
||||||
const navName = ref('');
|
const navName = ref('');
|
||||||
const mesArr = ref([]);
|
const mesArr = ref([]);
|
||||||
|
const marqueeDuration = computed(() => {
|
||||||
|
const n = Array.isArray(mesArr.value) ? mesArr.value.length : 0;
|
||||||
|
const seconds = Math.max(14, n * 2);
|
||||||
|
return `${seconds}s`;
|
||||||
|
});
|
||||||
|
|
||||||
function changeTimeRound(e) {
|
function changeTimeRound(e) {
|
||||||
navName.value = e.name;
|
navName.value = e.name;
|
||||||
@@ -462,7 +471,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.notice-text {
|
.notice-text {
|
||||||
flex: 1;
|
// flex: 1;
|
||||||
|
width: 300rpx;
|
||||||
font-size: 22rpx;
|
font-size: 22rpx;
|
||||||
color: #111111;
|
color: #111111;
|
||||||
line-height: 50rpx;
|
line-height: 50rpx;
|
||||||
@@ -482,7 +492,7 @@
|
|||||||
transform: translateX(0);
|
transform: translateX(0);
|
||||||
will-change: transform;
|
will-change: transform;
|
||||||
&.is-scroll {
|
&.is-scroll {
|
||||||
animation: notice-marquee-move 16s linear infinite;
|
animation: notice-marquee-move var(--marquee-duration, 16s) linear infinite;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user