"use strict";
const common_vendor = require("../../common/vendor.js");
const sheep_index = require("../../sheep/index.js");
const sheep_hooks_useModal = require("../../sheep/hooks/useModal.js");
const sheep_api_infra_file = require("../../sheep/api/infra/file.js");
const sheep_api_member_user = require("../../sheep/api/member/user.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/platform/provider/apple/index.js");
require("../../sheep/platform/share.js");
require("../../sheep/router/index.js");
require("../../sheep/helper/throttle.js");
require("../../sheep/url/index.js");
require("../../sheep/platform/pay.js");
require("../../sheep/helper/index.js");
require("../../sheep/helper/test.js");
require("../../sheep/helper/digit.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/member/address.js");
require("../../sheep/api/member/point.js");
require("../../sheep/api/member/signin.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");
if (!Array) {
  const _easycom_su_image2 = common_vendor.resolveComponent("su-image");
  const _easycom_uni_easyinput2 = common_vendor.resolveComponent("uni-easyinput");
  const _easycom_uni_forms_item2 = common_vendor.resolveComponent("uni-forms-item");
  const _easycom_su_radio2 = common_vendor.resolveComponent("su-radio");
  const _easycom_uni_forms2 = common_vendor.resolveComponent("uni-forms");
  const _easycom_su_fixed2 = common_vendor.resolveComponent("su-fixed");
  const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  (_easycom_su_image2 + _easycom_uni_easyinput2 + _easycom_uni_forms_item2 + _easycom_su_radio2 + _easycom_uni_forms2 + _easycom_su_fixed2 + _easycom_s_layout2)();
}
const _easycom_su_image = () => "../../sheep/ui/su-image/su-image.js";
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_su_radio = () => "../../sheep/ui/su-radio/su-radio.js";
const _easycom_uni_forms = () => "../../uni_modules/uni-forms/components/uni-forms/uni-forms.js";
const _easycom_su_fixed = () => "../../sheep/ui/su-fixed/su-fixed.js";
const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js";
if (!Math) {
  (_easycom_su_image + _easycom_uni_easyinput + _easycom_uni_forms_item + _easycom_su_radio + _easycom_uni_forms + _easycom_su_fixed + _easycom_s_layout)();
}
const _sfc_main = {
  __name: "info",
  setup(__props) {
    const state = common_vendor.reactive({
      model: {},
      // 个人信息
      rules: {},
      thirdInfo: {}
      // 社交用户的信息
    });
    const sexRadioMap = [
      {
        name: "男",
        value: "1"
      },
      {
        name: "女",
        value: "2"
      }
    ];
    const userInfo = common_vendor.computed(() => sheep_index.sheep.$store("user").userInfo);
    function onChangeGender(e) {
      state.model.sex = e.detail.value;
    }
    const onChangeMobile = () => {
      sheep_hooks_useModal.showAuthModal("changeMobile");
    };
    function onChooseAvatar(e) {
      const tempUrl = e.detail.avatarUrl || "";
      uploadAvatar(tempUrl);
    }
    async function uploadAvatar(tempUrl) {
      if (!tempUrl) {
        return;
      }
      let { data } = await sheep_api_infra_file.FileApi.uploadFile(tempUrl);
      state.model.avatar = data;
    }
    function onSetPassword() {
      sheep_hooks_useModal.showAuthModal("changePassword");
    }
    async function bindThirdOauth() {
      await sheep_index.sheep.$platform.useProvider("wechat").bind();
    }
    function unBindThirdOauth() {
      common_vendor.index.showModal({
        title: "解绑提醒",
        content: "解绑后您将无法通过微信登录此账号",
        cancelText: "再想想",
        confirmText: "确定",
        success: async function(res) {
          if (!res.confirm) {
            return;
          }
          const result = await sheep_index.sheep.$platform.useProvider("wechat").unbind(state.thirdInfo.openid);
          if (result) {
            await getUserInfo();
          }
        }
      });
    }
    async function onSubmit() {
      const { code } = await sheep_api_member_user.UserApi.updateUser({
        avatar: state.model.avatar,
        nickname: state.model.nickname,
        sex: state.model.sex
      });
      if (code === 0) {
        await getUserInfo();
      }
    }
    const getUserInfo = async () => {
      const userInfo2 = await sheep_index.sheep.$store("user").getInfo();
      state.model = common_vendor.lodashExports.clone(userInfo2);
      if (sheep_index.sheep.$platform.name !== "H5") {
        let result = await sheep_index.sheep.$platform.useProvider("wechat").getInfo();
        state.thirdInfo = result || {};
      }
    };
    common_vendor.onLoad(async (options) => {
      getUserInfo();
      setTimeout(getUserInfo, 2e3);
    });
    return (_ctx, _cache) => {
      var _a, _b, _c, _d, _e;
      return common_vendor.e({
        a: common_vendor.p({
          isPreview: true,
          current: 0,
          src: (_a = state.model) == null ? void 0 : _a.avatar,
          height: 160,
          width: 160,
          radius: 80,
          mode: "scaleToFill"
        }),
        b: common_vendor.o(onChooseAvatar),
        c: common_vendor.o(($event) => state.model.nickname = $event),
        d: common_vendor.p({
          type: "nickname",
          placeholder: "设置昵称",
          inputBorder: false,
          placeholderStyle: _ctx.placeholderStyle,
          modelValue: state.model.nickname
        }),
        e: common_vendor.p({
          name: "nickname",
          label: "昵称"
        }),
        f: common_vendor.f(sexRadioMap, (item, k0, i0) => {
          var _a2;
          return {
            a: item.value,
            b: parseInt(item.value) === ((_a2 = state.model) == null ? void 0 : _a2.sex),
            c: common_vendor.t(item.name),
            d: item.value
          };
        }),
        g: common_vendor.o(onChangeGender),
        h: common_vendor.p({
          name: "sex",
          label: "性别"
        }),
        i: (_b = userInfo.value.verification) == null ? void 0 : _b.mobile
      }, ((_c = userInfo.value.verification) == null ? void 0 : _c.mobile) ? {
        j: common_vendor.p({
          modelValue: true
        })
      } : {}, {
        k: common_vendor.o(($event) => userInfo.value.mobile = $event),
        l: common_vendor.p({
          placeholder: "请绑定手机号",
          inputBorder: false,
          disabled: true,
          styles: {
            disableColor: "#fff"
          },
          placeholderStyle: _ctx.placeholderStyle,
          clearable: false,
          modelValue: userInfo.value.mobile
        }),
        m: common_vendor.o(onChangeMobile),
        n: common_vendor.p({
          name: "mobile",
          label: "手机号"
        }),
        o: (_d = userInfo.value.verification) == null ? void 0 : _d.password
      }, ((_e = userInfo.value.verification) == null ? void 0 : _e.password) ? {
        p: common_vendor.p({
          modelValue: true
        })
      } : {}, {
        q: common_vendor.o(($event) => userInfo.value.password = $event),
        r: common_vendor.p({
          placeholder: "点击修改登录密码",
          inputBorder: false,
          styles: {
            disableColor: "#fff"
          },
          disabled: true,
          placeholderStyle: "color:#BBBBBB;font-size:28rpx;line-height:normal",
          clearable: false,
          modelValue: userInfo.value.password
        }),
        s: common_vendor.o(onSetPassword),
        t: common_vendor.p({
          name: "password",
          label: "登录密码"
        }),
        v: common_vendor.p({
          model: state.model,
          rules: state.rules,
          labelPosition: "left",
          border: true
        }),
        w: common_vendor.unref(sheep_index.sheep).$platform.name !== "H5"
      }, common_vendor.unref(sheep_index.sheep).$platform.name !== "H5" ? common_vendor.e({
        x: "WechatOfficialAccount" === common_vendor.unref(sheep_index.sheep).$platform.name
      }, "WechatOfficialAccount" === common_vendor.unref(sheep_index.sheep).$platform.name ? {
        y: common_vendor.unref(sheep_index.sheep).$url.static("/static/images/WechatOfficialAccount.png")
      } : {}, {
        z: "WechatMiniProgram" === common_vendor.unref(sheep_index.sheep).$platform.name
      }, "WechatMiniProgram" === common_vendor.unref(sheep_index.sheep).$platform.name ? {
        A: common_vendor.unref(sheep_index.sheep).$url.static("/static/images/WechatMiniProgram.png")
      } : {}, {
        B: "App" === common_vendor.unref(sheep_index.sheep).$platform.name
      }, "App" === common_vendor.unref(sheep_index.sheep).$platform.name ? {
        C: common_vendor.unref(sheep_index.sheep).$url.static("/static/images/wechat.png")
      } : {}, {
        D: state.thirdInfo
      }, state.thirdInfo ? {
        E: common_vendor.unref(sheep_index.sheep).$url.cdn(state.thirdInfo.avatar),
        F: common_vendor.t(state.thirdInfo.nickname)
      } : {}, {
        G: state.thirdInfo.openid
      }, state.thirdInfo.openid ? {
        H: common_vendor.o(unBindThirdOauth)
      } : {
        I: common_vendor.o(bindThirdOauth)
      }) : {}, {
        J: common_vendor.o(onSubmit),
        K: common_vendor.p({
          bottom: true,
          placeholder: true,
          bg: "none"
        }),
        L: common_vendor.p({
          title: "用户信息"
        })
      });
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-aab93774"], ["__file", "D:/zx/mall-front-app/pages/user/info.vue"]]);
wx.createPage(MiniProgramPage);
