refund-reason-popup.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. Component({
  2. properties: {
  3. visible: { type: Boolean, value: false },
  4. initialReason: { type: String, value: "" },
  5. },
  6. data: {
  7. selectedReason: "",
  8. reasons: [
  9. "商品信息描述不符",
  10. "与商家协商一致退款",
  11. "质量问题",
  12. "少件(含缺少配件)",
  13. "包装/商品破损/污渍",
  14. "未按约定时间发货",
  15. "发票问题",
  16. "卖家发错货",
  17. ],
  18. },
  19. observers: {
  20. visible(v: boolean) {
  21. if (v) {
  22. this.setData({ selectedReason: this.data.initialReason || "" });
  23. }
  24. },
  25. },
  26. methods: {
  27. onPopupVisibleChange(e: WechatMiniprogram.CustomEvent<{ visible: boolean }>) {
  28. if (!e?.detail?.visible) {
  29. this.triggerEvent("close");
  30. }
  31. },
  32. onClose() {
  33. this.triggerEvent("close");
  34. },
  35. onSelectReason(e: any) {
  36. const reason = e.detail?.value;
  37. if (reason) {
  38. this.setData({ selectedReason: reason });
  39. }
  40. },
  41. onNext() {
  42. const reason = this.data.selectedReason;
  43. if (!reason) {
  44. wx.showToast({ title: "请选择退款原因", icon: "none" });
  45. return;
  46. }
  47. this.triggerEvent("next", { reason });
  48. },
  49. },
  50. });