import request from '@/router/axios';
/*
**忘记密码
/

/*图形验证码*/
export const getCaptcha = () => request({
  url: '/api/jobslink-api/system/front/account/captcha',
  method: 'get'
});

/*发送短信验证码*/
export const sendCodeFgt = (form) => {
  return request({
    url: '/api/jobslink-api/system/front/account/sendValidate',
    method: 'get',
    headers: {
      'Captcha-Key': form.key,
      'Captcha-Code': form.imgCode
    },
    params: {
      mobile: form.phone
    }
  })
}

/*提交忘记密码*/
export const forgetPwd = (phone, code, password, authType) => {
  return request({
    headers: {
      'SCaptcha-Key': phone,
      'SCaptcha-Code': code
    },
    url: '/api/jobslink-api/system/front/account/password',
    method: 'post',
    params: {
      mobile: phone,
      password,
      authType
    }
  })
}


/*
**账户安全
/

/*变更负责人*/
export const changeLeader = (form, id) => {
  return request({
    headers: {
      'SCaptcha-Key': form.phone,
      'SCaptcha-Code': form.code
    },
    url: '/api/jobslink-api/system/tuser/updateAdmin',
    method: 'post',
    data: {
      realName: form.realName,
      idNumber: form.idNumber,
      account: form.phone,
      id: id
    }
  })
}

/*修改密码*/
export const changePwd = (oldPassword, newPassword, newPassword1) => {
  return request({
    url: '/api/jobslink-api/system/tuser/update-password',
    method: 'post',
    params: {
      oldPassword,
      newPassword,
      newPassword1,
    }
  })
}

/*获取账户信息*/
export const getAccount = () => {
  return request({
    url: '/api/jobslink-api/system/tuser/info',
    method: 'get'
  })
}


/*获取是否是管理员*/
export const getIsAdmin = () => {
  return request({
    url: '/api/jobslink-api/system/tuser/isAdmin',
    method: 'get'
  })
}

/*发送验证码*/
export const sendCode = (mobile) => {
  return request({
    url: '/api/jobslink-api/system/tuser/sendValidate',
    method: 'get',
    params: {
      mobile
    }
  })
}

/*换绑手机号*/
export const changePhone = (form, id) => {
  return request({
    headers: {
      'SCaptcha-Key': form.newPhone,
      'SCaptcha-Code': form.code
    },
    url: '/api/jobslink-api/system/tuser/updateAccount',
    method: 'post',
    data: {
      account: form.newPhone,
      id: id
    }
  })
}
