uploadFile(file,token,key) {
let that = this
const uploadTask = wx.uploadFile({
url: `https://up-z2.qiniup.com`,
filePath: file,
name: 'file',
formData: {
key: key,
token: token,
},
success(res) {
const data = JSON.parse(res.data);
const imgSrc = that.data.domain + data.key
that.updateUser(data.key)
console.log('上传成功',data);
},
fail(err) {
console.log('上传失败',err)
}
})
uploadTask.onProgressUpdate((res) => {
if(res.progress < 100){
wx.showLoading({
title: `上传中 ${res.progress}%`,
});
} else if (res.progress == 100){
wx.showToast({
title: '完成',
icon: 'success'
});
}
})
},
