"use strict";
const common_vendor = require("../../../../common/vendor.js");
const sheep_index = require("../../../index.js");
const sheep_validate_form = require("../../../validate/form.js");
const sheep_hooks_useModal = require("../../../hooks/useModal.js");
const sheep_api_member_user = require("../../../api/member/user.js");
const sheep_api_member_auth = require("../../../api/member/auth.js");
require("../../../api/index.js");
require("../../../api/distri/score.js");
require("../../../request/index.js");
require("../../../config/index.js");
require("../../../store/index.js");
require("../../../store/app.js");
require("../../../api/promotion/diy.js");
require("../../../platform/index.js");
require("../../../platform/provider/wechat/index.js");
require("../../../platform/provider/wechat/miniProgram.js");
require("../../../api/member/social.js");
require("../../../platform/provider/apple/index.js");
require("../../../platform/share.js");
require("../../../router/index.js");
require("../../../helper/throttle.js");
require("../../../url/index.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("../../../api/distri/share.js");
require("../../../api/distri/team.js");
require("../../../api/infra/file.js");
require("../../../api/member/address.js");
require("../../../api/member/point.js");
require("../../../api/member/signin.js");
require("../../../api/migration/app.js");
require("../../../api/migration/chat.js");
require("../../../api/migration/index.js");
require("../../../api/migration/third.js");
require("../../../api/pay/channel.js");
require("../../../api/product/category.js");
require("../../../api/product/comment.js");
require("../../../api/product/favorite.js");
require("../../../api/product/history.js");
require("../../../api/product/spu.js");
require("../../../api/promotion/activity.js");
require("../../../api/promotion/article.js");
require("../../../api/promotion/bargain.js");
require("../../../api/promotion/combination.js");
require("../../../api/promotion/rewardActivity.js");
require("../../../api/promotion/seckill.js");
require("../../../api/system/area.js");
require("../../../api/system/voice.js");
require("../../../api/trade/afterSale.js");
require("../../../api/trade/brokerage.js");
require("../../../api/trade/config.js");
require("../../../api/trade/delivery.js");
require("../../../config/zIndex.js");
if (!Array) {
  const _easycom_uni_easyinput2 = common_vendor.resolveComponent("uni-easyinput");
  const _easycom_uni_forms_item2 = common_vendor.resolveComponent("uni-forms-item");
  const _easycom_uni_forms2 = common_vendor.resolveComponent("uni-forms");
  (_easycom_uni_easyinput2 + _easycom_uni_forms_item2 + _easycom_uni_forms2)();
}
const _easycom_uni_easyinput = () => "../../../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.js";
const _easycom_uni_forms_item = () => "../../../../uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.js";
const _easycom_uni_forms = () => "../../../../uni_modules/uni-forms/components/uni-forms/uni-forms.js";
if (!Math) {
  (_easycom_uni_easyinput + _easycom_uni_forms_item + _easycom_uni_forms)();
}
const _sfc_main = {
  __name: "change-mobile",
  setup(__props) {
    const step = common_vendor.ref(0);
    const changeMobileRef = common_vendor.ref(null);
    const userInfo = common_vendor.computed(() => sheep_index.sheep.$store("user").userInfo);
    const state = common_vendor.reactive({
      isMobileEnd: false,
      // 手机号输入完毕
      model: {
        oldMobile: "",
        oldCode: "",
        mobile: "",
        // 手机号
        code: ""
        // 验证码
      },
      rules: {
        code: sheep_validate_form.code,
        mobile: sheep_validate_form.mobile
      }
    });
    async function nextStep() {
      const validate = await common_vendor.unref(changeMobileRef).validate().catch((error) => {
        console.log("error: ", error);
      });
      if (!validate) {
        return;
      }
      const {
        code,
        data
      } = await sheep_api_member_auth.AuthUtil.validatePhone(state.model.oldMobile, state.model.oldCode, 2);
      console.log("下一步的请求校验", data);
      if (data) {
        step.value = 1;
      }
    }
    async function changeMobileSubmit() {
      const validate = await common_vendor.unref(changeMobileRef).validate().catch((error) => {
        console.log("error: ", error);
      });
      if (!validate) {
        return;
      }
      const {
        code
      } = await sheep_api_member_user.UserApi.updateUserMobile({ "mobile": state.model.mobile, "code": state.model.code });
      if (code !== 0) {
        return;
      }
      sheep_index.sheep.$store("user").getInfo();
      sheep_hooks_useModal.closeAuthModal();
    }
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.t(userInfo.value.mobile ? "更换手机号" : "绑定手机号"),
        b: !step.value
      }, !step.value ? {
        c: common_vendor.t(common_vendor.unref(sheep_hooks_useModal.getSmsTimer)("changeMobileOld")),
        d: state.isMobileEnd,
        e: state.isMobileEnd ? 1 : "",
        f: common_vendor.o(($event) => common_vendor.unref(sheep_hooks_useModal.getSmsCode)("changeMobileOld", state.model.oldMobile)),
        g: common_vendor.o(($event) => state.model.oldMobile = $event),
        h: common_vendor.p({
          placeholder: "请输入原手机号",
          inputBorder: false,
          type: "number",
          modelValue: state.model.oldMobile
        }),
        i: common_vendor.p({
          name: "mobile",
          label: "原手机号"
        }),
        j: common_vendor.o(($event) => state.model.oldCode = $event),
        k: common_vendor.p({
          placeholder: "请输入验证码",
          inputBorder: false,
          type: "number",
          maxlength: "4",
          modelValue: state.model.oldCode
        }),
        l: common_vendor.p({
          name: "code",
          label: "验证码"
        }),
        m: common_vendor.o(nextStep),
        n: common_vendor.sr(changeMobileRef, "146b49fd-0", {
          "k": "changeMobileRef"
        }),
        o: common_vendor.o(($event) => state.model = $event),
        p: common_vendor.p({
          rules: state.rules,
          validateTrigger: "bind",
          labelWidth: "140",
          labelAlign: "center",
          modelValue: state.model
        })
      } : {
        q: common_vendor.t(common_vendor.unref(sheep_hooks_useModal.getSmsTimer)("changeMobileNew")),
        r: state.isMobileEnd,
        s: state.isMobileEnd ? 1 : "",
        t: common_vendor.o(($event) => common_vendor.unref(sheep_hooks_useModal.getSmsCode)("changeMobileNew", state.model.mobile)),
        v: common_vendor.o(($event) => state.model.mobile = $event),
        w: common_vendor.p({
          placeholder: "请输入新手机号",
          inputBorder: false,
          type: "number",
          modelValue: state.model.mobile
        }),
        x: common_vendor.p({
          name: "mobile",
          label: "新手机号"
        }),
        y: common_vendor.o(($event) => state.model.code = $event),
        z: common_vendor.p({
          placeholder: "请输入验证码",
          inputBorder: false,
          type: "number",
          maxlength: "4",
          modelValue: state.model.code
        }),
        A: common_vendor.p({
          name: "code",
          label: "验证码"
        }),
        B: common_vendor.o(changeMobileSubmit),
        C: common_vendor.sr(changeMobileRef, "146b49fd-5", {
          "k": "changeMobileRef"
        }),
        D: common_vendor.o(($event) => state.model = $event),
        E: common_vendor.p({
          rules: state.rules,
          validateTrigger: "bind",
          labelWidth: "140",
          labelAlign: "center",
          modelValue: state.model
        })
      });
    };
  }
};
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-146b49fd"], ["__file", "D:/zx/mall-front-app/sheep/components/s-auth-modal/components/change-mobile.vue"]]);
wx.createComponent(Component);
