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