feat:修改售后参数
This commit is contained in:
@@ -175,25 +175,73 @@
|
|||||||
});
|
});
|
||||||
const rules = reactive({});
|
const rules = reactive({});
|
||||||
|
|
||||||
// 提交表单
|
// 提交表单:接口 POST /trade/after-sale/create
|
||||||
|
// Body: appAfterSaleCreateReqVOs: AppAfterSaleCreateReqVO[] (数组!)
|
||||||
|
// - 单品售后(state.itemId > 0):数组只含 1 项,orderItemId = 当前商品项 id
|
||||||
|
// - 整单售后(state.itemId = 0):数组包含订单全部商品,每一项 orderItemId = 对应商品项 id,refundPrice = 该商品项自己的 payPrice
|
||||||
|
// 每个 VO 字段:orderItemId(必填)、way(1仅退款/2退货退款 必填)、refundPrice(单位分 必填)
|
||||||
|
// applyReason(必填 string)、applyDescription(选填)、applyPicUrls(选填 数组)
|
||||||
async function submit() {
|
async function submit() {
|
||||||
let data = {
|
if (!formData.way) {
|
||||||
orderItemId: state.item?.id,
|
uni.showToast({ title: '请选择售后类型', icon: 'none' });
|
||||||
refundPrice: state.payPrice,
|
return;
|
||||||
...formData,
|
}
|
||||||
|
if (!formData.applyReason) {
|
||||||
|
uni.showToast({ title: '请选择申请原因', icon: 'none' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 通用字段(整单/单品都一样)
|
||||||
|
const way = formData.way === '20' ? 2 : 1;
|
||||||
|
const applyReason = String(formData.applyReason);
|
||||||
|
const applyDescription = String(formData.applyDescription || '');
|
||||||
|
// applyPicUrls:保持数组(用户示例说"传递的是数组才对"),过滤空值
|
||||||
|
const applyPicUrls = Array.isArray(formData.applyPicUrls)
|
||||||
|
? formData.applyPicUrls.filter(Boolean)
|
||||||
|
: formData.applyPicUrls
|
||||||
|
? [String(formData.applyPicUrls)]
|
||||||
|
: [];
|
||||||
|
|
||||||
|
// 选择要提交的订单项列表
|
||||||
|
let targetItems = [];
|
||||||
|
if (state.itemId > 0 && state.item?.id) {
|
||||||
|
// 单品售后:只传当前选择的这一个订单项
|
||||||
|
targetItems = [state.item];
|
||||||
|
} else {
|
||||||
|
// 整单售后:传所有商品项(orderItems 就是整个订单的 items 列表)
|
||||||
|
targetItems = Array.isArray(state.orderItems) ? state.orderItems.slice() : [];
|
||||||
|
}
|
||||||
|
if (!targetItems.length) {
|
||||||
|
uni.showToast({ title: '缺少可申请售后的商品', icon: 'none' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 组装数组 AppAfterSaleCreateReqVO[]
|
||||||
|
const appAfterSaleCreateReqVOs = targetItems
|
||||||
|
.filter((it) => it && it.id)
|
||||||
|
.map((it) => ({
|
||||||
|
orderItemId: it.id,
|
||||||
|
way,
|
||||||
|
// 退款金额:按订单项自己的 payPrice(单品=选中项payPrice,整单每项=对应项payPrice),安全兜底转 Number
|
||||||
|
refundPrice: Number(it.payPrice ?? 0) || 0,
|
||||||
|
applyReason,
|
||||||
|
applyDescription,
|
||||||
|
applyPicUrls,
|
||||||
|
}));
|
||||||
|
|
||||||
|
if (!appAfterSaleCreateReqVOs.length) {
|
||||||
|
uni.showToast({ title: '缺少订单项信息', icon: 'none' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
appAfterSaleCreateReqVOs,
|
||||||
};
|
};
|
||||||
const { code } = await AfterSaleApi.createAfterSale(data);
|
const { code } = await AfterSaleApi.createAfterSale(data);
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
uni.showToast({
|
uni.showToast({ title: '申请成功' });
|
||||||
title: '申请成功',
|
uni.navigateBack({ delta: 1 });
|
||||||
});
|
|
||||||
uni.navigateBack({
|
|
||||||
delta: 1,
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
uni.navigateBack({
|
uni.navigateBack({ delta: 1 });
|
||||||
delta: 1,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//申请原因
|
//申请原因
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
:data="state.orderInfo"
|
:data="state.orderInfo"
|
||||||
:source="state.source"
|
:source="state.source"
|
||||||
:delay-records="state.delayRecords"
|
:delay-records="state.delayRecords"
|
||||||
:hide-item-after-sale="true"
|
:hide-item-after-sale="isAiActionOrder"
|
||||||
type="2"
|
type="2"
|
||||||
theme="2"
|
theme="2"
|
||||||
@getOrderDetail="getOrderDetail"
|
@getOrderDetail="getOrderDetail"
|
||||||
|
|||||||
Reference in New Issue
Block a user