deming/pageC/groupBuy/index.vue
2020-07-21 21:02:28 +08:00

84 lines
2.3 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="group">
<view>
<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>
</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">
<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>
</scroll-view>
</swiper-item>
</swiper>
</view>
</template>
<script>
import SpecialGoods from "../../components/shop/special-shop/index"
export default {
data() {
return {
tabList: [],
current: Number,
swiperCurrent: 0,
page: 0,
pinTuanList: [],
}
},
components: {
SpecialGoods
},
onLoad() {
this.getGoodsClass();
},
watch: {
current(index) {
console.log(this.tabList);
this.getPinTuanList(this.tabList[index].gc_id);
}
},
methods: {
// 获取优惠券拼团分类
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;
})
},
// 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;
},
// scroll-view到底部加载更多
onreachBottom() {
}
}
};
</script>
<style lang="scss" scoped>
</style>