"use strict"; const common_vendor = require("../common/vendor.js"); const common_assets = require("../common/assets.js"); const EvanSwitch = () => "../components/evan-switch/evan-switch.js"; const popupBottom = () => "../components/px-popup-bottom/px-popup-bottom.js"; const _sfc_main = { components: { EvanSwitch, popupBottom }, data() { return { liveId: null, temps: [], totalMoney: 0, couponUserId: null, couponText: "请选择", couponsList: [], couponVisible: false, companyUserId: null, packageId: null, address: null, package: {}, // checked: false, // type:null, // cartIds:null, form: { // useIntegral:0, orderKey: null, addressId: null, mark: null } }; }, onLoad(option) { }, onShow() { }, methods: { getWeixinTemps: function() { getWeixinTemps().then( (res) => { if (res.code == 200) { this.temps = res.temp; } }, (rej) => { } ); }, couponSelect(item) { this.couponText = "-¥" + item.couponPrice.toFixed(2); this.couponUserId = item.id; this.couponVisible = false; this.computedPackageOrder(); }, openCoupon() { let that = this; var data = { packageCateId: this.package.cateId, couponType: 1, useMinPrice: this.totalMoney }; getMyEnableCouponList(data).then((res) => { this.couponVisible = true; that.couponsList = res.data; }); }, confirmPackageOrder() { let data = { packageId: this.packageId, couponUserId: this.couponUserId }; confirmPackageOrder(data).then( (res) => { if (res.code == 200) { this.form.orderKey = res.orderKey; this.address = res.address; this.package = res.package; if (res.address != null) { this.form.addressId = res.address.id; } this.totalMoney = res.totalMoney; } else { common_vendor.index.showToast({ icon: "none", title: res.msg }); } }, (rej) => { } ); }, computedPackageOrder() { let data = { packageId: this.packageId, couponUserId: this.couponUserId }; computedPackageOrder(data).then( (res) => { if (res.code == 200) { this.totalMoney = res.totalMoney; } else { common_vendor.index.showToast({ icon: "none", title: res.msg }); } }, (rej) => { } ); }, // 提交订单 submitOrder() { var that = this; if (this.form.orderKey == null) { common_vendor.index.showToast({ icon: "none", title: "订单KEY不存在" }); return; } if (this.form.addressId == null) { common_vendor.index.showToast({ icon: "none", title: "收货地址不能为空" }); return; } common_vendor.index.requestSubscribeMessage({ tmplIds: this.temps, success(res) { that.createPackageOrder(); }, fail(res) { that.createPackageOrder(); } }); }, createPackageOrder() { common_vendor.index.showLoading({ title: "正在处理中..." }); let data = { couponUserId: this.couponUserId, mark: this.form.mark, orderKey: this.form.orderKey, addressId: this.form.addressId, packageId: this.packageId, companyUserId: this.companyUserId }; createPackageOrder(data).then( (res) => { common_vendor.index.hideLoading(); if (res.code == 200) { if (res.order.isPrescribe == 1) { setTimeout(function() { common_vendor.index.redirectTo({ url: "prescribe?orderId=" + res.order.id }); }, 200); } else { setTimeout(function() { common_vendor.index.redirectTo({ url: "./paymentOrder?orderId=" + res.order.id }); }, 200); } return; } else { if (res.code == 501) { common_vendor.index.showToast({ icon: "none", title: res.msg }); setTimeout(function() { common_vendor.index.navigateBack({ delta: 1 }); }, 200); return; } else { common_vendor.index.showToast({ icon: "none", title: res.msg }); } } }, (rej) => { } ); }, openAddress() { common_vendor.index.navigateTo({ url: "/pages_user/user/address" }); } } }; if (!Array) { const _component_popupBottom = common_vendor.resolveComponent("popupBottom"); _component_popupBottom(); } function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return common_vendor.e({ a: $data.address == null }, $data.address == null ? { b: common_assets._imports_0$11, c: common_vendor.o(($event) => $options.openAddress()) } : {}, { d: $data.address != null }, $data.address != null ? common_vendor.e({ e: common_vendor.t($data.address.realName), f: $data.address.phone != null }, $data.address.phone != null ? { g: common_vendor.t(_ctx.utils.parsePhone($data.address.phone)) } : {}, { h: common_vendor.t($data.address.province), i: common_vendor.t($data.address.city), j: common_vendor.t($data.address.district), k: common_vendor.t($data.address.detail), l: common_assets._imports_0$11, m: common_vendor.o(($event) => $options.openAddress()) }) : {}, { n: $data.package.imgUrl, o: common_vendor.t($data.package.title), p: common_vendor.t($data.package.descs), q: $data.package.payMoney != null }, $data.package.payMoney != null ? { r: common_vendor.t($data.package.payMoney.toFixed(2)) } : {}, { s: $data.package.payMoney != null }, $data.package.payMoney != null ? { t: common_vendor.t($data.package.payMoney.toFixed(2)) } : {}, { v: common_vendor.t($data.couponText), w: common_assets._imports_1$7, x: common_vendor.o(($event) => $options.openCoupon()), y: $data.form.mark, z: common_vendor.o(($event) => $data.form.mark = $event.detail.value), A: $data.totalMoney != null }, $data.totalMoney != null ? { B: common_vendor.t($data.totalMoney.toFixed(2)) } : {}, { C: common_vendor.o((...args) => $options.submitOrder && $options.submitOrder(...args)), D: $data.couponsList.length > 0 }, $data.couponsList.length > 0 ? { E: common_vendor.f($data.couponsList, (item, index, i0) => { return common_vendor.e({ a: item.status == 0 }, item.status == 0 ? { b: common_assets._imports_2$6 } : {}, { c: item.status != 0 }, item.status != 0 ? { d: common_assets._imports_3$2 } : {}, { e: common_vendor.t(item.couponPrice), f: common_vendor.t(item.useMinPrice), g: common_vendor.t(item.couponTitle), h: common_vendor.t(item.limitTime), i: common_vendor.o(($event) => $options.couponSelect(item), index), j: index }); }) } : {}, { F: $data.couponsList.length == 0 }, $data.couponsList.length == 0 ? { G: common_assets._imports_2$3 } : {}, { H: common_vendor.sr("popup", "365fa217-0"), I: common_vendor.p({ visible: $data.couponVisible, title: " ", bgColor: "#f5f5f5", radius: "30", maxHeight: "60%" }) }); } const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-365fa217"]]); wx.createPage(MiniProgramPage);