123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242 |
- <template>
- <view>
- <!-- #ifdef MP-ALIPAY -->
- <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="优惠券使用记录" leftIconSize="0"></u-navbar>
- <!-- #endif -->
- <!-- #ifndef MP-ALIPAY -->
- <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="优惠券使用记录"></u-navbar>
- <!-- #endif -->
- <!-- 优惠券筛选 -->
- <view class="prize-state">
- <u-tabs @change="changeTab" :scrollable="false" :list="stateArr" lineWidth="20" lineHeight="4"
- lineColor="#F9822C" :activeStyle="{
- color: '#333',
- transform: 'scale(1.1)',
- width: '50px',
-
- }" :inactiveStyle="{
- color: '#666666',
- transform: 'scale(1)',
- width: '50px'
- }" itemStyle="padding-left: 15px; padding-right: 15px; height: 44px;text-align: center;">
- </u-tabs>
- </view>
- <!-- 已使用 -->
- <view class="prize-coupon">
- <view class="prize-coupon-list">
- <view class="prize-coupon-list-item" v-for="(item, index) in list" :key="index">
- <view class="content flex">
- <view class="content-left flex">
- <image src="../static/prize_coupon_use.png" mode="scaleToFill"></image>
- <view class="price flex">
- <text>{{ item.discount / 100 }}</text>
- <text>元</text>
- </view>
- </view>
- <view class="content-right flex">
- <view class="title ells-one">{{ item.title }}</view>
- <view class="desc">适用范围:{{ item.useAreaDesc || '-' }}</view>
- <view class="desc">使用期限:{{ $parseTime(item.validStart, '{y}.{m}.{d}') }} ~ {{ $parseTime(item.validEnd, '{y}.{m}.{d}') }}</view>
- </view>
- </view>
- <image class="image-use" src="../static/coupon_use1.png" mode="scaleToFill" v-if="item.status.value == 1"></image>
- <image class="image-use" src="../static/coupon_use2.png" mode="scaleToFill" v-else></image>
- </view>
- <u-loadmore :line="true" v-if="list.length>6" :status="status" :loading-text="'努力加载中'" :nomore-text="'已经到底了'" />
- </view>
- </view>
- <view class="flex empty" v-if="!list.length">
- <view class="center">
- <image class="center-img" src="https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/v2/nodata_1.png" mode="scaleToFill"></image>
- <view class="center-font">暂无优惠券</view>
- </view>
- <!-- <u-empty text="数据为空" mode="order" /> -->
- </view>
- </view>
- </template>
- <script>
- import env from '../../config/env.js'
- import $http from '@/utils/request.js'
- export default {
- data() {
- return {
- status: 'nomore',//上拉刷新状态
- stateArr: [{
- name: '已使用'
- }, {
- name: '已过期',
- }],
- state: 2,
- pageNum: 1,
- total: 0,
- list: [],
- };
- },
- onShow() {
- this.pageList()
- },
- methods: {
- getList() {
- let _this = this
- let url = '/api/v1/mp/user/mine/coupon/list'
- this.loading = true
- $http.post(`${ url }?pageNum=${_this.pageNum}&pageSize=20`, {
- status: this.state
- }).then(res => {
- this.loading = false
- if (res.code == 0) {
- res.rows.forEach(item => {
- let picUrlArr = item.picUrl.split(',')
- item.picUrl = env.filePublic + picUrlArr[0] + '?imageView2/2/w/170'
- item.status = JSON.parse(item.status)
- })
- _this.total = res.total
- _this.list = _this.list.concat(res.rows)
- }
- }).catch(() => {
- this.loading = false
- })
- },
- pageList() {
- this.pageNum = 1
- this.list = []
- this.getList()
- },
- changeTab(e) {
- if (e.index == 0) {
- this.state = 2
- } else if (e.index == 1) {
- this.state = 3
- }
- this.pageList()
- },
- changeChecked() {
- },
- },
- onReachBottom() {
- if(this.total < this.pageNum * 20) return ;
- this.status = 'loading';
- ++this.pageNum
- if(this.total < this.pageNum * 20) this.status = 'nomore';
- else this.status = 'loading';
- this.getList()
- },
- }
- </script>
- <style lang="scss" scoped>
- .prize-state {
- display: flex;
- position: fixed;
- background-color: #FFFFFF;
- width: 100%;
- padding-bottom: 16rpx;
- z-index: 10;
- }
- .prize-coupon {
- margin-top: 104rpx;
- padding: 30rpx 34rpx 100rpx;
- &-list {
- &-item {
- position: relative;
- padding-top: 30rpx;
- margin-bottom: 30rpx;
- background-color: #fff;
-
- .content {
- width: 100%;
- height: 184rpx;
- justify-content: flex-start;
-
- &-left {
- width: 210rpx;
- height: 100%;
- margin-right: 20rpx;
-
- image {
- width: 100%;
- height: 100%;
- }
-
- .price {
- position: absolute;
- color: #fff;
-
- text:first-child {
- font-size: 70rpx;
- padding-right: 20rpx;
- }
-
- text:last-child {
- font-size: 40rpx;
- }
- }
- }
-
- &-right {
- flex: 1;
- align-items: flex-start;
- flex-direction: column;
- justify-content: space-between;
- height: 100%;
- padding: 24rpx 0;
-
- .title {
- font-size: 32rpx;
- line-height: 32rpx;
- height: 32rpx;
- overflow: hidden;
- font-weight: bold;
- }
-
- .desc {
- font-size: 24rpx;
- line-height: 24rpx;
- color: #999999;
- }
- }
- }
-
- .image-use {
- position: absolute;
- right: 34rpx;
- bottom: 10rpx;
- width: 170rpx;
- height: 170rpx;
- }
- }
-
- &-item:last-child {
- margin-bottom: 0;
- }
- }
- }
- .empty {
- height: 60vh;
-
- .center {
- text-align: center;
-
- &-img {
- width: 228rpx;
- height: 320rpx;
- }
-
- &-font {
- font-size: 30rpx;
- font-weight: 400;
- color: #999999;
- margin-bottom: 250rpx;
- }
- }
- }
- </style>
|