refundOrder.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. "use strict";
  2. const common_vendor = require("../common/vendor.js");
  3. const common_assets = require("../common/assets.js");
  4. const _sfc_main = {
  5. data() {
  6. return {
  7. orderId: null,
  8. order: null,
  9. orderCode: null,
  10. items: [],
  11. type: null,
  12. reasonsList: [],
  13. reasons: "请选择",
  14. explains: "",
  15. refundAmount: 0
  16. };
  17. },
  18. onLoad(option) {
  19. this.type = option.type;
  20. this.orderCode = option.orderCode;
  21. this.reasonsList = this.utils.getDict("storeAfterSalesReasons");
  22. this.orderId = option.orderId;
  23. console.log(this.orderId);
  24. this.getMyStoreOrderItemByOrderId();
  25. },
  26. methods: {
  27. getMyStoreOrderItemByOrderId() {
  28. var data = { orderId: this.orderId };
  29. getMyStoreOrderItemByOrderId(data).then((res) => {
  30. if (res.code == 200) {
  31. this.order = res.order;
  32. this.items = res.items;
  33. if (this.order.isPayRemain == 0) {
  34. this.refundAmount = this.order.payMoney.toFixed(2);
  35. } else {
  36. this.refundAmount = this.order.payPrice.toFixed(2);
  37. }
  38. } else {
  39. common_vendor.index.showToast({
  40. icon: "none",
  41. title: "请求失败"
  42. });
  43. }
  44. });
  45. },
  46. reasonsChange(e) {
  47. console.log(e.detail.value);
  48. this.reasons = this.reasonsList[e.detail.value].dictLabel;
  49. },
  50. submit() {
  51. if (this.reasons == "请选择") {
  52. common_vendor.index.showToast({
  53. icon: "none",
  54. title: "请选择原因"
  55. });
  56. return;
  57. }
  58. if (this.refundAmount < 0) {
  59. common_vendor.index.showToast({
  60. icon: "none",
  61. title: "请输入退款金额"
  62. });
  63. return;
  64. }
  65. var productIds = this.items.map((item2) => item2.productId);
  66. var products = [];
  67. for (var i = 0; i < productIds.length; i++) {
  68. var item = { productId: productIds[i] };
  69. products.push(item);
  70. }
  71. var data = { refundAmount: this.refundAmount, orderCode: this.orderCode, serviceType: this.type, reasons: this.reasons, explains: this.explains, productList: products };
  72. applyAfterSales(data).then((res) => {
  73. if (res.code == 200) {
  74. common_vendor.index.showToast({
  75. icon: "success",
  76. title: "提交成功"
  77. });
  78. setTimeout(function() {
  79. common_vendor.index.$emit("refreshOrder");
  80. common_vendor.index.navigateBack({
  81. delta: 1
  82. });
  83. }, 500);
  84. } else {
  85. common_vendor.index.showToast({
  86. icon: "none",
  87. title: res.msg
  88. });
  89. }
  90. });
  91. }
  92. }
  93. };
  94. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  95. return common_vendor.e({
  96. a: $data.order != null && $data.order.isPackage != 1
  97. }, $data.order != null && $data.order.isPackage != 1 ? {
  98. b: common_vendor.f($data.items, (item, index, i0) => {
  99. return {
  100. a: JSON.parse(item.jsonInfo).image,
  101. b: common_vendor.t(JSON.parse(item.jsonInfo).productName),
  102. c: common_vendor.t(JSON.parse(item.jsonInfo).sku),
  103. d: common_vendor.t(JSON.parse(item.jsonInfo).price.toFixed(2)),
  104. e: common_vendor.t(JSON.parse(item.jsonInfo).num),
  105. f: index
  106. };
  107. })
  108. } : {}, {
  109. c: $data.order != null && $data.order.isPackage == 1 && $data.order.packageJson != null
  110. }, $data.order != null && $data.order.isPackage == 1 && $data.order.packageJson != null ? {
  111. d: JSON.parse($data.order.packageJson).imgUrl,
  112. e: common_vendor.t(JSON.parse($data.order.packageJson).title),
  113. f: common_vendor.t(JSON.parse($data.order.packageJson).descs)
  114. } : {}, {
  115. g: $data.refundAmount,
  116. h: common_vendor.o(($event) => $data.refundAmount = $event.detail.value),
  117. i: common_vendor.t($data.reasons),
  118. j: common_assets._imports_0$10,
  119. k: common_vendor.o((...args) => $options.reasonsChange && $options.reasonsChange(...args)),
  120. l: $data.reasons,
  121. m: $data.reasonsList,
  122. n: $data.explains,
  123. o: common_vendor.o(($event) => $data.explains = $event.detail.value),
  124. p: common_vendor.o(($event) => $options.submit())
  125. });
  126. }
  127. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
  128. wx.createPage(MiniProgramPage);