Переглянути джерело

Merge branch 'master' of http://120.77.221.199:3000/public/JingTieXueTang.H5

aaa 4 роки тому
батько
коміт
e2f7395249

+ 51 - 3
src/utils/common.js

@@ -12,9 +12,57 @@ exports.install = function(Vue, options) {
     }
     return path;
   };
-  // Vue.prototype.$pushH = function() { // 全局函数
-  //     xxx
-  // };
+
+  /**
+   * 过滤选项的编号
+   * @index {Number} 下标
+   */
+  Vue.prototype.formatQuestionIndex = function(index) {
+    return String.fromCharCode(index + 65);
+  };
+
+  /**
+   *
+   * 过滤标准日期为 x年-x月-x日
+   * @time {String} 标准日期时间格式
+   */
+  Vue.prototype.formateDateTimeFun = function(time) {
+    // 全局函数
+    // 获取当前日期
+    let date = new Date(time);
+    // 获取当前月份
+    let nowMonth = date.getMonth() + 1;
+    // 获取当前是几号
+    let strDate = date.getDate();
+    // 添加分隔符“-”
+    let seperator = "-";
+    // 对月份进行处理,1-9月在前面添加一个“0”
+    if (nowMonth >= 1 && nowMonth <= 9) {
+      nowMonth = "0" + nowMonth;
+    }
+    // 对月份进行处理,1-9号在前面添加一个“0”
+    if (strDate >= 0 && strDate <= 9) {
+      strDate = "0" + strDate;
+    }
+    // 最后拼接字符串,得到一个格式为(yyyy-MM-dd)的日期
+    return date.getFullYear() + seperator + nowMonth + seperator + strDate;
+  };
+
+  /**
+   * 根据秒数获取 XX时:XX分:XX秒
+   * @secondsNumber {Number} 数字
+   */
+  Vue.prototype.getTimeHoursMinuteSecondsFun = function(secondsNumber) {
+    let hours = Math.floor(secondsNumber / (60 * 60));
+    let minutes = Math.floor((secondsNumber - hours * 60 * 60) / 60);
+    let seconds = Math.floor(secondsNumber - hours * 60 * 60 - minutes * 60);
+    let timeDiff = zero(hours) + ":" + zero(minutes) + ":" + zero(seconds);
+    // 数字补零
+    function zero(num) {
+      return num < 10 ? "0" + num : num;
+    }
+    return timeDiff;
+  };
   // Vue.prototype.$pushHN = function() { // 全局函数
   //     xxx
   // };

+ 16 - 9
src/views/home/answer/page-answer-recruit.vue

@@ -25,7 +25,10 @@
         </div>
         <!-- 描述 -->
         <div class="exam-question-describe">
-          {{ examQuestionList[answerIndex].content }}
+          {{
+            examQuestionList[answerIndex].questionContent ||
+              examQuestionList[answerIndex].content
+          }}
         </div>
         <!-- 答题列表 -->
         <!-- 单选题、多选题的选项区域 -->
