group buy 8.8
This commit is contained in:
@@ -4,15 +4,18 @@
|
||||
<view class="title">全部优惠券</view>
|
||||
<view class="view-more" @click="toCouponPage">查看更多></view>
|
||||
</view>
|
||||
<u-tabs-swiper ref="coupon" :list="couponGroupList" name="gc_name" :is-scroll="true" active-color="#FF780F" :current="couponCurrent" font-size="24" :show-bar="false" @change="couponTabsChange" height="60" ></u-tabs-swiper>
|
||||
<!-- <u-tabs-swiper ref="coupon" :list="couponGroupList" name="gc_name" :is-scroll="true" active-color="#FF780F" :current="couponCurrent" font-size="24" :show-bar="false" @change="couponTabsChange" height="60" ></u-tabs-swiper> -->
|
||||
<u-tabs :list="couponGroupList" name="gc_name" :is-scroll="true" :current="couponCurrent" @change="couponTabsChange" active-color="#FF780F" :show-bar="false" height="60" font-size="24" inactive-color="#333333"></u-tabs>
|
||||
<!-- :style="{ height: swiperHeight }" -->
|
||||
<swiper class="box" :current="swiperCouponCurrent" @animationfinish="couponAnimationFinish" :style="{height: swiperHeight}">
|
||||
<swiper-item class="swiper-coupon-item" v-for="(_, i) in couponGroupList" :key="i">
|
||||
<!-- 最多显示四个 -->
|
||||
<view v-for="(coupon, index) in couponList.slice(0, 4)" :key="index" class="coupon-item">
|
||||
<Coupon :couponInfo="coupon" :status='0' :type="0"></Coupon>
|
||||
<view v-if="couponList[i]">
|
||||
<view v-for="(coupon, index) in couponList[i].slice(0, 4)" :key="index" class="coupon-item">
|
||||
<Coupon :couponInfo="coupon" :status='0' :type="0"></Coupon>
|
||||
</view>
|
||||
</view>
|
||||
<u-empty text="暂无优惠券" mode="coupon" color="#000" v-if="!couponList.length"></u-empty>
|
||||
<u-empty text="暂无优惠券" mode="coupon" color="#000" v-if="!couponList[i] || !couponList[i].length"></u-empty>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
</view>
|
||||
@@ -56,16 +59,18 @@ export default {
|
||||
gc_id: gc_id,
|
||||
}).then(res => {
|
||||
if(res.errCode == 0) {
|
||||
this.couponList = res.data;
|
||||
this.couponList[this.couponCurrent] = res.data;
|
||||
} else {
|
||||
this.couponList = [];
|
||||
this.couponList[this.couponCurrent] = [];
|
||||
}
|
||||
// 设置 swiper 高度
|
||||
this.setViewHeight();
|
||||
this.$forceUpdate();
|
||||
})
|
||||
},
|
||||
couponTabsChange(index) {
|
||||
this.couponCurrent = index;
|
||||
this.swiperCouponCurrent = this.couponCurrent;
|
||||
},
|
||||
couponAnimationFinish(e) {
|
||||
const current = e.detail.current;
|
||||
@@ -75,8 +80,8 @@ export default {
|
||||
setViewHeight() {
|
||||
// 一个优惠券的高度 97px, 下距离 10px
|
||||
let num = 0;
|
||||
num = this.couponList.length
|
||||
? this.couponList.length > 4 ? 4 : this.couponList.length
|
||||
num = this.couponList[this.couponCurrent].length
|
||||
? this.couponList[this.couponCurrent].length > 4 ? 4 : this.couponList[this.couponCurrent].length
|
||||
: 1
|
||||
this.swiperHeight = (200 + 20) * num + 'rpx';
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user