import axios from 'axios'

var validatePhoneUrl = process.env.VUE_APP_BASE_API + "/sys/user/checkPhone"
var validateUserNameUrl = process.env.VUE_APP_BASE_API + "/sys/user/checkAccount"


/**
 * 验证电话是否重复
 * @param data
 * @returns {Promise}
 */
export function checkPhone(data) {
  return new Promise((resolve, reject) => {
    axios.post(validatePhoneUrl, data).then(response => {
      resolve(response.data)
    }).catch(error => {
      reject(error)
    })
  })
}

/**
 * 验证用户名是否重复
 * @param data
 * @returns {Promise}
 */
 export function checkUserName(data) {
    return new Promise((resolve, reject) => {
      axios.post(validateUserNameUrl, data, {
        headers: {
          'Content-Type': 'multipart/form-data;boundary = ' + new Date().getTime(),
        }
      }).then(response => {
        resolve(response.data)
      }).catch(error => {
        reject(error)
      })
    })
  }
  
  