|
@@ -20,7 +20,7 @@
|
|
|
<!-- 标签切换 -->
|
|
<!-- 标签切换 -->
|
|
|
<u-tabs
|
|
<u-tabs
|
|
|
:list="tabs"
|
|
:list="tabs"
|
|
|
- :current="categoryIndex"
|
|
|
|
|
|
|
+ :current="opType"
|
|
|
@change="handleTabChange"
|
|
@change="handleTabChange"
|
|
|
lineWidth="60"
|
|
lineWidth="60"
|
|
|
lineColor="#20CAC2"
|
|
lineColor="#20CAC2"
|
|
@@ -39,23 +39,26 @@
|
|
|
|
|
|
|
|
<!-- 积分记录列表 -->
|
|
<!-- 积分记录列表 -->
|
|
|
<view class="records-container">
|
|
<view class="records-container">
|
|
|
- <u-list @scrolltolower="loadMore" style="height:calc(75vh - 60rpx)">
|
|
|
|
|
- <u-list-item v-for="(item, index) in filteredRecords" :key="item.id" class="record-item">
|
|
|
|
|
|
|
+ <u-list @scrolltolower="loadMore" ref="list" style="height:calc(75vh - 60rpx)">
|
|
|
|
|
+ <u-list-item v-for="(item, index) in filteredRecords" :key="index" class="record-item">
|
|
|
<view class="record-info">
|
|
<view class="record-info">
|
|
|
- <text class="record-description">{{ item.description }}</text>
|
|
|
|
|
- <text class="record-date">{{ item.date }}</text>
|
|
|
|
|
|
|
+ <text class="record-description">{{ item.activityName }}</text>
|
|
|
|
|
+ <text class="record-date">{{ item.createTime }}</text>
|
|
|
</view>
|
|
</view>
|
|
|
- <text class="record-amount" :class="{ income: item.amount > 0, expense: item.amount < 0 }">
|
|
|
|
|
- {{ item.amount > 0 ? '+' : '' }}{{ item.amount }}
|
|
|
|
|
|
|
+ <text class="record-amount" :class="{ income: item.opType == 2, expense: item.opType == 1 }">
|
|
|
|
|
+ {{ item.opType == 1 ? '+' : '-' }}{{ item.points }}
|
|
|
</text>
|
|
</text>
|
|
|
</u-list-item>
|
|
</u-list-item>
|
|
|
<!-- 空数据状态 -->
|
|
<!-- 空数据状态 -->
|
|
|
<u-empty
|
|
<u-empty
|
|
|
- v-if="filteredRecords.length === 0"
|
|
|
|
|
- icon="document"
|
|
|
|
|
|
|
+ v-if="filteredRecords.length === 0 && !loading"
|
|
|
text="暂无积分记录"
|
|
text="暂无积分记录"
|
|
|
- mode="page"
|
|
|
|
|
|
|
+ mode="list"
|
|
|
></u-empty>
|
|
></u-empty>
|
|
|
|
|
+ <!-- 加载中状态 -->
|
|
|
|
|
+ <view v-if="loading && filteredRecords.length === 0" class="loading-container">
|
|
|
|
|
+ <u-loading-icon text="加载中..."></u-loading-icon>
|
|
|
|
|
+ </view>
|
|
|
<!-- 加载更多 -->
|
|
<!-- 加载更多 -->
|
|
|
<u-loadmore
|
|
<u-loadmore
|
|
|
v-if="filteredRecords.length > 0"
|
|
v-if="filteredRecords.length > 0"
|
|
@@ -72,42 +75,23 @@
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
import {mapState} from "vuex";
|
|
import {mapState} from "vuex";
|
|
|
-
|
|
|
|
|
|
|
+import { getPointDetails } from '@/api/points'
|
|
|
export default {
|
|
export default {
|
|
|
name: "billPage",
|
|
name: "billPage",
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
|
// 标签数据
|
|
// 标签数据
|
|
|
tabs: [
|
|
tabs: [
|
|
|
- { key: 'all', name: '明细' },
|
|
|
|
|
- { key: 'income', name: '收入' },
|
|
|
|
|
- { key: 'expense', name: '支出' }
|
|
|
|
|
|
|
+ { key: '', name: '明细' },
|
|
|
|
|
+ { key: '1', name: '收入' },
|
|
|
|
|
+ { key: '2', name: '支出' }
|
|
|
],
|
|
],
|
|
|
// 当前选中的标签
|
|
// 当前选中的标签
|
|
|
- activeTab: 'all',
|
|
|
|
|
|
|
+ activeTab: '',
|
|
|
// 积分记录数据
|
|
// 积分记录数据
|
|
|
- pointRecords: [
|
|
|
|
|
- { id: 1, type: 'order', description: '订单消费', amount: 10, date: '2026.10.1 12:22:54' },
|
|
|
|
|
- { id: 2, type: 'exchange', description: '购物兑换', amount: -10, date: '2026.10.1 12:22:54' },
|
|
|
|
|
- { id: 3, type: 'order', description: '完成订单', amount: 10, date: '2026.10.1 12:22:54' },
|
|
|
|
|
- { id: 4, type: 'reward', description: '好评奖励', amount: -10, date: '2026.10.1 12:22:54' },
|
|
|
|
|
- { id: 5, type: 'order', description: '完成订单', amount: 10, date: '2026.10.1 12:22:54' },
|
|
|
|
|
- { id: 6, type: 'reward', description: '好评奖励', amount: -10, date: '2026.10.1 12:22:54' },
|
|
|
|
|
- { id: 7, type: 'order', description: '订单消费', amount: 10, date: '2026.10.1 12:22:54' },
|
|
|
|
|
- { id: 8, type: 'exchange', description: '购物兑换', amount: -10, date: '2026.10.1 12:22:54' },
|
|
|
|
|
- { id: 9, type: 'order', description: '完成订单', amount: 10, date: '2026.10.1 12:22:54' },
|
|
|
|
|
- { id: 10, type: 'reward', description: '好评奖励', amount: -10, date: '2026.10.1 12:22:54' },
|
|
|
|
|
- { id: 11, type: 'order', description: '完成订单', amount: 10, date: '2026.10.1 12:22:54' },
|
|
|
|
|
- { id: 12, type: 'reward', description: '好评奖励', amount: -10, date: '2026.10.1 12:22:54' },
|
|
|
|
|
- { id: 13, type: 'order', description: '订单消费', amount: 10, date: '2026.10.1 12:22:54' },
|
|
|
|
|
- { id: 14, type: 'exchange', description: '购物兑换', amount: -10, date: '2026.10.1 12:22:54' },
|
|
|
|
|
- { id: 15, type: 'order', description: '完成订单', amount: 10, date: '2026.10.1 12:22:54' },
|
|
|
|
|
- { id: 16, type: 'reward', description: '好评奖励', amount: -10, date: '2026.10.1 12:22:54' },
|
|
|
|
|
- { id: 17, type: 'order', description: '完成订单', amount: 10, date: '2026.10.1 12:22:54' },
|
|
|
|
|
- { id: 18, type: 'reward', description: '好评奖励', amount: -10, date: '2026.10.1 12:22:54' }
|
|
|
|
|
- ],
|
|
|
|
|
|
|
+ pointRecords: [],
|
|
|
// 分页数据
|
|
// 分页数据
|
|
|
- page: 1,
|
|
|
|
|
|
|
+ pageNum: 1,
|
|
|
pageSize: 10,
|
|
pageSize: 10,
|
|
|
hasMore: true,
|
|
hasMore: true,
|
|
|
loading: false
|
|
loading: false
|
|
@@ -118,69 +102,70 @@ export default {
|
|
|
myPoint: state => state.points.myPoint
|
|
myPoint: state => state.points.myPoint
|
|
|
}),
|
|
}),
|
|
|
totalPoints() {
|
|
totalPoints() {
|
|
|
- return this.myPoint.totalPoints || 0;
|
|
|
|
|
|
|
+ return this.myPoint && this.myPoint.totalPoints || 0;
|
|
|
},
|
|
},
|
|
|
earnedPoints() {
|
|
earnedPoints() {
|
|
|
- return this.myPoint.earnedPoints || 0;
|
|
|
|
|
|
|
+ return this.myPoint && this.myPoint.earnedPoints || 0;
|
|
|
},
|
|
},
|
|
|
expirePoints() {
|
|
expirePoints() {
|
|
|
- return this.myPoint.expirePoints || 0;
|
|
|
|
|
|
|
+ return this.myPoint && this.myPoint.expirePoints || 0;
|
|
|
},
|
|
},
|
|
|
- categoryIndex() {
|
|
|
|
|
|
|
+ opType() {
|
|
|
return this.tabs.findIndex(item => item.key === this.activeTab)
|
|
return this.tabs.findIndex(item => item.key === this.activeTab)
|
|
|
},
|
|
},
|
|
|
- // 过滤后的积分记录
|
|
|
|
|
|
|
+ // 积分记录(直接使用原始数据,因为已经通过接口参数过滤)
|
|
|
filteredRecords() {
|
|
filteredRecords() {
|
|
|
- if (this.activeTab === 'all') {
|
|
|
|
|
- return this.pointRecords
|
|
|
|
|
- } else if (this.activeTab === 'income') {
|
|
|
|
|
- return this.pointRecords.filter(record => record.amount > 0)
|
|
|
|
|
- } else if (this.activeTab === 'expense') {
|
|
|
|
|
- return this.pointRecords.filter(record => record.amount < 0)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ return this.pointRecords
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+ mounted() {
|
|
|
|
|
+ // 初始获取数据
|
|
|
|
|
+ this.fetchPointDetails()
|
|
|
|
|
+ },
|
|
|
methods: {
|
|
methods: {
|
|
|
// 切换标签
|
|
// 切换标签
|
|
|
handleTabChange(data) {
|
|
handleTabChange(data) {
|
|
|
this.activeTab = data.key
|
|
this.activeTab = data.key
|
|
|
// 重置分页数据
|
|
// 重置分页数据
|
|
|
- this.page = 1
|
|
|
|
|
|
|
+ this.pageNum = 1
|
|
|
this.hasMore = true
|
|
this.hasMore = true
|
|
|
- // 重置滚动位置
|
|
|
|
|
- this.$nextTick(() => {
|
|
|
|
|
- const list = this.$refs.list
|
|
|
|
|
- if (list) {
|
|
|
|
|
- list.scrollTo(0, 0)
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ // 清空数据
|
|
|
|
|
+ this.pointRecords = []
|
|
|
|
|
+ // 重新获取数据
|
|
|
|
|
+ this.fetchPointDetails();
|
|
|
},
|
|
},
|
|
|
// 加载更多数据
|
|
// 加载更多数据
|
|
|
loadMore() {
|
|
loadMore() {
|
|
|
if (this.loading || !this.hasMore) return
|
|
if (this.loading || !this.hasMore) return
|
|
|
|
|
|
|
|
|
|
+ this.pageNum++
|
|
|
|
|
+ this.fetchPointDetails(true)
|
|
|
|
|
+ },
|
|
|
|
|
+ // 获取积分明细数据
|
|
|
|
|
+ async fetchPointDetails(isLoadMore = false) {
|
|
|
this.loading = true
|
|
this.loading = true
|
|
|
- this.page++
|
|
|
|
|
-
|
|
|
|
|
- // 模拟加载数据
|
|
|
|
|
- setTimeout(() => {
|
|
|
|
|
- // 模拟新数据
|
|
|
|
|
- const newRecords = [
|
|
|
|
|
- { id: this.pointRecords.length + 1, type: 'order', description: '订单消费', amount: 10, date: '2026.10.1 12:22:54' },
|
|
|
|
|
- { id: this.pointRecords.length + 2, type: 'exchange', description: '购物兑换', amount: -10, date: '2026.10.1 12:22:54' },
|
|
|
|
|
- { id: this.pointRecords.length + 3, type: 'order', description: '完成订单', amount: 10, date: '2026.10.1 12:22:54' }
|
|
|
|
|
- ]
|
|
|
|
|
-
|
|
|
|
|
- // 添加新数据
|
|
|
|
|
- this.pointRecords = [...this.pointRecords, ...newRecords]
|
|
|
|
|
-
|
|
|
|
|
- // 模拟没有更多数据
|
|
|
|
|
- if (this.page >= 3) {
|
|
|
|
|
- this.hasMore = false
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ const res = await getPointDetails({
|
|
|
|
|
+ pageNum: this.pageNum,
|
|
|
|
|
+ pageSize: this.pageSize,
|
|
|
|
|
+ opType: this.activeTab
|
|
|
|
|
+ })
|
|
|
|
|
+ if (res.code === 200) {
|
|
|
|
|
+ if (isLoadMore) {
|
|
|
|
|
+ // 加载更多数据
|
|
|
|
|
+ this.pointRecords = [...this.pointRecords, ...res.rows]
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 初始加载数据
|
|
|
|
|
+ this.pointRecords = res.rows
|
|
|
|
|
+ }
|
|
|
|
|
+ // 判断是否还有更多数据
|
|
|
|
|
+ this.hasMore = this.pointRecords.length < res.total
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error('获取积分明细失败:', error)
|
|
|
|
|
+ } finally {
|
|
|
this.loading = false
|
|
this.loading = false
|
|
|
- }, 1000)
|
|
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -271,5 +256,13 @@ export default {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ .u-empty{
|
|
|
|
|
+ margin-top: 20vh!important;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /* 加载中容器 */
|
|
|
|
|
+ .loading-container {
|
|
|
|
|
+ margin-top: 20vh!important;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
</style>
|
|
</style>
|