import {
  apiUrl
} from "../apis/apiConfig"

function uploadFile(filePath, formData, type) {
  return new Promise((resolve, reject) => {
    wx.uploadFile({
      url: `${apiUrl}${type?"/user/wx/oneStepLogin":"/cos/upload"}`,
      filePath,
      name: 'file',
      formData,
      success: e => {
        resolve(JSON.parse(e.data))
      },
      fail: reject
    })
  })
}

module.exports = {
  uploadFile
}