peixue-dev/Archive/[一次性]积分明细显示修复-2026-01-31.md

1.7 KiB

积分明细显示修复 - 2026-01-31

问题描述

积分明细中,"注册赠送"、"签到赠送"、"订单赠送"等获得积分的记录显示为负号(-),应该显示为正号(+)

问题原因

数据库数据

type = 'EARN' (大写)
points = 350, 50, 100 (正数)

前端判断逻辑

{{ item.type === 'earn' ? '+' : '-' }}

问题

  • 数据库存储的是 'EARN' (大写)
  • 前端判断的是 'earn' (小写)
  • 'EARN' === 'earn'false
  • 所以显示 -

修复方案

修改前端代码,使用不区分大小写的比较:

修改前

<text class="item-points" :class="item.type === 'earn' ? 'earn' : 'spend'">
  {{ item.type === 'earn' ? '+' : '-' }}{{ Math.abs(item.points) }}
</text>

修改后

<text class="item-points" :class="item.type && item.type.toLowerCase() === 'earn' ? 'earn' : 'spend'">
  {{ item.type && item.type.toLowerCase() === 'earn' ? '+' : '-' }}{{ Math.abs(item.points) }}
</text>

getTypeText 方法也需要修改

getTypeText(type) {
  if (!type) return ''
  const typeMap = {
    'earn': '获得',
    'spend': '使用',
    'consume': '使用',
    'expire': '过期'
  }
  return typeMap[type.toLowerCase()] || type
}

修复文件

  • peidu/uniapp/src/user-package/pages/user/points.vue

执行步骤

清除缓存并重新编译:

Archive/[一次性]清除缓存重新编译-积分修复-2026-01-31.bat

验证结果

修复后:

  • "注册赠送" 显示 +100
  • "签到赠送" 显示 +50
  • "订单赠送" 显示 +350
  • 类型标签显示"获得"

修复完成时间

2026-01-31