feat: banner跳转ai店铺判断
This commit is contained in:
@@ -15,7 +15,7 @@ SHOPRO_VERSION=v2.4.1
|
|||||||
#SHOPRO_DEV_BASE_URL=http://192.168.101.58:48090
|
#SHOPRO_DEV_BASE_URL=http://192.168.101.58:48090
|
||||||
|
|
||||||
# 服务器
|
# 服务器
|
||||||
# SHOPRO_DEV_BASE_URL=http://www.qflyqzy.net:48090
|
SHOPRO_DEV_BASE_URL=http://www.qflyqzy.net:48090
|
||||||
|
|
||||||
#SHOPRO_DEV_BASE_URL=https://www.qflyqzy.net/yg-api
|
#SHOPRO_DEV_BASE_URL=https://www.qflyqzy.net/yg-api
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ SHOPRO_VERSION=v2.4.1
|
|||||||
# SHOPRO_DEV_BASE_URL=http://192.168.1.7:48080
|
# SHOPRO_DEV_BASE_URL=http://192.168.1.7:48080
|
||||||
|
|
||||||
# 测试环境
|
# 测试环境
|
||||||
SHOPRO_DEV_BASE_URL=https://yougoutest.api.riananyoumu.com
|
# SHOPRO_DEV_BASE_URL=https://yougoutest.api.riananyoumu.com
|
||||||
|
|
||||||
# 本地
|
# 本地
|
||||||
# SHOPRO_DEV_BASE_URL=http://8.136.55.200:48090
|
# SHOPRO_DEV_BASE_URL=http://8.136.55.200:48090
|
||||||
|
|||||||
@@ -40,9 +40,14 @@
|
|||||||
type: Array,
|
type: Array,
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
|
defaultTabName: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
});
|
});
|
||||||
const hasPurchasedShop = ref(null);
|
const hasPurchasedShop = ref(null);
|
||||||
const displayList = ref([]);
|
const displayList = ref([]);
|
||||||
|
const hasAppliedDefaultTab = ref(false);
|
||||||
|
|
||||||
const computeDisplayList = () => {
|
const computeDisplayList = () => {
|
||||||
const list = Array.isArray(props.list) ? props.list : [];
|
const list = Array.isArray(props.list) ? props.list : [];
|
||||||
@@ -67,10 +72,24 @@
|
|||||||
onReachBottom,
|
onReachBottom,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const applyDefaultTabIfNeeded = (list) => {
|
||||||
|
const target = String(props.defaultTabName || '').trim();
|
||||||
|
if (!target) return;
|
||||||
|
if (hasAppliedDefaultTab.value) return;
|
||||||
|
const index = (Array.isArray(list) ? list : []).findIndex(
|
||||||
|
(v) => String(v?.name || '').trim() === target,
|
||||||
|
);
|
||||||
|
if (index >= 0) {
|
||||||
|
tabIndex.value = index;
|
||||||
|
hasAppliedDefaultTab.value = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const refreshDisplay = () => {
|
const refreshDisplay = () => {
|
||||||
const next = computeDisplayList();
|
const next = computeDisplayList();
|
||||||
displayList.value = next;
|
displayList.value = next;
|
||||||
syncMescrollItems(next);
|
syncMescrollItems(next);
|
||||||
|
applyDefaultTabIfNeeded(next);
|
||||||
if (tabIndex.value >= next.length) tabIndex.value = 0;
|
if (tabIndex.value >= next.length) tabIndex.value = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -96,6 +115,15 @@
|
|||||||
},
|
},
|
||||||
{ immediate: true, deep: true },
|
{ immediate: true, deep: true },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.defaultTabName,
|
||||||
|
() => {
|
||||||
|
hasAppliedDefaultTab.value = false;
|
||||||
|
applyDefaultTabIfNeeded(displayList.value);
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
);
|
||||||
// let tabIndex = ref(0);
|
// let tabIndex = ref(0);
|
||||||
const navChange = (i) => {
|
const navChange = (i) => {
|
||||||
// scrollToLastY()
|
// scrollToLastY()
|
||||||
|
|||||||
@@ -35,12 +35,12 @@
|
|||||||
v-if="props.type == 1"
|
v-if="props.type == 1"
|
||||||
>
|
>
|
||||||
<view class="label" v-if="props.data.tagSaleName">{{ props.data.tagSaleName }}</view>
|
<view class="label" v-if="props.data.tagSaleName">{{ props.data.tagSaleName }}</view>
|
||||||
<view class="num">已售{{ props.data.salesCount }}</view>
|
<view class="num" v-if="!props.memberPreferred">已售{{ props.data.salesCount }}</view>
|
||||||
</view>
|
</view>
|
||||||
<view v-else-if="props.type == 2">
|
<view v-else-if="props.type == 2">
|
||||||
<view class="flex-center ju-between mt10 wrap">
|
<view class="flex-center ju-between mt10 wrap">
|
||||||
<view class="num size26 m-r-4">{{ props.data.categoryText }}</view>
|
<view class="num size26 m-r-4">{{ props.data.categoryText }}</view>
|
||||||
<view class="num">销量:{{ props.data.salesCount }}</view>
|
<view class="num" v-if="!props.memberPreferred">销量:{{ props.data.salesCount }}</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="flex-row wrap" v-if="props.data.tagSaleName">
|
<view class="flex-row wrap" v-if="props.data.tagSaleName">
|
||||||
<view
|
<view
|
||||||
|
|||||||
+2
-2
@@ -2,8 +2,8 @@
|
|||||||
"name" : "优购商城",
|
"name" : "优购商城",
|
||||||
"appid" : "__UNI__8B19741",
|
"appid" : "__UNI__8B19741",
|
||||||
"description" : "",
|
"description" : "",
|
||||||
"versionName" : "1.3.8",
|
"versionName" : "1.3.9",
|
||||||
"versionCode" : 138,
|
"versionCode" : 139,
|
||||||
"transformPx" : false,
|
"transformPx" : false,
|
||||||
"app-plus" : {
|
"app-plus" : {
|
||||||
"privacy" : {
|
"privacy" : {
|
||||||
|
|||||||
+88
-1
@@ -176,6 +176,30 @@
|
|||||||
import aistore_tab1 from './components/aistore_tab1.vue';
|
import aistore_tab1 from './components/aistore_tab1.vue';
|
||||||
import aistore_tab2 from './components/aistore_tab2.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 searchText = ref('');
|
||||||
|
|
||||||
const search = () => {
|
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();
|
getSpuTimeList();
|
||||||
getCartList();
|
getCartList();
|
||||||
getMessageList();
|
getMessageList();
|
||||||
|
|||||||
+12
-4
@@ -50,7 +50,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view> -->
|
</view> -->
|
||||||
<!-- 暂时废弃 -->
|
<!-- 暂时废弃 -->
|
||||||
<view class="activeList flex-row wrap ju-between" v-if="activeList?.length">
|
<!-- <view class="activeList flex-row wrap ju-between" v-if="activeList?.length">
|
||||||
<view
|
<view
|
||||||
class="activeItem"
|
class="activeItem"
|
||||||
:style="{
|
:style="{
|
||||||
@@ -71,10 +71,10 @@
|
|||||||
>
|
>
|
||||||
<image :src="sheep.$url.cdn(v.bannerImage)" mode="scaleToFill" />
|
<image :src="sheep.$url.cdn(v.bannerImage)" mode="scaleToFill" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view> -->
|
||||||
</view>
|
</view>
|
||||||
<view class="goodsIndex">
|
<view class="goodsIndex">
|
||||||
<goods :list="tagList" v-if="tagList?.length" />
|
<goods :list="tagList" :defaultTabName="defaultTabName" v-if="tagList?.length" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -83,11 +83,13 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed } from 'vue';
|
import { ref, computed } from 'vue';
|
||||||
import { onLoad, onPullDownRefresh } from '@dcloudio/uni-app';
|
import { onLoad, onShow, onPullDownRefresh } from '@dcloudio/uni-app';
|
||||||
import goods from '@/components/goods/goods.vue';
|
import goods from '@/components/goods/goods.vue';
|
||||||
import sheep from '@/sheep';
|
import sheep from '@/sheep';
|
||||||
import $share from '@/sheep/platform/share';
|
import $share from '@/sheep/platform/share';
|
||||||
import * as api from '@/sheep/api/index/index';
|
import * as api from '@/sheep/api/index/index';
|
||||||
|
const HOME_DEFAULT_TAB_STORAGE_KEY = 'home.goods.defaultTabName';
|
||||||
|
const defaultTabName = ref('');
|
||||||
let template = ref({
|
let template = ref({
|
||||||
page: {
|
page: {
|
||||||
backgroundColor: '#F2F4F7',
|
backgroundColor: '#F2F4F7',
|
||||||
@@ -235,6 +237,12 @@
|
|||||||
sheep.$router.go(decodeURIComponent(options.page));
|
sheep.$router.go(decodeURIComponent(options.page));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onShow(() => {
|
||||||
|
const next = uni.getStorageSync(HOME_DEFAULT_TAB_STORAGE_KEY);
|
||||||
|
defaultTabName.value = next ? String(next) : '';
|
||||||
|
if (next) uni.removeStorageSync(HOME_DEFAULT_TAB_STORAGE_KEY);
|
||||||
|
});
|
||||||
//跳转浏览器
|
//跳转浏览器
|
||||||
const openExternal = (url) => {
|
const openExternal = (url) => {
|
||||||
if (!url) return;
|
if (!url) return;
|
||||||
|
|||||||
@@ -37,8 +37,9 @@
|
|||||||
</uni-swiper-dot>
|
</uni-swiper-dot>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup>
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
import * as AiApi from '@/sheep/api/ai/index';
|
||||||
let current = ref(0);
|
let current = ref(0);
|
||||||
// 轮播图
|
// 轮播图
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@@ -62,14 +63,59 @@
|
|||||||
current.value = e.detail.current;
|
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) {
|
if (!url) {
|
||||||
uni.showToast({
|
// uni.showToast({
|
||||||
title: '功能开发中, 敬请期待',
|
// title: '功能开发中, 敬请期待',
|
||||||
icon: 'none',
|
// icon: 'none',
|
||||||
});
|
// });
|
||||||
return;
|
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({
|
uni.navigateTo({
|
||||||
url: url,
|
url: url,
|
||||||
data: obj,
|
data: obj,
|
||||||
|
|||||||
Reference in New Issue
Block a user