2020-07-08 18:14:41 +08:00
|
|
|
<template>
|
|
|
|
<view class="coupon-swiper">
|
2020-07-17 17:34:42 +08:00
|
|
|
<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="88" ></u-tabs-swiper>
|
2020-07-08 18:14:41 +08:00
|
|
|
<swiper :current="swiperCouponCurrent" @animationfinish="couponAnimationFinish" :style="{ height: swiperHeight }">
|
|
|
|
<swiper-item class="swiper-coupon-item" v-for="(_, i) in couponGroupList" :key="i">
|
|
|
|
<scroll-view scroll-y style="height: 100%;">
|
|
|
|
<view v-for="(coupon, index) in couponList" :key="index" class="coupon-item">
|
|
|
|
<Coupon :couponInfo="coupon" :status='0' :type="0" @exchange="exchangeCoupon($event)"></Coupon>
|
|
|
|
</view>
|
|
|
|
<u-empty text="暂无优惠券" mode="coupon" color="#000" v-if="!couponList.length"></u-empty>
|
|
|
|
</scroll-view>
|
|
|
|
</swiper-item>
|
|
|
|
</swiper>
|
|
|
|
</view>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import Coupon from "@/components/mine/coupon/index";
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
swiperHeight: '',
|
|
|
|
couponCurrent: 0,
|
|
|
|
swiperCouponCurrent: 0,
|
2020-07-17 17:34:42 +08:00
|
|
|
couponGroupList: [],
|
|
|
|
couponList: [],
|
|
|
|
page: 0,
|
2020-07-27 17:59:47 +08:00
|
|
|
loadStatus: 'loadmore',
|
|
|
|
timer: true,
|
2020-07-08 18:14:41 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
components: {
|
|
|
|
Coupon
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.setViewHeight();
|
2020-07-17 17:34:42 +08:00
|
|
|
this.getGoodsClass();
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
couponCurrent(index) {
|
|
|
|
const id = this.couponGroupList[index].gc_id;
|
|
|
|
this.getCouponList({ gc_id: id });
|
|
|
|
}
|
2020-07-08 18:14:41 +08:00
|
|
|
},
|
|
|
|
methods: {
|
2020-07-27 17:59:47 +08:00
|
|
|
loadMore(page) {
|
|
|
|
if(!this.timer) return false;
|
|
|
|
this.loadStatus = "loading";
|
|
|
|
this.page++;
|
|
|
|
this.getGoodsRecommend({
|
|
|
|
gc_id: this.classifyList[this.current].gc_id,
|
|
|
|
page: this.page,
|
|
|
|
reload: false,
|
|
|
|
}).then(length => {
|
|
|
|
// console.log(length);
|
|
|
|
if(length == 0) {
|
|
|
|
this.page--;
|
|
|
|
this.loadStatus = 'nomore';
|
|
|
|
} else {
|
|
|
|
this.loadStatus = 'loading';
|
|
|
|
}
|
|
|
|
}).catch(() => {
|
|
|
|
this.loadStatus = "nomore";
|
|
|
|
this.page--;
|
|
|
|
})
|
|
|
|
},
|
2020-07-17 17:34:42 +08:00
|
|
|
getGoodsClass() {
|
|
|
|
this.$u.api.getGoodsClass().then(res => {
|
|
|
|
if(res.errCode == 0) {
|
|
|
|
this.couponGroupList = res.data;
|
|
|
|
this.getCouponList(this.couponGroupList[0].gc_id);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
getCouponList({ gc_id }) {
|
|
|
|
this.$u.api.getCouponList({
|
|
|
|
page: this.page,
|
|
|
|
gc_id: gc_id,
|
|
|
|
}).then(res => {
|
|
|
|
if(res.errCode == 0) {
|
|
|
|
this.couponList = res.data;
|
|
|
|
} else {
|
|
|
|
this.couponList = [];
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
2020-07-08 18:14:41 +08:00
|
|
|
exchangeCoupon(id) {
|
|
|
|
console.log(id);
|
|
|
|
|
|
|
|
},
|
|
|
|
couponTabsChange(index) {
|
|
|
|
this.couponCurrent = index;
|
|
|
|
},
|
|
|
|
couponAnimationFinish(e) {
|
|
|
|
const current = e.detail.current;
|
|
|
|
this.swiperCouponCurrent = current;
|
|
|
|
this.couponCurrent = current;
|
|
|
|
},
|
|
|
|
setViewHeight() {
|
|
|
|
const res = uni.getSystemInfoSync();
|
|
|
|
this.swiperHeight = res.windowHeight - ((88 + 10 + 88) / 2) + 'px';
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.coupon-swiper {
|
|
|
|
.swiper-coupon-item {
|
|
|
|
box-sizing: border-box;
|
|
|
|
background-color: #ffffff;
|
|
|
|
padding: 30rpx {
|
|
|
|
top: 0;
|
|
|
|
};
|
|
|
|
.coupon-item {
|
|
|
|
margin-bottom: 20rpx;
|
|
|
|
}
|
|
|
|
// .coupon-item {
|
|
|
|
// padding: 30rpx;
|
|
|
|
// background-color: #ffffff;
|
|
|
|
// display: flex;
|
|
|
|
// align-items: flex-end;
|
|
|
|
// // margin-bottom: 2rpx;
|
|
|
|
// > img {
|
|
|
|
// width: 180rpx;
|
|
|
|
// height: 160rpx;
|
|
|
|
// border-radius: 10rpx;
|
|
|
|
// margin-right: 30rpx;
|
|
|
|
// }
|
|
|
|
// .coupon-main {
|
|
|
|
// .coupon-title {
|
|
|
|
// font-size: 30rpx;
|
|
|
|
// color: rgba(51,51,51,1);
|
|
|
|
// }
|
|
|
|
// .coupon-date {
|
|
|
|
// display: flex;
|
|
|
|
// align-items: center;
|
|
|
|
// margin: 29rpx 0 20rpx;
|
|
|
|
// > img {
|
|
|
|
// width: 24rpx;
|
|
|
|
// height: 24rpx;
|
|
|
|
// margin-right: 15rpx;
|
|
|
|
// }
|
|
|
|
// > view {
|
|
|
|
// font-size: 24rpx;
|
|
|
|
// color: rgba(153,153,153,1);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// .coupon-integral {
|
|
|
|
// font-size: 30rpx;
|
|
|
|
// font-weight: 500;
|
|
|
|
// color: rgba(255,120,15,1);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// .coupon-btn {
|
|
|
|
// margin-left: auto;
|
|
|
|
// width: 85rpx;
|
|
|
|
// // height: 42rpx;
|
|
|
|
// border: 2rpx solid rgba(255,120,15,1);
|
|
|
|
// border-radius: 10rpx;
|
|
|
|
// font-size: 26rpx;
|
|
|
|
// color: rgba(255,120,15,1);
|
|
|
|
// line-height: 42rpx;
|
|
|
|
// text-align: center;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|