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

194 lines
4.0 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">
2024-03-05 09:57:45 +08:00
<!-- <image :src="item.src" mode=""></image> -->
<u-image width="100%" height="355rpx" :src="item.src"></u-image>
2023-10-16 11:21:27 +08:00
<view class="servename">
{{item.prizeName?item.prizeName:''}}
</view>
<view class="PointsRecord">
{{item.score?item.score:''}}积分
</view>
<view class="button" @tap="goexchange(item)">
2024-03-18 19:23:28 +08:00
兑换
2023-10-16 11:21:27 +08:00
</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>
2024-03-18 19:23:28 +08:00
<u-modal v-model="updatashow" content="是否确认兑换?" :show-cancel-button='true' @confirm='updataconfirm'></u-modal>
2023-10-16 11:21:27 +08:00
<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,
2024-03-04 17:42:30 +08:00
prizeExchangesave,
2023-10-16 10:08:17 +08:00
} from '@/api/pagesB/PointsMall/index.js'
2024-03-05 09:57:45 +08:00
import {
getImgById
} from '@/api/pagesB/getimg/index.js'
2023-09-26 17:59:59 +08:00
export default {
data() {
2023-10-16 10:08:17 +08:00
return {
2024-03-18 19:23:28 +08:00
updatashow: false,
updataitem: {},
2023-10-16 10:08:17 +08:00
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,
},
2024-03-05 09:57:45 +08:00
list: [],
2023-10-16 10:08:17 +08:00
total: 0,
};
2023-09-26 17:59:59 +08:00
},
2024-01-22 10:50:10 +08:00
onReady() { //更改导航栏文字
if (uni.getStorageSync('region') == 2) {
uni.setNavigationBarTitle({
2024-02-02 17:17:47 +08:00
title: '东营健康银行'
2024-01-22 10:50:10 +08:00
});
} else {
uni.setNavigationBarTitle({
title: '积分兑换'
});
}
},
2023-09-26 17:59:59 +08:00
methods: {
2024-03-18 19:23:28 +08:00
updataconfirm() {
2023-10-16 11:21:27 +08:00
var obj = {
identity: this.query.identity,
2024-03-18 19:23:28 +08:00
prizeId: this.updataitem.prizeId,
2024-03-16 18:57:35 +08:00
source: 2
2023-10-16 11:21:27 +08:00
}
prizeExchangesave(obj).then(res => {
if (res.code == 200) {
2024-03-16 17:39:32 +08:00
uni.showModal({
title: '兑换申请提示',
content: '兑换申请已提交,机构正在审批中,如长时间未通过,请联系您的签约医生',
showCancel: false,
success: function(res) {}
});
2023-10-16 11:21:27 +08:00
} else {
this.$refs.uToast.show({
title: res.msg,
type: 'error',
})
}
})
2023-09-26 17:59:59 +08:00
},
2024-03-18 19:23:28 +08:00
goexchange(item) {
this.updatashow = true
this.updataitem = item
},
2023-10-16 10:08:17 +08:00
info() {
2023-10-16 11:21:27 +08:00
prizelist(this.query).then(res => {
2024-03-04 17:42:30 +08:00
res.rows.forEach(e => {
e.src = ''
})
2024-03-05 09:57:45 +08:00
this.list = [
...this.list,
...res.rows
]
2024-03-04 17:42:30 +08:00
this.list.forEach(async (e) => {
2024-03-05 09:57:45 +08:00
if (e.src == '') {
e.src = await this.getimg(e.prizeId);
}
2024-03-04 17:42:30 +08:00
});
2023-10-16 10:08:17 +08:00
this.total = res.total
})
},
2024-03-04 17:42:30 +08:00
async getimg(id) {
try {
const res = await getImgById(id);
return res.data
} catch (error) {
return null;
}
},
2023-10-16 10:08:17 +08:00
},
onLoad() {
this.info();
},
2024-03-05 09:57:45 +08:00
onReachBottom() { //上滑加载
2023-10-16 10:08:17 +08:00
if (this.list.length >= this.total) {} else {
this.query.pageNum++
2024-03-05 09:57:45 +08:00
this.info();
2023-10-16 10:08:17 +08:00
}
},
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 {
2024-01-22 10:50:10 +08:00
::v-deep .u-empty {
2023-10-16 11:21:27 +08:00
margin-top: 25vh !important;
}
2024-01-22 10:50:10 +08:00
2023-10-16 11:21:27 +08:00
.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;
2024-03-05 09:57:45 +08:00
border: 1px solid #fff;
2023-09-26 17:59:59 +08:00
.button {
2024-03-16 16:47:38 +08:00
width: 150rpx;
height: 50rpx;
line-height: 50rpx;
2023-09-26 17:59:59 +08:00
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%;
}
2024-03-05 09:57:45 +08:00
::v-deep .u-image {
2023-10-16 10:08:17 +08:00
width: 100%;
height: 355rpx;
border-radius: 5rpx;
2023-09-26 17:59:59 +08:00
}
}
}
2024-01-22 10:50:10 +08:00
</style>