Open mianmalife opened 4 years ago
uploadTao = (info) => { let that = this; const data = new FormData() data.append('file', info.file) axios({ url: `http://47.92.xx.xx/upload?merchant=${this.state.merchantNum}&user=${this.state.operator_name}&data_type=2`, method: 'post', headers: { "Content-type": 'multipat/form-data' }, data: data, onUploadProgress: function (progressEvent) { //原生获取上传进度的事件 if (progressEvent.lengthComputable) { //属性lengthComputable主要表明总共需要完成的工作量和已经完成的工作是否可以被测量 //如果lengthComputable为false,就获取不到progressEvent.total和progressEvent.loaded let percent = Math.floor((progressEvent.loaded / progressEvent.total) * 100); that.setState({ progressone: percent }); } } }).then(res => { if (res.data.code == 0) { this.setState({ uploadStatusTaobao: false, uploadAfter: true, initStatus: false, upload_task_id: res.data.upload_task_id, }) message.info('上传成功') } }).catch(error => { console.log(error) }) }