deming/pageE/tool/MineCoupon.vue

108 lines
2.4 KiB
Vue
Raw Normal View History

2020-07-08 18:14:41 +08:00
<template>
<view class="coupon">
<u-tabs-swiper ref="tabs" :list="list" :is-scroll="false" active-color="#FF780F" :current="current" font-size="32" :show-bar="false" @change="tabsChange" height="88" ></u-tabs-swiper>
<swiper :current="swiperCurrent" @animationfinish="animationfinish" :style="{ height: swiperHeight }">
<swiper-item class="swiper-item" v-for="(_, index) in list" :key="index">
<scroll-view scroll-y class="scroll-coupon">
2020-07-17 17:34:42 +08:00
<view class="coupon-item" v-for="(coupon, c_index) in couponList" :key="c_index">
2020-07-18 17:43:37 +08:00
<Coupon :couponInfo="coupon" :status='index' :type="1" @use="useCoupon($event)" :goodsClass="goodsClass"></Coupon>
2020-07-08 18:14:41 +08:00
</view>
2020-07-18 17:43:37 +08:00
<u-empty text="暂无优惠券" mode="coupon" v-if="!couponList.length"></u-empty>
2020-07-08 18:14:41 +08:00
</scroll-view>
</swiper-item>
</swiper>
</view>
</template>
<script>
2020-07-18 17:43:37 +08:00
import Coupon from "@/components/mine/coupon/mine"
2020-07-08 18:14:41 +08:00
export default {
data() {
return {
list: [{
name: '未使用'
}, {
name: '已使用'
}, {
name: '已过期'
}],
2020-07-17 17:34:42 +08:00
current: Number,
2020-07-08 18:14:41 +08:00
swiperCurrent: 0,
swiperHeight: '',
2020-07-18 17:43:37 +08:00
couponList: [],
goodsClass: [],
2020-07-08 18:14:41 +08:00
}
},
components: {
Coupon
},
onLoad() {
this.setViewHeight();
2020-07-18 17:43:37 +08:00
this.getGoodsClass();
2020-07-08 18:14:41 +08:00
},
2020-07-17 17:34:42 +08:00
onShow() {
this.current = 0;
},
watch: {
current(value) {
let status = value + 1;
this.getMemberCouponList(status);
}
},
2020-07-08 18:14:41 +08:00
methods: {
2020-07-18 17:43:37 +08:00
getGoodsClass() {
this.$u.api.getGoodsClass().then(res => {
this.goodsClass = res.data;
})
},
2020-07-17 17:34:42 +08:00
getMemberCouponList(current) {
this.$u.api.getMemberCouponList({
status: current
}).then(res => {
if(res.errCode == 0) {
this.couponList = res.data;
2020-07-18 17:43:37 +08:00
} else {
this.couponList = [];
2020-07-17 17:34:42 +08:00
}
})
},
2020-07-08 18:14:41 +08:00
useCoupon(id) {
console.log(id);
},
setViewHeight() {
const res = uni.getSystemInfoSync();
this.swiperHeight = res.windowHeight - (88 / 2 + 11 / 2) + 'px';
},
tabsChange(index) {
this.swiperCurrent = index;
},
animationfinish(e) {
let current = e.detail.current;
this.swiperCurrent = current;
this.current = current;
},
},
};
</script>
<style lang="scss" scoped>
.coupon {
overflow: hidden;
.u-tabs {
border: {
top: 1rpx #ECECEC solid;
bottom: 10rpx #ECECEC solid;
};
}
.swiper-item {
box-sizing: border-box;
padding: 20rpx 30rpx;
.scroll-coupon {
height: 100%;
.coupon-item {
margin-bottom: 20rpx;
// position: relative;
// z-index: 9;
}
}
}
}
</style>