优化领劵中心的逻辑以及页面

master
lemon橪 2022-05-31 15:42:21 +08:00
parent ded0ab5381
commit 3c9f0d3c5c
2 changed files with 280 additions and 277 deletions

View File

@ -1,9 +1,9 @@
<template> <template>
<view class="coupon-center"> <view class="coupon-center">
<swiper class="swiper-box"> <div class="swiper-box">
<swiper-item class="swiper-item"> <div class="swiper-item">
<scroll-view class="scroll-v" enableBackToTop="true" scroll-y @scrolltolower="loadMore"> <div class="scroll-v" enableBackToTop="true" scroll-y>
<u-empty mode="coupon" text="没有优惠券了" v-if="whetherEmpty"></u-empty> <u-empty mode="coupon" style='margin-top: 20%;' text="没有优惠券了" v-if="whetherEmpty"></u-empty>
<view v-else class="coupon-item" v-for="(item, index) in couponList" :key="index"> <view v-else class="coupon-item" v-for="(item, index) in couponList" :key="index">
<view class="left"> <view class="left">
<view class="wave-line"> <view class="wave-line">
@ -23,10 +23,11 @@
<view class="right"> <view class="right">
<view> <view>
<!-- 根据scopeType 判断是否是 平台品类或店铺 --> <!-- 根据scopeType 判断是否是 平台品类或店铺 -->
<view v-if="item.scopeType"> <view class="coupon-title wes-3" v-if="item.scopeType">
<span v-if="item.scopeType == 'ALL' && item.id == 'platform'"></span> <span v-if="item.scopeType == 'ALL' && item.id == 'platform'"></span>
<span v-if="item.scopeType == 'PORTION_CATEGORY'"></span> <span v-if="item.scopeType == 'PORTION_CATEGORY'"></span>
<view v-else>{{ item.storeName == 'platform' ? '' :item.storeName+'' }}使</view> <view v-else>{{ item.storeName == 'platform' ? '' :item.storeName+'' }}使
</view>
</view> </view>
<view v-if="item.endTime">{{ item.endTime.split(" ")[0] }}</view> <view v-if="item.endTime">{{ item.endTime.split(" ")[0] }}</view>
</view> </view>
@ -37,16 +38,20 @@
<view class="bg-quan"> </view> <view class="bg-quan"> </view>
</view> </view>
</view> </view>
<uni-load-more :status="loadStatus"></uni-load-more>
</scroll-view> </div>
</swiper-item> </div>
</swiper> </div>
</view> </view>
</template> </template>
<script> <script>
import { receiveCoupons } from "@/api/members.js"; import {
import { getAllCoupons } from "@/api/promotions.js"; receiveCoupons
} from "@/api/members.js";
import {
getAllCoupons
} from "@/api/promotions.js";
export default { export default {
data() { data() {
return { return {
@ -57,13 +62,18 @@ export default {
pageNumber: 1, pageNumber: 1,
pageSize: 10, pageSize: 10,
}, },
storeId: "", // id storeId: "", // id,
couponData: ""
}; };
}, },
onLoad(option) { onLoad(option) {
this.storeId = option.storeId; this.storeId = option.storeId;
this.getCoupon(); this.getCoupon();
}, },
onReachBottom() {
this.loadMore()
},
onPullDownRefresh() { onPullDownRefresh() {
// //
this.params.pageNumber = 1; this.params.pageNumber = 1;
@ -78,21 +88,26 @@ export default {
uni.showLoading({ uni.showLoading({
title: "加载中", title: "加载中",
}); });
let submitData = { ...this.params }; let submitData = {
...this.params
};
// //
this.storeId ? (submitData = { ...this.params, storeId: this.storeId }): "", this.storeId ? (submitData = {
...this.params,
storeId: this.storeId
}) : "",
getAllCoupons(submitData) getAllCoupons(submitData)
.then((res) => { .then((res) => {
uni.hideLoading(); uni.hideLoading();
uni.stopPullDownRefresh(); uni.stopPullDownRefresh();
if (res.data.code == 200) { if (res.data.code == 200) {
// //
let data = res.data.result; this.couponData = res.data.result
if (data.total == 0) { if (this.couponData.total == 0) {
// //
this.whetherEmpty = true; this.whetherEmpty = true;
} else { } else {
this.couponList.push(...data.records); this.couponList.push(...this.couponData.records);
this.loadStatus = "noMore"; this.loadStatus = "noMore";
} }
} }
@ -123,9 +138,9 @@ export default {
* 加载更多 * 加载更多
*/ */
loadMore() { loadMore() {
if (this.loadStatus != "noMore") { if (this.couponData.total > this.params.pageNumber * this.params.pageSize) {
this.params.pageNumber++; this.params.pageNumber++;
this.getAllCoupons(); this.getCoupon();
} }
}, },
}, },
@ -145,41 +160,7 @@ page {
.coupon-center { .coupon-center {
height: 100%; height: 100%;
.couponList-scroll-content {
position: relative;
width: 100%;
display: flex;
white-space: nowrap;
align-items: center;
justify-content: space-between;
align-items: center;
background-color: $main-color;
color: #ffffff;
.tab-item {
width: 160rpx;
height: 80rpx;
line-height: 60rpx;
text-align: center;
display: inline-block;
}
.active {
border-bottom: 2px solid #ffffff;
broder-width: 60rpx;
font-size: 30rpx;
font-weight: 700;
padding-bottom: 4rpx;
}
}
.swiper-box { .swiper-box {
height: 100%;
.scroll-v {
height: 100%;
}
.coupon-item { .coupon-item {
display: flex; display: flex;
align-items: center; align-items: center;
@ -191,6 +172,7 @@ page {
width: 260rpx; width: 260rpx;
background-color: $light-color; background-color: $light-color;
position: relative; position: relative;
.message { .message {
color: $font-color-white; color: $font-color-white;
display: flex; display: flex;
@ -226,6 +208,7 @@ page {
margin-top: 4rpx; margin-top: 4rpx;
} }
} }
.circle { .circle {
width: 40rpx; width: 40rpx;
height: 40rpx; height: 40rpx;
@ -234,10 +217,12 @@ page {
border-radius: 50%; border-radius: 50%;
z-index: 111; z-index: 111;
} }
.circle-top { .circle-top {
top: -20rpx; top: -20rpx;
right: -20rpx; right: -20rpx;
} }
.circle-bottom { .circle-bottom {
bottom: -20rpx; bottom: -20rpx;
right: -20rpx; right: -20rpx;
@ -254,10 +239,15 @@ page {
background-color: #ffffff; background-color: #ffffff;
overflow: hidden; overflow: hidden;
position: relative; position: relative;
>view:nth-child(1) { >view:nth-child(1) {
color: #666666; color: #666666;
margin-left: 20rpx; margin-left: 20rpx;
line-height: 3em; display: flex;
height: 100%;
flex-direction: column;
justify-content: space-around;
>view:nth-child(1) { >view:nth-child(1) {
color: #ff6262; color: #ff6262;
font-size: 30rpx; font-size: 30rpx;
@ -296,4 +286,9 @@ page {
} }
} }
} }
.coupon-title {
width: 260rpx;
}
</style> </style>

View File

@ -169,3 +169,11 @@ $font-weight: 400;
-webkit-line-clamp: 2; -webkit-line-clamp: 2;
overflow: hidden; overflow: hidden;
} }
.wes-3 {
/* 适用于webkit内核和移动端 */
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
overflow: hidden;
}