refund-processing.ts 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. Page({
  2. data: {
  3. pageTitle: '商家处理',
  4. refundState: 'processing', // 测试数据:processing, approved, revoked, rejected, 或 completed
  5. days: '06',
  6. hours: '23',
  7. minutes: '43',
  8. seconds: '59',
  9. goods: {
  10. name: "肝血贴穴位贴",
  11. meta1: "10贴",
  12. price: "240",
  13. image: ""
  14. },
  15. refundDetail: {
  16. reason: "少件(含缺少配件)",
  17. amount: "240.00",
  18. finishTime: "2025-02-19 20:30:27",
  19. applyTime: "2025-02-19 14:30:27",
  20. refundNo: "7364647828273462271"
  21. },
  22. refundDestination: {
  23. type: '退回微信',
  24. account: '梅*** 158******26'
  25. },
  26. // 弹窗状态
  27. refundReasonPopupVisible: false,
  28. refundConfirmPopupVisible: false,
  29. refundProofPopupVisible: false,
  30. refundStatus: 'received',
  31. refundMaxAmount: '240',
  32. refundProofImages: [],
  33. },
  34. timer: null as any,
  35. onLoad() {
  36. this.updatePageTitle();
  37. if (this.data.refundState === 'processing' || this.data.refundState === 'rejected') {
  38. this.startCountdown();
  39. }
  40. },
  41. updatePageTitle() {
  42. let title = '商家处理';
  43. if (this.data.refundState === 'revoked') {
  44. title = '撤销申请';
  45. } else if (this.data.refundState === 'completed') {
  46. title = '退款完成';
  47. }
  48. this.setData({ pageTitle: title });
  49. },
  50. onUnload() {
  51. if (this.timer) {
  52. clearInterval(this.timer);
  53. }
  54. },
  55. startCountdown() {
  56. // 模拟真实的倒计时,预设当前剩余时间(处理中通常为48小时,拒绝重填通常为7天)
  57. const targetHours = this.data.refundState === 'rejected' ? 7 * 24 : 48;
  58. const targetTime = new Date().getTime() + targetHours * 60 * 60 * 1000 - 1000;
  59. this.timer = setInterval(() => {
  60. const now = new Date().getTime();
  61. const diff = targetTime - now;
  62. if (diff <= 0) {
  63. clearInterval(this.timer);
  64. this.setData({ days: '00', hours: '00', minutes: '00', seconds: '00' });
  65. return;
  66. }
  67. const d = Math.floor(diff / (1000 * 60 * 60 * 24));
  68. const h = Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  69. const m = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60));
  70. const s = Math.floor((diff % (1000 * 60)) / 1000);
  71. this.setData({
  72. days: d < 10 ? '0' + d : String(d),
  73. hours: h < 10 ? '0' + h : String(h),
  74. minutes: m < 10 ? '0' + m : String(m),
  75. seconds: s < 10 ? '0' + s : String(s),
  76. });
  77. }, 1000);
  78. },
  79. // 修改申请:打开确认弹窗
  80. onModify() {
  81. this.setData({ refundConfirmPopupVisible: true });
  82. },
  83. // 确认弹窗处理
  84. onRefundConfirmClose() {
  85. this.setData({ refundConfirmPopupVisible: false });
  86. },
  87. onChangeRefundStatus(e: any) {
  88. this.setData({ refundStatus: e.detail.status });
  89. },
  90. onOpenRefundReasonAgain() {
  91. this.setData({
  92. refundConfirmPopupVisible: false,
  93. refundReasonPopupVisible: true
  94. });
  95. },
  96. onOpenRefundProofEditor() {
  97. this.setData({
  98. refundConfirmPopupVisible: false,
  99. refundProofPopupVisible: true
  100. });
  101. },
  102. onRefundAmountConfirm(e: any) {
  103. this.setData({
  104. ['refundDetail.amount']: e.detail.amount
  105. });
  106. },
  107. onSubmitRefundApply() {
  108. this.setData({ refundConfirmPopupVisible: false });
  109. wx.showLoading({ title: '正在提交' });
  110. setTimeout(() => {
  111. wx.hideLoading();
  112. wx.navigateTo({
  113. url: '/module/order/pages/refund-success/refund-success'
  114. });
  115. }, 1000);
  116. },
  117. // 原因弹窗处理
  118. onRefundReasonPopupClose() {
  119. this.setData({ refundReasonPopupVisible: false });
  120. },
  121. onRefundReasonNext(e: any) {
  122. this.setData({
  123. ['refundDetail.reason']: e.detail.reason,
  124. refundReasonPopupVisible: false,
  125. refundConfirmPopupVisible: true
  126. });
  127. },
  128. // 凭证弹窗处理
  129. onRefundProofPopupClose() {
  130. this.setData({ refundProofPopupVisible: false });
  131. },
  132. onRefundProofSubmit(e: any) {
  133. this.setData({
  134. refundProofImages: e.detail.images,
  135. refundProofPopupVisible: false,
  136. refundConfirmPopupVisible: true
  137. });
  138. },
  139. onViewHistory() {
  140. wx.navigateTo({
  141. url: '/module/order/pages/negotiation-history/negotiation-history'
  142. });
  143. },
  144. onCopyRefundNo() {
  145. wx.setClipboardData({
  146. data: this.data.refundDetail.refundNo,
  147. success: () => {
  148. wx.showToast({ title: '已复制', icon: 'none' });
  149. }
  150. });
  151. },
  152. onCallService() {
  153. wx.makePhoneCall({
  154. phoneNumber: '400-123-4567', // 替换为真实的客服电话
  155. fail: () => {
  156. // 用户取消拨打
  157. }
  158. });
  159. },
  160. onRevoke() {
  161. wx.showModal({
  162. title: '撤销退款申请',
  163. content: '撤销退款申请后,可以再次发起退款申请(总共可发起2次)',
  164. confirmText: '确定撤销',
  165. cancelText: '暂不撤销',
  166. success: (res) => {
  167. if (res.confirm) {
  168. wx.showToast({ title: '已撤销', icon: 'success' });
  169. setTimeout(() => {
  170. wx.redirectTo({
  171. url: '/module/article/pages/success-page/success-page?title=撤销退款申请成功'
  172. });
  173. }, 1500);
  174. }
  175. }
  176. });
  177. }
  178. });