Liuyi
2024-12-20 d470e67ac1997882502b75cbfdaf359626cfaaa8
unpackage/dist/dev/mp-weixin/pages/recharge/index.js
@@ -14,6 +14,7 @@
  setup(__props) {
    const choosedMoney = common_vendor.ref(50);
    const disabled = common_vendor.ref(true);
    const userInfo = JSON.parse(common_vendor.index.getStorageSync("userInfo"));
    const moneyList = common_vendor.ref([
      { value: 50, active: true },
      { value: 100, active: false },
@@ -49,16 +50,44 @@
      { text: "微信支付", value: 2, checked: true, img: "../../static/images/recharge/wx.png" }
      // {text:"余额",value:3,checked:false,img:'../../static/images/recharge/balance.png'},
    ]);
    const e = common_vendor.ref("123125");
    let timerId;
    let payStatus = common_vendor.ref(true);
    async function submit() {
      let money = "";
      if (disabled.value) {
        money = choosedMoney.value;
      if (payStatus.value) {
        payStatus.value = false;
        timerId = setTimeout(() => {
          payStatus.value = true;
        }, 2e4);
        let money = "";
        if (disabled.value) {
          money = choosedMoney.value;
        } else {
          money = Number(otherMoney.value);
        }
        let data = {
          cardNumber: userInfo.waterCardNumber,
          paymentMethod: 1,
          rechargeAmount: money
        };
        await api_index.rechargeApi(data).then(async (res) => {
          if (res.code == 200) {
            let data2 = {
              businessType: 1,
              businessNo: res.data
            };
            await wxPay(data2);
            otherMoney.value = "";
          }
        });
      } else {
        money = Number(otherMoney.value);
        common_vendor.index.showToast({
          title: "充值间隔20秒,请稍后!",
          icon: "none"
        });
      }
      await api_index.wxPayApi({ businessType: 1, tradeAmount: money }).then((res) => {
        e.value = res;
    }
    async function wxPay(data) {
      await api_index.wxPayApi(data).then((res) => {
        if (res.code == 200) {
          common_vendor.wx$1.requestPayment({
            //预支付订单信息
@@ -100,6 +129,9 @@
        }
      });
    }
    common_vendor.onUnmounted(() => {
      clearTimeout(timerId);
    });
    return (_ctx, _cache) => {
      return {
        a: common_vendor.p({
@@ -125,7 +157,7 @@
            d: item.checked
          };
        }),
        h: common_vendor.t(e.value),
        h: common_vendor.unref(payStatus) ? 1 : 0.7,
        i: common_vendor.o(($event) => submit())
      };
    };