feat: 调整参数结构
This commit is contained in:
@@ -176,11 +176,11 @@
|
||||
const rules = reactive({});
|
||||
|
||||
// 提交表单:接口 POST /trade/after-sale/create
|
||||
// Body: appAfterSaleCreateReqVOs: AppAfterSaleCreateReqVO[] (数组!)
|
||||
// Body 直接就是数组:AppAfterSaleCreateReqVO[]
|
||||
// - 单品售后(state.itemId > 0):数组只含 1 项,orderItemId = 当前商品项 id
|
||||
// - 整单售后(state.itemId = 0):数组包含订单全部商品,每一项 orderItemId = 对应商品项 id,refundPrice = 该商品项自己的 payPrice
|
||||
// 每个 VO 字段:orderItemId(必填)、way(1仅退款/2退货退款 必填)、refundPrice(单位分 必填)
|
||||
// applyReason(必填 string)、applyDescription(选填)、applyPicUrls(选填 数组)
|
||||
// applyReason(必填 string)、applyDescription(选填)、applyPicUrls(选填 逗号拼接字符串)
|
||||
async function submit() {
|
||||
if (!formData.way) {
|
||||
uni.showToast({ title: '请选择售后类型', icon: 'none' });
|
||||
@@ -194,12 +194,13 @@
|
||||
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)]
|
||||
: [];
|
||||
// applyPicUrls:数组 → 逗号拼接字符串(按用户最新给的示例)
|
||||
let applyPicUrls = '';
|
||||
if (Array.isArray(formData.applyPicUrls)) {
|
||||
applyPicUrls = formData.applyPicUrls.filter(Boolean).join(',');
|
||||
} else if (formData.applyPicUrls) {
|
||||
applyPicUrls = String(formData.applyPicUrls);
|
||||
}
|
||||
|
||||
// 选择要提交的订单项列表
|
||||
let targetItems = [];
|
||||
@@ -215,8 +216,8 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// 组装数组 AppAfterSaleCreateReqVO[]
|
||||
const appAfterSaleCreateReqVOs = targetItems
|
||||
// 组装数组 AppAfterSaleCreateReqVO[](直接就是数组,不要外层对象包裹)
|
||||
const body = targetItems
|
||||
.filter((it) => it && it.id)
|
||||
.map((it) => ({
|
||||
orderItemId: it.id,
|
||||
@@ -228,15 +229,12 @@
|
||||
applyPicUrls,
|
||||
}));
|
||||
|
||||
if (!appAfterSaleCreateReqVOs.length) {
|
||||
if (!body.length) {
|
||||
uni.showToast({ title: '缺少订单项信息', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
const data = {
|
||||
appAfterSaleCreateReqVOs,
|
||||
};
|
||||
const { code } = await AfterSaleApi.createAfterSale(data);
|
||||
const { code } = await AfterSaleApi.createAfterSale(body);
|
||||
if (code === 0) {
|
||||
uni.showToast({ title: '申请成功' });
|
||||
uni.navigateBack({ delta: 1 });
|
||||
|
||||
Reference in New Issue
Block a user