const uploadTask = uni.uploadFile({
url: aaa, //开发者服务器 url
filePath: filePath, //要上传文件资源的路径
name: 'file', //必须填file
})
uploadTask.onProgressUpdate((res) => {
this.updata = res
// console.log(res.totalBytesSent + '/' + res.totalBytesExpectedToSend)
console.log('上传进度' + res.progress);
console.log('已经上传的数据长度' + res.totalBytesSent);
console.log('预期需要上传的数据总长度' + res.totalBytesExpectedToSend);
//回调中打印一下时间戳
let a = res.totalBytesSent
let b = res.totalBytesExpectedToSend
that.per = ((a / b) * 100).toFixed(0)
console.log("per " + that.per + "time " + new Date().toLocaleString())
});