2020-06-11 16:12:04 +08:00
|
|
|
<template>
|
2020-07-17 17:34:42 +08:00
|
|
|
<view class="coupon-swiper">
|
|
|
|
<view class="top">
|
|
|
|
<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="88" ></u-tabs-swiper>
|
|
|
|
<!-- :style="{ height: swiperHeight }" -->
|
|
|
|
<swiper :current="swiperCouponCurrent" @animationfinish="couponAnimationFinish">
|
|
|
|
<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.slice(0, 4)" :key="index" class="coupon-item">
|
|
|
|
<Coupon :couponInfo="coupon" :status='0' :type="0"></Coupon>
|
|
|
|
</view>
|
|
|
|
<u-empty text="暂无优惠券" mode="coupon" color="#000" v-if="!couponList.length"></u-empty>
|
|
|
|
<!-- </scroll-view> -->
|
|
|
|
</swiper-item>
|
|
|
|
</swiper>
|
|
|
|
</view>
|
2020-06-11 16:12:04 +08:00
|
|
|
</template>
|
|
|
|
<script>
|
2020-07-17 17:34:42 +08:00
|
|
|
import Coupon from "@/components/mine/coupon/index";
|
2020-06-11 16:12:04 +08:00
|
|
|
export default {
|
2020-07-17 17:34:42 +08:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
swiperHeight: '',
|
|
|
|
couponCurrent: 0,
|
|
|
|
swiperCouponCurrent: 0,
|
|
|
|
couponGroupList: [],
|
|
|
|
couponList: [],
|
|
|
|
}
|
|
|
|
},
|
|
|
|
components: {
|
|
|
|
Coupon
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
couponCurrent(index) {
|
|
|
|
const id = this.couponGroupList[index].gc_id;
|
|
|
|
this.getCouponList(id);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.setViewHeight();
|
|
|
|
this.getGoodsClass();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
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: 0,
|
|
|
|
gc_id: gc_id,
|
|
|
|
}).then(res => {
|
|
|
|
if(res.errCode == 0) {
|
|
|
|
this.couponList = res.data;
|
|
|
|
} else {
|
|
|
|
this.couponList = [];
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
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';
|
|
|
|
this.swiperHeight = '450px';
|
|
|
|
},
|
|
|
|
toCouponPage() {
|
|
|
|
this.$u.route({
|
|
|
|
url: '/pageE/mine/MemberServe',
|
|
|
|
params: {
|
|
|
|
current: 1
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
2020-06-11 16:12:04 +08:00
|
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
2020-07-17 17:34:42 +08:00
|
|
|
.coupon-swiper {
|
|
|
|
.top {
|
|
|
|
padding-top: 30rpx;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: space-between;
|
|
|
|
.title {
|
|
|
|
font-size: 30rpx;
|
|
|
|
font-weight: 500;
|
|
|
|
color: rgba(51,51,51,1);
|
|
|
|
}
|
|
|
|
.view-more {
|
|
|
|
font-size: 18rpx;
|
|
|
|
color: rgba(153,153,153,1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.swiper-coupon-item {
|
|
|
|
box-sizing: border-box;
|
|
|
|
background-color: #ffffff;
|
|
|
|
// padding: 30rpx {
|
|
|
|
// top: 0;
|
|
|
|
// };
|
|
|
|
.coupon-item {
|
|
|
|
margin-bottom: 20rpx;
|
|
|
|
}
|
|
|
|
}
|
2020-06-11 16:12:04 +08:00
|
|
|
}
|
|
|
|
</style>
|