xinelu-applet-ui/pagesB/coupon/coupon.vue

157 lines
4.1 KiB
Vue
Raw Normal View History

2023-09-20 12:09:09 +08:00
<template>
2023-09-20 13:52:08 +08:00
<view class="app">
2023-09-26 14:30:59 +08:00
<view class="tabs">
2023-09-20 13:52:08 +08:00
<view class="tab-item">
<view class="title">
</view>
<view class="text">
{{total}}
</view>
</view>
2023-09-26 14:30:59 +08:00
</view>
2023-09-20 13:52:08 +08:00
<view class="content">
<view class="statuss">
2023-09-26 14:30:59 +08:00
<view class="statusitem" @tap="changingcoupon('')" :style="couponstatus==''?'color: #F44B2F;':''">
2023-09-20 13:52:08 +08:00
全部
</view>
<span> |</span>
2023-09-26 14:30:59 +08:00
<view class="statusitem" @tap="changingcoupon('NOT_USED')"
:style="couponstatus=='NOT_USED'?'color: #F44B2F;':''">
未使用
2023-09-20 13:52:08 +08:00
</view>
<span> |</span>
2023-09-26 14:30:59 +08:00
<view class="statusitem" @tap="changingcoupon('USED')"
:style="couponstatus=='USED'?'color: #F44B2F;':''">
2023-09-20 13:52:08 +08:00
已使用
</view>
<span> |</span>
2023-09-26 14:30:59 +08:00
<view class="statusitem" @tap="changingcoupon('EXPIRED')"
:style="couponstatus=='EXPIRED'?'color: #F44B2F;':''">
2023-09-20 13:52:08 +08:00
已过期
</view>
</view>
2023-09-26 14:30:59 +08:00
<view class="rollup" v-if="couponlist">
<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-09-20 13:52:08 +08:00
<view class="title">
<span class="text">
</span>
<span class="price">
2023-09-26 14:30:59 +08:00
{{item.couponPrice}}
2023-09-20 13:52:08 +08:00
</span>
</view>
2023-09-26 14:30:59 +08:00
<view class="what" :style="item.useStatus!='NOT_USED'?'background: #DADADA;;':''">
{{item.couponTitle}}
2023-09-20 13:52:08 +08:00
</view>
<view class="texts">
2023-09-26 14:30:59 +08:00
{{item.couponConsumePrice}}可用
2023-09-20 13:52:08 +08:00
</view>
<view class="time">
2023-09-26 14:30:59 +08:00
有效期至{{item.expirationEndTime}}
</view>
<view class="btngq" v-if="item.useStatus!='NOT_USED'">
{{item.useStatus=='EXPIRED'?'已过期':''}}
{{item.useStatus=='USED'?'已使用':''}}
2023-09-20 13:52:08 +08:00
</view>
2023-09-26 14:30:59 +08:00
<view class="btn" v-else @tap='goshoping'>
{{item.useStatus=='NOT_USED'?'使用':''}}
2023-09-20 13:52:08 +08:00
</view>
</view>
2023-09-26 14:30:59 +08:00
<view class="bottom" v-if="item.useStatus=='NOT_USED'||item.useStatus=='RECEIVE'">
领取来源{{item.receiveSource =='NEW_PEOPLE_WELFARE'?'新人福利':''}}
{{item.receiveSource =='EVENT_GIFT'?'活动赠送':''}}
{{item.receiveSource =='CONSUME_REBATE'?'消费返券':''}}
2023-09-20 13:52:08 +08:00
</view>
</view>
</view>
2023-09-26 14:30:59 +08:00
<view class="noorder" v-if="couponlist==null||couponlist.length==0">
2023-09-20 13:52:08 +08:00
<u-empty mode="coupon" icon-size='220'></u-empty>
</view>
</view>
<u-toast ref="uToast" />
2023-09-20 12:09:09 +08:00
</view>
</template>
<script>
2023-09-26 14:30:59 +08:00
import {
selectCoupon
} from '@/api/pagesB/coupon/index.js'
2023-09-20 12:09:09 +08:00
export default {
data() {
return {
2023-09-20 13:52:08 +08:00
pageNum: 1,
pageSize: 10,
couponlist: null,
total: 0,
2023-09-26 14:30:59 +08:00
couponstatus: '', //状态
patientId: null,
2023-09-20 12:09:09 +08:00
};
2023-09-20 13:52:08 +08:00
},
2023-09-26 14:30:59 +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: '2000',
})
}
},
methods: {
getlist() {
selectCoupon(this.pageNum, this.pageSize, this.patientId, this.couponstatus).then(res => {
if (res.rows.length > 0) {
this.couponlist = res.rows
}
this.total = res.total
})
},
changingcoupon(item) {
this.pageNum = 1
if (this.couponstatus == item) {
this.couponstatus = ''
} else {
this.couponstatus = item
}
selectCoupon(this.pageNum, this.pageSize, this.patientId, this.couponstatus).then(res => {
this.couponlist = res.rows
this.total = res.total
})
},
goshoping() {
uni.navigateTo({
url: '/pages/shopping/shopping'
})
},
},
2023-09-20 13:52:08 +08:00
onReachBottom() { //下滑加载
if (this.couponlist.length >= this.total) {} else {
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-09-20 12:09:09 +08:00
}
</script>
<style lang="scss">
2023-09-26 14:30:59 +08:00
@import "./coupon.scss";
2024-06-25 18:25:50 +08:00
</style>