WXL
19 小时以前 05c363fdd7ab04e3bd9a753e2c5d5bfff04d681c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
"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