"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_trade_config = require("../../sheep/api/trade/config.js");
const sheep_api_trade_brokerage = require("../../sheep/api/trade/brokerage.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/pay/wallet.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/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_uploader2 = common_vendor.resolveComponent("s-uploader");
  const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  (_easycom_uni_easyinput2 + _easycom_s_uploader2 + _easycom_s_layout2)();
}
const _easycom_uni_easyinput = () => "../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.js";
const _easycom_s_uploader = () => "../../sheep/components/s-uploader/s-uploader.js";
const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js";
if (!Math) {
  (_easycom_uni_easyinput + _easycom_s_uploader + accountTypeSelect + _easycom_s_layout)();
}
const accountTypeSelect = () => "./components/account-type-select.js";
const _sfc_main = {
  __name: "withdraw",
  setup(__props) {
    common_vendor.useCssVars((_ctx) => ({
      "11aa8d88": common_vendor.unref(headerBg)
    }));
    const headerBg = sheep_index.sheep.$url.css("/static/img/shop/user/withdraw_bg.png");
    const statusBarHeight = sheep_index.sheep.$platform.device.statusBarHeight * 2;
    const userStore = sheep_index.sheep.$store("user");
    common_vendor.computed(() => userStore.userInfo);
    const state = common_vendor.reactive({
      accountInfo: {
        // 提现表单
        type: void 0,
        accountNo: void 0,
        accountQrCodeUrl: void 0,
        name: void 0,
        bankName: void 0,
        bankAddress: void 0
      },
      accountSelect: false,
      brokerageInfo: {},
      // 分销信息
      frozenDays: 0,
      // 冻结天数
      minPrice: 0,
      // 最低提现金额
      withdrawTypes: []
      // 提现方式
    });
    const onAccountSelect = (e) => {
      state.accountSelect = e;
    };
    const onConfirm = async () => {
      debugger;
      if (!state.accountInfo.price || state.accountInfo.price > state.brokerageInfo.price || state.accountInfo.price <= 0) {
        sheep_index.sheep.$helper.toast("请输入正确的提现金额");
        return;
      }
      if (!state.accountInfo.type) {
        sheep_index.sheep.$helper.toast("请选择提现方式");
        return;
      }
      let { code } = await sheep_api_trade_brokerage.BrokerageApi.createBrokerageWithdraw({
        ...state.accountInfo,
        price: state.accountInfo.price * 100
      });
      if (code !== 0) {
        return;
      }
      common_vendor.index.showModal({
        title: "操作成功",
        content: "您的提现申请已成功提交",
        cancelText: "继续提现",
        confirmText: "查看记录",
        success: (res) => {
          if (res.confirm) {
            sheep_index.sheep.$router.go("/pages/commission/wallet", { type: 2 });
            return;
          }
          getBrokerageUser();
          state.accountInfo = {};
        }
      });
    };
    async function getWithdrawRules() {
      let { code, data } = await sheep_api_trade_config.TradeConfigApi.getTradeConfig();
      if (code !== 0) {
        return;
      }
      if (data) {
        state.minPrice = data.brokerageWithdrawMinPrice || 0;
        state.frozenDays = data.brokerageFrozenDays || 0;
        state.withdrawTypes = data.brokerageWithdrawTypes;
      }
    }
    async function getBrokerageUser() {
      const { data, code } = await sheep_api_trade_brokerage.BrokerageApi.getBrokerageUser();
      if (code === 0) {
        state.brokerageInfo = data;
      }
    }
    common_vendor.onBeforeMount(() => {
      getWithdrawRules();
      getBrokerageUser();
    });
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.brokerageInfo.brokeragePrice)),
        b: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/commission/wallet", {
          type: 2
        })),
        c: common_vendor.s({
          marginTop: "-" + Number(statusBarHeight + 88) + "rpx",
          paddingTop: Number(statusBarHeight + 108) + "rpx"
        }),
        d: !state.accountInfo.type
      }, !state.accountInfo.type ? {} : {}, {
        e: state.accountInfo.type === "1"
      }, state.accountInfo.type === "1" ? {} : {}, {
        f: state.accountInfo.type === "2"
      }, state.accountInfo.type === "2" ? {} : {}, {
        g: state.accountInfo.type === "3"
      }, state.accountInfo.type === "3" ? {} : {}, {
        h: state.accountInfo.type === "4"
      }, state.accountInfo.type === "4" ? {} : {}, {
        i: common_vendor.o(($event) => onAccountSelect(true)),
        j: common_vendor.o(($event) => state.accountInfo.price = $event),
        k: common_vendor.p({
          inputBorder: false,
          type: "number",
          placeholder: "请输入提现金额",
          modelValue: state.accountInfo.price
        }),
        l: ["2", "3", "4"].includes(state.accountInfo.type),
        m: common_vendor.o(($event) => state.accountInfo.accountNo = $event),
        n: common_vendor.p({
          inputBorder: false,
          placeholder: "请输入提现账号",
          modelValue: state.accountInfo.accountNo
        }),
        o: ["2", "3", "4"].includes(state.accountInfo.type),
        p: ["2", "3"].includes(state.accountInfo.type),
        q: common_vendor.o(($event) => state.accountInfo.accountQrCodeUrl = $event),
        r: common_vendor.p({
          fileMediatype: "image",
          limit: "1",
          mode: "grid",
          imageStyles: {
            width: "168rpx",
            height: "168rpx"
          },
          url: state.accountInfo.accountQrCodeUrl
        }),
        s: ["2", "3"].includes(state.accountInfo.type),
        t: state.accountInfo.type === "4",
        v: common_vendor.o(($event) => state.accountInfo.name = $event),
        w: common_vendor.p({
          inputBorder: false,
          placeholder: "请输入持卡人姓名",
          modelValue: state.accountInfo.name
        }),
        x: state.accountInfo.type === "4",
        y: state.accountInfo.type === "4",
        z: common_vendor.o(($event) => state.accountInfo.bankName = $event),
        A: common_vendor.p({
          inputBorder: false,
          placeholder: "请输入提现银行",
          modelValue: state.accountInfo.bankName
        }),
        B: state.accountInfo.type === "4",
        C: state.accountInfo.type === "4",
        D: common_vendor.o(($event) => state.accountInfo.bankAddress = $event),
        E: common_vendor.p({
          inputBorder: false,
          placeholder: "请输入开户地址",
          modelValue: state.accountInfo.bankAddress
        }),
        F: state.accountInfo.type === "4",
        G: common_vendor.o(onConfirm),
        H: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.minPrice)),
        I: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(state.brokerageInfo.frozenPrice)),
        J: common_vendor.t(state.frozenDays),
        K: common_vendor.o(($event) => onAccountSelect(false)),
        L: common_vendor.o(($event) => state.accountInfo = $event),
        M: common_vendor.p({
          show: state.accountSelect,
          round: "10",
          methods: state.withdrawTypes,
          modelValue: state.accountInfo
        }),
        N: common_vendor.s(_ctx.__cssVars()),
        O: common_vendor.p({
          title: "申请提现",
          navbar: "inner"
        })
      });
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-cf14c8af"], ["__file", "D:/zx/mall-front-app/pages/commission/withdraw.vue"]]);
wx.createPage(MiniProgramPage);
