"use strict";
const common_vendor = require("../../common/vendor.js");
const sheep_index = require("../../sheep/index.js");
const sheep_hooks_useGoods = require("../../sheep/hooks/useGoods.js");
const sheep_api_pay_wallet = require("../../sheep/api/pay/wallet.js");
require("../../sheep/api/index.js");
require("../../sheep/api/distri/score.js");
require("../../sheep/request/index.js");
require("../../sheep/config/index.js");
require("../../sheep/store/index.js");
require("../../sheep/store/app.js");
require("../../sheep/api/promotion/diy.js");
require("../../sheep/platform/index.js");
require("../../sheep/platform/provider/wechat/index.js");
require("../../sheep/platform/provider/wechat/miniProgram.js");
require("../../sheep/api/member/auth.js");
require("../../sheep/api/member/social.js");
require("../../sheep/api/member/user.js");
require("../../sheep/platform/provider/apple/index.js");
require("../../sheep/platform/share.js");
require("../../sheep/router/index.js");
require("../../sheep/hooks/useModal.js");
require("../../sheep/helper/index.js");
require("../../sheep/helper/test.js");
require("../../sheep/helper/digit.js");
require("../../sheep/api/member/signin.js");
require("../../sheep/helper/throttle.js");
require("../../sheep/url/index.js");
require("../../sheep/platform/pay.js");
require("../../sheep/api/pay/order.js");
require("../../sheep/store/user.js");
require("../../sheep/store/cart.js");
require("../../sheep/api/trade/cart.js");
require("../../sheep/api/trade/order.js");
require("../../sheep/api/promotion/coupon.js");
require("../../sheep/store/sys.js");
require("../../sheep/store/modal.js");
require("../../sheep/api/distri/share.js");
require("../../sheep/api/distri/team.js");
require("../../sheep/api/infra/file.js");
require("../../sheep/api/member/address.js");
require("../../sheep/api/member/point.js");
require("../../sheep/api/migration/app.js");
require("../../sheep/api/migration/chat.js");
require("../../sheep/api/migration/index.js");
require("../../sheep/api/migration/third.js");
require("../../sheep/api/pay/channel.js");
require("../../sheep/api/product/category.js");
require("../../sheep/api/product/comment.js");
require("../../sheep/api/product/favorite.js");
require("../../sheep/api/product/history.js");
require("../../sheep/api/product/spu.js");
require("../../sheep/api/promotion/activity.js");
require("../../sheep/api/promotion/article.js");
require("../../sheep/api/promotion/bargain.js");
require("../../sheep/api/promotion/combination.js");
require("../../sheep/api/promotion/rewardActivity.js");
require("../../sheep/api/promotion/seckill.js");
require("../../sheep/api/system/area.js");
require("../../sheep/api/system/voice.js");
require("../../sheep/api/trade/afterSale.js");
require("../../sheep/api/trade/brokerage.js");
require("../../sheep/api/trade/config.js");
require("../../sheep/api/trade/delivery.js");
require("../../sheep/config/zIndex.js");
require("../../sheep/util/index.js");
if (!Array) {
  const _easycom_uni_easyinput2 = common_vendor.resolveComponent("uni-easyinput");
  const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  (_easycom_uni_easyinput2 + _easycom_s_layout2)();
}
const _easycom_uni_easyinput = () => "../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.js";
const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js";
if (!Math) {
  (_easycom_uni_easyinput + _easycom_s_layout)();
}
const _sfc_main = {
  __name: "recharge",
  setup(__props) {
    common_vendor.useCssVars((_ctx) => ({
      "dd851cb6": common_vendor.unref(headerBg)
    }));
    const userWallet = common_vendor.computed(() => sheep_index.sheep.$store("user").userWallet);
    const statusBarHeight = sheep_index.sheep.$platform.device.statusBarHeight * 2;
    const headerBg = sheep_index.sheep.$url.css("/static/img/shop/user/withdraw_bg.png");
    const state = common_vendor.reactive({
      recharge_money: "",
      // 输入的充值金额
      packageList: []
    });
    function onCard(e) {
      state.recharge_money = sheep_hooks_useGoods.fen2yuan(e);
    }
    async function getRechargeTabs() {
      const { code, data } = await sheep_api_pay_wallet.PayWalletApi.getWalletRechargePackageList();
      if (code !== 0) {
        return;
      }
      state.packageList = data;
    }
    async function onConfirm() {
      var _a;
      const { code, data } = await sheep_api_pay_wallet.PayWalletApi.createWalletRecharge({
        packageId: (_a = state.packageList.find((item) => sheep_hooks_useGoods.fen2yuan(item.payPrice) === state.recharge_money)) == null ? void 0 : _a.id,
        payPrice: state.recharge_money * 100
      });
      if (code !== 0) {
        return;
      }
      sheep_index.sheep.$platform.useProvider("wechat").subscribeMessage("money_change");
      sheep_index.sheep.$router.go("/pages/pay/index", {
        id: data.payOrderId,
        orderType: "recharge"
      });
    }
    common_vendor.onLoad(() => {
      getRechargeTabs();
    });
    return (_ctx, _cache) => {
      return {
        a: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(userWallet.value.balance)),
        b: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/pay/recharge-log")),
        c: common_vendor.s({
          marginTop: "-" + Number(statusBarHeight + 88) + "rpx",
          paddingTop: Number(statusBarHeight + 108) + "rpx"
        }),
        d: common_vendor.o(($event) => state.recharge_money = $event),
        e: common_vendor.p({
          type: "digit",
          placeholder: "请输入充值金额",
          inputBorder: false,
          modelValue: state.recharge_money
        }),
        f: common_vendor.f(state.packageList, (item, k0, i0) => {
          return common_vendor.e({
            a: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(item.payPrice)),
            b: item.bonusPrice
          }, item.bonusPrice ? {
            c: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(item.bonusPrice))
          } : {}, {
            d: item.money,
            e: common_vendor.n({
              "btn-active": state.recharge_money === common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(item.payPrice)
            }),
            f: common_vendor.o(($event) => onCard(item.payPrice), item.money)
          });
        }),
        g: common_vendor.o(onConfirm),
        h: common_vendor.s(_ctx.__cssVars()),
        i: common_vendor.p({
          title: "充值",
          navbar: "inner"
        })
      };
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-b0187d83"], ["__file", "D:/zx/mall-front-app/pages/pay/recharge.vue"]]);
wx.createPage(MiniProgramPage);
