修复了积分不能正常显示的bug
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
</div>
|
||||
<div class="points-info">
|
||||
<div class="points-value">{{ userPoints }}</div>
|
||||
<div class="points-label">当前积分</div>
|
||||
<!-- <div class="points-label">当前积分</div> -->
|
||||
</div>
|
||||
<img src="/imgs/point.png" alt="我的积分图标" class="balance-image">
|
||||
</div>
|
||||
@@ -288,11 +288,18 @@ const viewOrder = (orderId) => {
|
||||
const getUserPoints = async () => {
|
||||
try {
|
||||
const response = await api.get('/user/points')
|
||||
userPoints.value = response.data.currentPoints
|
||||
totalEarned.value = response.data.totalEarned
|
||||
totalSpent.value = response.data.totalSpent
|
||||
|
||||
// 添加更灵活的数据提取方式
|
||||
userPoints.value = response.data?.currentPoints ?? response.data?.points ?? 0
|
||||
totalEarned.value = response.data?.totalEarned ?? 0
|
||||
totalSpent.value = response.data?.totalSpent ?? 0
|
||||
|
||||
} catch (error) {
|
||||
console.error("获取积分信息失败:", error)
|
||||
ElMessage.error('获取积分信息失败')
|
||||
userPoints.value = 0
|
||||
totalEarned.value = 0
|
||||
totalSpent.value = 0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user