Prechádzať zdrojové kódy

生成微信小程序二维码

Michael Wang 5 rokov pred
rodič
commit
cc4a41b94c

+ 1 - 1
.env.development

@@ -1,4 +1,4 @@
 VUE_APP_TK_SERVER_HTML_URL=http://192.168.10.39:5220
 VUE_APP_TK_SERVER_API_URL=http://192.168.10.39:8008
 VUE_APP_WK_SERVER_SOCKET=wss://ecs-dev.qmth.com.cn:8878/oewebsocket/
-VUE_APP_WK_SERVER_SOCKET_FOR_AUDIO=wss://ecs-dev.qmth.com.cn:8878/oewebsocket/audioAnswer/
+VUE_APP_WK_SERVER_SOCKET_FOR_AUDIO=wss://ecs-dev.qmth.com.cn:8878/oewebsocket/fileAnswer/

+ 1 - 1
.env.production

@@ -1,5 +1,5 @@
 VUE_APP_TK_SERVER_HTML_URL=http://ecs.qmth.com.cn
 VUE_APP_TK_SERVER_API_URL=http://ecs.qmth.com.cn
 VUE_APP_WK_SERVER_SOCKET=wss://ecs.qmth.com.cn:8878/oewebsocket/
-VUE_APP_WK_SERVER_SOCKET_FOR_AUDIO=wss://ecs.qmth.com.cn:8878/oewebsocket/audioAnswer/
+VUE_APP_WK_SERVER_SOCKET_FOR_AUDIO=wss://ecs.qmth.com.cn:8878/oewebsocket/fileAnswer/
 VUE_APP_GIT_REPO_VERSION=TO_BE_OVERRIDED

+ 25 - 8
src/features/OnlineExam/Examing/ExamingHome.vue