@@ -210,15 +213,19 @@ export default {
     },
     // 方法:过滤试题的类型,添加用户作答的字段
     setPersonDataFun(httpResultDataItme) {
-      httpResultDataItme.typeTxt = this.formatQuestionType(
-        httpResultDataItme.type
+      let results = this.formatQuestionType(
+        httpResultDataItme.type,
+        httpResultDataItme.content
       );
+      httpResultDataItme.typeTxt = results.typeTxt;
+      httpResultDataItme.questionContent = results.questionContent;
       httpResultDataItme.userAnswer = [];
       return httpResultDataItme;
     },
     // 方法:过滤试题的类型
-    formatQuestionType(type) {
+    formatQuestionType(type, content) {
       let typeTxt = "";
+      let questionContent = null;
       switch (type) {
         case this.questionType.singleChoice:
           typeTxt = "单选题";
@@ -228,15 +235,15 @@ export default {
           break;
         case this.questionType.gapFilling:
           typeTxt = "填空题";
+          questionContent = content.replace("$PH$", "()");
           break;
         default:
           break;
       }
-      return typeTxt;
-    },
-    // 方法:过滤选项的编号
-    formatQuestionIndex(index) {
-      return String.fromCharCode(index + 65);
+      return {
+        typeTxt: typeTxt,
+        questionContent: questionContent
+      };
     },
     // 方法:过滤正确答案的选项的编号
     formatQuestionFinalAnswerIndex(finalAnswer) {

+ 2 - 1
src/views/home/exam/page-exam-item-detail.vue

@@ -104,7 +104,8 @@ export default {
     },
     // 操作:开始考试
     handleStartExamFun() {
-      this.$refs.uploadUserInput.click(); // 调用拍照工具
+      // this.$refs.uploadUserInput.click(); // 调用拍照工具
+      this.$router.replace({ name: "Exam" });
     },
     // 操作:返回
     handleBackFun() {

+ 21 - 14
src/views/home/exam/page-exam-item-doing.vue

@@ -49,7 +49,10 @@
         </div>
         <!-- 描述 -->
         <div class="exam-question-describe">
-          {{ examQuestionList[answerIndex].content }}
+          {{
+            examQuestionList[answerIndex].questionContent ||
+              examQuestionList[answerIndex].content
+          }}
         </div>
         <!-- 答题列表 -->
         <!-- 单选题、多选题的选项区域 -->
@@ -81,7 +84,7 @@
             ref="questionInputRef"
             v-model="inputValue"
             maxlength="200"
-            rows="5"
+            rows="1"
             @change="handleExamQuestionOptionsItemFun(inputValue)"
           />
         </div>
@@ -220,15 +223,18 @@ export default {
     },
     // 方法:过滤试题的类型,添加用户作答的字段
     setPersonDataFun(httpResultDataItme) {
-      httpResultDataItme.typeTxt = this.formatQuestionType(
-        httpResultDataItme.type
+      let results = this.formatQuestionType(
+        httpResultDataItme.type,
+        httpResultDataItme.content
       );
+      httpResultDataItme.typeTxt = results.typeTxt;
+      httpResultDataItme.questionContent = results.questionContent;
       httpResultDataItme.userAnswer = [];
       return httpResultDataItme;
     },
     // 获取:考试限定的时间点
     getExamTimeFun() {
-      let tarTime = this.getTimeHoursMinuteSecondsFun(
+      let tarTime = this.getTimeHoursMinuteSecondsTogetherFun(
         this.examItem.examTimeMins
       );
       let curTime = new Date();
@@ -250,7 +256,7 @@ export default {
       this.endTimeSeconds = curTime.getTime(); // 赋值结束时间的秒数
     },
     // 方法:分别获取时 分 秒
-    getTimeHoursMinuteSecondsFun(e) {
+    getTimeHoursMinuteSecondsTogetherFun(e) {
       let time = e;
       let len = time.split(":");
       if (len.length === 3) {
@@ -303,9 +309,10 @@ export default {
         }
       }, 1000);
     },
-    // 方法:过滤试题的类型
-    formatQuestionType(type) {
+    // 方法:过滤试题的类型、填空题的题目
+    formatQuestionType(type, content) {
       let typeTxt = "";
+      let questionContent = "";
       switch (type) {
         case this.questionType.singleChoice:
           typeTxt = "单选题";
@@ -315,15 +322,15 @@ export default {
           break;
         case this.questionType.gapFilling:
           typeTxt = "填空题";
+          this.questionContent = content.replace("$PH$", "()");
           break;
         default:
           break;
       }
-      return typeTxt;
-    },
-    // 方法:过滤选项的编号
-    formatQuestionIndex(index) {
-      return String.fromCharCode(index + 65);
+      return {
+        typeTxt: typeTxt,
+        questionContent: questionContent
+      };
     },
     // 操作:点击了某个题序
     handleExamQuestionItemFun(item, index) {
@@ -378,7 +385,6 @@ export default {
         default:
           break;
       }
-      this.handleNextFun(); // 方法:下一题
     },
     // 方法:下一题
     handleNextFun() {
@@ -394,6 +400,7 @@ export default {
     // 操作:确定
     handleSureFun() {
       this.examQuestionList[this.answerIndex].userAnswer = this.answerValue;
+      this.handleNextFun();
     },
     // 操作:交卷 isAuto:true(时间到了的自动交卷)  false(手动交卷)
     handleSubmitFun() {

+ 0 - 32
src/views/home/learn/page-learn-child.vue

@@ -118,38 +118,6 @@ export default {
         name: "learn-content",
         params: { materialId: this.contentList[index].id }
       });
-    },
-    formateDateTimeFun(time) {
-      // 获取当前日期
-      let date = new Date(time);
-      // 获取当前月份
-      let nowMonth = date.getMonth() + 1;
-      // 获取当前是几号
-      let strDate = date.getDate();
-      // 添加分隔符“-”
-      let seperator = "-";
-      // 对月份进行处理,1-9月在前面添加一个“0”
-      if (nowMonth >= 1 && nowMonth <= 9) {
-        nowMonth = "0" + nowMonth;
-      }
-      // 对月份进行处理,1-9号在前面添加一个“0”
-      if (strDate >= 0 && strDate <= 9) {
-        strDate = "0" + strDate;
-      }
-      // 最后拼接字符串,得到一个格式为(yyyy-MM-dd)的日期
-      return date.getFullYear() + seperator + nowMonth + seperator + strDate;
-    },
-    // 方法:分别获取时-分-秒
-    getTimeHoursMinuteSecondsFun(time) {
-      let hours = Math.floor(time / (60 * 60));
-      let minutes = Math.floor((time - hours * 60 * 60) / 60);
-      let seconds = Math.floor(time - hours * 60 * 60 - minutes * 60);
-      let timeDiff = zero(hours) + ":" + zero(minutes) + ":" + zero(seconds);
-      // 数字补零
-      function zero(num) {
-        return num < 10 ? "0" + num : num;
-      }
-      return timeDiff;
     }
   }
 };

+ 2 - 35
src/views/home/learn/page-learn-content.vue

@@ -47,9 +47,9 @@
         <div class="learn-content-body-count-btn">
           阅读<span>{{ contentObj.readerCount }}</span>
         </div>
-        <div class="learn-content-body-count-btn">
+        <!-- <div class="learn-content-body-count-btn">
           点赞<span>{{ contentObj.likesCount }}</span>
-        </div>
+        </div> -->
       </div>
     </div>
     <!-- 评论 -->
@@ -247,39 +247,6 @@ export default {
     // 操作:取消评论
     canclePostCommentFun() {
       this.commentValue = "";
-    },
-    // 方法:过滤日期时间为 年-月-日
-    formateDateTimeFun(time) {
-      // 获取当前日期
-      let date = new Date(time);
-      // 获取当前月份
-      let nowMonth = date.getMonth() + 1;
-      // 获取当前是几号
-      let strDate = date.getDate();
-      // 添加分隔符“-”
-      let seperator = "-";
-      // 对月份进行处理,1-9月在前面添加一个“0”
-      if (nowMonth >= 1 && nowMonth <= 9) {
-        nowMonth = "0" + nowMonth;
-      }
-      // 对月份进行处理,1-9号在前面添加一个“0”
-      if (strDate >= 0 && strDate <= 9) {
-        strDate = "0" + strDate;
-      }
-      // 最后拼接字符串,得到一个格式为(yyyy-MM-dd)的日期
-      return date.getFullYear() + seperator + nowMonth + seperator + strDate;
-    },
-    // 方法:根据秒数,获取时:分:秒
-    getTimeHoursMinuteSecondsFun(time) {
-      let hours = Math.floor(time / (60 * 60));
-      let minutes = Math.floor((time - hours * 60 * 60) / 60);
-      let seconds = Math.floor(time - hours * 60 * 60 - minutes * 60);
-      let timeDiff = zero(hours) + ":" + zero(minutes) + ":" + zero(seconds);
-      // 数字补零
-      function zero(num) {
-        return num < 10 ? "0" + num : num;
-      }
-      return timeDiff;
     }
   }
 };