Browse Source

截图上传

zengyicheng 2 years ago
parent
commit
26d7815e8d
1 changed files with 13 additions and 18 deletions
  1. 13 18
      src/components/liveProjectDetail.vue

+ 13 - 18
src/components/liveProjectDetail.vue

@@ -1009,11 +1009,7 @@ export default {
       this.noneBtnImg = _tmp.length >= 1;
     },
     beforeUpload1(event, type) {
-      if (type == 100) {
-        var file = event;
-      } else {
-        var file = event.target.files[0];
-      }
+      var file = event.target.files[0];
       var credentials = {
         accessKeyId: "AKIATLPEDU37QV5CHLMH",
         secretAccessKey: "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",
@@ -1074,13 +1070,6 @@ export default {
                   uid: file.uid,
                 });
                 _this.imgChange(null, null, type);
-              } else if (type == 100) {
-                _this.imgFileUp.push({
-                  name: file.name,
-                  url: data.Location,
-                  uid: file.uid,
-                });
-                _this.imgChange(null, null, type);
               }
               console.log(data.Location);
             }
@@ -1177,17 +1166,22 @@ export default {
       let params = {
         uid: this.userid,
         cid: this.cid,
-        upload: JSON.stringify(this.upload),
+        // upload: JSON.stringify(this.upload),
+        upload: JSON.stringify(this.imgFileUp),
       };
       this.ajax
         .get(this.$store.state.api + "insertSWork", params)
         .then((res) => {
-          this.isNoHomeWork = true;
+          // this.isNoHomeWork = true;
           this.dialogVisible = true;
-          this.selectSWork(); // this.upload = res.data[0][0].upload;
+          // this.selectSWork(); // this.upload = res.data[0][0].upload;
+          this.$message({
+            message: "截图上传成功",
+            type: "success",
+          });
         })
         .catch((err) => {
-          this.$message.error("提交失败");
+          this.$message.error("截图上传失败");
           console.error(err);
         });
     },
@@ -1218,7 +1212,7 @@ export default {
       } else if (this.toolsList[0].tools[this.howTools] == 7) {
         iframeHtml = this.$refs.grid;
       }
-      iframeBody = iframeHtml.contentWindow.docunment.body;
+      iframeBody = iframeHtml.contentWindow.document.body;
       // 第一个参数是需要生成截图的元素,第二个是自己需要配置的参数,宽高等
       html2canvas(iframeBody, {
         backgroundColor: null, //画出来的图片有白色的边框,不要可设置背景为透明色(null)
@@ -1236,6 +1230,7 @@ export default {
         let file = this.dataURLtoFile(url, "作业");
         this.imgFile = file;
         this.beforeUpload2(this.imgFile);
+        this.addSWork();
         console.log(this.imgFile);
       });
     },
@@ -1318,7 +1313,7 @@ export default {
     this.timer = null;
   },
   created() {
-    this.selectSWork();
+    // this.selectSWork();
     let _this = this;
     this.timer = setInterval(() => {
       _this.setPage();