feat: ’已开通不展示会员优选‘兜底
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
# Changelog
|
||||
|
||||
所有版本改动记录在此文件中。
|
||||
|
||||
## [Unreleased]
|
||||
-
|
||||
|
||||
## [1.3.9] - 2026-06-05
|
||||
- 添加“会员优选”标签下列表api
|
||||
- 我的订单添加`店铺订单`列
|
||||
- 添加商城订单列type为5(开通ai店铺订单)详情接口api
|
||||
- 首页`会员优选`分类兜底(已开通ai店铺不展示)
|
||||
@@ -6,7 +6,7 @@
|
||||
<view
|
||||
class="navItem flex-center flex-column flex1 shrink nowrap"
|
||||
:class="{ tabIndex: i == tabIndex, c34: i == tabIndex }"
|
||||
v-for="(v, i) in props.list"
|
||||
v-for="(v, i) in displayList"
|
||||
:key="i"
|
||||
@click="navChange(i)"
|
||||
>
|
||||
@@ -18,31 +18,80 @@
|
||||
</su-sticky>
|
||||
<view class="goodsPages">
|
||||
<goods-item
|
||||
v-for="(tab, i) in props.list"
|
||||
v-for="(tab, i) in displayList"
|
||||
:key="tab.id || i"
|
||||
:ref="(el) => mescrollItems[i] && (mescrollItems[i].value = el)"
|
||||
:i="i"
|
||||
:index="tabIndex"
|
||||
:tabs="props.list"
|
||||
:tabs="displayList"
|
||||
></goods-item>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { ref, watch } from 'vue';
|
||||
import goodsItem from '../goodsItem/goodsItem.vue';
|
||||
import { onPageScroll, onReachBottom, onShow } from '@dcloudio/uni-app';
|
||||
import useMescrollMore from '@/uni_modules/mescroll-uni/hooks/useMescrollMore.js';
|
||||
import UserApi from '@/sheep/api/member/user';
|
||||
let props = defineProps({
|
||||
list: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
});
|
||||
const hasPurchasedShop = ref(null);
|
||||
const displayList = ref([]);
|
||||
|
||||
const computeDisplayList = () => {
|
||||
const list = Array.isArray(props.list) ? props.list : [];
|
||||
const hasVip = list.some((v) => String(v?.name || '').trim() === '会员优选');
|
||||
if (hasVip && Number(hasPurchasedShop.value) === 1) {
|
||||
return list.filter((v) => String(v?.name || '').trim() !== '会员优选');
|
||||
}
|
||||
return list;
|
||||
};
|
||||
|
||||
// 动态生成与 tabs 同步的 refs 数组,供 useMescrollMore 使用
|
||||
const mescrollItems = props.list.map(() => ref(null));
|
||||
const { tabIndex, getMescroll, scrollToLastY } = useMescrollMore(
|
||||
const mescrollItems = [];
|
||||
const syncMescrollItems = (list) => {
|
||||
const n = Array.isArray(list) ? list.length : 0;
|
||||
while (mescrollItems.length < n) mescrollItems.push(ref(null));
|
||||
if (mescrollItems.length > n) mescrollItems.splice(n);
|
||||
};
|
||||
|
||||
const refreshDisplay = () => {
|
||||
const next = computeDisplayList();
|
||||
displayList.value = next;
|
||||
syncMescrollItems(next);
|
||||
if (tabIndex.value >= next.length) tabIndex.value = 0;
|
||||
};
|
||||
|
||||
const loadShopStatus = async () => {
|
||||
const list = Array.isArray(props.list) ? props.list : [];
|
||||
const hasVip = list.some((v) => String(v?.name || '').trim() === '会员优选');
|
||||
if (!hasVip) return;
|
||||
if (hasPurchasedShop.value !== null && hasPurchasedShop.value !== undefined) return;
|
||||
const res = await UserApi.getUserInfo().catch(() => ({ code: -1 }));
|
||||
if (res?.code === 0) {
|
||||
hasPurchasedShop.value = Number(res?.data?.hasPurchasedShop) || 0;
|
||||
refreshDisplay();
|
||||
}
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.list,
|
||||
() => {
|
||||
refreshDisplay();
|
||||
if (hasPurchasedShop.value === null || hasPurchasedShop.value === undefined) {
|
||||
loadShopStatus();
|
||||
}
|
||||
},
|
||||
{ immediate: true, deep: true },
|
||||
);
|
||||
|
||||
const { tabIndex } = useMescrollMore(
|
||||
mescrollItems,
|
||||
onPageScroll,
|
||||
onReachBottom,
|
||||
@@ -52,6 +101,10 @@
|
||||
// scrollToLastY()
|
||||
tabIndex.value = i;
|
||||
};
|
||||
|
||||
onShow(() => {
|
||||
loadShopStatus();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
+4
-4
@@ -88,14 +88,14 @@
|
||||
</s-pages>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted, watch, getCurrentInstance } from 'vue';
|
||||
import SpuApi from '@/sheep/api/product/spu';
|
||||
import CartApi from '@/sheep/api/trade/cart.js';
|
||||
import { ref, watch, getCurrentInstance } from 'vue';
|
||||
// import SpuApi from '@/sheep/api/product/spu';
|
||||
// import CartApi from '@/sheep/api/trade/cart.js';
|
||||
import * as api from '@/sheep/api/ai/index';
|
||||
import aiOrder from '@/components/ai_order/ai_order';
|
||||
import card_payment from '@/components/card_payment/card_payment';
|
||||
import { onShow } from '@dcloudio/uni-app';
|
||||
const { proxy } = getCurrentInstance();
|
||||
// const { proxy } = getCurrentInstance();
|
||||
const searchText = ref('');
|
||||
const search = (text = '') => {
|
||||
pageCommodity.value.downCallback();
|
||||
|
||||
Reference in New Issue
Block a user