xinelu-applet-ui/pagesB/exchangerecords/exchangerecords.vue
2024-03-05 09:57:45 +08:00

164 lines
3.1 KiB
Vue

<template>
<view class="app">
<view class="" v-if="list&&list.length>0">
<view class="content" v-for="item in list">
<view class="time">
{{item.exchangeDate?item.exchangeDate:''}}
<span>
{{item.score?item.score:0}} 积分
</span>
</view>
<u-image width="180rpx" height="180rpx" :src="item.src"></u-image>
<view class="servename">
{{item.prizeName?item.prizeName:''}}
</view>
<view class="servetime" v-if='item.useDate'>
服务时间:{{item.useDate}}
</view>
</view>
</view>
<u-empty v-else mode="list" icon-size='220' text='暂无兑换记录'></u-empty>
</view>
</template>
<script>
import {
prizeExchangelist
} from '@/api/pagesB/exchangerecords/index.js'
import {
getImgById
} from '@/api/pagesB/getimg/index.js'
export default {
data() {
return {
query: {
identity: uni.getStorageSync('userinfo').cardNo,
pageNum: 1,
pageSize: 10,
},
list: [],
total: 0,
};
},
onLoad() {
this.info()
},
methods: {
async getimg(id) {
try {
const res = await getImgById(id);
return res.data
} catch (error) {
return null;
}
},
info() {
prizeExchangelist(this.query).then(res => {
res.rows.forEach(e => {
e.src = ''
})
this.list = [
...this.list,
...res.rows
]
this.list.forEach(async (e) => {
if (e.src == '') {
e.src = await this.getimg(e.prizeId);
}
});
this.total = res.total
})
},
},
onReachBottom() { //下滑加载
if (this.list.length >= this.total) {} else {
this.query.pageNum++
this.info();
}
},
onPullDownRefresh() { //下拉刷新
this.query.pageNum = 1;
this.info();
setTimeout(function() {
uni.stopPullDownRefresh();
}, 1000);
},
}
</script>
<style lang="scss">
.app {
width: 100%;
text-align: justify;
padding: 25rpx 0 30rpx 0;
::v-deep .u-empty {
margin-top: 25vh !important;
}
.content {
width: 90%;
height: 321rpx;
background: #FFFFFF;
box-shadow: 0rpx 9rpx 31rpx 9rpx rgba(0, 0, 0, 0.03);
border-radius: 5rpx;
margin: 20rpx auto;
position: relative;
.servetime {
font-size: 26rpx;
font-weight: 400;
color: #959595;
line-height: 38rpx;
position: absolute;
bottom: 23%;
left: 35%;
text-align: justify;
}
.servename {
font-size: 32rpx;
font-weight: 500;
color: #333333;
line-height: 38rpx;
position: absolute;
top: 38%;
left: 35%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
::v-deep .u-image {
position: absolute;
left: 3%;
top: 28%;
width: 180rpx;
height: 180rpx;
}
.time {
text-align: justify;
padding: 25rpx 0 0 20rpx;
font-size: 28rpx;
font-weight: 400;
color: #000000;
line-height: 38rpx;
position: relative;
span {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: 28rpx;
position: absolute;
font-weight: 500;
color: #26A888;
line-height: 38rpx;
right: 3%;
}
}
}
}
</style>