11wqe1 3 months ago
parent
commit
a4bf72e452
1 changed files with 49 additions and 199 deletions
  1. 49 199
      src/components/components/choseWorksDetailDialog.vue

+ 49 - 199
src/components/components/choseWorksDetailDialog.vue

@@ -720,7 +720,10 @@
 													</span>
 												</span>
                         
-
+                        <div class="answerSelect "  v-if="[57].includes(toolType)">
+                          <!-- <img style="width: 300px;" src="../../assets/icon/word2.png" /> -->
+                           <div style="width: 100%;height: 110px;text-align: center;line-height: 110px;">点击打开CocoPi</div>
+												</div>
                         <div class="answerSelect" v-if="[4].includes(toolType)">
 													<span v-for="(item2,index2) in JSON.parse(item.works)[0].anwer" 
                           :key="index2" 
@@ -1343,8 +1346,8 @@ export default {
                 " html2canvas(document.body,{allowTaint: true,useCORS: true,height: document.body.scrollHeight,windowHeight: document.body.scrollHeight}).then(canvas => {\n" +
                 '  var base64Url = canvas.toDataURL("image/png");\n' +
                 'var base64 = "<img src=" + base64Url + " />"\n' +
-                'var file = this.dataURLtoFile_shishi(base64Url, "截图")\n' +
-                "this.beforeUpload_shishi(file," +
+                'var file = dataURLtoFile_shishi(base64Url, "截图")\n' +
+                "beforeUpload_shishi(file," +
                 "'" +
                 this.userId +
                 "'" +
@@ -1362,11 +1365,11 @@ export default {
                 "'" +
                 ", " +
                 "'" +
-                this.toolType +
+                this.toolIndex +
                 "'" +
                 ", " +
                 "'" +
-                (str + '_loadLi_JieE' + this.courseId + this.courseType + this.taskCount + this.toolType + this.userId) +
+                (str + '_loadLi_JieE' + this.courseId + this.courseType + this.taskCount + this.toolIndex + this.userId) +
                 "'" +
                 ", " +
                 "'" +
@@ -1383,186 +1386,7 @@ export default {
                 iframeWindow.document.head.appendChild(_ajs);
                 console.log('66666');
     },
-    // 截图
-    dataURLtoFile_shishi(dataurl, filename) {
-      let arr = dataurl.split(","),
-        mime = arr[0].match(/:(.*?);/)[1],
-        bstr = atob(arr[1]),
-        n = bstr.length,
-        u8arr = new Uint8Array(n);
-      while (n--) {
-        u8arr[n] = bstr.charCodeAt(n);
-      }
-      return new File([u8arr], filename, {
-        type: mime
-      });
-    },
-    // 上传截图 
-    beforeUpload_shishi(nfile, uid, cid, stage, task, tool, loading, atool, text) {
-      // loading.style.display = 'flex'
-      // top.document.getElementById(loading);
-      //  document.body.appendChild(_loading)
-      var file = nfile;
-      var credentials = {
-        accessKeyId: "AKIATLPEDU37QV5CHLMH",
-        secretAccessKey: "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",
-      }; //秘钥形式的登录上传
-      window.AWS.config.update(credentials);
-      window.AWS.config.region = "cn-northwest-1"; //设置区域
-
-      var bucket = new window.AWS.S3({
-        params: {
-          Bucket: "ccrb"
-        }
-      }); //选择桶
-
-      if (file) {
-        var params = {
-          Key: file.name.split(".")[0] + new Date().getTime() + "." + "png",
-          ContentType: file.type,
-          Body: file,
-          "Access-Control-Allow-Credentials": "*",
-          ACL: "public-read",
-        }; //key可以设置为桶的相抵路径,Body为文件, ACL最好要设置
-        var options = {
-          partSize: 2048 * 1024 * 1024,
-          queueSize: 2,
-          leavePartsOnError: true,
-        };
-        bucket.upload(params, options)
-          .on("httpUploadProgress", function (evt) {
-            //这里可以写进度条
-            // console.log("Uploaded : " + parseInt((evt.loaded * 80) / evt.total) + '%');
-          }).send(function (err, data) {
-            if (data) {
-              console.log(data.Location);
-              var a = {
-                name: file.name,
-                url: data.Location,
-                uid: file.uid,
-              }
-              addSWork_shishi(uid, cid, stage, task, tool, data.Location, loading, atool, text)
-            } else {
-              var _a = document.getElementsByTagName("img")
-              for (var i = 0; i < _a.length; i++) {
-                _a[i].removeAttribute("crossorigin")
-              }
-              top.document.getElementById(loading).children[0].style.display = "none"
-              let _div = document.createElement('div')
-              _div.style = "width:100%;height:100%;background:#0000008f;position:fixed;top:0;left:0;z-index:99999999999999;display: flex;justify-content: center;align-items: center;"
-              let _inner = document.createElement('div')
-              _inner.style = "color: #fff;padding: 15px;background: #00000070;border-radius: 5px;font-size: 18px;"
-              _inner.innerHTML = "上传失败,网络错误"
-              _div.appendChild(_inner)
-              document.body.appendChild(_div)
-              setTimeout(() => {
-                document.body.removeChild(_div)
-              }, 1000);
-            }
-
-          });
-      }
-    },
-    // beforeUpload(event) {
-     
-    //     var file = event;
-        
-    //     var credentials = {
-    //       accessKeyId: "AKIATLPEDU37QV5CHLMH",
-    //       secretAccessKey: "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"
-    //     }; //秘钥形式的登录上传
-    //     window.AWS.config.update(credentials);
-    //     window.AWS.config.region = "cn-northwest-1"; //设置区域
-
-    //     var bucket = new window.AWS.S3({ params: { Bucket: "ccrb" } }); //选择桶
-    //     var imgA = [
-    //       "png",
-    //       "jpg",
-    //       "jpeg",
-    //       "bmp",
-    //       "gif",
-    //       "webp",
-    //       "psd",
-    //       "svg",
-    //       "tiff"
-    //     ];
-    //     var _this = this;
-      
-    //     _this.$forceUpdate();
-
-    //     if (file) {
-    //       var params = {
-    //         Key:
-    //           file.name.split(".")[0] +
-    //           new Date().getTime() +
-    //           "." +
-    //           file.name.split(".")[file.name.split(".").length - 1],
-    //         ContentType: file.type,
-    //         Body: file,
-    //         "Access-Control-Allow-Credentials": "*",
-    //         ACL: "public-read"
-    //       }; //key可以设置为桶的相抵路径,Body为文件, ACL最好要设置
-    //       var options = {
-    //         partSize: 2048 * 1024 * 1024,
-    //         queueSize: 2,
-    //         leavePartsOnError: true
-    //       };
-    //       bucket
-    //         .upload(params, options)
-    //         .on("httpUploadProgress", function(evt) {
-    //           //这里可以写进度条
-    //           // _this.progress = parseInt((evt.loaded / evt.total) * 100);
-    //           // _this.isFinishSize = (evt.loaded / 1024 / 1024).toFixed(2);
-    //           // _this.$forceUpdate();
-    //         })
-    //         .send(function(err, data) {
-    //             console.log(data.Location);
-
-    //           _this.questionsData = data.Location
-    //           _this.submitWork2()
-    //         });
-    //     }
-    //   // var file = event.target.files[0];
-    // },
-    // submitWork2(){
-    //   let yym = ''
-    //   if (this.toolType == 1) {
-    //     yym = []
-    //   }else if (this.toolType == 3) {
-    //     yym = {}
-    //   }
-
-    //   let params = [
-    //     {
-    //       uid: this.userId,
-    //       cid: this.id,
-    //       stage: this.courseType,
-    //       task: this.taskCount,
-    //       tool: this.toolIndex,
-    //       content: this.questionsData,
-    //       type: 1,
-    //       atool: this.toolType,
-    //       text: yym
-    //     },
-    //   ];
-    //   this.ajax
-    //       .post(this.$store.state.api + addCourseWorks4, params)
-    //       .then((res) => {
-    //         this.$message({
-    //           message: "提交成功",
-    //           type: "success",
-    //         });
-    //         // this.askList = [];
-    //         this.$emit("selectStudent")
-    //         this.$emit("selectSWorks")
-    //         this.$emit("selectSLook")
-    //       })
-    //       .catch((err) => {
-    //         this.$message.error("提交失败");
-    //         console.error(err);
-    //       });
-      
-    // },
+   
     // 提交作业
     submitWork(){
       // 选择题提交
@@ -1755,6 +1579,28 @@ export default {
       this.dialogVisibleWordCloud = true
     },
     StudentWork(item){
+      console.log('item',item);
+      
+      if (this.toolType == 57) {
+        console.log('666666');
+        
+       let student = {
+            userid: item.userid,
+            student: item.sName
+          };
+          window.parent.postMessage(
+            {
+              tools: this.toolType + "teacher",
+              cid: this.id,
+              stage: this.courseType,
+              task: this.taskCount,
+              tool: this.toolIndex,
+              student: student
+            },
+            "*"
+          );
+        return
+      }
 
       this.$refs.studentWorkPreviewDialogRef.open({work:item,testData:this.testData,testJson:this.testJson,tool:this.toolType});
       this.$emit("changeSplitScreenBehavior",{code: 1,
@@ -2006,6 +1852,7 @@ export default {
                   "https://cloud.cocorobo.cn/js/Common/jquery-3.6.0.min.js",
                   "https://cloud.cocorobo.cn/js/Common/aws-sdk-2.235.1.min.js",
                   "https://cloud.cocorobo.cn/js/Common/html2canvas.min.js",
+                  "https://cloud.cocorobo.cn/js/Common/jietu2.js"
                 ];
                 scripts.forEach(src => {
                   const script = document.createElement("script");
@@ -2039,6 +1886,7 @@ export default {
                   "https://cloud.cocorobo.cn/js/Common/jquery-3.6.0.min.js",
                   "https://cloud.cocorobo.cn/js/Common/aws-sdk-2.235.1.min.js",
                   "https://cloud.cocorobo.cn/js/Common/html2canvas.min.js",
+                  "https://cloud.cocorobo.cn/js/Common/jietu2.js"
                 ];
                 scripts.forEach(src => {
                   const script = document.createElement("script");
@@ -2052,21 +1900,22 @@ export default {
         })
 			}else if([57].includes(this.toolType)){
 
-        let _iframe = this.$refs.iframeWhiteBoardRef;
-        _iframe.onload = () =>{
+        // let _iframe = this.$refs.iframeWhiteBoardRef;
+        // _iframe.onload = () =>{
           console.log("CocoPiiframe加载数据👈")
-          // _iframe.contentWindow.h.app.updateScene({elements:JSON.parse(_data[0].text)})
-          const scripts = [
-            "https://cloud.cocorobo.cn/js/Common/jquery-3.6.0.min.js",
-            "https://cloud.cocorobo.cn/js/Common/aws-sdk-2.235.1.min.js",
-            "https://cloud.cocorobo.cn/js/Common/html2canvas.min.js",
-          ];
-          scripts.forEach(src => {
-            const script = document.createElement("script");
-            script.src = src;
-            _iframe.contentWindow.document.body.appendChild(script);
-          });
-        }
+        //   // _iframe.contentWindow.h.app.updateScene({elements:JSON.parse(_data[0].text)})
+        //   const scripts = [
+        //     "https://cloud.cocorobo.cn/js/Common/jquery-3.6.0.min.js",
+        //     "https://cloud.cocorobo.cn/js/Common/aws-sdk-2.235.1.min.js",
+        //     "https://cloud.cocorobo.cn/js/Common/html2canvas.min.js",
+        //     "https://cloud.cocorobo.cn/js/Common/jietu2.js"
+        //   ];
+        //   scripts.forEach(src => {
+        //     const script = document.createElement("script");
+        //     script.src = src;
+        //     _iframe.contentWindow.document.body.appendChild(script);
+        //   });
+        // }
 			}else if([7].includes(this.toolType)){
         console.log("思维网格")
         let _iframe = this.$refs.iframeWhiteBoardRef;
@@ -2077,6 +1926,7 @@ export default {
             "https://cloud.cocorobo.cn/js/Common/jquery-3.6.0.min.js",
             "https://cloud.cocorobo.cn/js/Common/aws-sdk-2.235.1.min.js",
             "https://cloud.cocorobo.cn/js/Common/html2canvas.min.js",
+            "https://cloud.cocorobo.cn/js/Common/jietu2.js"
           ];
           scripts.forEach(src => {
             const script = document.createElement("script");