import axios from 'axios';
import config from './config.js';

axios.default.timeout = 5000;
axios.defaults.headers.post['Content-Type'] = "application/json;charset=utf-8";

const urls = config.urls;
export default {
  getImgCode() {//获取图片验证码
    return axios.post(urls.getImgVerification, {})
  },
  vertifyImgCode(data) {//校验图片验证码
    return axios.post(
      urls.verifyImgVerification,
      {
        'code': data.imgCode,
        'imgId': data.imgId
      }
    )
  },
  loginMess(data) {
    return axios.post(urls.login,
      {
        'username': data.username,
        'password': data.password
      }
    )
  },
  checkTel(data){//注册
    return axios.post(urls.checkTel,{
      'username':data
    })
  },
  checkForgetTel(data){//忘记密码
    return axios.post(urls.checkForgetTel,{
      'username':data
    })
  },
  getMobileCode(data) {//获取短信验证码
    return axios.post(
      urls.getSmsWithRegister,
      {
        'code': data.imgCode,
        'imgId': data.imgId,
        'mobile': data.mobile
      }
    )
  },
  vertifyMobileCode(data) {//验证短信验证码
    return axios.post(
      urls.verifySmsVerification,
      {
        'code': data.imgCode,
        'imgId': data.imgId,
        'mobile': data.mobile,
        'smsCode': data.smsCode
      }
    )
  },
  regidtry(data) {//注册
    return axios.post(
      urls.registry,
      {
        "code": data.code,
        "email": data.email,
        "gmtCreate": '',
        "gmtModified": '',
        "id": 0,
        "imgId": data.imgId,
        "isDeleted": '',
        "linkman": data.linkman,
        "modifier": '',
        "organization": data.organization,
        "password": data.password,
        "username": data.username
      }
    )
  },

  /**************************找回密码****************************/

  forgetPswGetMobileCode(data) {//忘记密码获取短信验证码
    return axios.post(
      urls.getSmsWithResetPassword,
      {
        'code': data.imgCode,
        'imgId': data.imgId,
        'mobile': data.mobile
      }
    )
  },
  resetPsw(data) {
    return axios.post(
      urls.resetPassword,
      {
        'password': data.password,
        'username': data.username,
        'diffPassword':data.diffPassword
      }
    )
  },
  getAccessdMenu() {
    return axios.post(urls.getAccessdMenu);
  },
  getUserEnumsData() {
    return axios.post(urls.getUserEnumsData);
  }
}