negotiation-history.ts 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import { getAfterSaleNegotiationHistoryMethod } from "../../request";
  2. Page({
  3. data: {
  4. historyList: [] as Array<any>,
  5. },
  6. onLoad(options: any) {
  7. if (options.id) {
  8. this.loadHistory(options.id);
  9. }
  10. },
  11. async loadHistory(id: string) {
  12. wx.showLoading({ title: '加载中' });
  13. try {
  14. const res = await getAfterSaleNegotiationHistoryMethod(Number(id));
  15. const list = (res as any)?.data || [];
  16. const historyList = list.map((item: any) => {
  17. if (item.progress === '0') {
  18. // 发起售后 - 用户操作
  19. const content = item.aftersaleContent || {};
  20. const details: Array<{ label: string; value: string }> = [];
  21. if (content.receiptStatusStr) details.push({ label: '商品状态', value: content.receiptStatusStr });
  22. const receiptMap: Record<string, string> = { '0': '待发货', '1': '已发货', '2': '已收货' };
  23. if (content.receiptStatus !== undefined && content.receiptStatus !== null) {
  24. details.push({ label: '收货状态', value: receiptMap[String(content.receiptStatus)] || '未知' });
  25. }
  26. if (content.applyAmount) details.push({ label: '退款金额', value: `¥${content.applyAmount}` });
  27. if (content.reason) details.push({ label: '退款原因', value: content.reason });
  28. if (content.remark) details.push({ label: '退款说明', value: content.remark });
  29. return {
  30. type: 'user',
  31. avatar: '',
  32. name: item.createBy || '用户',
  33. time: item.createTime || '',
  34. actionTitle: '发起了退款申请',
  35. details,
  36. images: content.voucherImgs || [],
  37. };
  38. } else {
  39. // 平台操作
  40. const lines: string[] = [];
  41. if (item.title) lines.push(`${item.title}`);
  42. if (item.content) lines.push(`${item.content}`);
  43. return {
  44. type: 'platform',
  45. avatar: '',
  46. name: '平台',
  47. time: item.createTime || '',
  48. lines,
  49. };
  50. }
  51. });
  52. this.setData({ historyList });
  53. } catch (error: any) {
  54. wx.showToast({ title: error.errMsg || '获取协商历史失败', icon: 'none' });
  55. }
  56. wx.hideLoading();
  57. },
  58. previewImage(e: any) {
  59. const currentUrl = e.currentTarget.dataset.url;
  60. const images = e.currentTarget.dataset.images;
  61. wx.previewImage({
  62. current: currentUrl,
  63. urls: images,
  64. fail: (err) => {
  65. console.error('预览图片失败', err);
  66. },
  67. });
  68. }
  69. });