| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282 |
- <template>
- <view class="points-detail">
- <!-- 顶部导航栏 -->
- <view class="header">
- <view class="back-icon" @click="handleBack"></view>
- <text class="header-title">积分明细</text>
- <view class="header-right"></view>
- </view>
- <!-- 积分余额卡片 -->
- <view class="balance-card">
- <view class="balance-label">当前积分</view>
- <view class="balance-value">{{ balance }}</view>
- </view>
- <!-- 明细列表 -->
- <view class="records-section">
- <view class="section-title">积分记录</view>
-
- <view v-if="records.length === 0 && !loading" class="empty-tip">
- 暂无积分记录
- </view>
-
- <view class="record-list">
- <view class="record-item" v-for="(item, index) in records" :key="index">
- <view class="record-left">
- <view class="record-icon" :class="item.points > 0 ? 'income' : 'expense'">
- {{ item.points > 0 ? '+' : '-' }}
- </view>
- <view class="record-info">
- <view class="record-reason">{{ item.reason }}</view>
- <view class="record-time">{{ formatTime(item.createTime) }}</view>
- </view>
- </view>
- <view class="record-points" :class="item.points > 0 ? 'income' : 'expense'">
- {{ item.points > 0 ? '+' : '' }}{{ item.points }}
- </view>
- </view>
- </view>
-
- <!-- 加载更多 -->
- <view class="load-more" v-if="hasMore" @click="loadMore">
- {{ loading ? '加载中...' : '加载更多' }}
- </view>
- </view>
- </view>
- </template>
- <script>
- import api from '@/utils/api.js'
- export default {
- name: 'points-detail',
- data() {
- return {
- balance: 0,
- records: [],
- makerId: null,
- pageNum: 1,
- pageSize: 20,
- total: 0,
- loading: false
- }
- },
- computed: {
- hasMore() {
- return this.records.length < this.total
- }
- },
- onLoad() {
- this.initData()
- },
- methods: {
- async initData() {
- const userInfo = uni.getStorageSync('userInfo')
- if (userInfo && userInfo.matchmakerId) {
- this.makerId = userInfo.matchmakerId
- } else if (userInfo && userInfo.userId) {
- this.makerId = userInfo.userId
- }
-
- await this.loadRecords()
- },
-
- async loadRecords() {
- if (!this.makerId || this.loading) return
-
- this.loading = true
- try {
- const res = await api.pointsMall.getRecords(this.makerId, this.pageNum, this.pageSize)
- this.balance = res.balance || 0
- this.total = res.total || 0
-
- if (this.pageNum === 1) {
- this.records = res.list || []
- } else {
- this.records = [...this.records, ...(res.list || [])]
- }
- } catch (e) {
- console.error('获取积分明细失败:', e)
- uni.showToast({ title: '获取积分明细失败', icon: 'none' })
- } finally {
- this.loading = false
- }
- },
-
- loadMore() {
- if (this.hasMore && !this.loading) {
- this.pageNum++
- this.loadRecords()
- }
- },
-
- handleBack() {
- uni.navigateBack()
- },
-
- formatTime(timeStr) {
- if (!timeStr) return ''
- const date = new Date(timeStr)
- const year = date.getFullYear()
- const month = String(date.getMonth() + 1).padStart(2, '0')
- const day = String(date.getDate()).padStart(2, '0')
- const hour = String(date.getHours()).padStart(2, '0')
- const minute = String(date.getMinutes()).padStart(2, '0')
- return `${year}-${month}-${day} ${hour}:${minute}`
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .points-detail {
- min-height: 100vh;
- background: #F5F5F5;
- }
- .header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 25rpx 30rpx;
- padding-top: calc(25rpx + env(safe-area-inset-top));
- background: #FFFFFF;
-
- .back-icon {
- width: 44rpx;
- height: 44rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 32rpx;
- color: #333;
- &::before { content: '‹'; }
- }
-
- .header-title {
- font-size: 36rpx;
- font-weight: bold;
- color: #333;
- }
-
- .header-right {
- width: 44rpx;
- }
- }
- .balance-card {
- background: linear-gradient(135deg, #9C27B0 0%, #E91E63 100%);
- margin: 30rpx;
- padding: 40rpx;
- border-radius: 20rpx;
- text-align: center;
-
- .balance-label {
- font-size: 28rpx;
- color: rgba(255, 255, 255, 0.8);
- margin-bottom: 15rpx;
- }
-
- .balance-value {
- font-size: 72rpx;
- font-weight: bold;
- color: #FFFFFF;
- }
- }
- .records-section {
- background: #FFFFFF;
- margin: 0 30rpx;
- border-radius: 20rpx;
- padding: 30rpx;
-
- .section-title {
- font-size: 30rpx;
- font-weight: bold;
- color: #333;
- margin-bottom: 30rpx;
- }
-
- .empty-tip {
- text-align: center;
- color: #999;
- font-size: 28rpx;
- padding: 60rpx 0;
- }
- }
- .record-list {
- .record-item {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 25rpx 0;
- border-bottom: 1rpx solid #F0F0F0;
-
- &:last-child {
- border-bottom: none;
- }
-
- .record-left {
- display: flex;
- align-items: center;
-
- .record-icon {
- width: 60rpx;
- height: 60rpx;
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 32rpx;
- font-weight: bold;
- margin-right: 20rpx;
-
- &.income {
- background: #E8F5E9;
- color: #4CAF50;
- }
-
- &.expense {
- background: #FFEBEE;
- color: #F44336;
- }
- }
-
- .record-info {
- .record-reason {
- font-size: 28rpx;
- color: #333;
- margin-bottom: 8rpx;
- }
-
- .record-time {
- font-size: 24rpx;
- color: #999;
- }
- }
- }
-
- .record-points {
- font-size: 32rpx;
- font-weight: bold;
-
- &.income {
- color: #4CAF50;
- }
-
- &.expense {
- color: #F44336;
- }
- }
- }
- }
- .load-more {
- text-align: center;
- padding: 30rpx;
- color: #9C27B0;
- font-size: 26rpx;
- }
- </style>
|