apply.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. "use strict";
  2. const common_vendor = require("../../../common/vendor.js");
  3. const sheep_index = require("../../../sheep/index.js");
  4. const sheep_api_trade_order = require("../../../sheep/api/trade/order.js");
  5. const sheep_api_trade_config = require("../../../sheep/api/trade/config.js");
  6. const sheep_hooks_useGoods = require("../../../sheep/hooks/useGoods.js");
  7. const sheep_api_trade_afterSale = require("../../../sheep/api/trade/afterSale.js");
  8. require("../../../sheep/url/index.js");
  9. require("../../../sheep/store/index.js");
  10. require("../../../sheep/store/app.js");
  11. require("../../../sheep/api/promotion/diy.js");
  12. require("../../../sheep/request/index.js");
  13. require("../../../sheep/config/index.js");
  14. require("../../../sheep/platform/index.js");
  15. require("../../../sheep/platform/provider/wechat/index.js");
  16. require("../../../sheep/platform/provider/wechat/miniProgram.js");
  17. require("../../../sheep/api/member/auth.js");
  18. require("../../../sheep/api/member/social.js");
  19. require("../../../sheep/api/member/user.js");
  20. require("../../../sheep/platform/provider/apple/index.js");
  21. require("../../../sheep/platform/share.js");
  22. require("../../../sheep/router/index.js");
  23. require("../../../sheep/hooks/useModal.js");
  24. require("../../../sheep/helper/index.js");
  25. require("../../../sheep/helper/test.js");
  26. require("../../../sheep/helper/digit.js");
  27. require("../../../sheep/api/member/signin.js");
  28. require("../../../sheep/helper/throttle.js");
  29. require("../../../sheep/platform/pay.js");
  30. require("../../../sheep/api/pay/order.js");
  31. require("../../../sheep/store/user.js");
  32. require("../../../sheep/store/cart.js");
  33. require("../../../sheep/api/trade/cart.js");
  34. require("../../../sheep/api/pay/wallet.js");
  35. require("../../../sheep/api/promotion/coupon.js");
  36. require("../../../sheep/store/sys.js");
  37. require("../../../sheep/store/modal.js");
  38. require("../../../sheep/config/zIndex.js");
  39. require("../../../sheep/util/index.js");
  40. if (!Array) {
  41. const _easycom_s_goods_item2 = common_vendor.resolveComponent("s-goods-item");
  42. const _easycom_uni_easyinput2 = common_vendor.resolveComponent("uni-easyinput");
  43. const _easycom_s_uploader2 = common_vendor.resolveComponent("s-uploader");
  44. const _easycom_uni_forms2 = common_vendor.resolveComponent("uni-forms");
  45. const _easycom_su_fixed2 = common_vendor.resolveComponent("su-fixed");
  46. const _easycom_su_popup2 = common_vendor.resolveComponent("su-popup");
  47. const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  48. (_easycom_s_goods_item2 + _easycom_uni_easyinput2 + _easycom_s_uploader2 + _easycom_uni_forms2 + _easycom_su_fixed2 + _easycom_su_popup2 + _easycom_s_layout2)();
  49. }
  50. const _easycom_s_goods_item = () => "../../../sheep/components/s-goods-item/s-goods-item.js";
  51. const _easycom_uni_easyinput = () => "../../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.js";
  52. const _easycom_s_uploader = () => "../../../sheep/components/s-uploader/s-uploader.js";
  53. const _easycom_uni_forms = () => "../../../uni_modules/uni-forms/components/uni-forms/uni-forms.js";
  54. const _easycom_su_fixed = () => "../../../sheep/ui/su-fixed/su-fixed.js";
  55. const _easycom_su_popup = () => "../../../sheep/ui/su-popup/su-popup.js";
  56. const _easycom_s_layout = () => "../../../sheep/components/s-layout/s-layout.js";
  57. if (!Math) {
  58. (_easycom_s_goods_item + _easycom_uni_easyinput + _easycom_s_uploader + _easycom_uni_forms + _easycom_su_fixed + _easycom_su_popup + _easycom_s_layout)();
  59. }
  60. const _sfc_main = {
  61. __name: "apply",
  62. setup(__props) {
  63. const form = common_vendor.ref(null);
  64. const state = common_vendor.reactive({
  65. orderId: 0,
  66. // 订单编号
  67. itemId: 0,
  68. // 订单项编号
  69. order: {},
  70. // 订单
  71. item: {},
  72. // 订单项
  73. config: {},
  74. // 交易配置
  75. // 售后类型
  76. wayList: [
  77. {
  78. text: "仅退款",
  79. value: "10"
  80. },
  81. {
  82. text: "退款退货",
  83. value: "20"
  84. }
  85. ],
  86. reasonList: [],
  87. // 可选的申请原因数组
  88. showModal: false,
  89. // 是否显示申请原因弹窗
  90. currentValue: ""
  91. // 当前选择的售后原因
  92. });
  93. const formData = common_vendor.reactive({
  94. way: "",
  95. applyReason: "",
  96. applyDescription: "",
  97. applyPicUrls: []
  98. });
  99. const rules = common_vendor.reactive({});
  100. async function submit() {
  101. if (formData.way == "") {
  102. common_vendor.index.showToast({
  103. title: "请选择售后类型",
  104. icon: "error",
  105. duration: 1e3
  106. });
  107. return false;
  108. }
  109. if (state.currentValue == "") {
  110. common_vendor.index.showToast({
  111. title: "请选择申请原因",
  112. icon: "error",
  113. duration: 1e3
  114. });
  115. return false;
  116. }
  117. if (formData.applyDescription == "") {
  118. common_vendor.index.showToast({
  119. title: "请填写相关描述",
  120. icon: "error",
  121. duration: 1e3
  122. });
  123. return false;
  124. }
  125. sheep_index.sheep.$platform.useProvider("wechat").subscribeMessage("order_aftersale_change");
  126. let data = {
  127. orderItemId: state.itemId,
  128. refundPrice: state.item.payPrice,
  129. ...formData
  130. };
  131. const { code } = await sheep_api_trade_afterSale.AfterSaleApi.createAfterSale(data);
  132. if (code === 0) {
  133. common_vendor.index.showToast({
  134. title: "申请成功"
  135. });
  136. sheep_index.sheep.$router.go("/pages/order/aftersale/list");
  137. }
  138. }
  139. function onRefundChange(e) {
  140. formData.way = e.detail.value;
  141. state.reasonList = formData.way === "10" ? state.config.afterSaleRefundReasons || [] : state.config.afterSaleReturnReasons || [];
  142. formData.applyReason = "";
  143. state.currentValue = "";
  144. }
  145. function onChange(e) {
  146. state.currentValue = e.detail.value;
  147. }
  148. function onReason() {
  149. formData.applyReason = state.currentValue;
  150. state.showModal = false;
  151. }
  152. common_vendor.onLoad(async (options) => {
  153. if (!options.orderId || !options.itemId) {
  154. sheep_index.sheep.$helper.toast(`缺少订单信息,请检查`);
  155. return;
  156. }
  157. state.orderId = options.orderId;
  158. state.itemId = parseInt(options.itemId);
  159. const { code, data } = await sheep_api_trade_order.OrderApi.getOrder(state.orderId);
  160. if (code !== 0) {
  161. return;
  162. }
  163. state.order = data;
  164. state.item = data.items.find((item) => item.id === state.itemId) || {};
  165. if (state.order.status === 10) {
  166. state.wayList.splice(1, 1);
  167. }
  168. state.config = (await sheep_api_trade_config.TradeConfigApi.getTradeConfig()).data;
  169. });
  170. return (_ctx, _cache) => {
  171. var _a;
  172. return common_vendor.e({
  173. a: common_vendor.p({
  174. img: state.item.picUrl,
  175. title: state.item.spuName,
  176. skuText: (_a = state.item.properties) == null ? void 0 : _a.map((property) => property.valueName).join(" "),
  177. price: state.item.price,
  178. num: state.item.count
  179. }),
  180. b: common_vendor.f(state.wayList, (item, index, i0) => {
  181. return {
  182. a: formData.type === item.value,
  183. b: item.value,
  184. c: common_vendor.t(item.text),
  185. d: index
  186. };
  187. }),
  188. c: common_vendor.o(onRefundChange),
  189. d: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.item.payPrice)),
  190. e: common_vendor.o(($event) => state.showModal = true),
  191. f: formData.applyReason
  192. }, formData.applyReason ? {
  193. g: common_vendor.t(formData.applyReason)
  194. } : {}, {
  195. h: common_vendor.o(($event) => state.showModal = true),
  196. i: common_vendor.o(($event) => formData.applyDescription = $event),
  197. j: common_vendor.p({
  198. inputBorder: false,
  199. type: "textarea",
  200. maxlength: "120",
  201. autoHeight: true,
  202. placeholder: "客官~请描述您遇到的问题,建议上传照片",
  203. modelValue: formData.applyDescription
  204. }),
  205. k: common_vendor.o(($event) => formData.applyPicUrls = $event),
  206. l: common_vendor.p({
  207. fileMediatype: "image",
  208. limit: "9",
  209. mode: "grid",
  210. imageStyles: {
  211. width: "168rpx",
  212. height: "168rpx"
  213. },
  214. url: formData.applyPicUrls
  215. }),
  216. m: common_vendor.sr(form, "5be4d0ee-2,5be4d0ee-0", {
  217. "k": "form"
  218. }),
  219. n: common_vendor.o(($event) => formData = $event),
  220. o: common_vendor.p({
  221. rules,
  222. ["label-position"]: "top",
  223. modelValue: formData
  224. }),
  225. p: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/chat/index")),
  226. q: common_vendor.o(submit),
  227. r: common_vendor.p({
  228. bottom: true,
  229. placeholder: true
  230. }),
  231. s: common_vendor.f(state.reasonList, (item, k0, i0) => {
  232. return {
  233. a: common_vendor.t(item),
  234. b: item,
  235. c: item === state.currentValue,
  236. d: item
  237. };
  238. }),
  239. t: common_vendor.o(onChange),
  240. v: common_vendor.o(onReason),
  241. w: common_vendor.o(($event) => state.showModal = false),
  242. x: common_vendor.p({
  243. show: state.showModal,
  244. round: "10",
  245. showClose: true
  246. }),
  247. y: common_vendor.p({
  248. title: "申请售后"
  249. })
  250. });
  251. };
  252. }
  253. };
  254. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-5be4d0ee"], ["__file", "D:/zx/mall-front-app/pages/order/aftersale/apply.vue"]]);
  255. wx.createPage(MiniProgramPage);