Files
2026-05-12 15:19:37 +08:00

369 lines
8.4 KiB
Vue

<template>
<view class="point-page">
<view v-if="isLoad">
<view class="rule-btn" @click="showHidePopup(true)">
积分规则
</view>
<view class="tab-wrap">
<view
:class="query.pm === 1 ? 'curr' : ''"
class="tab-item"
@click="tabItemClick(1)"
>
<view class="txt">当前总积分</view>
<view class="number">
<image
v-if="query.pm === 1"
:src="webUrl + '/page/my/coin.png'"
class="icon"
/>
{{ point.currentPoints }}
</view>
</view>
<view
:class="query.pm === 0 ? 'curr' : ''"
class="tab-item"
@click="tabItemClick(0)"
>
<view class="txt">已使用积分</view>
<view class="number">
<image
v-if="query.pm === 0"
:src="webUrl + '/page/my/coin.png'"
class="icon"
/>
{{ point.totalUsedPoints }}
</view>
</view>
</view>
<view class="list-wrap">
<view
v-for="(item, index) in list"
:key="index"
class="item"
>
<view v-if="item.orderId" class="order">
<view class="title">
<view class="img">
<image :src="item.image" class="img" />
</view>
<view class="name more-t">
<view class="more-t">
{{ item.title }}
</view>
<view
:class="item.pm ? 'red' : 'green'"
class="number"
>
{{ item.pm ? '+' : '-' }}{{ item.number }}
<text class="txt">积分</text>
</view>
</view>
</view>
<view class="bottom" @click="goOrderDetails(item)">
<view class="txt">
点击查看详情 >>
</view>
<text class="iconfont icon-jiantou"></text>
</view>
</view>
<view v-else class="lottery">
<image :src="webUrl + '/points-lottery.png'" class="img" />
<view class="one-t title">
{{ item.title }}
</view>
<view
:class="item.pm ? 'red' : 'green'"
class="number"
>
{{ item.pm ? '+' : '-' }}{{ item.number }}
<text class="txt">积分</text>
</view>
</view>
</view>
<goo-skeleton
v-if="isLoading"
:show-avatar="false"
/>
<view v-else>
<view v-if="list.length === 0" class="no-data">
暂无数据
</view>
<!-- <u-loadmore
v-if="query.page >= totalPage && list.length > 0"
:line="true"
status="nomore"
nomore-text="到底了"
/> -->
</view>
</view>
</view>
<goo-skeleton
v-else
:show-avatar="false"
/>
<u-popup
:show="show"
mode="center"
round="10"
closeable
@close="showHidePopup(false)"
>
<view class="popup-body">
<view class="title bold">积分规则</view>
<view class="content">
<view class="content-html">
<rich-text :nodes="point.pointsRule" />
</view>
</view>
</view>
</u-popup>
</view>
</template>
<script>
import {
getUserPointInfo,
getUserPointBill
} from '@/api/user'
import { pageListenMixins } from '@/mixins/pageListenMixins'
export default {
name: 'UserPoints',
mixins: [pageListenMixins],
data: function() {
return {
webUrl: this.$VUE_APP_RESOURCES_URL,
query: {
pm: 1, // 0-支出,1-收入
page: 1,
limit: 10
},
isLoading: false,
list: [],
totalPage: 1,
isLoad: false,
point: {
currentPoints: 0, // 当前总积分
totalUsedPoints: 0, // 累计使用积分
pointsRule: ''
},
show: false,
pageKeyId: Object.freeze('userPointsBill')
}
},
created() {
this.getInfo()
},
onReachBottom() {
if (this.isLoading || this.query.page >= this.totalPage) {
return
}
this.query.page++
this.getList()
},
methods: {
tabItemClick(type) {
if (this.query.pm === type) {
return
}
this.query.pm = type
this.query.page = 1
this.list = []
this.getList()
},
getInfo() {
getUserPointInfo().then(res => {
const { success, data } = res
if (success) {
this.isLoad = true
this.point = data
this.getList()
}
})
},
getList() {
this.isLoading = true
getUserPointBill(this.query).then(res => {
const { success, data } = res
if (success) {
this.totalPage = data.pages || 1
if (data.records.length > 0) {
data.records.map(item => {
this.list.push(item)
})
}
}
}).finally(() => {
this.isLoading = false
})
},
goOrderDetails(order) {
this.$yrouter.push({
path: '/pagesOrder/order/OrderDetails/index',
query: {
id: order.orderId
}
})
},
showHidePopup(value) {
this.show = value
}
}
}
</script>
<style lang="less" scoped>
.point-page {
padding: 30rpx;
.rule-btn {
position: fixed;
right: 0;
top: 255rpx;
z-index: 9;
height: 24rpx;
padding: 20rpx 30rpx 20rpx 40rpx;
border-top-left-radius: 35rpx;
border-bottom-left-radius: 35rpx;
color: #fff;
font-size: 14px;
line-height: 24rpx;
background-color: #C51919;
}
.tab-wrap {
display: flex;
align-items: center;
.tab-item {
flex: 1;
justify-content: center;
padding: 20rpx;
border-radius: 15rpx;
background-color: #fff;
.txt {
width: 100px;
height: 36px;
padding: 0 20rpx;
margin: 0 auto;
border-radius: 4px;
border: 1px solid #C51919;
line-height: 36px;
text-align: center;
color: #C51919;
font-size: 16px;
}
.number {
display: flex;
justify-content: center;
align-items: center;
margin: 20rpx 0 0 0;
font-size: 20px;
color: #333;
font-weight: bold;
line-height: 26px;
.icon {
width: 40rpx;
height: 40rpx;
margin: 0 20rpx 0 0;
}
}
&.curr {
padding: 35rpx 20rpx;
background-color: #C51919;
.txt {
border-color: #fff;
color: #fff;
}
.number {
font-size: 26px;
color: #fff;
}
}
}
}
.list-wrap {
padding: 60rpx 0 0 0;
.item {
margin: 30rpx 0 0 0;
border-radius: 8px;
background-color: #fff;
.order {
.title {
display: flex;
padding: 20rpx;
.img {
display: block;
width: 120rpx;
height: 120rpx;
margin: 0 20rpx 0 0;
background-color: #f6f6f6;
}
.name {
width: calc(100% - 140rpx);
color: #333;
}
}
.bottom {
display: flex;
padding: 20rpx;
border-top: 1rpx solid #f6f6f6;
font-size: 12px;
color: #666;
.txt {
flex: 1;
color: #FD5749;
}
.iconfont {
font-size: 14px;
}
}
}
.lottery {
display: flex;
align-items: center;
padding: 20rpx;
.img {
display: block;
width: 62rpx;
height: 62rpx;
margin: 0 20rpx 0 0;
}
.title {
flex: 1;
}
}
.number {
text-align: right;
font-size: 18px;
font-weight: bold;
.txt {
font-size: 12px;
}
&.red {
color: #FD5749;
}
&.green {
color: #3DC260;
}
}
}
}
.no-data {
line-height: 200rpx;
text-align: center;
font-size: 16px;
color: #999;
}
.popup-body {
.title {
line-height: 80rpx;
text-align: center;
}
.content {
padding: 0 30rpx 30rpx 30rpx;
.content-html {
max-height: 70vh;
overflow-y: auto;
}
}
}
}
</style>