From dde77fb6d7e8ccbf1a2e39d9e4fddcea92aa2acf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=A7=E5=96=B5=E5=92=AA?= <15233722133@163.com>
Date: Fri, 7 Aug 2026 14:18:26 +0800
Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E7=94=B3=E8=AF=B7=E5=94=AE?=
=?UTF-8?q?=E5=90=8E=E4=BB=B7=E6=A0=BC=E5=B1=95=E7=A4=BA=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages/order/aftersale/apply.vue | 36 ++++++++++++++++++++++++---------
1 file changed, 26 insertions(+), 10 deletions(-)
diff --git a/pages/order/aftersale/apply.vue b/pages/order/aftersale/apply.vue
index 48d0109..62d285c 100644
--- a/pages/order/aftersale/apply.vue
+++ b/pages/order/aftersale/apply.vue
@@ -43,8 +43,8 @@
@tap="state.showModal = true"
>
退款金额
-
- ¥{{ fen2yuan(state.item.payPrice) }}
+
+ ¥{{ fen2yuan(state.payPrice) }}
@@ -130,6 +130,7 @@
order: {}, // 订单
item: {}, // 订单项
config: {}, // 交易配置
+ payPrice: 0, // 退款金额:单品取item.payPrice,整单取外层order.payPrice
// 售后类型
wayList: [
@@ -157,8 +158,8 @@
// 提交表单
async function submit() {
let data = {
- orderItemId: state.item.id,
- refundPrice: state.item.payPrice,
+ orderItemId: state.item?.id,
+ refundPrice: state.payPrice,
...formData,
};
const { code } = await AfterSaleApi.createAfterSale(data);
@@ -210,22 +211,37 @@
}
onLoad(async (options) => {
- // 解析参数
- if (!options.id || !options.id) {
+ // 解析参数:兼容单品入口(传orderId+itemId)和整单入口(传订单对象即props.data.id)
+ const orderId = parseInt(options.orderId || options.id);
+ const itemId = options.itemId ? parseInt(options.itemId) : 0;
+ if (!orderId) {
sheep.$helper.toast(`缺少订单信息,请检查`);
return;
}
- state.orderId = options.id;
- state.itemId = parseInt(options.itemId);
+ state.orderId = orderId;
+ state.itemId = itemId;
// 读取订单信息
const { code, data } = await OrderApi.getOrderDetail(state.orderId);
if (code !== 0) {
return;
}
- // console.log('aaa',data);
state.order = data;
- state.item = data.items.find((item) => item.orderId == state.orderId) || {};
+
+ // 按itemId精确查找订单项(单品入口),否则默认取第1项(整单入口仅用于商品卡片展示)
+ if (state.itemId > 0) {
+ state.item = data.items.find((item) => item.id === state.itemId) || {};
+ } else {
+ state.item = data.items?.[0] || {};
+ }
+
+ // 退款金额:单品用订单项的payPrice,整单使用订单外层的payPrice(含randomDiscountPrice等优惠抵扣后的值)
+ if (state.itemId > 0 && state.item?.id) {
+ state.payPrice = state.item.payPrice;
+ } else {
+ state.payPrice = state.order.payPrice;
+ }
+
// 设置选项
if (state.order.status === 10) {
state.wayList.splice(1, 1);