Selaa lähdekoodia

fix:bug修复

钱新宇 3 kuukautta sitten
vanhempi
sitoutus
494ccfcf71
2 muutettua tiedostoa jossa 110 lisäystä ja 48 poistoa
  1. 108 47
      pages/video/detail.vue
  2. 2 1
      pages/video/exam.vue

+ 108 - 47
pages/video/detail.vue

@@ -15,7 +15,10 @@
         @ended="_videoEnd"
         @fullscreenchange="screenChange"
       ></video>
-      <cover-view v-if="videoInfo.learn_status == 0" :class="bigsScreen ? 'bigScreen' : 'cover'"></cover-view>
+      <cover-view
+        v-if="videoInfo.learn_status == 0"
+        :class="bigsScreen ? 'bigScreen' : 'cover'"
+      ></cover-view>
     </view>
     <view class="video_title">{{ videoInfo.name }}</view>
     <view class="rich_text">
@@ -29,22 +32,45 @@
           <view class="question_content">{{ questinInfo.question_title }}</view>
           <!-- 问题选项 -->
           <view class="question_options">
-            <view v-for="(option, index) in questinInfo.answer_list" :key="index" :class="['question_answer', { active: answer_id == option.id }]" @click="_selectAnswer(option.id)">
+            <view
+              v-for="(option, index) in questinInfo.answer_list"
+              :key="index"
+              :class="['question_answer', { active: answer_id == option.id }]"
+              @click="_selectAnswer(option.id)"
+            >
               {{ option.value }}
             </view>
           </view>
-          <view :class="['submit_btn', { active: answer_id }]" @click="_submitAnswer">提交</view>
+          <view
+            :class="['submit_btn', { active: answer_id }]"
+            @click="_submitAnswer"
+            >提交</view
+          >
         </view>
         <!-- 结果区域 -->
         <view class="content" v-else>
-          <icon :type="answerInfo.is_answer == 1 ? 'success' : 'cancel'" size="64" />
-          <view class="title">{{ answerInfo.is_answer == 1 ? "恭喜您,答对啦!" : "很遗憾,答错了" }}</view>
-          <view class="tip">{{ answerInfo.is_answer == 1 ? "继续保持,你正在进步!" : "别灰心,再接再厉!" }}</view>
+          <icon
+            :type="answerInfo.is_answer == 1 ? 'success' : 'cancel'"
+            size="64"
+          />
+          <view class="title">{{
+            answerInfo.is_answer == 1 ? "恭喜您,答对啦!" : "很遗憾,答错了"
+          }}</view>
+          <view class="tip">{{
+            answerInfo.is_answer == 1
+              ? "继续保持,你正在进步!"
+              : "别灰心,再接再厉!"
+          }}</view>
           <view class="score_content">
             <view>得分</view>
-            <view :style="answerInfo.get_score == 0 ? 'color:red' : 'color:green'">+{{ answerInfo.get_score }}</view>
+            <view
+              :style="answerInfo.get_score == 0 ? 'color:red' : 'color:green'"
+              >+{{ answerInfo.get_score }}</view
+            >
           </view>
-          <view class="submit_btn active" @click="_goPlayVedio">继续学习视频</view>
+          <view class="submit_btn active" @click="_goPlayVedio"
+            >继续学习视频</view
+          >
         </view>
       </view>
     </uni-popup>
@@ -109,17 +135,25 @@ export default {
       title: `999智控终端平台\n${this.videoInfo.title}`,
       path: "/pages/video/detail?id=" + this.videoInfo.id,
       promise: new Promise((resolve, reject) => {
-        this.$http.request("api/share_message/get_item", { item_id: this.videoInfo.id, pages: "/pages/video/detail" }).then((callback) => {
-          console.log(callback, "api/share_message/get_item");
-          let obj = {
-            title: callback.data?.title == "" ? `999智控终端平台\n${this.videoInfo.title}` : callback.data.title,
-            path: "/pages/video/detail?id=" + this.videoInfo.id,
-          };
-          if (callback.data?.image_url !== "") {
-            obj.imageUrl = callback.data.image_url;
-          }
-          resolve(obj);
-        });
+        this.$http
+          .request("api/share_message/get_item", {
+            item_id: this.videoInfo.id,
+            pages: "/pages/video/detail",
+          })
+          .then((callback) => {
+            console.log(callback, "api/share_message/get_item");
+            let obj = {
+              title:
+                callback.data?.title == ""
+                  ? `999智控终端平台\n${this.videoInfo.title}`
+                  : callback.data.title,
+              path: "/pages/video/detail?id=" + this.videoInfo.id,
+            };
+            if (callback.data?.image_url !== "") {
+              obj.imageUrl = callback.data.image_url;
+            }
+            resolve(obj);
+          });
       }),
     };
   },
