"use strict";
const common_vendor = require("../../common/vendor.js");
const utils_api = require("../../utils/api.js");
const _sfc_main = {
  __name: "index",
  setup(__props) {
    common_vendor.onLoad(() => {
      common_vendor.index.login({
        success: (res) => {
          vertify(res.code);
        }
      });
    });
    const vertify = async (code) => {
      const res = await utils_api.myRequest({
        url: "/wanzai/api/wechat/vertify",
        data: {
          code
        }
      });
      if (res.code == 200) {
        common_vendor.index.setStorageSync("token", JSON.parse(res.message).token);
        common_vendor.index.setStorageSync("userhead", JSON.parse(res.message).userhead);
        common_vendor.index.setStorageSync("userInfo", JSON.parse(res.message).user[0]);
        common_vendor.index.redirectTo({
          url: "/pages/home/home"
        });
      } else {
        common_vendor.index.redirectTo({
          url: "/pages/login/login"
        });
      }
    };
    return (_ctx, _cache) => {
      return {};
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-1cf27b2a"], ["__file", "E:/workSpace/WanZai_School_app/pages/index/index.vue"]]);
wx.createPage(MiniProgramPage);
