|
@@ -115,7 +115,7 @@ export default {
|
|
|
objectPath: "", // 用于上传文件的传参
|
|
|
isUploading: false,
|
|
|
uploadUrl: this.$api.common.uploadProcessBar,
|
|
|
- timer: "", // 用来接收进度条的定时器
|
|
|
+ timer: null, // 用来接收进度条的定时器
|
|
|
percentage: 0, // 进度条数据
|
|
|
customColor: "", // 进度条颜色
|
|
|
};
|
|
@@ -170,10 +170,9 @@ export default {
|
|
|
objectPath: this.objectPath,
|
|
|
},
|
|
|
}).then((res) => {
|
|
|
- // console.log(res);
|
|
|
if (res.code == 200 && res.info) {
|
|
|
console.log(res.info);
|
|
|
-
|
|
|
+
|
|
|
if (this.percentage >= res.info * 100) {
|
|
|
if (this.percentage < 99) {
|
|
|
++this.percentage;
|
|
@@ -190,7 +189,9 @@ export default {
|
|
|
|
|
|
if (!this.isUploading) {
|
|
|
clearInterval(this.timer);
|
|
|
+ this.timer = null;
|
|
|
this.percentage = 0;
|
|
|
+ this.objectPath = this.$getObjectPathByRandom();
|
|
|
}
|
|
|
} else {
|
|
|
this.$message.error(res.message || "获取进度信息失败");
|
|
@@ -200,24 +201,16 @@ export default {
|
|
|
willUpload() {
|
|
|
this.isUploading = true;
|
|
|
|
|
|
- // let timer = setTimeout(() => {
|
|
|
- // this.isUploading = true;
|
|
|
- // this.onProgress();
|
|
|
- // clearTimeout(timer);
|
|
|
- // }, 100);
|
|
|
-
|
|
|
this.timer = setInterval(() => {
|
|
|
this.onProgress();
|
|
|
- if (!this.isUploading) {
|
|
|
- clearInterval(this.timer);
|
|
|
- this.percentage = 0;
|
|
|
- }
|
|
|
}, 4500);
|
|
|
},
|
|
|
didUpload(state) {
|
|
|
this.isUploading = false;
|
|
|
clearInterval(this.timer);
|
|
|
+ this.timer = null;
|
|
|
this.percentage = 0;
|
|
|
+ this.objectPath = this.$getObjectPathByRandom();
|
|
|
},
|
|
|
},
|
|
|
|
|
@@ -245,6 +238,11 @@ export default {
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
+ beforeDestroy() {
|
|
|
+ clearInterval(this.timer);
|
|
|
+ this.timer = null;
|
|
|
+ }
|
|
|
};
|
|
|
</script>
|
|
|
|