"use strict";
const common_vendor = require("../common/vendor.js");
const utils_api = require("../utils/api.js");
if (!Array) {
  const _easycom_wd_popup2 = common_vendor.resolveComponent("wd-popup");
  _easycom_wd_popup2();
}
const _easycom_wd_popup = () => "../uni_modules/wot-design-uni/components/wd-popup/wd-popup.js";
if (!Math) {
  _easycom_wd_popup();
}
const _sfc_main = /* @__PURE__ */ Object.assign({
  options: {
    styleIsolation: "shared"
  }
}, {
  __name: "AuthorizePopup",
  props: {
    show: {
      type: Boolean,
      default: false
    }
  },
  emits: ["update:show", "close"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emits = __emit;
    const localShow = common_vendor.ref(props.show);
    const info = common_vendor.ref({
      nickname: "微信用户",
      code1: "",
      code2: ""
    });
    common_vendor.watch(
      () => props.show,
      (val) => {
        localShow.value = val;
      }
    );
    common_vendor.watch(localShow, (val) => {
      if (val !== props.show) {
        emits("update:show", val);
      }
    });
    common_vendor.ref(false);
    function getPhoneNumber(e) {
      if (e.detail.code) {
        info.value.code2 = e.detail.code;
        common_vendor.index.login({
          provider: "weixin",
          success: (loginRes) => {
            if (loginRes.code) {
              info.value.code1 = loginRes.code;
              authorize();
            }
          }
        });
      }
    }
    const authorize = async () => {
      const res = await utils_api.myRequest({
        url: "/tAppgetOpenid.action",
        data: info.value
      });
      if (res.code == 200) {
        common_vendor.index.setStorageSync("carUserInfo", res.data);
        emits("close", true);
      }
    };
    return (_ctx, _cache) => {
      return {
        a: common_vendor.o(getPhoneNumber),
        b: common_vendor.o(($event) => emits("close", false)),
        c: common_vendor.o(($event) => localShow.value = $event),
        d: common_vendor.p({
          position: "bottom",
          closable: true,
          ["safe-area-inset-bottom"]: true,
          ["custom-class"]: "popup-wrapper-auth",
          modelValue: localShow.value
        })
      };
    };
  }
});
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-5380cac8"], ["__file", "D:/创海项目/CH2025/约车小程序/yueche_app/components/AuthorizePopup.vue"]]);
wx.createComponent(Component);
