2020-06-11 16:12:04 +08:00
|
|
|
|
<template>
|
|
|
|
|
<view class="list">
|
2020-06-11 16:37:52 +08:00
|
|
|
|
<view class="top">
|
|
|
|
|
商品推荐
|
|
|
|
|
</view>
|
2020-07-17 17:34:42 +08:00
|
|
|
|
<!-- <view class="label">
|
2020-06-18 14:57:26 +08:00
|
|
|
|
<text v-for="item in classifyList" :key="item.gc_id">{{ item.gc_name }}</text>
|
2020-06-11 16:37:52 +08:00
|
|
|
|
</view>
|
|
|
|
|
<view class="item">
|
2020-06-18 14:57:26 +08:00
|
|
|
|
<item v-for="item in goodsList" :key="item.goods_id" :info="item"></item>
|
2020-07-17 17:34:42 +08:00
|
|
|
|
</view> -->
|
|
|
|
|
<view>
|
|
|
|
|
<u-tabs-swiper ref="uTabs" :list="classifyList" name="gc_name" :is-scroll="true" active-color="#FF780F" :current="current" font-size="24" :show-bar="false" @change="tabsChange" height="60" ></u-tabs-swiper>
|
2020-07-16 17:39:06 +08:00
|
|
|
|
</view>
|
|
|
|
|
<swiper :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish" >
|
2020-07-17 17:34:42 +08:00
|
|
|
|
<swiper-item class="swiper-item" v-for="(_, index) in classifyList" :key="index">
|
|
|
|
|
<!-- <scroll-view scroll-y style="height: 800rpx;width: 100%;"> -->
|
2020-07-16 17:39:06 +08:00
|
|
|
|
<view class="item">
|
|
|
|
|
<item v-for="item in goodsList" :key="item.goods_id" :info="item"></item>
|
|
|
|
|
</view>
|
2020-07-17 17:34:42 +08:00
|
|
|
|
<u-empty text="暂无商品" mode="list" color="#000" v-if="!goodsList.length"></u-empty>
|
|
|
|
|
<!-- </scroll-view> -->
|
2020-07-16 17:39:06 +08:00
|
|
|
|
</swiper-item>
|
2020-07-17 17:34:42 +08:00
|
|
|
|
</swiper>
|
2020-06-11 16:12:04 +08:00
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
<script>
|
2020-06-11 16:37:52 +08:00
|
|
|
|
import item from "./item"
|
2020-06-11 16:12:04 +08:00
|
|
|
|
export default {
|
2020-07-16 17:39:06 +08:00
|
|
|
|
name:"list",
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
2020-07-17 17:34:42 +08:00
|
|
|
|
current: Number,
|
2020-07-16 17:39:06 +08:00
|
|
|
|
swiperCurrent: 0,
|
2020-07-17 17:34:42 +08:00
|
|
|
|
goodsList: [],
|
2020-07-16 17:39:06 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
2020-06-11 16:37:52 +08:00
|
|
|
|
components:{
|
|
|
|
|
item
|
2020-06-18 14:57:26 +08:00
|
|
|
|
},
|
|
|
|
|
props: {
|
2020-07-17 17:34:42 +08:00
|
|
|
|
classifyList: Array
|
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
current(index) {
|
|
|
|
|
const id = this.classifyList[index].gc_id;
|
|
|
|
|
this.getGoodsRecommend(id);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
created() {
|
|
|
|
|
this.current = 0;
|
|
|
|
|
console.log(this.classifyList);
|
2020-07-16 17:39:06 +08:00
|
|
|
|
},
|
|
|
|
|
methods: {
|
2020-07-17 17:34:42 +08:00
|
|
|
|
getGoodsRecommend(gc_id) {
|
|
|
|
|
this.$u.api.getGoodsRecommend({
|
|
|
|
|
page: 1,
|
|
|
|
|
gc_id: gc_id,
|
|
|
|
|
}).then((res)=>{
|
|
|
|
|
if (res.errCode == 0) {
|
|
|
|
|
this.goodsList = res.data.goodsList;
|
|
|
|
|
console.log(this.goodsList);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
2020-07-16 17:39:06 +08:00
|
|
|
|
// tabs通知swiper切换
|
|
|
|
|
tabsChange(index) {
|
|
|
|
|
this.swiperCurrent = index;
|
|
|
|
|
},
|
|
|
|
|
// swiper-item左右移动,通知tabs的滑块跟随移动
|
|
|
|
|
transition(e) {
|
|
|
|
|
let dx = e.detail.dx;
|
|
|
|
|
this.$refs.uTabs.setDx(dx);
|
|
|
|
|
},
|
|
|
|
|
// 由于swiper的内部机制问题,快速切换swiper不会触发dx的连续变化,需要在结束时重置状态
|
|
|
|
|
// swiper滑动结束,分别设置tabs和swiper的状态
|
|
|
|
|
animationfinish(e) {
|
|
|
|
|
let current = e.detail.current;
|
|
|
|
|
this.$refs.uTabs.setFinishCurrent(current);
|
|
|
|
|
this.swiperCurrent = current;
|
|
|
|
|
this.current = current;
|
|
|
|
|
},
|
2020-06-18 14:57:26 +08:00
|
|
|
|
}
|
2020-06-11 16:12:04 +08:00
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.list{
|
2020-06-11 16:37:52 +08:00
|
|
|
|
.top{
|
|
|
|
|
font-size: 30rpx;
|
|
|
|
|
height: 90rpx;
|
|
|
|
|
line-height: 90rpx;
|
|
|
|
|
text-align: center;
|
|
|
|
|
color: #333;
|
|
|
|
|
}
|
2020-07-17 17:34:42 +08:00
|
|
|
|
// .label{
|
|
|
|
|
// display: flex;
|
|
|
|
|
// color: #999;
|
|
|
|
|
// flex-wrap: wrap;
|
|
|
|
|
// >text{
|
|
|
|
|
// margin-right: 34rpx;
|
|
|
|
|
// margin-bottom: 10rpx;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// .item{
|
|
|
|
|
// display: flex;
|
|
|
|
|
// flex-wrap: wrap;
|
|
|
|
|
// justify-content: space-between;
|
|
|
|
|
// margin-top: 20rpx;
|
2020-06-11 16:37:52 +08:00
|
|
|
|
|
2020-07-17 17:34:42 +08:00
|
|
|
|
// }
|
2020-06-11 16:12:04 +08:00
|
|
|
|
}
|
|
|
|
|
</style>
|