"use strict"; const common_vendor = require("../common/vendor.js"); const api_order = require("../api/order.js"); const common_assets = require("../common/assets.js"); const _sfc_main = { data() { return { orderId: null, order: null, orderCode: null, items: [], type: null, reasonsList: [], reasons: "请选择", explains: "", refundAmount: 0 }; }, onLoad(option) { this.type = option.type; this.orderCode = option.orderCode; this.orderId = option.orderId; console.log(this.orderId); this.getStoreOrder(); this.getDicts(); }, methods: { getDicts() { var data = { key: "store_after_sales_reasons" }; api_order.Dicts(data).then((res) => { if (res.code == 200) { this.reasonsList = res.data; } else { common_vendor.index.showToast({ icon: "none", title: "请求失败" }); } }); }, getStoreOrder() { var data = { orderId: this.orderId }; api_order.getStoreOrderItems(data).then((res) => { if (res.code == 200) { this.order = res.order; this.items = res.items; if (this.order.isPayRemain == 0) { this.refundAmount = this.order.totalPrice.toFixed(2); } else { this.refundAmount = this.order.totalPrice.toFixed(2); } } else { common_vendor.index.showToast({ icon: "none", title: "请求失败" }); } }); }, reasonsChange(e) { console.log(e.detail.value); this.reasons = this.reasonsList[e.detail.value].dictLabel; }, submit() { if (this.reasons == "请选择") { common_vendor.index.showToast({ icon: "none", title: "请选择原因" }); return; } if (this.refundAmount < 0) { common_vendor.index.showToast({ icon: "none", title: "请输入退款金额" }); return; } var productIds = this.items.map((item2) => item2.productId); var products = []; for (var i = 0; i < productIds.length; i++) { var item = { productId: productIds[i] }; products.push(item); } var data = { orderId: this.orderId, refundType: this.type, //0仅退款1退货退款 refundAmount: this.refundAmount, orderCode: this.orderCode, reasons: this.reasons, explains: this.explains, productList: products }; api_order.applyAfterSales(data).then((res) => { if (res.code == 200) { common_vendor.index.showToast({ icon: "success", title: "提交成功" }); setTimeout(function() { common_vendor.index.redirectTo({ url: "./order" }); }, 500); } else { common_vendor.index.showToast({ icon: "none", title: res.msg }); } }); } } }; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return common_vendor.e({ a: $data.order != null && $data.order.isPackage != 1 }, $data.order != null && $data.order.isPackage != 1 ? { b: common_vendor.f($data.items, (item, index, i0) => { return { a: JSON.parse(item.jsonInfo).image, b: common_vendor.t(JSON.parse(item.jsonInfo).productName), c: common_vendor.t(JSON.parse(item.jsonInfo).sku), d: common_vendor.t(JSON.parse(item.jsonInfo).price.toFixed(2)), e: common_vendor.t(JSON.parse(item.jsonInfo).num), f: index }; }) } : {}, { c: $data.order != null && $data.order.isPackage == 1 && $data.order.packageJson != null }, $data.order != null && $data.order.isPackage == 1 && $data.order.packageJson != null ? { d: JSON.parse($data.order.packageJson).imgUrl, e: common_vendor.t(JSON.parse($data.order.packageJson).title), f: common_vendor.t(JSON.parse($data.order.packageJson).descs) } : {}, { g: $data.refundAmount, h: common_vendor.o(($event) => $data.refundAmount = $event.detail.value), i: common_vendor.t($data.reasons), j: common_assets._imports_0$10, k: common_vendor.o((...args) => $options.reasonsChange && $options.reasonsChange(...args)), l: $data.reasons, m: $data.reasonsList, n: $data.explains, o: common_vendor.o(($event) => $data.explains = $event.detail.value), p: common_vendor.o(($event) => $options.submit()) }); } const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]); wx.createPage(MiniProgramPage);