';
- afterSales.forEach(function (item) {
+ afterSales.forEach(function (item, index) {
var labels = { pending: "待审核", processing: "处理中", approved: "已通过", rejected: "已拒绝", cancelled: "已取消", completed: "已完成" };
var asStatus = String(item.status || "");
var asLabel = labels[asStatus] || asStatus;
@@ -195,13 +195,50 @@
html += '' + escapeHtml(asLabel) + "";
if (item.created_at) html += "";
html += "
";
- if (item.reason) html += '' + escapeHtml(item.reason).replace(/\r\n|\r|\n/g, "
") + "
";
+ // 原因 / 申请理由:新数据走 apply_form 结构化字段;老数据无 apply_form 时兜底展示融合串。
+ var applyForm = item.apply_form && typeof item.apply_form === "object" ? item.apply_form : null;
+ if (applyForm) {
+ var reasonLabel = String(applyForm.reason_label || "");
+ var applyDesc = String(applyForm.description || "");
+ if (reasonLabel !== "") html += '原因:' + escapeHtml(reasonLabel) + "
";
+ if (applyDesc !== "") html += '申请理由:' + escapeHtml(applyDesc).replace(/\r\n|\r|\n/g, "
") + "
";
+ } else if (item.reason) {
+ html += '' + escapeHtml(item.reason).replace(/\r\n|\r|\n/g, "
") + "
";
+ }
html += '';
html += "- 退款金额
- " + escapeHtml(afterSaleAmount(item.refund_amount, order)) + "
";
if (item.admin_note) html += "- 处理备注
- " + escapeHtml(item.admin_note) + "
";
if (item.gateway_result) html += "- 渠道结果
- " + escapeHtml(gatewayResultText(item.gateway_result)) + "
";
html += "
";
- if (asStatus === "pending") html += '';
+ // 查看详细:逐记录构造售后详细弹窗载荷(after_sale.latest 指向本条记录);
+ // 再次申请仅对最新一条且订单级可再申请时开放(after_sales 按 id 倒序,首条即最新)。
+ var recordPayload = escapeHtml(JSON.stringify({
+ order_number: order.order_number || "",
+ product_name: order.product_name || "",
+ amount: order.amount || "0",
+ is_points: !!order.is_points,
+ currency_symbol: order.currency_symbol || "",
+ status_label: order.status_label || "",
+ after_sale: {
+ enabled: true,
+ has_application: true,
+ can_reapply: index === 0 && !!((order.after_sale || {}).can_reapply),
+ latest: {
+ status: asStatus,
+ reason: String(item.reason || ""),
+ apply_form: applyForm,
+ images: Array.isArray(item.images) ? item.images : [],
+ refund_amount: String(item.refund_amount || "0"),
+ created_at: String(item.created_at || ""),
+ completed_at: String(item.completed_at || ""),
+ admin_note: String(item.admin_note || ""),
+ },
+ },
+ }));
+ html += '";
html += "";
});
html += "