rewrite tab swiper 8.7

This commit is contained in:
2020-08-07 17:34:59 +08:00
parent f4ba942870
commit 9d3f8da629
8 changed files with 153 additions and 92 deletions

View File

@@ -1,9 +1,11 @@
<template>
<view class="coupon-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="88" ></u-tabs-swiper>
<swiper :current="swiperCouponCurrent" @animationfinish="couponAnimationFinish" :style="{ height: swiperHeight }">
<scroll-view scroll-x="true" class="classify-coupon">
<view v-for="(classify, index) in couponGroupList" :key="index" class="classify-item" :class="{ 'active': couponCurrent == index }" @click="couponTabsChange(index)">{{ classify.gc_name }}</view>
</scroll-view>
<!-- <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%;" @scrolltolower="onreachBottom">
<scroll-view scroll-y style="height: 100%;" @scrolltolower="onreachBottom" class="coupon-scroll">
<view v-for="(coupon, index) in couponList" :key="index" class="coupon-item">
<Coupon :couponInfo="coupon" :status='0' :type="0" @exchange="exchangeCoupon($event)"></Coupon>
</view>
@@ -11,7 +13,14 @@
<u-empty text="暂无优惠券" mode="coupon" color="#000" v-if="!couponList.length"></u-empty>
</scroll-view>
</swiper-item>
</swiper>
</swiper> -->
<scroll-view scroll-y style="height: 100%;" @scrolltolower="onreachBottom" class="coupon-scroll" :style="{ height: swiperHeight }">
<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>
</view>
</template>
<script>
@@ -19,7 +28,7 @@ import Coupon from "@/components/mine/coupon/index";
export default {
data() {
return {
pageSize: 12,
pageSize: 5, // 页面显示的条数
swiperHeight: '',
couponCurrent: 0,
swiperCouponCurrent: 0,
@@ -39,9 +48,10 @@ export default {
},
watch: {
couponCurrent(index) {
this.couponList = [];
const id = this.couponGroupList[index].gc_id;
this.getCouponList({ gc_id: id, load: 'reload' });
}
},
},
methods: {
onreachBottom() {
@@ -89,6 +99,7 @@ export default {
},
couponTabsChange(index) {
this.couponCurrent = index;
this.swiperCouponCurrent = this.couponCurrent;
},
couponAnimationFinish(e) {
const current = e.detail.current;
@@ -104,64 +115,92 @@ export default {
</script>
<style lang="scss" scoped>
.coupon-swiper {
.swiper-coupon-item {
box-sizing: border-box;
.classify-coupon {
white-space: nowrap;
width: 100%;
height: 88rpx;
background-color: #ffffff;
padding: 30rpx {
top: 0;
};
.coupon-item {
margin-bottom: 20rpx;
margin-bottom: 2rpx;
.classify-item {
display: inline-block;
line-height: 88rpx;
text-align: center;
font-size: 24rpx;
color: #333;
padding: 0 30rpx;
}
.active {
color: #FF780F;
font-weight: 700;
}
}
// .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;
// }
// }
// }
.coupon-scroll {
background-color: #ffffff;
padding-top: 30rpx;
.coupon-item {
padding: 30rpx {
top: 0;
};
}
// .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>