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