@@ -128,27 +162,31 @@ export default {
     // 如果存在产品ID的话
     if (this.requestParam.id > 0) {
       // 请求详情
-      this.$http.request("api/video_course/get_detail", this.requestParam).then((re) => {
-        // 成功渲染数据
-        if (re.code == "success") {
-          // 刷新数据
-          this.videoInfo = re.data;
-          if (re.data.question_list) {
-            this.questionTime_list = re.data?.question_list.map((item) => item.play_time);
-          }
-          // 获取视频容器的上下文
-          this.videoContext = uni.createVideoContext("myVideo");
-          // 暂停播放
-          this.videoContext.stop();
-        } else {
-          if (re.code != "no_login") {
-            uni.showModal({
-              content: re.msg,
-              showCancel: false,
-            });
+      this.$http
+        .request("api/video_course/get_detail", this.requestParam)
+        .then((re) => {
+          // 成功渲染数据
+          if (re.code == "success") {
+            // 刷新数据
+            this.videoInfo = re.data;
+            if (re.data.question_list) {
+              this.questionTime_list = re.data?.question_list.map(
+                (item) => item.play_time
+              );
+            }
+            // 获取视频容器的上下文
+            this.videoContext = uni.createVideoContext("myVideo");
+            // 暂停播放
+            this.videoContext.stop();
+          } else {
+            if (re.code != "no_login") {
+              uni.showModal({
+                content: re.msg,
+                showCancel: false,
+              });
+            }
           }
-        }
-      });
+        });
     }
   },
   methods: {
@@ -166,12 +204,20 @@ export default {
           this._postVideoDuration(this.currentTime, 1);
         }
         // 判断当前时间是否接近答题时间,并且该问题尚未回答
-        if (this.questionTime_list.includes(parseInt(this.currentTime) + 3) && !this.answeredQuestions.has(parseInt(this.currentTime) + 3)) {
+        if (
+          this.questionTime_list.includes(parseInt(this.currentTime) + 3) &&
+          !this.answeredQuestions.has(parseInt(this.currentTime) + 3)
+        ) {
           this.countdown = 3;
           this._startCountdown();
         }
-        if (this.questionTime_list.includes(parseInt(this.currentTime)) && !this.answeredQuestions.has(parseInt(this.currentTime))) {
-          this.questinInfo = this.videoInfo.question_list.find((item) => item.play_time == parseInt(this.currentTime));
+        if (
+          this.questionTime_list.includes(parseInt(this.currentTime)) &&
+          !this.answeredQuestions.has(parseInt(this.currentTime))
+        ) {
+          this.questinInfo = this.videoInfo.question_list.find(
+            (item) => item.play_time == parseInt(this.currentTime)
+          );
           this.videoContext.pause();
           this.videoContext.exitFullScreen();
           this.$refs.questionRef.open("center");
@@ -187,11 +233,17 @@ export default {
     //上报视频播放时间
     _postVideoDuration(video_playtime, status) {
       if (status == 1) clearInterval(this.timer);
-      this.$http.request("api/video_learn_record/update_playtime", { record_id: this.videoInfo.record_id, video_playtime, status }).then((re) => {
-        if (re.code == "success") {
-          console.log("上报成功");
-        }
-      });
+      this.$http
+        .request("api/video_learn_record/update_playtime", {
+          record_id: this.videoInfo.record_id,
+          video_playtime,
+          status,
+        })
+        .then((re) => {
+          if (re.code == "success") {
+            console.log("上报成功");
+          }
+        });
     },
     _selectAnswer(answer_id) {
       this.answer_id = answer_id;
@@ -241,16 +293,25 @@ export default {
       }, 1000);
     },
     _videoEnd() {
+      const _this = this;
       this.videoContext.pause();
       this.videoContext.exitFullScreen();
       uni.showModal({
         title: "学习结束",
         content: "恭喜您学习结束,是否查看报告?",
+        cancelText: "重新学习",
         success: (res) => {
           if (res.confirm) {
             uni.redirectTo({
               url: `/pages/video/record?type=learn&record_id=${this.videoInfo.record_id}`,
             });
+          } else {
+            //用户重新学习,将播放进度重新设为0
+            setTimeout(() => {
+              // 跳转到指定的时间位置
+              _this.videoContext.seek(0);
+              // _this.videoContext.play();
+            }, 200);
           }
         },
       });

+ 2 - 1
pages/video/exam.vue

@@ -98,6 +98,7 @@ export default {
       }
     },
     _handleIn() {
+      const _this = this
       const question_list = this.question_Info.question_list.filter((item) => item.checkAnswer);
       const answer_list = question_list.map((item) => {
         return { question_id: item.question_id, answer_id: item.checkAnswer };
@@ -121,7 +122,7 @@ export default {
               success(res) {
                 if (res.confirm) {
                   uni.redirectTo({
-                    url: `/pages/video/record?type=exam&record_id=${this.question_Info.record_id}`,
+                    url: `/pages/video/record?type=exam&record_id=${_this.question_Info.record_id}`,
                   });
                 } else {
                   uni.redirectTo({