This commit is contained in:
2020-07-30 20:33:16 +08:00
parent 04adc72d92
commit 6d00107944
17 changed files with 241 additions and 124 deletions

View File

@@ -3,10 +3,11 @@
<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>
<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%;">
<scroll-view scroll-y style="height: 100%;" @scrolltolower="onreachBottom">
<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-loadmore :status="loadStatus" bgColor="#FFF" margin-top="20" margin-bottom="20" v-if="couponList.length>=pageSize" @loadmore="onreachBottom"></u-loadmore>
<u-empty text="暂无优惠券" mode="coupon" color="#000" v-if="!couponList.length"></u-empty>
</scroll-view>
</swiper-item>
@@ -18,6 +19,7 @@ import Coupon from "@/components/mine/coupon/index";
export default {
data() {
return {
pageSize: 1,
swiperHeight: '',
couponCurrent: 0,
swiperCouponCurrent: 0,
@@ -38,20 +40,18 @@ export default {
watch: {
couponCurrent(index) {
const id = this.couponGroupList[index].gc_id;
this.getCouponList({ gc_id: id });
this.getCouponList({ gc_id: id, load: 'reload' });
}
},
methods: {
loadMore(page) {
onreachBottom() {
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,
this.getCouponList({
gc_id: this.couponGroupList[this.couponCurrent].gc_id,
load: 'loadmore',
}).then(length => {
// console.log(length);
if(length == 0) {
this.page--;
this.loadStatus = 'nomore';
@@ -67,24 +67,24 @@ export default {
this.$u.api.getGoodsClass().then(res => {
if(res.errCode == 0) {
this.couponGroupList = res.data;
this.getCouponList(this.couponGroupList[0].gc_id);
this.getCouponList({ gc_id: this.couponGroupList[0].gc_id, load: 'reload' });
}
})
},
getCouponList({ gc_id }) {
this.$u.api.getCouponList({
async getCouponList({ gc_id, load }) {
const res = await this.$u.api.getCouponList({
page: this.page,
gc_id: gc_id,
}).then(res => {
if(res.errCode == 0) {
this.couponList = res.data;
} else {
this.couponList = [];
}
})
this.timer = true;
if(res.errCode == 0) {
if(load == 'reload') this.couponList = res.data;
else if(load == 'loadmore') this.couponList.push(...res.data);
}
return res.data.length;
},
exchangeCoupon(id) {
console.log(id);
// console.log(id);
},
couponTabsChange(index) {