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

156 lines
2.9 KiB
Vue
Raw Normal View History

2023-09-26 17:59:59 +08:00
<template>
<view class="app">
2023-10-16 11:21:27 +08:00
<view class="contents" v-if="list&&list.length>0">
<view class="content" v-for="item in list">
<image :src="item.attachment" mode=""></image>
<view class="servename">
{{item.prizeName?item.prizeName:''}}
</view>
<view class="PointsRecord">
{{item.score?item.score:''}}积分
</view>
<view class="button" @tap="goexchange(item)">
兑换
</view>
2023-10-16 09:25:38 +08:00
</view>
2023-10-16 11:21:27 +08:00
<view style="width: 48%;" v-if="list.length%2!=0">
2023-10-16 09:25:38 +08:00
</view>
2023-09-27 13:50:42 +08:00
</view>
2023-10-16 11:21:27 +08:00
<u-empty v-else mode="list" icon-size='220' text='暂无可兑换商品'></u-empty>
<u-toast ref="uToast" />
2023-09-27 13:50:42 +08:00
</view>
2023-09-26 17:59:59 +08:00
</template>
<script>
2023-10-16 10:08:17 +08:00
import {
2023-10-16 11:21:27 +08:00
prizelist,
prizeExchangesave
2023-10-16 10:08:17 +08:00
} from '@/api/pagesB/PointsMall/index.js'
2023-09-26 17:59:59 +08:00
export default {
data() {
2023-10-16 10:08:17 +08:00
return {
query: {
2023-10-16 11:21:27 +08:00
identity: uni.getStorageSync('userinfo').cardNo,
2023-10-16 10:08:17 +08:00
pageNum: 1,
pageSize: 10,
},
2023-10-16 11:21:27 +08:00
list: null,
2023-10-16 10:08:17 +08:00
total: 0,
};
2023-09-26 17:59:59 +08:00
},
methods: {
2023-10-16 11:21:27 +08:00
goexchange(item) {
var obj = {
identity: this.query.identity,
prizeId: item.prizeId
}
prizeExchangesave(obj).then(res => {
if (res.code == 200) {
this.$refs.uToast.show({
title: '兑换成功',
type: 'success',
})
} else {
this.$refs.uToast.show({
title: res.msg,
type: 'error',
})
}
})
2023-09-26 17:59:59 +08:00
},
2023-10-16 10:08:17 +08:00
info() {
2023-10-16 11:21:27 +08:00
prizelist(this.query).then(res => {
2023-10-16 10:08:17 +08:00
this.list = res.rows
this.total = res.total
})
},
},
onLoad() {
this.info();
},
onReachBottom() { //下滑加载
if (this.list.length >= this.total) {} else {
this.query.pageNum++
2023-10-16 11:21:27 +08:00
prizelist(this.query).then(res => {
2023-10-16 10:08:17 +08:00
if (res.rows) {
res.rows.forEach(e => {
this.list.push(e)
})
}
})
}
},
onPullDownRefresh() { //下拉刷新
this.query.pageNum = 1;
this.info();
setTimeout(function() {
uni.stopPullDownRefresh();
}, 1000);
2023-09-26 17:59:59 +08:00
},
}
</script>
<style lang="scss">
.app {
2023-10-16 11:21:27 +08:00
::v-deep .u-empty{
margin-top: 25vh !important;
}
.contents {
padding-top: 10rpx;
display: flex;
width: 100%;
flex-wrap: wrap;
justify-content: space-evenly;
}
2023-09-26 17:59:59 +08:00
.content {
height: 514rpx;
background: #fff;
2023-10-16 10:08:17 +08:00
width: 48%;
2023-09-26 17:59:59 +08:00
position: relative;
border-radius: 5rpx;
2023-10-16 10:08:17 +08:00
margin: 0 0 20rpx 0;
2023-09-26 17:59:59 +08:00
.button {
width: 100rpx;
height: 44rpx;
line-height: 44rpx;
position: absolute;
text-align: center;
font-size: 22rpx;
font-weight: 400;
color: #fff;
right: 3%;
bottom: 5%;
background: #26A888;
border-radius: 5rpx;
}
.PointsRecord {
2023-10-16 10:08:17 +08:00
padding-top: 20rpx;
font-size: 22rpx;
2023-09-26 17:59:59 +08:00
font-weight: 400;
color: #26A888;
padding-left: 3%;
}
.servename {
2023-09-27 13:50:42 +08:00
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
2023-10-16 10:08:17 +08:00
font-size: 28rpx;
2023-09-26 17:59:59 +08:00
font-weight: 400;
color: #000000;
padding-left: 3%;
}
2023-10-16 10:08:17 +08:00
image {
width: 100%;
height: 355rpx;
border-radius: 5rpx;
2023-09-26 17:59:59 +08:00
}
}
}
2023-10-16 11:21:27 +08:00
</style>