"use strict"; const common_vendor = require("../../common/vendor.js"); const _sfc_main = { __name: "payment-method", setup(__props) { const bankCards = common_vendor.ref([ { id: 1, bankName: "中国银行(青岛)", cardType: "储蓄卡", lastFour: "8888", type: "bocm", logo: "/static/payment/bocm.png", isDefault: true }, { id: 2, bankName: "工商银行(青岛)", cardType: "储蓄卡", lastFour: "6666", type: "icbcm", logo: "/static/payment/icbcm.png", isDefault: false } ]); const paymentMethods = common_vendor.ref([ { id: 1, name: "支付宝国际版", desc: "支持青岛元/港币/人民币支付", icon: "/static/payment/alipay.png", enabled: true }, { id: 2, name: "MPay青岛钱包", desc: "青岛本地移动支付工具", icon: "/static/payment/mpay.png", enabled: true }, { id: 3, name: "BOC Pay", desc: "中银青岛手机支付", icon: "/static/payment/bocpay.png", enabled: false }, { id: 4, name: "WeChat Pay HK", desc: "支持港币/青岛元支付", icon: "/static/payment/wechat.png", enabled: true } ]); const addBankCard = () => { common_vendor.index.navigateTo({ url: "/pages/my/add-bank-card" }); }; const setDefault = (card) => { common_vendor.index.showModal({ title: "提示", content: "确定要将该卡设为默认支付卡吗?", success: (res) => { if (res.confirm) { bankCards.value.forEach((item) => { item.isDefault = item.id === card.id; }); common_vendor.index.showToast({ title: "设置成功", icon: "success" }); } } }); }; const unbindCard = (card) => { if (card.isDefault) { common_vendor.index.showToast({ title: "默认卡不能解绑", icon: "none" }); return; } common_vendor.index.showModal({ title: "提示", content: "确定要解除该银行卡绑定吗?", success: (res) => { if (res.confirm) { const index = bankCards.value.findIndex((item) => item.id === card.id); if (index > -1) { bankCards.value.splice(index, 1); common_vendor.index.showToast({ title: "解绑成功", icon: "success" }); } } } }); }; const togglePayment = (payment, value) => { if (typeof value === "undefined") { value = !payment.enabled; } payment.enabled = value; common_vendor.index.showToast({ title: value ? "已开启" : "已关闭", icon: "success" }); }; return (_ctx, _cache) => { return { a: common_vendor.o(addBankCard), b: common_vendor.f(bankCards.value, (card, index, i0) => { return common_vendor.e({ a: card.logo, b: common_vendor.t(card.bankName), c: common_vendor.t(card.cardType), d: common_vendor.t(card.lastFour), e: card.isDefault }, card.isDefault ? {} : {}, { f: !card.isDefault }, !card.isDefault ? { g: common_vendor.o(($event) => setDefault(card), index) } : {}, { h: common_vendor.o(($event) => unbindCard(card), index), i: index, j: common_vendor.n(card.type) }); }), c: common_vendor.f(paymentMethods.value, (payment, index, i0) => { return { a: payment.icon, b: common_vendor.t(payment.name), c: common_vendor.t(payment.desc), d: payment.enabled, e: common_vendor.o((e) => togglePayment(payment, e.detail.value), index), f: index, g: common_vendor.o(($event) => togglePayment(payment), index) }; }), d: common_vendor.gei(_ctx, "") }; }; } }; wx.createPage(_sfc_main); //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/my/payment-method.js.map