"use strict";
const common_vendor = require("../../../common/vendor.js");
const sheep_index = require("../../index.js");
const sheep_hooks_useModal = require("../../hooks/useModal.js");
require("../../url/index.js");
require("../../store/index.js");
require("../../store/app.js");
require("../../api/promotion/diy.js");
require("../../request/index.js");
require("../../config/index.js");
require("../../platform/index.js");
require("../../platform/provider/wechat/index.js");
require("../../platform/provider/wechat/miniProgram.js");
require("../../api/member/auth.js");
require("../../api/member/social.js");
require("../../api/member/user.js");
require("../../platform/provider/apple/index.js");
require("../../platform/share.js");
require("../../router/index.js");
require("../../helper/throttle.js");
require("../../platform/pay.js");
require("../../helper/index.js");
require("../../helper/test.js");
require("../../helper/digit.js");
require("../../api/pay/order.js");
require("../../store/user.js");
require("../../store/cart.js");
require("../../api/trade/cart.js");
require("../../api/pay/wallet.js");
require("../../api/trade/order.js");
require("../../api/promotion/coupon.js");
require("../../store/sys.js");
require("../../store/modal.js");
require("../../config/zIndex.js");
if (!Array) {
  const _easycom_su_popup2 = common_vendor.resolveComponent("su-popup");
  _easycom_su_popup2();
}
const _easycom_su_popup = () => "../../ui/su-popup/su-popup.js";
if (!Math) {
  (accountLogin + smsLogin + resetPassword + changeMobile + changePassword + mpAuthorization + _easycom_su_popup)();
}
const accountLogin = () => "./components/account-login.js";
const smsLogin = () => "./components/sms-login.js";
const resetPassword = () => "./components/reset-password.js";
const changeMobile = () => "./components/change-mobile.js";
const changePassword = () => "./components/change-password.js";
const mpAuthorization = () => "./components/mp-authorization.js";
const _sfc_main = {
  __name: "s-auth-modal",
  setup(__props) {
    common_vendor.computed(() => sheep_index.sheep.$store("app").info);
    const modalStore = sheep_index.sheep.$store("modal");
    const authType = common_vendor.computed(() => modalStore.auth);
    const state = common_vendor.reactive({
      protocol: false
    });
    const isActive = common_vendor.ref("accountLogin");
    const currentProtocol = common_vendor.ref(false);
    function onChange() {
      state.protocol = !state.protocol;
    }
    function onProtocol(title) {
      sheep_hooks_useModal.closeAuthModal();
      sheep_index.sheep.$router.go("/pages/public/richtext", {
        title
      });
    }
    function onConfirm(e) {
      currentProtocol.value = e;
      setTimeout(() => {
        currentProtocol.value = false;
      }, 1e3);
    }
    const thirdLogin = async (provider) => {
      if (!state.protocol) {
        currentProtocol.value = true;
        setTimeout(() => {
          currentProtocol.value = false;
        }, 1e3);
        sheep_index.sheep.$helper.toast("请勾选同意");
        return;
      }
      const loginRes = await sheep_index.sheep.$platform.useProvider(provider).login();
      if (loginRes) {
        sheep_hooks_useModal.closeAuthModal();
        sheep_hooks_useModal.showAuthModal("mpAuthorization");
      }
    };
    const getPhoneNumber = async (e) => {
      if (e.detail.errMsg !== "getPhoneNumber:ok") {
        sheep_index.sheep.$helper.toast("快捷登录失败");
        return;
      }
      let result = await sheep_index.sheep.$platform.useProvider().mobileLogin(e.detail);
      if (result) {
        sheep_hooks_useModal.closeAuthModal();
      }
    };
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: ["accountLogin", "smsLogin"].includes(common_vendor.unref(authType))
      }, ["accountLogin", "smsLogin"].includes(common_vendor.unref(authType)) ? {
        b: common_vendor.n(isActive.value == "accountLogin" ? `head-title ss-m-r-40 head-title-animation` : `head-title-active ss-m-r-40`),
        c: common_vendor.o(($event) => {
          isActive.value = "accountLogin";
          common_vendor.unref(sheep_hooks_useModal.showAuthModal)("accountLogin");
        }),
        d: common_vendor.n(isActive.value == "smsLogin" ? `head-title head-title-line head-title-animation` : `head-title-active head-title-line`),
        e: common_vendor.o(($event) => {
          isActive.value = "smsLogin";
          common_vendor.unref(sheep_hooks_useModal.showAuthModal)("smsLogin");
        })
      } : {}, {
        f: ["accountLogin", "smsLogin"].includes(common_vendor.unref(authType))
      }, ["accountLogin", "smsLogin"].includes(common_vendor.unref(authType)) ? {
        g: state.protocol,
        h: common_vendor.o(onChange),
        i: common_vendor.o(($event) => onProtocol("用户协议")),
        j: common_vendor.o(($event) => onProtocol("隐私协议")),
        k: common_vendor.o(onChange),
        l: currentProtocol.value ? 1 : ""
      } : {}, {
        m: ["accountLogin", "smsLogin"].includes(common_vendor.unref(authType))
      }, ["accountLogin", "smsLogin"].includes(common_vendor.unref(authType)) ? common_vendor.e({
        n: ["WechatOfficialAccount", "WechatMiniProgram", "App"].includes(common_vendor.unref(sheep_index.sheep).$platform.name) && common_vendor.unref(sheep_index.sheep).$platform.isWechatInstalled
      }, ["WechatOfficialAccount", "WechatMiniProgram", "App"].includes(common_vendor.unref(sheep_index.sheep).$platform.name) && common_vendor.unref(sheep_index.sheep).$platform.isWechatInstalled ? {
        o: common_vendor.unref(sheep_index.sheep).$url.static("/static/img/shop/platform/wechat.png"),
        p: common_vendor.o(($event) => thirdLogin("wechat"))
      } : {}) : {}, {
        q: common_vendor.unref(authType) === "accountLogin"
      }, common_vendor.unref(authType) === "accountLogin" ? {
        r: common_vendor.o(onConfirm),
        s: common_vendor.p({
          agreeStatus: state.protocol
        })
      } : {}, {
        t: common_vendor.unref(authType) === "smsLogin"
      }, common_vendor.unref(authType) === "smsLogin" ? {
        v: common_vendor.o(onConfirm),
        w: common_vendor.p({
          agreeStatus: state.protocol
        })
      } : {}, {
        x: common_vendor.unref(authType) === "resetPassword"
      }, common_vendor.unref(authType) === "resetPassword" ? {} : {}, {
        y: common_vendor.unref(authType) === "changeMobile"
      }, common_vendor.unref(authType) === "changeMobile" ? {} : {}, {
        z: common_vendor.unref(authType) === "changePassword"
      }, common_vendor.unref(authType) === "changePassword" ? {} : {}, {
        A: common_vendor.unref(authType) === "mpAuthorization"
      }, common_vendor.unref(authType) === "mpAuthorization" ? {} : {}, {
        B: ["accountLogin", "smsLogin"].includes(common_vendor.unref(authType))
      }, ["accountLogin", "smsLogin"].includes(common_vendor.unref(authType)) ? common_vendor.e({
        C: common_vendor.unref(sheep_index.sheep).$platform.name === "WechatMiniProgram"
      }, common_vendor.unref(sheep_index.sheep).$platform.name === "WechatMiniProgram" ? {
        D: common_vendor.o(getPhoneNumber)
      } : {}, {
        E: common_vendor.unref(sheep_index.sheep).$platform.os === "ios" && common_vendor.unref(sheep_index.sheep).$platform.name === "App"
      }, common_vendor.unref(sheep_index.sheep).$platform.os === "ios" && common_vendor.unref(sheep_index.sheep).$platform.name === "App" ? {
        F: common_vendor.unref(sheep_index.sheep).$url.static("/static/img/shop/platform/apple.png"),
        G: common_vendor.o(($event) => thirdLogin("apple"))
      } : {}) : {}, {
        H: common_vendor.o(common_vendor.unref(sheep_hooks_useModal.closeAuthModal)),
        I: common_vendor.p({
          show: common_vendor.unref(authType) !== "",
          round: "10",
          showClose: true
        })
      });
    };
  }
};
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-21181321"], ["__file", "/Users/RuHu.Xu/Desktop/mall-newfeifan-zx-app/sheep/components/s-auth-modal/s-auth-modal.vue"]]);
wx.createComponent(Component);
