上传文件到服务器 调用uploadFile()方法
请求相关后台api需要在请求头中设置authorization进行授权
static uploadFile (filePath) {
if (this.isWx) {
return new Promise((resolve, reject) => {
wx.uploadFile({
url: config.baseURL + 'bc/v1/storage',
filePath,
header: {
authorization: this.getStorageSync(`token`)
},
name: 'file',
success (res) {
resolve(JSON.parse(res.data))
},
fail (err) {
reject(err)
}
})
})
}
}