nurseWeChatAppletUI/pages/coupon/coupon.vue

306 lines
6.4 KiB
Vue
Raw Normal View History

2023-02-24 14:35:29 +08:00
<template>
<view class="app">
<view class="tabs">
<view class="tab-item">
<view class="title">
2023-03-02 11:22:01 +08:00
2023-02-24 14:35:29 +08:00
</view>
<view class="text">
2023-02-27 11:28:17 +08:00
{{total}}
2023-02-24 14:35:29 +08:00
</view>
</view>
</view>
2023-02-24 15:45:25 +08:00
<view class="content">
<view class="statuss">
2023-03-03 14:53:28 +08:00
<view class="statusitem" @tap="changingcoupon('')" :style="couponstatus==''?'color: #F44B2F;':''">
全部
</view>
<span> |</span>
2023-02-27 11:28:17 +08:00
<view class="statusitem" @tap="changingcoupon('NOT_USED')"
:style="couponstatus=='NOT_USED'?'color: #F44B2F;':''">
未使用
2023-02-24 15:45:25 +08:00
</view>
<span> |</span>
2023-02-27 11:28:17 +08:00
<view class="statusitem" @tap="changingcoupon('USED')"
:style="couponstatus=='USED'?'color: #F44B2F;':''">
2023-02-24 15:45:25 +08:00
已使用
</view>
<span> |</span>
2023-02-27 11:28:17 +08:00
<view class="statusitem" @tap="changingcoupon('EXPIRED')"
:style="couponstatus=='EXPIRED'?'color: #F44B2F;':''">
2023-02-24 15:45:25 +08:00
已过期
</view>
</view>
<view class="rollup">
2023-02-27 11:28:17 +08:00
<view class="item" v-for="(item,index) in couponlist" :key="index"
:style="item.useStatus!='NOT_USED'?'height:180rpx':''">
<view class="top" :style="item.useStatus!='NOT_USED'?'background: #EFECEC;color: #4B4B4B;':''">
2023-02-24 15:45:25 +08:00
<view class="title">
<span class="text">
</span>
<span class="price">
2023-02-27 11:28:17 +08:00
{{item.couponPrice}}
2023-02-24 15:45:25 +08:00
</span>
</view>
2023-02-27 11:28:17 +08:00
<view class="what" :style="item.useStatus!='NOT_USED'?'background: #DADADA;;':''">
2023-03-02 11:22:01 +08:00
{{item.couponTitle}}
2023-02-24 15:45:25 +08:00
</view>
<view class="texts">
2023-02-27 11:28:17 +08:00
{{item.couponConsumePrice}}可用
2023-02-24 15:45:25 +08:00
</view>
<view class="time">
2023-02-27 11:28:17 +08:00
有效期至{{item.expirationEndTime}}
2023-02-24 15:45:25 +08:00
</view>
2023-02-27 11:28:17 +08:00
<view class="btngq" v-if="item.useStatus!='NOT_USED'">
{{item.useStatus=='EXPIRED'?'已过期':''}}
{{item.useStatus=='USED'?'已使用':''}}
</view>
2023-03-03 14:13:06 +08:00
<view class="btn" v-else @tap='goshoping'>
2023-02-27 11:28:17 +08:00
{{item.useStatus=='NOT_USED'?'使用':''}}
2023-02-24 15:45:25 +08:00
</view>
</view>
2023-03-02 11:22:01 +08:00
<view class="bottom" v-if="item.useStatus=='NOT_USED'||item.useStatus=='RECEIVE'">
2023-02-27 11:28:17 +08:00
领取来源{{item.receiveSource =='NEW_PEOPLE_WELFARE'?'新人福利':''}}
2023-03-02 11:22:01 +08:00
{{item.receiveSource =='EVENT_GIFT'?'活动赠送':''}}
{{item.receiveSource =='CONSUME_REBATE'?'消费返券':''}}
2023-02-24 15:45:25 +08:00
</view>
</view>
</view>
2023-02-24 14:35:29 +08:00
</view>
2023-02-27 11:28:17 +08:00
<u-toast ref="uToast" />
2023-02-24 14:35:29 +08:00
</view>
</template>
<script>
2023-02-27 11:28:17 +08:00
import {
selectCoupon
} from '@/api/coupon/index.js'
2023-02-24 14:35:29 +08:00
export default {
data() {
return {
2023-02-27 11:28:17 +08:00
pageNum: 1,
pageSize: 10,
couponlist: null,
total: 0,
couponstatus: '', //状态
2023-03-02 11:22:01 +08:00
patientId: null,
2023-02-24 14:35:29 +08:00
};
2023-02-27 11:28:17 +08:00
},
onLoad() {
this.pageNum = 1
var that = this
const value = uni.getStorageSync('patientId');
if (value) {
that.patientId = value
that.getlist();
} else {
that.$refs.uToast.show({
title: '请先登录',
type: 'error',
duration: '1000',
})
}
},
methods: {
getlist() {
selectCoupon(this.pageNum, this.pageSize, this.patientId, this.couponstatus).then(res => {
this.couponlist = res.rows
this.total = res.total
})
},
changingcoupon(item) {
if (this.couponstatus == item) {
this.couponstatus = ''
} else {
this.couponstatus = item
}
this.getlist();
},
2023-03-03 14:13:06 +08:00
goshoping() {
uni.switchTab({
url: '/pages/shopping/shopping'
})
},
2023-02-27 11:28:17 +08:00
},
onReachBottom() { //下滑加载
2023-03-02 11:22:01 +08:00
if (this.couponlist.length >= this.total) {} else {
2023-02-27 11:28:17 +08:00
this.pageNum++;
selectCoupon(this.pageNum, this.pageSize, this.patientId, this.couponstatus).then(res => {
res.rows.forEach(e => {
this.couponlist.push(e)
})
})
}
},
onPullDownRefresh() { //下拉刷新
this.pageNum = 1;
this.getlist();
setTimeout(function() {
uni.stopPullDownRefresh();
}, 1000);
},
2023-02-24 14:35:29 +08:00
}
</script>
<style lang="scss">
.app {
padding: 0;
2023-02-24 15:45:25 +08:00
.content {
width: 96%;
margin: 20rpx auto 0;
background-color: #fff;
padding-bottom: 100rpx;
.rollup {
border-radius: 5rpx;
.item {
width: 94%;
height: 240rpx;
margin: 20rpx auto 0;
border: 1rpx solid #f4f5f7;
2023-02-27 11:28:17 +08:00
border-radius: 10rpx;
2023-02-24 15:45:25 +08:00
.bottom {
font-size: 22rpx;
color: #969394;
line-height: 60rpx;
padding-left: 25rpx;
2023-02-27 11:28:17 +08:00
border-radius: 0 0 10rpx 10rpx;
2023-02-24 15:45:25 +08:00
}
.top {
width: 100%;
height: 180rpx;
background: #FDE9E8;
position: relative;
color: #F44B2F;
2023-02-27 11:28:17 +08:00
border-radius: 10rpx 10rpx 0 0;
2023-02-24 15:45:25 +08:00
.what {
2023-03-02 11:22:01 +08:00
padding: 0 10rpx;
2023-02-24 15:45:25 +08:00
height: 40rpx;
background: #FED1D2;
border-radius: 16rpx;
font-size: 20rpx;
line-height: 40rpx;
text-align: center;
position: absolute;
top: 120rpx;
2023-03-02 11:22:01 +08:00
left: 20rpx;
2023-02-24 15:45:25 +08:00
}
2023-02-27 11:28:17 +08:00
.btngq {
2023-03-03 14:13:06 +08:00
width: 110rpx;
height: 50rpx;
border: 2rpx solid #DFDEDE;
border-radius: 24rpx;
font-size: 24rpx;
2023-02-27 11:28:17 +08:00
position: absolute;
2023-03-03 14:13:06 +08:00
top: 70rpx;
right: 20rpx;
2023-02-27 11:28:17 +08:00
text-align: center;
2023-03-03 14:13:06 +08:00
line-height: 50rpx;
background: #DFDEDE;
2023-02-27 11:28:17 +08:00
}
2023-02-24 15:45:25 +08:00
.btn {
width: 98rpx;
height: 50rpx;
border: 2rpx solid #F44B2F;
border-radius: 24rpx;
font-size: 24rpx;
position: absolute;
top: 70rpx;
2023-03-02 11:22:01 +08:00
right: 20rpx;
2023-02-24 15:45:25 +08:00
text-align: center;
2023-03-03 14:13:06 +08:00
line-height: 50rpx;
2023-02-24 15:45:25 +08:00
}
.time {
font-size: 24rpx;
position: absolute;
top: 120rpx;
2023-03-03 14:13:06 +08:00
left: 240rpx;
2023-02-24 15:45:25 +08:00
}
.texts {
2023-03-02 11:22:01 +08:00
font-size: 32rpx;
2023-02-24 15:45:25 +08:00
font-weight: 800;
position: absolute;
top: 44rpx;
2023-03-03 14:13:06 +08:00
left: 240rpx;
2023-02-24 15:45:25 +08:00
}
.title {
position: absolute;
top: 30rpx;
2023-03-02 11:22:01 +08:00
left: 10rpx;
2023-02-24 15:45:25 +08:00
.price {
2023-03-02 11:22:01 +08:00
font-size: 54rpx;
2023-02-24 15:45:25 +08:00
font-weight: 700;
}
.text {
font-weight: 600;
font-size: 34rpx;
}
}
}
}
}
.statuss {
padding-top: 25rpx;
span {
color: #c1c1c1;
font-size: 18rpx;
line-height: 60rpx;
}
.statusitem {
text-align: center;
padding: 0 40rpx;
display: inline-block;
height: 60rpx;
font-size: 30rpx;
color: #969394;
line-height: 60rpx;
}
}
}
2023-02-24 14:35:29 +08:00
.tabs {
width: 100%;
.tab-item {
margin: 20rpx 0 0 24rpx;
text-align: center;
width: 20%;
2023-02-24 15:45:25 +08:00
2023-02-24 14:35:29 +08:00
.text {
width: 70%;
margin-left: 15%;
height: 30rpx;
background: #F44B2F;
border-radius: 9rpx;
color: #fff;
font-size: 24rpx;
line-height: 30rpx;
}
.title {
font-size: 40rpx;
font-family: Source Han Sans CN;
font-weight: 500;
color: #F44B2F;
line-height: 59rpx;
}
}
}
}
</style>