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
|
<view
|
||||||
class="navItem flex-center flex-column flex1 shrink nowrap"
|
class="navItem flex-center flex-column flex1 shrink nowrap"
|
||||||
:class="{ tabIndex: i == tabIndex, c34: i == tabIndex }"
|
:class="{ tabIndex: i == tabIndex, c34: i == tabIndex }"
|
||||||
v-for="(v, i) in props.list"
|
v-for="(v, i) in displayList"
|
||||||
:key="i"
|
:key="i"
|
||||||
@click="navChange(i)"
|
@click="navChange(i)"
|
||||||
>
|
>
|
||||||
@@ -18,31 +18,80 @@
|
|||||||
</su-sticky>
|
</su-sticky>
|
||||||
<view class="goodsPages">
|
<view class="goodsPages">
|
||||||
<goods-item
|
<goods-item
|
||||||
v-for="(tab, i) in props.list"
|
v-for="(tab, i) in displayList"
|
||||||
:key="tab.id || i"
|
:key="tab.id || i"
|
||||||
:ref="(el) => mescrollItems[i] && (mescrollItems[i].value = el)"
|
:ref="(el) => mescrollItems[i] && (mescrollItems[i].value = el)"
|
||||||
:i="i"
|
:i="i"
|
||||||
:index="tabIndex"
|
:index="tabIndex"
|
||||||
:tabs="props.list"
|
:tabs="displayList"
|
||||||
></goods-item>
|
></goods-item>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue';
|
import { ref, watch } from 'vue';
|
||||||
import goodsItem from '../goodsItem/goodsItem.vue';
|
import goodsItem from '../goodsItem/goodsItem.vue';
|
||||||
import { onPageScroll, onReachBottom, onShow } from '@dcloudio/uni-app';
|
import { onPageScroll, onReachBottom, onShow } from '@dcloudio/uni-app';
|
||||||
import useMescrollMore from '@/uni_modules/mescroll-uni/hooks/useMescrollMore.js';
|
import useMescrollMore from '@/uni_modules/mescroll-uni/hooks/useMescrollMore.js';
|
||||||
|
import UserApi from '@/sheep/api/member/user';
|
||||||
let props = defineProps({
|
let props = defineProps({
|
||||||
list: {
|
list: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => [],
|
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 使用
|
// 动态生成与 tabs 同步的 refs 数组,供 useMescrollMore 使用
|
||||||
const mescrollItems = props.list.map(() => ref(null));
|
const mescrollItems = [];
|
||||||
const { tabIndex, getMescroll, scrollToLastY } = useMescrollMore(
|
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,
|
mescrollItems,
|
||||||
onPageScroll,
|
onPageScroll,
|
||||||
onReachBottom,
|
onReachBottom,
|
||||||
@@ -52,6 +101,10 @@
|
|||||||
// scrollToLastY()
|
// scrollToLastY()
|
||||||
tabIndex.value = i;
|
tabIndex.value = i;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onShow(() => {
|
||||||
|
loadShopStatus();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
+4
-4
@@ -88,14 +88,14 @@
|
|||||||
</s-pages>
|
</s-pages>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, reactive, onMounted, watch, getCurrentInstance } from 'vue';
|
import { ref, watch, getCurrentInstance } from 'vue';
|
||||||
import SpuApi from '@/sheep/api/product/spu';
|
// import SpuApi from '@/sheep/api/product/spu';
|
||||||
import CartApi from '@/sheep/api/trade/cart.js';
|
// import CartApi from '@/sheep/api/trade/cart.js';
|
||||||
import * as api from '@/sheep/api/ai/index';
|
import * as api from '@/sheep/api/ai/index';
|
||||||
import aiOrder from '@/components/ai_order/ai_order';
|
import aiOrder from '@/components/ai_order/ai_order';
|
||||||
import card_payment from '@/components/card_payment/card_payment';
|
import card_payment from '@/components/card_payment/card_payment';
|
||||||
import { onShow } from '@dcloudio/uni-app';
|
import { onShow } from '@dcloudio/uni-app';
|
||||||
const { proxy } = getCurrentInstance();
|
// const { proxy } = getCurrentInstance();
|
||||||
const searchText = ref('');
|
const searchText = ref('');
|
||||||
const search = (text = '') => {
|
const search = (text = '') => {
|
||||||
pageCommodity.value.downCallback();
|
pageCommodity.value.downCallback();
|
||||||
|
|||||||
Reference in New Issue
Block a user