import request from "@/utils/request";
let { api, mpApi } = process.env.CONFIG;

/**查询版本号 */
export async function getVersions() {
  return request({ url: mpApi + "/erp/config/sysVersion/versions.wechat" })
}
/**获取钉钉扫码前的后台KEY*/
export async function getDingKey() {
  return request({ url: mpApi + "/erp/user/dLoginState" })
}
/**钉钉登录*/
export async function ddlogin(params: { code: string; stateKey: string | null; state: string; }) {
  let { code, stateKey, state } = params;
  return request({
    url: mpApi + `/erp/user/dLogin?code=${code}&stateKey=${stateKey}&state=${state}`,
    method: "POST"
  })
}
// 选择公司
export async function selectCompanyApi(companyId: number) {
  return request({
    url: mpApi + `/erp/user/chooseCompany/${companyId}`,
    method: "PUT"
  })
}
// 手机验证码获取
export async function getCode(phone: string) {
  return request({ url: mpApi + `/erp/user/dCodeLoginState/${phone}` })
}

// 手机登录
export async function phoneLogin(data: { phone: string; code: string }) {
  return request({
    url: mpApi + `/erp/user/dCodeLogin`,
    method: "POST",
    data
  })
}

// 邮箱code
export async function getEmailNoteCodeApi(email: string) {
  return request(mpApi + `/erp/user/emailCodeLoginState/${email}`)
}

// 邮箱登录
export async function emailLoginApi(params: { email: string, code: string }) {
  return request(mpApi + `/erp/user/emailCodeLogin`, {
    method: 'POST',
    data: params
  })
}

// 手机短信验证码获取
export async function getNoteCode(phone: string) {
  return request({ url: mpApi + `/erp/user/smsCodeLoginState/${phone}` })
}


/**
 * 投手列表
 * @returns 
 */
export async function getSubUserWithSelfListApi() {
  return request(api + '/erp/user/subUserWithSelf');
}


/**
 * 所有用户
 * @returns 
 */
export async function getUserAllListApi() {
  return request(api + '/erp/user/all');
}