import R from '@/utils/request'

import store from '@/store'
import Axios from 'axios'

const axios = Axios.create({
  timeout: 30000,
  baseURL: process.env.VUE_APP_BASE_URL
})

export async function $verifyCode (data) {
  return await R({ url: 'message/verify_code/send', data })
}

export async function $uploadFile (data, type) {
  const fd = new FormData()
  const headers = {
    'Content-Type': 'multipart/form-data',
    Authorization: 'Bearer ' + store.getters.mwxtoken,
    Identifier: store.getters.mwxidntf
  }
  if (type === 'rotate') {
    fd.append('file', data)
  } else {
    fd.append('file', data.file)
  }
  return axios.post('message/upload/file', fd, { headers: headers })
}
