"use strict";
const common_vendor = require("../common/vendor.js");
const utils_request = require("../utils/request.js");
function wxLogin(loginParams) {
  var _a, _b, _c, _d, _e, _f;
  const csrfToken = common_vendor.index.getStorageSync("csrfToken");
  const requestData = {
    code: loginParams.code,
    userInfo: {
      nickname: ((_a = loginParams.userInfo) == null ? void 0 : _a.nickName) || "微信用户",
      avatarUrl: ((_b = loginParams.userInfo) == null ? void 0 : _b.avatarUrl) || "",
      gender: ((_c = loginParams.userInfo) == null ? void 0 : _c.gender) || 0,
      province: ((_d = loginParams.userInfo) == null ? void 0 : _d.province) || "",
      city: ((_e = loginParams.userInfo) == null ? void 0 : _e.city) || "",
      country: ((_f = loginParams.userInfo) == null ? void 0 : _f.country) || ""
    },
    signature: loginParams.signature || "",
    rawData: loginParams.rawData || "",
    encryptedData: loginParams.encryptedData || "",
    iv: loginParams.iv || "",
    _csrf: csrfToken
    // 添加 CSRF token
  };
  return utils_request.http.post("/wechat/wechatLogin", requestData, {
    header: {
      "X-CSRF-Token": csrfToken
    }
  });
}
const getUserInfo = (userId) => {
  const url = userId ? `/wechat/getUserDetail?id=${userId}` : "/wechat/getUserDetail";
  return utils_request.http.get(url);
};
const getUserPhoneNumber = (params) => {
  return utils_request.http.post("/wechat/getUserPhoneNumber", params);
};
const logout = () => {
  return utils_request.http.post("/api/user/logout");
};
const getJobList = (params = {}) => {
  const defaultParams = {
    page: 1,
    pageSize: 10,
    searchTerms: "",
    status: "",
    tenant_id: 1
  };
  ({ ...defaultParams, ...params });
  return utils_request.http.get("/api/job/list", defaultParams);
};
const fillUserInfo = (params) => {
  return utils_request.http.post("/api/system/wechat/save_user_info", params);
};
const getInterviewList = (params) => {
  return utils_request.http.get("/system/job/questions", params);
};
const applyJob = (params) => {
  return utils_request.http.post("/api/job/apply", params);
};
exports.applyJob = applyJob;
exports.fillUserInfo = fillUserInfo;
exports.getInterviewList = getInterviewList;
exports.getJobList = getJobList;
exports.getUserInfo = getUserInfo;
exports.getUserPhoneNumber = getUserPhoneNumber;
exports.logout = logout;
exports.wxLogin = wxLogin;
