<template> <view class="page"> <u-navbar title="我的骑行卡" :border-bottom="false" :background="bgc" title-color='#000' title-size='36' height='45'></u-navbar> <view class="cont"> <view class="card1" v-for="(item,index) in CouponLists" :key="index" v-show="(item.couponType==3||item.couponType==4)&&item.status==1"> <view class="tit1"> {{item.couponName}} </view> <view class="tit2"> 有效期至{{formatDate(item.expirationTime) }} </view> <view class="txt3"> 剩余次数 <span>{{item.limitNum}}</span> </view> </view> <view class="card2" v-for="(item,index) in CouponLists" :key="index" v-show="(item.couponType==3||item.couponType==4)&&item.status==3"> <view class="tit1"> {{item.couponName}} </view> <view class="tit2"> 有效期至{{formatDate(item.expirationTime) }} </view> <view class="txt3"> <span style="font-size: 64rpx;">已过期</span> </view> </view> <view class="card3" v-for="(item,index) in CouponLists" :key="index" v-show="item.couponType==2"> <view class="txt4"> 有效期至{{formatDate(item.expirationTime) }} </view> </view> <view class="card4" v-for="(item,index) in CouponLists" :key="index" v-show="item.couponType==1"> <view class="txt4"> 有效期至{{formatDate(item.expirationTime) }} </view> </view> </view> </view> </template> <script> export default { data() { return { bgc: { backgroundColor: '#fff' }, sn: '', istrue: false, CouponLists:[] } }, onShow() { this.getinfo() }, methods: { getinfo() { // uni.showLoading({ // title:'加载中' // }) this.$u.get("/getAppInfo").then((res) => { if (res.code == 200) { this.$store.commit('SET_USERID', res.user.userId); this.userinfo = res.user this.getcard() } else { } }); }, formatDate(dateString) { if (!dateString) return ''; const date = new Date(dateString); const year = date.getFullYear(); const month = (date.getMonth() + 1).toString().padStart(2, '0'); // 月份从0开始,需要加1 const day = date.getDate().toString().padStart(2, '0'); return `${year}-${month}-${day}`; }, getcard(){ let data={ userId:this.userinfo.userId } this.$u.get("/appVerify/getCouponListByUserId?",data ).then((res) => { if (res.code == 200) { this.CouponLists = res.data } else { // uni.showToast({ // title: res.msg, // icon: 'none', // duration: 2000 // }); } }); } } } </script> <style lang="scss"> page { background-color: #fff; } .page { width: 750rpx; .cont { display: flex; justify-content: center; flex-wrap: wrap; .tit1 { font-weight: 500; font-size: 32rpx; color: #FFFFFF; } .tit2 { margin-top: 10rpx; font-weight: 500; font-size: 24rpx; color: #FFFFFF; } .card1 { position: relative; margin-top: 18rpx; width: 680rpx; height: 176rpx; background-image: url('https://lxnapi.ccttiot.com/bike/img/static/uTKFB3So9QZGTuttNGD0'); background-size: cover; /* 背景图片等比缩放以覆盖整个容器 */ background-position: center; /* 背景图片居中显示 */ background-repeat: no-repeat; padding: 22rpx 46rpx; .txt3 { position: absolute; right: 42rpx; bottom: 16rpx; font-weight: 400; font-size: 28rpx; color: #FFFFFF; span { margin-left: 26rpx; font-size: 100rpx; } } /* 防止背景图片重复 */ } .card2 { position: relative; padding: 22rpx 46rpx; margin-top: 18rpx; width: 680rpx; height: 176rpx; background-image: url('https://lxnapi.ccttiot.com/bike/img/static/uhYH4FVnYOsjGK2iky8X'); background-size: cover; /* 背景图片等比缩放以覆盖整个容器 */ background-position: center; /* 背景图片居中显示 */ background-repeat: no-repeat; /* 防止背景图片重复 */ .txt3 { position: absolute; right: 42rpx; bottom: 16rpx; font-weight: 400; font-size: 28rpx; color: #FFFFFF; span { margin-left: 26rpx; font-size: 100rpx; } } } .card3 { position: relative; margin-top: 18rpx; width: 680rpx; height: 410rpx; background-image: url('https://lxnapi.ccttiot.com/bike/img/static/uZCTchd4XbAwsmNDuGun'); background-size: cover; /* 背景图片等比缩放以覆盖整个容器 */ background-position: center; /* 背景图片居中显示 */ background-repeat: no-repeat; /* 防止背景图片重复 */ .txt4{ position: absolute; top: 72rpx; right: 78rpx; font-weight: 400; font-size: 24rpx; color: #F5C164; } } .card4 { position: relative; margin-top: 18rpx; width: 680rpx; height: 410rpx; background-image: url('https://lxnapi.ccttiot.com/bike/img/static/uiT97zPTbkZOMkGGmsAc'); background-size: cover; /* 背景图片等比缩放以覆盖整个容器 */ background-position: center; /* 背景图片居中显示 */ background-repeat: no-repeat; /* 防止背景图片重复 */ .txt4{ position: absolute; top: 72rpx; right: 78rpx; font-weight: 400; font-size: 24rpx; color: #BBB7B7 ; } } } } </style>