storeOrderRefundSubmit.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. reasonsOptions: [],
  13. reasons: "请选择",
  14. explains: "",
  15. refundAmount: 0
  16. };
  17. },
  18. onLoad(option) {
  19. this.type = option.type;
  20. this.orderId = option.orderId;
  21. this.getStoreOrderItems();
  22. this.getDictByKey("sys_sales_reasons");
  23. },
  24. methods: {
  25. getDictByKey(key) {
  26. var data = { key };
  27. getDictByKey(data).then(
  28. (res) => {
  29. if (res.code == 200) {
  30. if (key == "sys_sales_reasons") {
  31. this.reasonsOptions = res.data;
  32. }
  33. }
  34. },
  35. (err) => {
  36. }
  37. );
  38. },
  39. getStoreOrderItems() {
  40. var data = { orderId: this.orderId };
  41. getStoreOrderItems(data).then((res) => {
  42. if (res.code == 200) {
  43. this.order = res.order;
  44. this.items = res.items;
  45. this.refundAmount = this.order.payMoney.toFixed(2);
  46. } else {
  47. common_vendor.index.showToast({
  48. icon: "none",
  49. title: "请求失败"
  50. });
  51. }
  52. });
  53. },
  54. handleReasons(e) {
  55. console.log(e.detail.value);
  56. this.reasons = this.reasonsOptions[e.detail.value].dictLabel;
  57. },
  58. submit() {
  59. if (this.reasons == "请选择") {
  60. common_vendor.index.showToast({
  61. icon: "none",
  62. title: "请选择原因"
  63. });
  64. return;
  65. }
  66. if (this.refundAmount < 0) {
  67. common_vendor.index.showToast({
  68. icon: "none",
  69. title: "请输入退款金额"
  70. });
  71. return;
  72. }
  73. var productIds = this.items.map((item2) => item2.productId);
  74. var products = [];
  75. for (var i = 0; i < productIds.length; i++) {
  76. var item = { productId: productIds[i] };
  77. products.push(item);
  78. }
  79. var data = {
  80. refundAmount: this.refundAmount,
  81. orderId: this.orderId,
  82. refundType: this.type,
  83. reasons: this.reasons,
  84. explains: this.explains,
  85. productList: products
  86. };
  87. applyAfterSales(data).then((res) => {
  88. if (res.code == 200) {
  89. common_vendor.index.showToast({
  90. icon: "success",
  91. title: "提交成功"
  92. });
  93. setTimeout(function() {
  94. common_vendor.index.$emit("refreshOrder");
  95. common_vendor.index.navigateBack({
  96. delta: 1
  97. });
  98. }, 500);
  99. } else {
  100. common_vendor.index.showToast({
  101. icon: "none",
  102. title: res.msg
  103. });
  104. }
  105. });
  106. }
  107. }
  108. };
  109. if (!Array) {
  110. const _easycom_u__textarea2 = common_vendor.resolveComponent("u--textarea");
  111. _easycom_u__textarea2();
  112. }
  113. const _easycom_u__textarea = () => "../uni_modules/uview-plus/components/u--textarea/u--textarea.js";
  114. if (!Math) {
  115. _easycom_u__textarea();
  116. }
  117. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  118. return common_vendor.e({
  119. a: $data.order != null
  120. }, $data.order != null ? {
  121. b: common_vendor.f($data.items, (item, index, i0) => {
  122. return {
  123. a: JSON.parse(item.jsonInfo).image == "" ? "/static/images/drug.svg" : JSON.parse(item.jsonInfo).image,
  124. b: common_vendor.t(JSON.parse(item.jsonInfo).productName),
  125. c: common_vendor.t(JSON.parse(item.jsonInfo).sku),
  126. d: common_vendor.t(JSON.parse(item.jsonInfo).price.toFixed(2)),
  127. e: common_vendor.t(JSON.parse(item.jsonInfo).num),
  128. f: index
  129. };
  130. })
  131. } : {}, {
  132. c: $data.refundAmount,
  133. d: common_vendor.o(($event) => $data.refundAmount = $event.detail.value),
  134. e: common_vendor.t($data.reasons),
  135. f: common_assets._imports_0$10,
  136. g: common_vendor.o((...args) => $options.handleReasons && $options.handleReasons(...args)),
  137. h: $data.reasons,
  138. i: $data.reasonsOptions,
  139. j: common_vendor.o(($event) => $data.explains = $event),
  140. k: common_vendor.p({
  141. height: 100,
  142. placeholder: "请描述申请售后服务的具体原因",
  143. count: 100,
  144. modelValue: $data.explains
  145. }),
  146. l: common_vendor.o(($event) => $options.submit())
  147. });
  148. }
  149. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
  150. wx.createPage(MiniProgramPage);