deming/components/shop/group/index.vue

116 lines
2.7 KiB
Vue
Raw Normal View History

2020-06-11 08:12:04 +00:00
<template>
<view class="group">
<view class="top">
<text>全部拼团</text>
2020-08-06 02:48:21 +00:00
<view class="more" @click="viewMore">
<text>查看更多</text>
<u-icon name="arrow-right" color="#999" size="22"></u-icon>
</view>
2020-06-11 08:12:04 +00:00
</view>
<view class="label">
2020-08-08 04:07:50 +00:00
<u-tabs :list="classifyList" name="gc_name" :is-scroll="true" :current="current" @change="tabsChange" active-color="#FF780F" :show-bar="false" height="60" font-size="24" inactive-color="#333333"></u-tabs>
2020-06-11 08:12:04 +00:00
</view>
2020-08-06 12:42:03 +00:00
<swiper :current="swiperCurrent" @animationfinish="animationfinish" style="height: 340rpx;">
2020-07-23 12:58:56 +00:00
<swiper-item class="swiper-item list" v-for="(_, i) in classifyList" :key="i">
2020-07-20 09:17:41 +00:00
<!-- 最多显示3个 -->
2020-08-08 04:07:50 +00:00
<view v-if="groupList[i]">
<sitem :info="info" v-for="(info, index) in groupList[i].slice(0, 3)" :key="index"></sitem>
</view>
<u-empty text="暂无拼团商品" mode="list" color="#000" v-if="!groupList[i] || !groupList[i].length" style="margin: 0 auto;"></u-empty>
2020-07-20 09:17:41 +00:00
</swiper-item>
</swiper>
2020-06-11 08:12:04 +00:00
</view>
</template>
<script>
import sitem from "./item"
export default {
name:"group",
components:{
sitem
2020-07-20 09:17:41 +00:00
},
2020-06-11 08:12:04 +00:00
data(){
return {
2020-07-24 11:48:57 +00:00
current: -1,
2020-07-20 09:17:41 +00:00
swiperCurrent: 0,
2020-07-24 11:48:57 +00:00
groupList: [], // 拼团商品
2020-07-24 12:35:28 +00:00
classifyList: [],
2020-06-11 08:12:04 +00:00
}
2020-07-20 09:17:41 +00:00
},
2020-07-24 11:48:57 +00:00
watch: {
current(value) {
this.getPinTuanList(this.classifyList[value].gc_id);
}
},
created() {
2020-07-24 12:35:28 +00:00
this.getGoodsClass();
2020-07-24 11:48:57 +00:00
},
2020-07-20 09:17:41 +00:00
methods: {
2020-07-24 12:35:28 +00:00
// 获取优惠券拼团分类
getGoodsClass() {
this.$u.api.getGoodsClass().then(res => {
if(res.errCode == 0) {
this.classifyList = res.data;
this.current = 0;
}
})
},
2020-07-24 11:48:57 +00:00
// 拼团列表
getPinTuanList(id) {
this.$u.api.getPinTuanList({
page: 0,
gc_id: id,
}).then(res => {
2020-08-08 04:07:50 +00:00
this.groupList[this.current] = res.data;
// console.log(this.groupList);
this.$forceUpdate();
2020-07-24 11:48:57 +00:00
})
},
2020-07-20 09:17:41 +00:00
tabsChange(index) {
this.swiperCurrent = index;
},
animationfinish(e) {
let current = e.detail.current;
this.swiperCurrent = current;
this.current = current;
},
2020-07-21 13:02:28 +00:00
viewMore() {
this.$u.route({
url: 'pageC/groupBuy/index',
})
}
2020-07-20 09:17:41 +00:00
}
2020-06-11 08:12:04 +00:00
}
</script>
<style lang="scss" scoped>
.group{
2020-07-24 11:48:57 +00:00
background-color: #ffffff;
.top {
padding: 0 30rpx;
2020-08-05 13:39:02 +00:00
height:80rpx;
2020-06-11 08:12:04 +00:00
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
>text:first-child{
font-size: 30rpx;
color: #333;
}
2020-08-06 02:48:21 +00:00
.more {
2020-08-06 12:42:03 +00:00
font-size: 20rpx;
2020-08-06 02:48:21 +00:00
display: flex;
align-items: center;
color: #999;
}
2020-06-11 08:12:04 +00:00
}
2020-07-24 11:48:57 +00:00
.list {
box-sizing: border-box;
2020-07-24 12:35:28 +00:00
padding: 0 30rpx;
2020-06-11 08:12:04 +00:00
display: flex;
2020-08-05 09:38:11 +00:00
> view {
&:not(:nth-child(3n)) {
2020-08-04 11:08:04 +00:00
margin-right: 20rpx;
}
}
2020-06-11 08:12:04 +00:00
}
}
</style>