apply.js 11 KB

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