This commit is contained in:
zmj 2024-05-11 10:05:21 +08:00
commit 56668bb2e0
1 changed files with 758 additions and 723 deletions

View File

@ -22,8 +22,8 @@
<view class='headScoll' ref='headscroll' :style="{height:isScroll?'0':'200rpx'}"> <view class='headScoll' ref='headscroll' :style="{height:isScroll?'0':'200rpx'}">
<scroll-view class="head-view" scroll-x> <scroll-view class="head-view" scroll-x>
<view class="list"> <view class="list">
<view class="item" :class="{'item-active': topActive===item.id}" <view class="item" :class="{'item-active': topActive===item.id}" v-for="(item, index) in goodClassList"
v-for="(item, index) in goodClassList" :key="index" @click="changeOne(item, index)"> :key="index" @click="changeOne(item, index)">
<view class="c-img"><up-image height="100rpx" width="100rpx" :src="item.pic"></up-image></view> <view class="c-img"><up-image height="100rpx" width="100rpx" :src="item.pic"></up-image></view>
<view class="c-text u-line-1">{{item.name}}</view> <view class="c-text u-line-1">{{item.name}}</view>
</view> </view>
@ -42,8 +42,8 @@
<view class="head-title">全部分类</view> <view class="head-title">全部分类</view>
<scroll-view scroll-y style="height: 600rpx;"> <scroll-view scroll-y style="height: 600rpx;">
<view class="list"> <view class="list">
<view class="item" :class="{'item-active': topActive===item.id}" <view class="item" :class="{'item-active': topActive===item.id}" v-for="(item, index) in goodClassList"
v-for="(item, index) in goodClassList" :key="index" @click="changeOne(item, index)"> :key="index" @click="changeOne(item, index)">
<view class="c-img"><up-image height="100rpx" width="100rpx" :src="item.pic"></up-image> <view class="c-img"><up-image height="100rpx" width="100rpx" :src="item.pic"></up-image>
</view> </view>
<view class="c-text u-line-1">{{item.name}}</view> <view class="c-text u-line-1">{{item.name}}</view>
@ -54,8 +54,8 @@
</viewPopup> </viewPopup>
<view class="scroll-box"> <view class="scroll-box">
<scroll-view class="left" scroll-y> <scroll-view class="left" scroll-y>
<view class="item u-line-1" :class="{'item-active': leftActive===item.id}" <view class="item u-line-1" :class="{'item-active': leftActive===item.id}" v-for="(item, index) in goodClassTow"
v-for="(item, index) in goodClassTow" :key="index" @click="changeTwo(item, index)">{{item.name}} :key="index" @click="changeTwo(item, index)">{{item.name}}
</view> </view>
<view style="width: 100%;height: 450rpx;"></view> <view style="width: 100%;height: 450rpx;"></view>
</scroll-view> </scroll-view>
@ -77,28 +77,24 @@
<view class="item" :class="{'order-active': where.order==''}" @click="changeOrder('')">综合</view> <view class="item" :class="{'order-active': where.order==''}" @click="changeOrder('')">综合</view>
<view class="item" :class="{'order-active': where.order=='desc'||where.order=='asc'}" <view class="item" :class="{'order-active': where.order=='desc'||where.order=='asc'}"
@click="changeOrder(where.order=='asc'?'desc':'asc')">价格</view> @click="changeOrder(where.order=='asc'?'desc':'asc')">价格</view>
<view class="item" :class="{'order-active': where.order=='sales'}" <view class="item" :class="{'order-active': where.order=='sales'}" @click="changeOrder('sales')">销量</view>
@click="changeOrder('sales')">销量</view>
</view> </view>
</view> </view>
<viewPopup v-if="show===2" @close="show=0"> <viewPopup v-if="show===2" @close="show=0">
<view class="cateOne"> <view class="cateOne">
<scroll-view scroll-y style="height: 230rpx;"> <scroll-view scroll-y style="height: 230rpx;">
<view class="classify-list"> <view class="classify-list">
<view class="classify-list-item u-line-1" <view class="classify-list-item u-line-1" :class="{'item-active': rightActive===item.id}"
:class="{'item-active': rightActive===item.id}" v-for="(item, index) in goodClassThree" :key="index" @click="changeThree(item, index)">
v-for="(item, index) in goodClassThree" :key="index"
@click="changeThree(item, index)">
{{item.name}} {{item.name}}
</view> </view>
</view> </view>
</scroll-view> </scroll-view>
</view> </view>
</viewPopup> </viewPopup>
<scroll-view class="list" id='drag_area' style="overscroll-behavior: none;" @scroll="hideHeadView" <scroll-view class="list" id='drag_area' style="overscroll-behavior: none;" @scroll="hideHeadView" scroll-y
scroll-y @scrolltolower="loadMoreGood"> @scrolltolower="loadMoreGood">
<view class="shop-item" v-for="(item, index) in goodList" :key="item.id" <view class="shop-item" v-for="(item, index) in goodList" :key="item.id" @click="openGoodPopup(item)">
@click="openGoodPopup(item)">
<view class="shop-img"> <view class="shop-img">
<up-image width="120rpx" height="120rpx" :src="item.imgs"></up-image> <up-image width="120rpx" height="120rpx" :src="item.imgs"></up-image>
</view> </view>
@ -201,7 +197,7 @@
const cartStore = useCartStore(); const cartStore = useCartStore();
const show = ref(0); const show = ref(0);
const topActive = ref(0); const topActive = ref(0);
const changeOne = (item, index) => { const changeOne = async (item, index) => {
console.log('选择', item, index); console.log('选择', item, index);
topActive.value = item.id; topActive.value = item.id;
show.value = 0; show.value = 0;
@ -210,6 +206,7 @@
leftActive.value = goodClassTow.value[0]?.id || ''; leftActive.value = goodClassTow.value[0]?.id || '';
rightActive.value = goodClassThree.value[0]?.id || ''; rightActive.value = goodClassThree.value[0]?.id || '';
getGoodList(); getGoodList();
if(!item.isLoading) getgoodClassList(topActive.value); // , ,
} }
const leftActive = ref(0); const leftActive = ref(0);
@ -220,6 +217,7 @@
goodClassThree.value = item?.children || []; goodClassThree.value = item?.children || [];
rightActive.value = goodClassThree.value[0]?.id || ''; rightActive.value = goodClassThree.value[0]?.id || '';
getGoodList(); getGoodList();
if(!item.isLoading) getgoodClassList(leftActive.value); // , ,
} }
const rightActive = ref(0); const rightActive = ref(0);
@ -294,10 +292,12 @@
const goodClassList = ref([]); // const goodClassList = ref([]); //
const goodClassTow = ref([]); // const goodClassTow = ref([]); //
const goodClassThree = ref([]); // const goodClassThree = ref([]); //
const getgoodClassList = () => { const getgoodClassList = (pid = 0) => {
goodClassListApi({ goodClassListApi({
page_size: 1000 pid: pid,
page_size: 10000
}).then(res => { }).then(res => {
if (pid == 0) { //
res.data?.lists?.unshift({ res.data?.lists?.unshift({
id: "", id: "",
name: "全部", name: "全部",
@ -308,7 +308,7 @@
if (!item.children) item.children = []; if (!item.children) item.children = [];
item.children?.unshift({ item.children?.unshift({
id: "", id: "",
pid: item.id, pid: item.id, //
name: "全部", name: "全部",
}) })
item.children = item.children.map(t => { item.children = item.children.map(t => {
@ -322,12 +322,47 @@
}) })
return item; return item;
}) })
//
goodClassList.value = res.data?.lists || []; goodClassList.value = res.data?.lists || [];
goodClassTow.value = goodClassList.value[0]?.children || []; goodClassTow.value = goodClassList.value[0]?.children || [];
goodClassThree.value = goodClassTow.value[0]?.children || []; goodClassThree.value = goodClassTow.value[0]?.children || [];
topActive.value = goodClassList.value[0]?.id; topActive.value = goodClassList.value[0]?.id;
leftActive.value = goodClassTow.value[0]?.id; leftActive.value = goodClassTow.value[0]?.id;
rightActive.value = goodClassThree.value[0]?.id; rightActive.value = goodClassThree.value[0]?.id;
} else {
let flag = 1;
goodClassList.value.forEach(item => { //
if (item.id == pid) {
if (!item.children) {
item.children = [];
item.children.unshift({
id: "",
pid: item.id,
name: "全部",
})
}
item.children = [...item.children, ...res.data.lists];
item.isLoading = true;
goodClassTow.value = item.children;
flag = 0;
}
})
if (flag) goodClassTow.value.forEach(item => { //
if (item.id == pid) {
if (!item.children) {
item.children = [];
item.children.unshift({
id: "",
pid: item.id,
name: "全部",
})
}
item.children = [...item.children, ...res.data.lists];
item.isLoading = true;
goodClassThree.value = item.children;
}
})
}
}) })
} }