瀏覽代碼

对接完成每日一练

xiejiebiao 2 年之前
父節點
當前提交
26160c7fdc

+ 29 - 2
src/apis/bank.js

@@ -305,6 +305,33 @@ export default {
 			params: data
 		})
 	},
-	
-
+	// 每日一练信息
+	getToDayExam(goodsId) {
+		return request({
+			url: `/bank/question/getToDayExam/${goodsId}`,
+			method: 'get'
+		})
+	},
+	// 打卡记录
+	getPunchRecord(data) {
+		return request({
+			url: '/bank/question/get/special/record',
+			method: 'get',
+			params: data
+		})
+	},
+	// 打卡
+	punchClock(data) {
+		return request({
+			url: '/bank/question/special/exam/record',
+			method: 'post',
+			data: data
+		})
+	},
+	getRandomExam(orderGoodsId) {
+		return request({
+			url: `/goods/bank/questionTempNum/${orderGoodsId}`,
+			method: 'get'
+		})
+	},
 }

+ 0 - 1
src/components/exam/HeaderTabBox.vue

@@ -31,7 +31,6 @@ export default {
     };
   },
   mounted() {
-    console.log(this.examId,8989898)
     if (this.examId || this.$route.query.examId * 1) {
       this.$request
         .bankExam(this.examId || this.$route.query.examId)

+ 25 - 8
src/pages/bank-exam/index.vue

@@ -793,7 +793,7 @@ export default {
       isSubmit: false,
       postTimer: null,
       examName: "",
-      number: ''
+      number: '',
     };
   },
   async mounted() {
@@ -1021,8 +1021,6 @@ export default {
 
           res.data.forEach((item, index) => {
             item.jsonStr = JSON.parse(item.jsonStr);
-
-            console.log(item.type, "item");
             if (item.type == 2) {
               //多选
               item.jsonStr.forEach((str) => {
@@ -1451,7 +1449,9 @@ export default {
           doQuestionNum: doQuestionNum,
           historyExamJson: JSON.stringify(this.questionList),
         })
-        .then((res) => { });
+        .then((res) => {
+          this.punchClock()
+        });
     },
 
     /**
@@ -2048,7 +2048,6 @@ export default {
      * 交卷,跳转报告页
      */
     examSubmit() {
-      console.log(12313);
       this.loading = true;
       clearInterval(this.timer);
       clearInterval(this.postTimer);
@@ -2235,7 +2234,7 @@ export default {
             type: "success",
             message: "交卷成功",
           });
-
+          this.punchClock()
           setTimeout(() => {
             this.$router.replace({
               path: "/bank-report/" + this.goodsId,
@@ -2245,6 +2244,7 @@ export default {
                 moduleId: this.moduleId,
                 examId: this.examId,
                 recordId: this.recordId,
+                examType: this.examType
               },
             });
           }, 1000);
@@ -2267,7 +2267,19 @@ export default {
         .then((res) => { })
         .catch((err) => { });
     },
-
+    // 打卡
+    punchClock() {
+      if (this.examType != 1) {
+        return
+      }
+      this.$request.punchClock({
+        chapterExamId: this.chapterId,
+        examId: this.examId,
+        goodsId: this.goodsId,
+        moduleExamId: this.moduleId,
+        recordTime: new Date(new Date().setHours(0, 0, 0, 0)) / 1000,
+      })
+    },
     /**
      * 交卷,不用跳转
      */
@@ -2438,7 +2450,9 @@ export default {
           doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
           historyExamJson: JSON.stringify(this.questionList),
         })
-        .then((res) => { });
+        .then((res) => {
+          this.punchClock()
+        });
 
       console.log(222);
       //错题集id提交(客观题)
@@ -2477,6 +2491,9 @@ export default {
     },
     doMode() {
       return this.number ? 2 : 1
+    },
+    examType() {
+      return this.$route.query.examType || (this.number ? 2 : 0)
     }
   },
 };

+ 91 - 107
src/pages/bank-report/index.vue

@@ -14,38 +14,30 @@
         >
       </div> -->
       <div class="container">
-        <div
-          class="section__header section__header--warm"
-          v-if="examData.doType == 2 && reportdata.reportStatus === null"
-        >
+        <div class="section__header section__header--warm"
+          v-if="examData.doType == 2 && reportdata.reportStatus === null">
           <div class="title">
             <span class="icon">X</span>
             测试未通过
           </div>
           <div class="desc" v-if="reportdata.doTime">
             总时间:{{ $tools.secondToTime(reportdata.examTime) }}
-            <span class="note"
-              >答题时长:{{
+            <span class="note">答题时长:{{
                 $tools.secondToTime(reportdata.doTime, false)
-              }}</span
-            >
+            }}</span>
           </div>
         </div>
-        <div
-          class="section__header section__header--success"
-          v-if="examData.doType == 2 && reportdata.reportStatus === 1"
-        >
+        <div class="section__header section__header--success"
+          v-if="examData.doType == 2 && reportdata.reportStatus === 1">
           <div class="title">
             <span class="icon">✔</span>
             测试通过
           </div>
           <div class="desc" v-if="reportdata.doTime">
             总时间:{{ $tools.secondToTime(reportdata.examTime) }}
-            <span class="note"
-              >答题时长:{{
+            <span class="note">答题时长:{{
                 $tools.secondToTime(reportdata.doTime, false)
-              }}</span
-            >
+            }}</span>
           </div>
         </div>
 
@@ -53,11 +45,9 @@
           <div class="section__header" v-if="reportdata.doTime">
             <div class="desc">
               总时间:{{ $tools.secondToTime(reportdata.examTime) }}
-              <span class="note"
-                >答题时长:{{
+              <span class="note">答题时长:{{
                   $tools.secondToTime(reportdata.doTime, false)
-                }}</span
-              >
+              }}</span>
             </div>
           </div>
         </template>
@@ -96,18 +86,18 @@
                   <!-- 练习 -->
                   <template v-if="examData.doType == 1">
                     {{
-                      ((reportdata.rightQuestionNum /
-                        reportdata.doQuestionNum || 0) *
-                        100)
+                        ((reportdata.rightQuestionNum /
+                          reportdata.doQuestionNum || 0) *
+                          100)
                         | toFixed(0)
                     }}%
                   </template>
                   <!-- 考试 -->
                   <template v-if="examData.doType == 2">
                     {{
-                      ((reportdata.rightQuestionNum /
-                        reportdata.totalQuestionNum || 0) *
-                        100)
+                        ((reportdata.rightQuestionNum /
+                          reportdata.totalQuestionNum || 0) *
+                          100)
                         | toFixed(0)
                     }}%
                   </template>
@@ -139,28 +129,17 @@
         </div>
 
         <div class="section__footer">
-          <el-button type="primary" @click="back" class="btn"
-            >返回列表</el-button
-          >
-          <el-button
-            type="primary"
-            class="btn"
-            v-if="nextExamId"
-            @click="backBank"
-            >练习下一节</el-button
-          >
-          <el-button type="primary" class="btn" @click="doRepeat(reportdata)"
-            >重新做题</el-button
-          >
-          <el-button
-            type="primary"
-            class="btn"
-            @click="wrongExplain(reportdata)"
-            >错题解析</el-button
-          >
-          <el-button type="primary" class="btn" @click="allExplain(reportdata)"
-            >全部解析</el-button
-          >
+          <template v-if="!examType">
+            <el-button type="primary" @click="back" class="btn">返回列表</el-button>
+            <el-button type="primary" class="btn" v-if="nextExamId" @click="backBank">练习下一节</el-button>
+            <el-button type="primary" class="btn" @click="doRepeat(reportdata)">重新做题</el-button>
+          </template>
+          <template v-else>
+            <el-button type="primary" @click="back" class="btn">返回</el-button>
+            <el-button type="primary" @click="back" class="btn">继续练习</el-button>
+          </template>
+          <el-button type="primary" class="btn" @click="wrongExplain(reportdata)">错题解析</el-button>
+          <el-button type="primary" class="btn" @click="allExplain(reportdata)">全部解析</el-button>
         </div>
 
         <div v-if="courseList.length" class="course_list">
@@ -186,13 +165,8 @@
           </div>
 
           <div class="pagination">
-            <el-pagination
-              @current-change="currentChangeCou"
-              background
-              layout="prev, pager, next"
-              :total="total"
-              :page-size="pageSize"
-            >
+            <el-pagination @current-change="currentChangeCou" background layout="prev, pager, next" :total="total"
+              :page-size="pageSize">
             </el-pagination>
           </div>
         </div>
@@ -230,9 +204,10 @@ export default {
       recordId: 0,
       orderGoodsId: "",
       courseList: [],
-			pageNum: 1,
-			pageSize: 10,
-			total: 0,
+      pageNum: 1,
+      pageSize: 10,
+      total: 0,
+      examType: 0
     };
   },
   computed: {
@@ -245,7 +220,7 @@ export default {
     this.recordId = this.$route.query.recordId;
     this.orderGoodsId = this.$route.query.orderGoodsId || "";
     this.goodsId = this.$route.params.goodsId;
-
+    this.examType = this.$route.query.examType
     this.getcourList()
     this.examWrongRecordWrongNum();
     this.bankExamNextExam();
@@ -254,21 +229,21 @@ export default {
   },
   methods: {
     getcourList() {
-        this.$axios({
-            url: '/apply/recommend/goodsList',
-            method: 'post',
-            data: {
-                examId: this.examId,
-                pageNum: this.pageNum,
-                pageSize: this.pageSize,
-                platform: 2,
-            }
-        }).then((res) => {
-            if (res.code == 200) {
-              this.courseList = res.rows || []
-              this.total = res.total
-            }
-        })
+      this.$axios({
+        url: '/apply/recommend/goodsList',
+        method: 'post',
+        data: {
+          examId: this.examId,
+          pageNum: this.pageNum,
+          pageSize: this.pageSize,
+          platform: 2,
+        }
+      }).then((res) => {
+        if (res.code == 200) {
+          this.courseList = res.rows || []
+          this.total = res.total
+        }
+      })
     },
     currentChangeCou(val) {
       this.pageNum = val
@@ -282,7 +257,10 @@ export default {
       //   },
       // });
       this.$router.replace({
-        path: "/person-center/my-bank/index"
+        path: "/person-center/my-bank/index",
+        query: {
+          examType: this.examType || undefined
+        },
       });
     },
     /**
@@ -444,10 +422,12 @@ export default {
   .re_back {
     text-align: right;
     margin: 10px 0px;
+
     .back-btn {
       width: 100px;
     }
   }
+
   .section {
     &__header {
       height: 120px;
@@ -456,6 +436,7 @@ export default {
 
       &--warm {
         background: #fff3f5;
+
         .title {
           text-align: center;
           font-size: 18px;
@@ -479,6 +460,7 @@ export default {
 
       &--success {
         background: #f8fef9;
+
         .title {
           text-align: center;
           font-size: 18px;
@@ -634,6 +616,7 @@ export default {
               border: 0;
               height: 100%;
               display: flex;
+
               .child {
                 flex: 1;
                 height: 100%;
@@ -707,47 +690,48 @@ export default {
   }
 
   .course_list {
-      .course {
-        background: #f5f7fa;
-        padding-top: 40px;
+    .course {
+      background: #f5f7fa;
+      padding-top: 40px;
 
-        &__header {
-          display: flex;
-          align-items: center;
-          justify-content: space-between;
-
-          .title {
-            background: url("~@/assets/video.png") no-repeat left center;
-            padding-left: 36px;
-            font-size: 24px;
-            font-family: YouSheBiaoTiHei;
-            font-weight: 400;
-            color: #333333;
-            text-shadow: 0px 6px 6px rgba(249, 113, 13, 0.08);
-          }
+      &__header {
+        display: flex;
+        align-items: center;
+        justify-content: space-between;
 
-          
+        .title {
+          background: url("~@/assets/video.png") no-repeat left center;
+          padding-left: 36px;
+          font-size: 24px;
+          font-family: YouSheBiaoTiHei;
+          font-weight: 400;
+          color: #333333;
+          text-shadow: 0px 6px 6px rgba(249, 113, 13, 0.08);
         }
 
-        
 
-        &__body {
-          .list {
-            width: 100%;
+      }
 
-            .course-item {
-              float: left;
-            }
+
+
+      &__body {
+        .list {
+          width: 100%;
+
+          .course-item {
+            float: left;
           }
         }
-
-      }
-      .pagination {
-        display: flex;
-        align-items: center;
-        justify-content: center;
-        margin: 20px 0px;
       }
+
+    }
+
+    .pagination {
+      display: flex;
+      align-items: center;
+      justify-content: center;
+      margin: 20px 0px;
     }
+  }
 }
 </style>

+ 92 - 32
src/pages/person-center/my-bank/bank-detailCopy/index.vue

@@ -3,35 +3,39 @@
     <section class="section">
       <div class="section__body">
         <div class="left-box">
-          <el-tabs v-model="activeName" @tab-click="goodsBank">
+          <el-tabs v-model="activeName" @tab-click="handelTab">
             <el-tab-pane v-for="tab in newList" :key="tab.paperId" :label="tab.paperName" :name="tab.paperId + ''">
               <div v-if="tab.paperName == '每日一练'">
-                <div class="day-box">
-                  <div>
-                    <p>打卡任务</p>
-                    <p>白金卷每日一练</p>
+                <template v-if="tab.examInfo">
+                  <div class="day-box">
+                    <div>
+                      <p>打卡任务</p>
+                      <p>{{ tab.examInfo.examName }}</p>
+                    </div>
+                    <div>打卡进度超过了{{ tab.examInfo.recordPercentage }}的学员,快来打卡呀~</div>
+                    <div @click="handelPunchClock(tab)">{{ tab.examInfo.examRecord ? '完成打卡' : '快来打卡' }}</div>
                   </div>
-                  <div>打卡进度超过了85%的学员,快来打卡呀~</div>
-                  <div>快来打卡</div>
-                </div>
-                <div class="clock-in-box">
-                  <p>累计打卡1天</p>
-                  <el-calendar>
-                    <template slot="dateCell" slot-scope="{date, data}">
-                      <p :class="data.isSelected ? 'is-selected' : ''" style="text-align: center;">
-                        {{ data.day.split('-').slice(2).join('-') }}
-                      </p>
-                      <div style="text-align: center;"> {{ data.isSelected ? '✔️' : '✔️' }}</div>
-                    </template>
-                  </el-calendar>
-                </div>
-
+                  <div class="clock-in-box">
+                    <p>累计打卡{{ tab.examInfo && tab.examInfo.recordCount }}天</p>
+                    <el-calendar>
+                      <template slot="dateCell" slot-scope="{date, data}">
+                        <p :class="isSelected(data.day) ? 'is-selected' : ''" style="text-align: center;">
+                          {{ data.day.split('-').slice(2).join('-') }}
+                        </p>
+                        <div style="text-align: center;"> {{ isSelected(data.day) ? '✔️' : '' }}</div>
+                      </template>
+                    </el-calendar>
+                  </div>
+                </template>
               </div>
               <div v-else-if="tab.paperName == '随机练习'">
                 <div class="day-box">
                   <p>试卷情况:</p>
-                  <p>已做/总题:100/1000</p>
-                  <p>已完成练习10%的题目,加油,希望就在前方~</p>
+                  <template v-if="tab.examInfo">
+                    <p>已做/总题:{{ tab.examInfo.doNum }}/{{ tab.examInfo.totalNum }}</p>
+                    <p>已完成练习{{ (tab.examInfo.doNum / tab.examInfo.totalNum).toFixed(2) }}%的题目,加油,希望就在前方~</p>
+                  </template>
+
                 </div>
                 <div>
                   <p>做题数量</p>
@@ -230,10 +234,8 @@
                             <el-button v-if="
                               item.recordStatus == 1 ||
                               (item.recordStatus == 0 && item.doType == 2)
-                            " :disabled="
-  item.answerNum > 0 &&
-  item.doNum >= item.answerNum
-" type="primary" @click="doRepeat(item, 0, 0)" class="btn">重新做题</el-button>
+                            " :disabled="item.answerNum > 0 && item.doNum >= item.answerNum" type="primary"
+                              @click="doRepeat(item, 0, 0)" class="btn">重新做题</el-button>
                           </div>
                         </div>
                       </div>
@@ -258,7 +260,7 @@ export default {
   },
   data() {
     return {
-      newList: [{ paperId: 12, paperName: "每日一练" }, { paperId: 14, paperName: "随机练习" }],
+      newList: [],
       examListNew: [],
       orderGoodsId: "",
       activeName: "0",
@@ -279,7 +281,8 @@ export default {
       needOpen: true, //是否需要打开第一章节
       recordItem: null,
       numList: [5, 10, 15, 20, 50, 100],
-      activeNum: 5
+      activeNum: 5,
+      punchList: []
     };
   },
   mounted() { },
@@ -308,6 +311,19 @@ export default {
     },
   },
   methods: {
+    toFixed(num) {
+      if (num) {
+        let str = String(num).indexOf(".");
+
+        if (str != -1) {
+          return +num.toFixed(2);
+        } else {
+          return num;
+        }
+      } else {
+        return 0;
+      }
+    },
     async initData(data, recordItem) {
       this.recordItem = recordItem;
       this.orderGoodsId = data.orderGoodsId;
@@ -474,11 +490,19 @@ export default {
     getExamType(id) {
       return new Promise((resolve, reject) => {
         this.$request.exampapergoodsExamPaper(id).then((res) => {
-          let data = [{ paperId: 12, paperName: "每日一练" }, { paperId: 14, paperName: "随机练习" }]
-          this.newList = [{ paperId: 0, paperName: "全部" }, ...res.data, ...data];
+          this.newList = [{ paperId: 0, paperName: "全部" }, ...res.data];
           // if (parseInt(this.activeName) > 0) {
           //   this.tabChange({ name: this.activeName });
           // }
+          // 从结果页返回
+          let examType = this.$route.query.examType
+          if (examType) {
+            let item = this.newList.find(e => e.paperName == ['每日一练', '随机练习'][examType - 1])
+            if (item) {
+              this.activeName = item.paperId + ''
+              this.handelTab()
+            }
+          }
           resolve();
         });
       });
@@ -509,6 +533,24 @@ export default {
     /**
      * 获取课程目录
      */
+    handelTab() {
+      let item = this.newList.find(tab => tab.paperId == this.activeName)
+      if (item.paperName == "每日一练") {
+        this.$request.getToDayExam(this.goodsId).then(res => {
+          this.$set(item, 'examInfo', res.data)
+        })
+        this.$request.getPunchRecord({ goodsId: this.goodsId }).then(res => {
+          this.punchList = res.data
+        })
+        return
+      } else if (item.paperName == "随机练习") {
+        this.$request.getRandomExam(this.orderGoodsId).then(res => {
+          this.$set(item, 'examInfo', res.data)
+        })
+        return
+      }
+      this.goodsBank()
+    },
     goodsBank() {
       return new Promise((resolve, reject) => {
         this.$request
@@ -648,12 +690,30 @@ export default {
       });
       this.studyLog(0, moduleId, chapterId, section.examId);
     },
-
+    handelPunchClock({ examInfo }) {
+      this.$router.push({
+        path: "/bank-exam/" + this.goodsId,
+        query: {
+          examId: examInfo.examId,
+          moduleId: examInfo.moduleExamId,
+          chapterId: examInfo.chapterExamId,
+          orderGoodsId: this.orderGoodsId,
+          examType: 1
+        },
+      });
+    },
+    isSelected(date) {
+      date = new Date(date + ' 00:00:00')
+      let time = date.valueOf() / 1000
+      if (!this.punchList.length) {
+        return false
+      }
+      return this.punchList.some(e => e.recordTime == time)
+    },
     /**
      * 继续做题
      */
     continueDo(section, chapterId, moduleId) {
-      console.log(section);
       this.$router.push({
         path: "/bank-exam-continue/" + this.goodsId,
         query: {