This commit is contained in:
2020-07-17 17:34:42 +08:00
parent 5a4e302899
commit 7b9479d56c
10 changed files with 308 additions and 291 deletions

View File

@@ -3,25 +3,25 @@
<view class="top">
商品推荐
</view>
<view class="label">
<!-- <view class="label">
<text v-for="item in classifyList" :key="item.gc_id">{{ item.gc_name }}</text>
</view>
<view class="item">
<item v-for="item in goodsList" :key="item.goods_id" :info="item"></item>
</view>
<!-- <view>
<u-tabs-swiper ref="uTabs" :list="tabList" :current="current" @change="tabsChange" :is-scroll="false"
swiperWidth="750" height="60"></u-tabs-swiper>
</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>
</view>
<swiper :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish" >
<swiper-item class="swiper-item" v-for="(_, index) in tabList" :key="index">
<scroll-view scroll-y style="height: 800rpx;width: 100%;">
<swiper-item class="swiper-item" v-for="(_, index) in classifyList" :key="index">
<!-- <scroll-view scroll-y style="height: 800rpx;width: 100%;"> -->
<view class="item">
<item v-for="item in goodsList" :key="item.goods_id" :info="item"></item>
</view>
</scroll-view>
<u-empty text="暂无商品" mode="list" color="#000" v-if="!goodsList.length"></u-empty>
<!-- </scroll-view> -->
</swiper-item>
</swiper> -->
</swiper>
</view>
</template>
<script>
@@ -30,21 +30,39 @@ export default {
name:"list",
data() {
return {
tabList: [{name: '推荐'}, {name: '推荐'}, {name: '推荐'}],
tabList: [],
current: 0,
current: Number,
swiperCurrent: 0,
goodsList: [],
}
},
components:{
item
},
props: {
classifyList: Array,
goodsList: Array,
classifyList: Array
},
watch: {
current(index) {
const id = this.classifyList[index].gc_id;
this.getGoodsRecommend(id);
}
},
created() {
this.current = 0;
console.log(this.classifyList);
},
methods: {
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);
}
})
},
// tabs通知swiper切换
tabsChange(index) {
this.swiperCurrent = index;
@@ -74,21 +92,21 @@ export default {
text-align: center;
color: #333;
}
.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;
// .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;
}
// }
}
</style>