"use strict"; const common_vendor = require("../../common/vendor.js"); const api_booking_card_index = require("../../api/booking/card/index.js"); const api_shop_order_index = require("../../api/shop/order/index.js"); const api_passport_login_index = require("../../api/passport/login/index.js"); const utils_common = require("../../utils/common.js"); const store_modules_car = require("../../store/modules/car.js"); const store_modules_user = require("../../store/modules/user.js"); const userStore = store_modules_user.useUserStore(); const carStore = store_modules_car.useCarStore(); const { goodsList, totalPrice, carNum, merchantId, merchantName, merchantCode, type, dateTime } = common_vendor.storeToRefs(carStore); const _sfc_main = { data() { return { cardId: 0, goodsId: 0, userInfo: {}, form: {}, address: {}, addressList: [], week: 0, goodsList, // 订单总金额 totalPrice, reducePrice: 0, merchantId, merchantName, merchantCode, getWeek: utils_common.getWeek, payType: 1, isLogin: false, disabled: false, // 支付密码是否正确 isPayPasswordCorrect: false, disabledPayPayPassword: false, payPassword: "" }; }, onLoad(option) { this.cardId = option.cardId; this.reload(); }, onShow() { if (common_vendor.index.getStorageSync("user_id") && common_vendor.index.getStorageSync("access_token")) { this.isLogin = true; } this.openLogin(); }, methods: { async reload() { const app = this; const { cardId } = this; const userInfo = await userStore.fetchUserInfo(); app.userInfo = userInfo; api_booking_card_index.getCard(cardId).then((data) => { app.form = data; }); }, onDisabled() { this.disabled = !this.disabled; }, navTo(url) { common_vendor.index.navigateTo({ url }); }, openUrl(url) { if (!this.isLogin) { this.$refs.login.open("bottom"); return false; } else { common_vendor.index.navigateTo({ url }); } }, onAddress(item) { this.address = item; this.$refs.addForm.close(); }, // 切换支付方式 onPayType(index) { console.log("e: ", index); this.payType = index; }, openAddressList() { this.$refs.addForm.open("center"); }, // 弹出登录提示框 openLogin() { if (!this.isLogin) { this.$refs.login.open("bottom"); return false; } }, // 验证支付密码 onPayPassword() { if (this.payPassword == "" || !this.payPassword) { common_vendor.index.showToast({ title: "请输入支付密码", icon: "none" }); return false; } this.disabledPayPayPassword = true; const { payPassword } = this; api_passport_login_index.checkPayPassword({ payPassword }).then((res) => { this.disabledPayPayPassword = false; this.isPayPasswordCorrect = true; this.save(); }).catch((err) => { common_vendor.index.showToast({ title: err.message, icon: "none" }); this.disabledPayPayPassword = false; }); }, save() { const app = this; const { form, payType } = this; if (!this.disabled) { common_vendor.index.showToast({ title: "请先阅读并同意服务协议", icon: "none" }); return false; } if (payType == 0 && !this.isPayPasswordCorrect) { this.$refs.payPasswordForm.open("center"); return false; } common_vendor.index.showLoading({ title: "订单提交中." }); api_shop_order_index.addOrder({ type: 2, // 0商城订单 1预定订单 2会员卡订单 cardId: form.cardId, merchantId: form.merchantId, merchantName: form.merchantName, totalPrice: form.price, payPrice: form.price, comments: form.cardName, payType }).then((data) => { const orderInfo = data; if (payType == 1) { common_vendor.index.requestPayment({ provider: orderInfo.provider, // 服务提供商 timeStamp: orderInfo.timeStamp, // 时间戳 nonceStr: orderInfo.nonceStr, // 随机字符串 package: orderInfo.package, signType: orderInfo.signType, // 签名算法 paySign: orderInfo.paySign, // 签名 success: function(res) { common_vendor.index.showToast({ title: "支付成功", icon: "success" }); setTimeout(function() { app.disabled = false; common_vendor.index.navigateTo({ url: "/package/user/card" }); }, 500); }, fail: function(err) { console.log("支付失败", err); app.disabled = false; } }); } if (payType == 0) { if (orderInfo) { common_vendor.index.showToast({ title: "支付成功", icon: "success" }); setTimeout(function() { app.disabled = false; common_vendor.index.navigateTo({ url: "/package/user/card" }); }, 500); return; } if (!orderInfo) { return common_vendor.index.showToast({ title: "支付失败", icon: "error" }); } } common_vendor.index.hideLoading(); }).catch((res) => { common_vendor.index.showToast({ title: res.message || "请检查您的网络.", icon: "none" }); common_vendor.index.hideLoading(); }); } } }; if (!Array) { const _easycom_uv_avatar2 = common_vendor.resolveComponent("uv-avatar"); const _easycom_ws_login2 = common_vendor.resolveComponent("ws-login"); const _easycom_uni_card2 = common_vendor.resolveComponent("uni-card"); const _easycom_uv_icon2 = common_vendor.resolveComponent("uv-icon"); const _easycom_uv_cell2 = common_vendor.resolveComponent("uv-cell"); const _easycom_uv_cell_group2 = common_vendor.resolveComponent("uv-cell-group"); const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons"); const _easycom_uv_gap2 = common_vendor.resolveComponent("uv-gap"); const _easycom_uv_count_to2 = common_vendor.resolveComponent("uv-count-to"); const _easycom_uv_button2 = common_vendor.resolveComponent("uv-button"); const _easycom_uni_tag2 = common_vendor.resolveComponent("uni-tag"); const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup"); const _easycom_uv_code_input2 = common_vendor.resolveComponent("uv-code-input"); const _easycom_uni_forms_item2 = common_vendor.resolveComponent("uni-forms-item"); const _easycom_uni_forms2 = common_vendor.resolveComponent("uni-forms"); (_easycom_uv_avatar2 + _easycom_ws_login2 + _easycom_uni_card2 + _easycom_uv_icon2 + _easycom_uv_cell2 + _easycom_uv_cell_group2 + _easycom_uni_icons2 + _easycom_uv_gap2 + _easycom_uv_count_to2 + _easycom_uv_button2 + _easycom_uni_tag2 + _easycom_uni_popup2 + _easycom_uv_code_input2 + _easycom_uni_forms_item2 + _easycom_uni_forms2)(); } const _easycom_uv_avatar = () => "../../uni_modules/uv-avatar/components/uv-avatar/uv-avatar.js"; const _easycom_ws_login = () => "../../uni_modules/ws-login/components/ws-login/ws-login.js"; const _easycom_uni_card = () => "../../uni_modules/uni-card/components/uni-card/uni-card.js"; const _easycom_uv_icon = () => "../../uni_modules/uv-icon/components/uv-icon/uv-icon.js"; const _easycom_uv_cell = () => "../../uni_modules/uv-cell/components/uv-cell/uv-cell.js"; const _easycom_uv_cell_group = () => "../../uni_modules/uv-cell/components/uv-cell-group/uv-cell-group.js"; const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js"; const _easycom_uv_gap = () => "../../uni_modules/uv-gap/components/uv-gap/uv-gap.js"; const _easycom_uv_count_to = () => "../../uni_modules/uv-count-to/components/uv-count-to/uv-count-to.js"; const _easycom_uv_button = () => "../../uni_modules/uv-button/components/uv-button/uv-button.js"; const _easycom_uni_tag = () => "../../uni_modules/uni-tag/components/uni-tag/uni-tag.js"; const _easycom_uni_popup = () => "../../uni_modules/uni-popup/components/uni-popup/uni-popup.js"; const _easycom_uv_code_input = () => "../../uni_modules/uv-code-input/components/uv-code-input/uv-code-input.js"; const _easycom_uni_forms_item = () => "../../uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.js"; const _easycom_uni_forms = () => "../../uni_modules/uni-forms/components/uni-forms/uni-forms.js"; if (!Math) { (_easycom_uv_avatar + _easycom_ws_login + _easycom_uni_card + _easycom_uv_icon + _easycom_uv_cell + _easycom_uv_cell_group + _easycom_uni_icons + _easycom_uv_gap + _easycom_uv_count_to + _easycom_uv_button + _easycom_uni_tag + _easycom_uni_popup + _easycom_uv_code_input + _easycom_uni_forms_item + _easycom_uni_forms)(); } function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return common_vendor.e({ a: common_vendor.t($data.merchantId), b: common_vendor.t($data.merchantCode), c: common_vendor.t($data.merchantName), d: common_vendor.t(_ctx.dateTime), e: common_vendor.t($data.week), f: common_vendor.t($data.totalPrice), g: common_vendor.t(_ctx.type), h: common_vendor.t($data.goodsList), i: common_vendor.t($data.form), j: common_vendor.p({ src: $data.form.merchantAvatar, size: "42" }), k: common_vendor.t($data.form.cardName), l: $data.form.cardCode == "月/年卡" }, $data.form.cardCode == "月/年卡" ? { m: common_vendor.t($data.form.month) } : {}, { n: $data.form.cardCode == "次卡" }, $data.form.cardCode == "次卡" ? { o: common_vendor.t($data.form.number) } : {}, { p: $data.form.cardCode == "充值卡" }, $data.form.cardCode == "充值卡" ? { q: common_vendor.t($data.form.discount) } : {}, { r: common_vendor.p({ src: "../../static/qrcode.png", size: "30", shape: "square" }), s: `url(${$data.form.image}) no-repeat center center`, t: common_vendor.sr("login", "b71f6ba9-2"), v: common_vendor.o($options.reload), w: common_vendor.p({ logo: _ctx.logo }), x: $data.form.comments, y: common_vendor.p({ title: "会员卡说明", border: false, ["is-shadow"]: false }), z: common_vendor.f(_ctx.payment, (item, index, i0) => { return { a: index }; }), A: $data.payType == 1 }, $data.payType == 1 ? { B: common_vendor.p({ size: "30rpx", name: "checkbox-mark" }) } : {}, { C: common_vendor.o(($event) => $options.onPayType(1)), D: common_vendor.p({ title: "微信支付", icon: "https://oss.wsdns.cn/20240511/8d7af0f0374040cb9b9255eff5fb812d.png?x-oss-process=image/resize,m_fixed,w_100,h_100/quality,Q_90", cellStyle: { padding: "20rpx 10rpx", borderRadius: "8rpx", backgroundColor: $data.payType == 1 ? "#f6fff1" : "" }, border: false }), E: $data.payType == 0 }, $data.payType == 0 ? { F: common_vendor.p({ size: "30rpx", name: "checkbox-mark" }) } : {}, { G: common_vendor.o(($event) => $options.onPayType(0)), H: common_vendor.p({ title: `余额支付(${$data.userInfo.balance})`, icon: "https://oss.wsdns.cn/20240511/fae57a94fa0042b9bceb721421304db1.png?x-oss-process=image/resize,m_fixed,w_100,h_100/quality,Q_90", cellStyle: { padding: "10px 5px", borderRadius: "8rpx", backgroundColor: $data.payType == 0 ? "#f6fff1" : "" }, border: false }), I: common_vendor.p({ customStyle: { backgroundColor: "#ffffff" }, border: false }), J: common_vendor.t($data.form.price || 0), K: common_vendor.o(($event) => _ctx.actionsClick("分享")), L: common_vendor.p({ title: "选择支付方式", border: false, ["is-shadow"]: false }), M: !$data.disabled }, !$data.disabled ? { N: common_vendor.o($options.onDisabled), O: common_vendor.p({ type: "circle", size: "20", color: "#a4a5a7" }) } : { P: common_vendor.o($options.onDisabled), Q: common_vendor.p({ type: "checkbox", size: "20", color: "#11a954" }) }, { R: common_vendor.o(($event) => $options.navTo("/package/article/detail?articleId=501")), S: common_vendor.o(($event) => $options.navTo("/package/article/detail?articleId=502")), T: common_vendor.o((...args) => $options.onDisabled && $options.onDisabled(...args)), U: common_vendor.p({ height: "50" }), V: common_vendor.p({ startVal: 0, decimals: "2", duration: "100", color: "#ebcf00", bold: true, endVal: $data.form.price }), W: common_vendor.o($options.save), X: common_vendor.p({ disabled: !$data.disabled, customStyle: { background: "linear-gradient(to right, #70b915, #008e04)", borderRadius: "0 30px 30px 0", color: "#ffffff", border: "none", padding: "22px 30px" }, text: "提交订单" }), Y: common_vendor.f($data.addressList, (item, index, i0) => { return common_vendor.e({ a: "b71f6ba9-19-" + i0 + "," + ("b71f6ba9-18-" + i0), b: common_vendor.p({ text: item.type, fontSize: "12", size: "32", randomBgColor: true }), c: common_vendor.t(item.name), d: common_vendor.t(item.phone), e: item.isDefault }, item.isDefault ? { f: "b71f6ba9-20-" + i0 + "," + ("b71f6ba9-18-" + i0), g: common_vendor.p({ text: "默认", size: "mini", inverted: true, type: "success" }) } : {}, { h: "b71f6ba9-21-" + i0 + "," + ("b71f6ba9-18-" + i0), i: common_vendor.o(($event) => $options.onAddress(item), index), j: "b71f6ba9-18-" + i0 + ",b71f6ba9-17", k: common_vendor.p({ cellStyle: { padding: "10px 0" }, label: item.address }), l: index }); }), Z: common_vendor.p({ type: "right" }), aa: common_vendor.o(($event) => $options.navTo("/package/user/address")), ab: common_vendor.p({ customStyle: { borderRadius: "30px" }, text: "收货地址管理" }), ac: common_vendor.p({ customStyle: { backgroundColor: "#ffffff" }, border: false }), ad: common_vendor.p({ title: "选择收货地址", border: false, ["is-shadow"]: false, padding: 0 }), ae: common_vendor.sr("addForm", "b71f6ba9-15"), af: common_vendor.p({ type: "center", ["border-radius"]: "10px 10px 0 0" }), ag: common_vendor.o(($event) => $data.payPassword = $event), ah: common_vendor.p({ mode: "box", dot: true, space: 0, maxlength: 6, hairline: true, modelValue: $data.payPassword }), ai: common_vendor.p({ label: "支付密码", name: "payPassword", required: true }), aj: common_vendor.o($options.onPayPassword), ak: common_vendor.p({ customStyle: { background: "linear-gradient(to right, #70b915, #008e04)", borderRadius: "30px", color: "#ffffff" }, text: "确定支付", disabled: $data.disabledPayPayPassword }), al: common_vendor.sr("form", "b71f6ba9-25,b71f6ba9-24"), am: common_vendor.p({ ["label-width"]: 80 }), an: common_vendor.o(($event) => $options.navTo(`/package/user/pay-password`)), ao: common_vendor.p({ title: "请输入支付密码", border: false, ["is-shadow"]: false, padding: 0 }), ap: common_vendor.sr("payPasswordForm", "b71f6ba9-23"), aq: common_vendor.p({ type: "center", ["border-radius"]: "10px 10px 0 0" }), ar: common_vendor.sr("login", "b71f6ba9-29"), as: common_vendor.o($options.reload), at: common_vendor.p({ logo: _ctx.logo }) }); } const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-b71f6ba9"], ["__file", "/Users/gxwebsoft/APP/gxtyzx-uniapp-cli/src/package/card/checkout.vue"]]); wx.createPage(MiniProgramPage);