|
|
@@ -222,6 +222,8 @@
|
|
|
data() {
|
|
|
return {
|
|
|
orderId: '',
|
|
|
+ isModify: false, // 是否是修改申请模式
|
|
|
+ refundOrderId: '', // 修改模式下的退款单ID
|
|
|
orderInfo: {
|
|
|
detailVoList: [],
|
|
|
discountMoney: 0,
|
|
|
@@ -291,14 +293,11 @@
|
|
|
|
|
|
if (totalOriginal === 0) return '0.00';
|
|
|
|
|
|
- let selectedOriginal = 0;
|
|
|
+ let refund = 0;
|
|
|
this.selectedGoods.forEach(item => {
|
|
|
- selectedOriginal += Number(item.payPrice) * item.refundNum;
|
|
|
+ refund += Number(item.payPrice) * item.refundNum;
|
|
|
});
|
|
|
|
|
|
- let payMoney = Number(this.orderInfo.payMoney) || 0;
|
|
|
- // 按比例计算: (选中商品原价 / 订单总原价) * 实付金额
|
|
|
- let refund = (selectedOriginal / totalOriginal) * payMoney;
|
|
|
return refund.toFixed(2);
|
|
|
},
|
|
|
refundMoney() {
|
|
|
@@ -321,10 +320,14 @@
|
|
|
}
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
- if (options.orderId) {
|
|
|
+ this.getRefundReasons();
|
|
|
+ if (options.isModify == '1' && options.refundOrderId) {
|
|
|
+ this.isModify = true;
|
|
|
+ this.refundOrderId = options.refundOrderId;
|
|
|
+ this.loadRefundDetail();
|
|
|
+ } else if (options.orderId) {
|
|
|
this.orderId = options.orderId;
|
|
|
this.loadOrderDetail();
|
|
|
- this.getRefundReasons();
|
|
|
}
|
|
|
},
|
|
|
onShow() {
|
|
|
@@ -338,6 +341,66 @@
|
|
|
|
|
|
},
|
|
|
methods: {
|
|
|
+ loadRefundDetail() {
|
|
|
+ // 使用退款详情接口回填数据
|
|
|
+ this.$u.api.getNewRefundOrderDetailAjax({
|
|
|
+ refundOrderId: this.refundOrderId
|
|
|
+ }).then(res => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ const data = res.data;
|
|
|
+ this.orderId = data.originOrderId; // 确保orderId存在
|
|
|
+
|
|
|
+ // 构造页面需要的 orderInfo 结构
|
|
|
+ // 注意:退款详情接口返回的 detailList 结构可能与订单详情的 detailVoList 略有不同,需要映射
|
|
|
+ this.orderInfo = {
|
|
|
+ ...data,
|
|
|
+ detailVoList: data.detailList.map(item => ({
|
|
|
+ ...item,
|
|
|
+ num: item.num, // 原购买数量
|
|
|
+ refundNum: item.refundNum // 之前申请的退款数量
|
|
|
+ }))
|
|
|
+ };
|
|
|
+ console.log(this.orderInfo, 'orderInfo');
|
|
|
+
|
|
|
+ // 回填表单数据
|
|
|
+ this.refundType = String(data.refundType);
|
|
|
+ // this.refundTypeText 需要根据 options 查找或直接设置,这里简单根据值设置
|
|
|
+ this.refundTypeText = this.refundType === '1' ? '退货退款' : '仅退款';
|
|
|
+
|
|
|
+ this.shopStatus = String(data.shopStatus);
|
|
|
+ this.shopStatusText = this.shopStatus === '1' ? '未收到货' : '已收到货';
|
|
|
+
|
|
|
+ this.refundReason = data.refundReason;
|
|
|
+ this.refundReasonText = data.refundReason; // 假设后端直接返回文本,或者需要遍历 reasonList 匹配
|
|
|
+
|
|
|
+ this.returnMethod = String(data.sendType);
|
|
|
+ // 查找 returnMethodText
|
|
|
+ const methodObj = this.returnMethodList.find(m => m.value === this.returnMethod);
|
|
|
+ this.returnMethodText = methodObj ? methodObj.label : '';
|
|
|
+
|
|
|
+ this.description = data.description || '';
|
|
|
+
|
|
|
+ // 回填图片
|
|
|
+ if (data.fileUrlList) {
|
|
|
+ this.fileList = data.fileUrlList;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 初始化选中状态
|
|
|
+ this.orderInfo.detailVoList.forEach(item => {
|
|
|
+ this.$set(item, 'checked', true);
|
|
|
+ // 修改模式下,默认显示上次申请的数量
|
|
|
+ this.$set(item, 'refundNum', item.refundNum || 1);
|
|
|
+ });
|
|
|
+
|
|
|
+ this.address = {
|
|
|
+ id: data.sendAddressId,
|
|
|
+ name: data.sendName,
|
|
|
+ mobile: data.sendMobile,
|
|
|
+ fullAddress: data.sendAddress,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
loadOrderDetail() {
|
|
|
this.$u.api.getShopOrderDetailAjax({ orderId: this.orderId }).then(res => {
|
|
|
if (res.code === 200) {
|
|
|
@@ -463,14 +526,22 @@
|
|
|
params.address = this.address;
|
|
|
}
|
|
|
|
|
|
- this.$u.api.applyRefundAjax(params).then(res => {
|
|
|
+ const api = this.isModify ? this.$u.api.refundApplyModifyAjax : this.$u.api.applyRefundAjax;
|
|
|
+ // 修改模式下可能需要传入 refundOrderId (虽然截图只有 orderId, 但为了保险起见或者后端根据 orderId 找)
|
|
|
+ // 截图显示 Request body 包含 orderId 和 refundDetailList 等。
|
|
|
+ // 如果是修改,通常 orderId 指的是原订单ID。后端可能通过 orderId 找到对应的 active refund application 或者需要 refundOrderId。
|
|
|
+ // 根据截图,只有 body,没有 path param。body 里有 orderId。
|
|
|
+ // 如果是修改,我们可能需要额外传 refundOrderId 吗? 截图里没有显示 refundOrderId 字段。
|
|
|
+ // 假设后端通过 orderId 识别当前正在进行的退款申请进行修改,或者复用 applyRefund 的逻辑只是接口不同。
|
|
|
+
|
|
|
+ api(params).then(res => {
|
|
|
if (res.code === 200) {
|
|
|
- this.$u.toast('提交成功');
|
|
|
+ this.$u.toast(this.isModify ? '修改成功' : '提交成功');
|
|
|
setTimeout(() => {
|
|
|
uni.navigateBack();
|
|
|
}, 1500);
|
|
|
} else {
|
|
|
- this.$u.toast(res.msg || '提交失败');
|
|
|
+ this.$u.toast(res.msg || (this.isModify ? '修改失败' : '提交失败'));
|
|
|
}
|
|
|
});
|
|
|
}
|