@@ -269,6 +269,7 @@ export default {
       "toggleSnapNow",
       "updateExamResult",
       "resetExamQuestionDirty",
+      "updatePicture",
     ]),
     async initData() {
       const [
@@ -390,7 +391,12 @@ export default {
       });
       // console.log(examQuestionList);
       // console.log(examQuestionList.find(v => v.answerType === "SINGLE_AUDIO"));
-      if (examQuestionList.find(v => v.answerType === "SINGLE_AUDIO")) {
+
+      const shouldOpenWS =
+        examQuestionList.find(v => v.answerType === "SINGLE_AUDIO") ||
+        this.$store.state.user.schoolDomain === "iepcc-ps.ecs.qmth.com.cn";
+
+      if (shouldOpenWS) {
         // console.log("have single");
         const examRecordDataId = this.$route.params.examRecordDataId;
         openWS({ examRecordDataId });
@@ -642,30 +648,41 @@ export default {
       const that = this;
       for (const q of value) {
         if (!q.saved) {
+          let acknowledgeStatus = "CONFIRMED";
+          if (q.order != this.$route.params.order) {
+            acknowledgeStatus = "DISCARDED";
+          }
           this.$http
             .post(
-              "/api/ecs_oe_student/examControl/confirmAudioUploadSaveStatus",
+              "/api/ecs_oe_student/examControl/saveUploadedFileAcknowledgeStatus",
               {
                 examRecordDataId,
                 filePath: q.audioFileUrl,
                 order: q.order,
+                acknowledgeStatus,
               }
             )
             .then(() => {
-              that.updateExamQuestion({
-                order: q.order,
-                studentAnswer: q.audioFileUrl,
-              });
+              if (q.transferFileType === "AUDIO") {
+                that.updateExamQuestion({
+                  order: q.order,
+                  studentAnswer: q.audioFileUrl,
+                });
+              } else if (q.transferFileType === "PIC") {
+                that.updatePicture({
+                  pictureAnswer: q,
+                });
+              }
               q.saved = true;
               this.$Message.info({
-                content: "音频题作答已更新",
+                content: "小程序作答已更新",
                 duration: 5,
                 closable: true,
               });
             })
             .catch(() => {
               this.$Message.error({
-                content: "更新音频题答案失败!",
+                content: "更新小程序答案失败!",
                 duration: 15,
                 closable: true,
               });

+ 20 - 6
src/features/OnlineExam/Examing/TextQuestionView.vue

@@ -64,7 +64,7 @@
           {{ answerWordCount }}
         </div>
       </div>
-      <div v-else>
+      <div v-if="shouldFetchQrCode">
         <div>
           <div v-if="qrValue" style="display: flex">
             <qrcode
@@ -75,7 +75,7 @@
             <div style="margin-top: 10px;">
               <div>
                 请使用<span style="font-weight: 900; color: #1E90FF;">微信</span
-                >扫描二维码后,在微信小程序上录音,并上传录音
+                >扫描二维码后,在微信小程序上录音/拍照,并上传文件
               </div>
               <div v-if="qrScanned" style="margin-top: 30px; font-size: 30px;">
                 {{ this.examQuestion.studentAnswer ? "已上传" : "已扫描" }}
@@ -90,7 +90,7 @@
           class="audio-answer audio-answer-line-height"
           style="margin-top: 20px ;"
         >
-          <span class="audio-answer-line-height">音频答案:</span>
+          <span class="audio-answer-line-height">答案:</span>
           <audio
             class="audio-answer-line-height"
             v-if="this.examQuestion.studentAnswer"
@@ -98,7 +98,7 @@
             controlsList="nodownload"
             :src="this.examQuestion.studentAnswer"
           />
-          <span v-else class="audio-answer-line-height">未上传音频</span>
+          <span v-else class="audio-answer-line-height">未上传文件</span>
         </div>
       </div>
 
@@ -232,8 +232,14 @@ export default {
       this.answerDivKey = Math.random();
     },
     fetchQRCode() {
-      if (this.examQuestion.answerType === "SINGLE_AUDIO") {
-        if (!getQRCode(this.examQuestion.order)) {
+      const shouldFetch =
+        this.examQuestion.answerType === "SINGLE_AUDIO" ||
+        this.$store.state.user.schoolDomain === "ecs-dev.qmth.com.cn";
+      this.$store.state.user.schoolDomain === "iepcc-ps.ecs.qmth.com.cn";
+      if (shouldFetch) {
+        const transferFileType =
+          this.examQuestion.answerType === "SINGLE_AUDIO" ? "AUDIO" : "PIC";
+        if (!getQRCode(this.examQuestion.order, transferFileType)) {
           setTimeout(() => {
             this.fetchQRCode();
           }, 3000);
@@ -316,6 +322,14 @@ export default {
     isAudioAnswerType() {
       return this.examQuestion.answerType === "SINGLE_AUDIO";
     },
+    shouldFetchQrCode() {
+      const shouldFetch =
+        this.examQuestion.answerType === "SINGLE_AUDIO" ||
+        this.$store.state.user.schoolDomain === "ecs-dev.qmth.com.cn";
+      this.$store.state.user.schoolDomain === "iepcc-ps.ecs.qmth.com.cn";
+
+      return shouldFetch;
+    },
     canAttachPhotos() {
       return (
         this.$store.state.user.schoolDomain === "csu.ecs.qmth.com.cn" ||

+ 20 - 5
src/features/OnlineExam/Examing/ws.js

@@ -105,12 +105,13 @@ export function closeWsWithoutReconnect() {
   }
 }
 
-export function getQRCode(order) {
+export function getQRCode(order, transferFileType) {
   if (ws.readyState === ws.OPEN) {
     ws.send(
       JSON.stringify({
         eventType: "GET_QR_CODE",
         order,
+        transferFileType: transferFileType,
       })
     );
     return true;
@@ -149,12 +150,26 @@ function processWSMessage(event) {
         order: res.data.order,
       });
       break;
-    case "GET_AUDIO_ANSWER":
-      console.log("get audio url", res);
+    case "GET_FILE_ANSWER":
+      console.log("get file url", res);
       window._hmt.push(["_trackEvent", "websocket", "获得音频地址"]);
-      store.commit("examingHomeModule/setQuestionAudioFileUrl", {
+
+      // location
+      // var urlOrder = window.location.pathname.split("/").pop();
+      // if (ws.readyState === ws.OPEN && res.data.order != urlOrder) {
+      //   ws.send(
+      //     JSON.stringify({
+      //       eventType: "REJECT_FILE",
+      //       order: res.data.order,
+      //       transferFileType: res.data.transferFileType,
+      //       fileUrl: res.data.fileUrl,
+      //     })
+      //   );
+      // }
+
+      store.commit("examingHomeModule/setQuestionFileAnswerUrl", {
         order: res.data.order,
-        audioFileUrl: res.data.audioFileUrl,
+        fileUrl: res.data.fileUrl,
       });
       break;
     case "SYSTEM_ERROR":

+ 5 - 1
src/store.js

@@ -34,6 +34,7 @@ const examingHomeModule = {
     questionQrCode: null,
     questionQrCodeScanned: null,
     questionAudioFileUrl: [],
+    pictureAnswer: null,
   },
   mutations: {
     updateRemainTime(state, remainTime) {
@@ -154,7 +155,7 @@ const examingHomeModule = {
     setQuestionQrCodeScanned(state, payload) {
       state.questionQrCodeScanned = payload;
     },
-    setQuestionAudioFileUrl(state, payload) {
+    setQuestionFileAnswerUrl(state, payload) {
       state.questionAudioFileUrl = state.questionAudioFileUrl.filter(
         v => !v.saved
       );
@@ -173,6 +174,9 @@ const examingHomeModule = {
         state.questionAudioFileUrl.push(payload);
       }
     },
+    updatePicture(state, payload) {
+      state.pictureAnswer = payload;
+    },
   },
   actions: {},
   getters: {