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