zhangbiao 4 лет назад
Родитель
Сommit
0095f1e830

+ 2 - 3
src/api/modules/learn.js

@@ -7,9 +7,8 @@ export default {
     // 查询目录详情
     JTXT_GET_CATEGORIES_CATEGROYID: "categories/{categoryId}",
     // 查询目录详情
-    JTXT_GET_CATEGORIES_CATEGROYID_MATERIALS:
-      "categories/{categoryId}/materials",
-    // 查询目录详情
+    JTXT_GET_CATEGORIES_CATEGROYID_MATERIALS: "categories/{categoryId}/materials",
+    // 查询素材详情
     JTXT_GET_MATERIAL_MATERIALID: "materials/{materialId}"
   }
 };

+ 5 - 1
src/api/modules/user.js

@@ -7,6 +7,10 @@ export default {
     //  查询考试历史
     JTXT_GET_USER_EXAMS_HISTORY: "exams/history",
     // 查询收藏
-    JTXT_GET_USER_FAVORITES: "/user/{userName}/favorites"
+    JTXT_GET_USER_FAVORITES: "/user/{userName}/favorites",
+    // 收藏
+    JTXT_POST_FAVORITE_MATERIALID: "/user/{userName}/favorites",
+    // 删除收藏
+    JTXT_DELETE_REMOVE_FAVORITE_MATERIALID: "user/{userName}/favorites"
   }
 };

+ 63 - 1
src/views/home/learn/page-learn-content.vue

@@ -1,7 +1,14 @@
 <template>
   <div>
     <van-nav-bar title="学习" left-arrow @click-left="onClickLeft" />
+    <div v-if="seconds>0">剩余学习时间: 0:0:{{seconds}}</div>
     <div>{{ contentObj.contents }}</div>
+    <div @click="clickCollection()">收藏</div>
+    <div @click="clickRemoveCollection()">取消收藏</div>
+    <div>阅读 {{contentObj.readerCount}}</div>
+    <div>点赞 {{contentObj.likesCount}}</div>
+    <div>评论:</div>
+    <div></div>
   </div>
 </template>
 
@@ -14,13 +21,15 @@ export default {
   components: {},
   data() {
     return {
-      contentObj: null
+      contentObj: { contents: "" },
+      seconds: 10
     };
   },
   computed: {},
   created() {},
   mounted() {
     this.getContent();
+    this.caculateTime();
   },
   methods: {
     //   查询具体内容
@@ -40,6 +49,59 @@ export default {
     },
     onClickLeft() {
       this.$router.back();
+    },
+    caculateTime() {
+      var interval = setInterval(() => {
+        if (this.seconds > 0) {
+          this.seconds--;
+        } else {
+          clearInterval(interval);
+        }
+      }, 1000);
+    },
+    // 点击收藏
+    clickCollection() {
+      let path = {
+        userName: "testuser-ztdxxDGdNj"
+      };
+      let params = {
+        id: this.materialId
+      };
+      this.$_http
+        .get(this.$pathParams(this.$_API.JTXT_POST_FAVORITE_MATERIALID, path), {
+          params
+        })
+        .then(res => {
+          console.log("--收藏--" + JSON.stringify(res.data));
+        })
+        .catch(() => {
+          this.$store.commit("toggleLoading", false);
+        });
+    },
+    // 移除收藏
+    clickRemoveCollection() {
+      let path = {
+        userName: "testuser-ztdxxDGdNj"
+      };
+      let params = {
+        id: this.materialId
+      };
+      this.$_http
+        .delete(
+          this.$pathParams(
+            this.$_API.JTXT_DELETE_REMOVE_FAVORITE_MATERIALID,
+            path
+          ),
+          {
+            params
+          }
+        )
+        .then(res => {
+          console.log("--取消收藏--" + JSON.stringify(res.data));
+        })
+        .catch(() => {
+          this.$store.commit("toggleLoading", false);
+        });
     }
   }
 };

+ 6 - 15
src/views/home/person/exam-history.vue

@@ -1,18 +1,9 @@
 <template>
   <div>
     <van-nav-bar title="成绩" left-arrow @click-left="onClickLeft" />
-    <van-list
-      v-model="loading"
-      :finished="finished"
-      finished-text="没有更多了"
-      @load="onLoad"
-    >
-      <van-cell
-        v-for="(item, index) in examHistoryList"
-        :key="index"
-        :title="item.name"
-      >
-        <div>{{ item.time }}</div>
+    <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
+      <van-cell v-for="(item, index) in examHistoryList" :key="index" :title="item.examId">
+        <div>{{ item.startTime }}</div>
       </van-cell>
     </van-list>
   </div>
@@ -42,14 +33,14 @@ export default {
   methods: {
     getExamHistory() {
       let params = {
-        user: "testuser-zirKBELIlg"
+        user: "testuser-ztdxxDGdNj"
       };
       this.$_http
         .get(this.$_API.JTXT_GET_USER_EXAMS_HISTORY, { params })
         .then(res => {
-          this.contentObj = res.data;
+          this.examHistoryList = res.data;
           console.log(
-            "--user-exam-history--" + JSON.stringify(this.contentObj)
+            "--user-exam-history--" + JSON.stringify(this.examHistoryList)
           );
           this.finished = true;
         })