diff --git a/frontend/uni-app/src/dynamic-pages/components/order/detail/PriceDetail.vue b/frontend/uni-app/src/dynamic-pages/components/order/detail/PriceDetail.vue index 0e6158ff1..5a368bf22 100644 --- a/frontend/uni-app/src/dynamic-pages/components/order/detail/PriceDetail.vue +++ b/frontend/uni-app/src/dynamic-pages/components/order/detail/PriceDetail.vue @@ -17,13 +17,13 @@ class="info-value" :class="isDiscount(item.value) ? 'discount' : ''" > - {{ isDiscount(item.value) ? '' : '¥' }}{{ item.value }} + {{ formatMoney(item.value) }} {{ $t('实付款') }}: - ¥{{ payPrice || '0.00' }} + {{ formatMoney(payPrice) }} @@ -32,7 +32,7 @@ /** * 价格明细卡片组件 * 展示多行金额明细和实付款总额 - * 折扣类金额(以"-"开头)显示为折扣样式,不带¥符号 + * 正负号统一显示在货币符号前面,例如 +¥2.70、-¥1.00 * 通过 componentKey='price_detail' 匹配 section.component */ export default { @@ -68,6 +68,18 @@ function isDiscount(val) { if (val === null || val === undefined) return false; return String(val).indexOf('-') === 0; } + +/** + * 统一金额显示格式,避免出现 ¥+2.70 这类符号顺序错误 + * @param {string|number} val 金额值 + * @return {string} 带货币符号的金额 + */ +function formatMoney(val) { + const text = String(val === null || val === undefined || val === '' ? '0.00' : val); + const sign = text[0] === '+' || text[0] === '-' ? text[0] : ''; + const amount = sign ? text.slice(1) : text; + return `${sign}¥${amount}`; +}