"use strict";
const common_vendor = require("../../common/vendor.js");
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  __name: "index",
  setup(__props) {
    var _a;
    const $api = (_a = common_vendor.getCurrentInstance()) == null ? void 0 : _a.appContext.config.globalProperties.$api;
    const openid = common_vendor.computed(() => {
      return common_vendor.index.getStorageSync("openid");
    });
    const agree = common_vendor.ref(false);
    const otherLogin = () => {
      if (agree.value) {
        if (openid.value) {
          common_vendor.index.getUserProfile({
            desc: "用于展示",
            success: async function(res) {
              let parmas = {
                openid: openid.value,
                nickname: res.userInfo.nickName + common_vendor.hooks().valueOf()
              };
              const arr = await $api(`/user`, "POST", parmas);
              if (arr.errcode == "0") {
                common_vendor.index.setStorageSync("user", arr.data);
                common_vendor.index.navigateBack({
                  delta: 1
                });
              } else {
                common_vendor.index.showToast({
                  title: arr.errmsg,
                  icon: "error"
                });
              }
            },
            fail: function(err) {
              console.log(err);
            }
          });
        } else {
          common_vendor.index.showToast({
            title: "系统更新中，请稍后再试!",
            icon: "none"
          });
        }
      } else {
        common_vendor.index.showToast({
          title: "请阅读并同意用户协议和隐私政策",
          icon: "none"
        });
      }
    };
    const toAgree = () => {
      common_vendor.index.navigateTo({
        url: `/pagesHome/agree/index`
      });
    };
    const changeAgree = () => {
      agree.value = !agree.value;
    };
    return (_ctx, _cache) => {
      return {
        a: common_vendor.o(($event) => otherLogin()),
        b: agree.value,
        c: common_vendor.o(($event) => toAgree()),
        d: common_vendor.o(changeAgree)
      };
    };
  }
});
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-7c2cfec5"], ["__file", "D:/project/赋强公证/notarization_applet/pagesHome/login/index.vue"]]);
wx.createPage(MiniProgramPage);
