Explorar el Código

fix:bug修复

钱新宇 hace 2 meses
padre
commit
7ae7063f9e
Se han modificado 3 ficheros con 107 adiciones y 54 borrados
  1. 5 1
      pages/video/detail.vue
  2. 49 33
      pages/video/index.vue
  3. 53 20
      pages/video/record.vue

+ 5 - 1
pages/video/detail.vue

@@ -223,6 +223,7 @@ export default {
           this.$refs.questionRef.open("center");
           //答题时间停止上报
           clearInterval(this.timer);
+          this.timer = null;
         }
       }
     },
@@ -232,7 +233,10 @@ export default {
     },
     //上报视频播放时间
     _postVideoDuration(video_playtime, status) {
-      if (status == 1) clearInterval(this.timer);
+      if (status == 1) {
+        clearInterval(this.timer);
+        this.timer = null;
+      }
       this.$http
         .request("api/video_learn_record/update_playtime", {
           record_id: this.videoInfo.record_id,

+ 49 - 33
pages/video/index.vue

@@ -15,12 +15,22 @@
           </view>
         </view>
         <view class="video_btn">
-          <button class="to_learn" @click.stop="goDetail(item.id)">开始学习</button>
-          <button class="after_exam" v-if="item.learn_status > 0" @click="goExam(item.id, item.report_id)">{{ item.report_id > 0 ? "查看报告" : "课后评测" }}</button>
+          <button class="to_learn" @click.stop="goDetail(item.id)">
+            开始学习
+          </button>
+          <button
+            class="after_exam"
+            v-if="item.learn_status > 0"
+            @click="goExam(item.id, item.report_id)"
+          >
+            {{ item.report_id > 0 ? "查看报告" : "课后评测" }}
+          </button>
         </view>
       </view>
     </view>
-    <view class="to_bottom" v-if="!videoList.length"> -----您还没有可学习课程-----</view>
+    <view class="to_bottom" v-if="!videoList.length">
+      -----您还没有可学习课程-----</view
+    >
     <view class="contact_follow">
       <button class="contact_btn" open-type="contact">
         <uni-icons type="headphones" size="30" color="#FFFFFF"></uni-icons>
@@ -57,15 +67,17 @@ export default {
     // 设置请求中
     this.isReqing = true;
     // 请求列表
-    this.$http.request("api/video_course/get_list", this.requestParam).then((re) => {
-      // 设置非请求中
-      this.isReqing = false;
-      // 成功结果
-      if (re.code == "success") {
-        if (re.data.last_page <= this.requestParam.page) this.isLast = true;
-        this.videoList = re.data.data;
-      }
-    });
+    this.$http
+      .request("api/video_course/get_list", this.requestParam)
+      .then((re) => {
+        // 设置非请求中
+        this.isReqing = false;
+        // 成功结果
+        if (re.code == "success") {
+          if (re.data.last_page <= this.requestParam.page) this.isLast = true;
+          this.videoList = re.data.data;
+        }
+      });
   },
   onPullDownRefresh() {
     // 如果请求中,不允许请求,
@@ -77,15 +89,17 @@ export default {
     // 设置请求中
     this.isReqing = true;
     // 请求列表
-    this.$http.request("api/video_course/get_list", this.requestParam).then((re) => {
-      // 设置非请求中
-      this.isReqing = false;
-      // 成功结果
-      if (re.code == "success") {
-        if (re.data.last_page <= this.requestParam.page) this.isLast = true;
-        this.videoList = re.data.data;
-      }
-    });
+    this.$http
+      .request("api/video_course/get_list", this.requestParam)
+      .then((re) => {
+        // 设置非请求中
+        this.isReqing = false;
+        // 成功结果
+        if (re.code == "success") {
+          if (re.data.last_page <= this.requestParam.page) this.isLast = true;
+          this.videoList = re.data.data;
+        }
+      });
     uni.stopPullDownRefresh();
   },
   onReachBottom() {
@@ -100,17 +114,19 @@ export default {
     // 设置请求中
     this.isReqing = true;
     // 请求列表
-    this.$http.request("api/video_course/get_list", this.requestParam).then((re) => {
-      // 设置非请求中
-      this.isReqing = false;
-      // 成功结果
-      if (re.code == "success") {
-        // 数据
-        if (re.data.last_page <= this.requestParam.page) this.isLast = true;
-        // 追加数据
-        this.videoList.push(...re.data.data);
-      }
-    });
+    this.$http
+      .request("api/video_course/get_list", this.requestParam)
+      .then((re) => {
+        // 设置非请求中
+        this.isReqing = false;
+        // 成功结果
+        if (re.code == "success") {
+          // 数据
+          if (re.data.last_page <= this.requestParam.page) this.isLast = true;
+          // 追加数据
+          this.videoList.push(...re.data.data);
+        }
+      });
   },
   methods: {
     goDetail(id) {
@@ -121,7 +137,7 @@ export default {
     goExam(id, report_id) {
       if (report_id > 0) {
         uni.navigateTo({
-          url: "/pages/video/record?type=exam&record_id=" + id,
+          url: "/pages/video/record?type=exam&record_id=" + report_id,
         });
         return;
       }

+ 53 - 20
pages/video/record.vue

@@ -2,14 +2,25 @@
   <view class="report_content">
     <view class="header">
       <view class="header_content">
-        <view class="title">本次{{ type == "exam" ? "测评" : "学习" }}概览</view>
+        <view class="title"
+          >本次{{ type == "exam" ? "测评" : "学习" }}概览</view
+        >
         <view class="content">
           <view class="content_row">
-            <view class="main">{{ reportInfo.exam_time }}</view>
+            <view class="main">{{
+              type == "exam"
+                ? reportInfo.exam_time
+                : (
+                    (reportInfo.video_lasttime - reportInfo.video_inittime) /
+                    60
+                  ).toFixed(2)
+            }}</view>
             <view class="tip">学习时长(分钟)</view>
           </view>
           <view class="content_row">
-            <view class="main">{{ reportInfo.isanswer_total + "/" + reportInfo.answer_total }}</view>
+            <view class="main">{{
+              reportInfo.isanswer_total + "/" + reportInfo.answer_total
+            }}</view>
             <view class="tip">答对题目</view>
           </view>
           <view class="content_row">
@@ -22,10 +33,22 @@
     <view class="content">
       <view class="title">答题情况</view>
       <view class="content_list">
-        <view class="conent_main" v-for="(item, index) in queston_list" :key="index">
+        <view
+          class="conent_main"
+          v-for="(item, index) in queston_list"
+          :key="index"
+        >
           <view class="item_num">
-            <view class="item_answer"><icon :type="item.is_answer == 0 ? 'cancel' : 'success'" size="20" /> &nbsp;第{{ index + 1 }}题</view>
-            <view :style="item.get_score > 0 ? 'color:green' : 'color:red'">+{{ item.get_score }}&nbsp;积分</view>
+            <view class="item_answer"
+              ><icon
+                :type="item.is_answer == 0 ? 'cancel' : 'success'"
+                size="20"
+              />
+              &nbsp;第{{ index + 1 }}题</view
+            >
+            <view :style="item.get_score > 0 ? 'color:green' : 'color:red'"
+              >+{{ item.get_score }}&nbsp;积分</view
+            >
           </view>
           <view class="item_title">{{ item.question_title }}</view>
         </view>
@@ -33,7 +56,9 @@
     </view>
     <view class="bottom_btn">
       <view class="submit_btn defult" @click="_backList">返回课程列表</view>
-      <view class="submit_btn" @click="_continue">{{ type == "exam" ? "重新练习" : "继续课后评测" }}</view>
+      <view class="submit_btn" @click="_continue">{{
+        type == "exam" ? "重新练习" : "继续课后评测"
+      }}</view>
     </view>
   </view>
 </template>
@@ -81,24 +106,32 @@ export default {
     },
     _continue() {
       uni.redirectTo({
-        url: `/pages/video/exam?id=${this.record_id}`,
+        url: `/pages/video/exam?id=${this.reportInfo.course_id}`,
       });
     },
     _getRecord(type) {
-      this.$http.request(`api/video_${type}_record/get_report`, { record_id: this.record_id }).then((re) => {
-        if (re.code == "success") {
-          console.log(re.data);
-          this.reportInfo = re.data;
-        }
-      });
+      this.$http
+        .request(`api/video_${type}_record/get_report`, {
+          record_id: this.record_id,
+        })
+        .then((re) => {
+          if (re.code == "success") {
+            console.log(re.data);
+            this.reportInfo = re.data;
+          }
+        });
     },
     _getAnswerList(type) {
-      this.$http.request(`api/video_${type}_answer/get_list`, { record_id: this.record_id }).then((re) => {
-        if (re.code == "success") {
-          console.log(re.data);
-          this.queston_list = re.data;
-        }
-      });
+      this.$http
+        .request(`api/video_${type}_answer/get_list`, {
+          record_id: this.record_id,
+        })
+        .then((re) => {
+          if (re.code == "success") {
+            console.log(re.data);
+            this.queston_list = re.data;
+          }
+        });
     },
   },
 };