recharge.js 3.1 KB
"use strict";
var common_vendor = require("../../common/vendor.js");
var api_index = require("../../api/index.js");
require("../../utils/request.js");
if (!Array) {
  const _easycom_u_navbar2 = common_vendor.resolveComponent("u-navbar");
  _easycom_u_navbar2();
}
const _easycom_u_navbar = () => "../../uni_modules/uview-plus/components/u-navbar/u-navbar.js";
if (!Math) {
  _easycom_u_navbar();
}
const _sfc_main = {
  setup(__props) {
    common_vendor.onShow(() => {
      getPackages();
      getyues();
    });
    let packageList = common_vendor.ref([]);
    let money = common_vendor.ref("");
    let cur = common_vendor.ref(0);
    let balance = common_vendor.ref(0);
    const checkPackage = (item, index) => {
      cur.value = index;
    };
    const rechargeBtn = () => {
      let packageMoney = packageList.value[cur.value].money;
      getRecharges(money.value == "" ? packageMoney : money.value);
    };
    const { proxy } = common_vendor.getCurrentInstance();
    const getRecharges = async (money2) => {
      try {
        const res = await api_index.getRecharge(money2);
        proxy.$methods.pay(res);
        console.log("getRecharge", res);
      } catch (err) {
        common_vendor.index.showToast({ title: err, icon: "none" });
        console.log("getRecharge", err);
      }
    };
    const getPackages = async () => {
      try {
        const res = await api_index.getPackage();
        packageList.value = res;
        console.log("getPackage", res);
      } catch (err) {
        common_vendor.index.showToast({ title: err, icon: "none" });
        console.log("getPackage", err);
      }
    };
    const getyues = async () => {
      try {
        const res = await api_index.getyue();
        balance.value = res.money;
        common_vendor.index.setStorageSync("balance", res.money);
        console.log("getyue", res);
      } catch (err) {
        common_vendor.index.showToast({ title: err, icon: "none" });
        console.log("getyue", err);
      }
    };
    return (_ctx, _cache) => {
      return {
        a: common_vendor.p({
          leftIconColor: "#fff",
          placeholder: true,
          title: "\u4F1A\u5458\u4E2D\u5FC3",
          bgColor: "#1D1E24",
          autoBack: true
        }),
        b: common_vendor.t(common_vendor.unref(balance)),
        c: common_vendor.unref(money),
        d: common_vendor.o(($event) => common_vendor.isRef(money) ? money.value = $event.detail.value : money = $event.detail.value),
        e: common_vendor.f(common_vendor.unref(packageList), (item, index, i0) => {
          return {
            a: common_vendor.t(item.money),
            b: common_vendor.t(item.discount),
            c: common_vendor.o(($event) => checkPackage(item, index), item.id),
            d: common_vendor.n(common_vendor.unref(cur) == index ? "check" : ""),
            e: item.id
          };
        }),
        f: common_vendor.o(rechargeBtn)
      };
    };
  }
};
var MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/vue/\u5927\u5065\u5EB7\u5546\u57CE/healthMall/pages/mine/recharge.vue"]]);
wx.createPage(MiniProgramPage);