2020-07-16 17:39:06 +08:00
|
|
|
|
<template>
|
|
|
|
|
<view class="group">
|
|
|
|
|
<view>
|
2020-07-21 21:02:28 +08:00
|
|
|
|
<u-tabs-swiper ref="uTabs" :list="tabList" name="gc_name" :current="current" @change="tabsChange" :is-scroll="true" active-color="#FF780F" swiperWidth="750" height="88" :show-bar="false"></u-tabs-swiper>
|
2020-07-16 17:39:06 +08:00
|
|
|
|
</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%;" @scrolltolower="onreachBottom">
|
2020-07-21 21:02:28 +08:00
|
|
|
|
<SpecialGoods v-for="(item, index) in pinTuanList" :key="index" :item="item" type='group'></SpecialGoods>
|
|
|
|
|
<u-empty text="暂无商品" mode="list" color="#000" v-if="!pinTuanList.length"></u-empty>
|
2020-07-16 17:39:06 +08:00
|
|
|
|
</scroll-view>
|
|
|
|
|
</swiper-item>
|
|
|
|
|
</swiper>
|
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
<script>
|
|
|
|
|
import SpecialGoods from "../../components/shop/special-shop/index"
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
2020-07-21 21:02:28 +08:00
|
|
|
|
tabList: [],
|
|
|
|
|
current: Number,
|
2020-07-16 17:39:06 +08:00
|
|
|
|
swiperCurrent: 0,
|
2020-07-21 21:02:28 +08:00
|
|
|
|
page: 0,
|
|
|
|
|
pinTuanList: [],
|
2020-07-16 17:39:06 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
components: {
|
|
|
|
|
SpecialGoods
|
|
|
|
|
},
|
2020-07-21 21:02:28 +08:00
|
|
|
|
onLoad() {
|
|
|
|
|
this.getGoodsClass();
|
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
current(index) {
|
2020-07-22 18:51:48 +08:00
|
|
|
|
// console.log(this.tabList);
|
2020-07-21 21:02:28 +08:00
|
|
|
|
this.getPinTuanList(this.tabList[index].gc_id);
|
|
|
|
|
}
|
2020-07-16 17:39:06 +08:00
|
|
|
|
},
|
|
|
|
|
methods: {
|
2020-07-21 21:02:28 +08:00
|
|
|
|
// 获取优惠券拼团分类
|
|
|
|
|
async getGoodsClass() {
|
|
|
|
|
return await this.$u.api.getGoodsClass().then(res => {
|
|
|
|
|
if(res.errCode == 0) {
|
|
|
|
|
this.tabList = res.data;
|
|
|
|
|
this.current = 0;
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
// 拼团列表
|
|
|
|
|
getPinTuanList(id) {
|
|
|
|
|
this.$u.api.getPinTuanList({
|
|
|
|
|
page: this.page,
|
|
|
|
|
gc_id: id,
|
|
|
|
|
}).then(res => {
|
|
|
|
|
this.pinTuanList = res.data;
|
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.swiperCurrent = current;
|
|
|
|
|
this.current = current;
|
|
|
|
|
},
|
|
|
|
|
// scroll-view到底部加载更多
|
|
|
|
|
onreachBottom() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
</style>
|