import { getAfterSaleNegotiationHistoryMethod } from "../../request"; Page({ data: { historyList: [] as Array, }, onLoad(options: any) { if (options.id) { this.loadHistory(options.id); } }, async loadHistory(id: string) { wx.showLoading({ title: '加载中' }); try { const res = await getAfterSaleNegotiationHistoryMethod(Number(id)); const list = (res as any)?.data || []; const historyList = list.map((item: any) => { if (item.progress === '0') { // 发起售后 - 用户操作 const content = item.aftersaleContent || {}; const details: Array<{ label: string; value: string }> = []; if (content.receiptStatusStr) details.push({ label: '商品状态', value: content.receiptStatusStr }); const receiptMap: Record = { '0': '待发货', '1': '已发货', '2': '已收货' }; if (content.receiptStatus !== undefined && content.receiptStatus !== null) { details.push({ label: '收货状态', value: receiptMap[String(content.receiptStatus)] || '未知' }); } if (content.applyAmount) details.push({ label: '退款金额', value: `¥${content.applyAmount}` }); if (content.reason) details.push({ label: '退款原因', value: content.reason }); if (content.remark) details.push({ label: '退款说明', value: content.remark }); return { type: 'user', avatar: '', name: item.createBy || '用户', time: item.createTime || '', actionTitle: '发起了退款申请', details, images: content.voucherImgs || [], }; } else { // 平台操作 const lines: string[] = []; if (item.title) lines.push(`${item.title}`); if (item.content) lines.push(`${item.content}`); return { type: 'platform', avatar: '', name: '平台', time: item.createTime || '', lines, }; } }); this.setData({ historyList }); } catch (error: any) { wx.showToast({ title: error.errMsg || '获取协商历史失败', icon: 'none' }); } wx.hideLoading(); }, previewImage(e: any) { const currentUrl = e.currentTarget.dataset.url; const images = e.currentTarget.dataset.images; wx.previewImage({ current: currentUrl, urls: images, fail: (err) => { console.error('预览图片失败', err); }, }); } });