Bladeren bron

调用接口

aaa 4 jaren geleden
bovenliggende
commit
a2b107490c

+ 0 - 10
src/api/modules/jtxt.js

@@ -1,10 +0,0 @@
-// TMC系统相关api
-export default {
-  basePath: process.env.VUE_APP_JTXT_URL,
-  apiList: {
-    // 查询根目录
-    JTXT_GET_CATEGORIES: "categories",
-    // 查询目录详情
-    JTXT_GET_CATEGORIES_CATEGROYID: "categories/{categoryId}"
-  }
-};

+ 14 - 0
src/api/modules/learn.js

@@ -0,0 +1,14 @@
+// TMC系统相关api
+export default {
+  basePath: process.env.VUE_APP_JTXT_URL,
+  apiList: {
+      // 查询根目录
+      JTXT_GET_CATEGORIES: "categories",
+      // 查询目录详情
+      JTXT_GET_CATEGORIES_CATEGROYID: "categories/{categoryId}",
+      // 查询目录详情
+      JTXT_GET_CATEGORIES_CATEGROYID_MATERIALS: "categories/{categoryId}/materials",
+      // 查询目录详情
+      JTXT_GET_MATERIAL_MATERIALID: "materials/{materialId}"
+  }
+};

+ 2 - 1
src/router/index.js

@@ -27,8 +27,9 @@ let routes = [
     component: () => import("@/views/home/exam/page-exam-item-doing")
   }, // 单个考试的试卷页
   {
-    path: "/Learn-Content",
+    path: "/learn-content/:materialId",
     name: "learn-content",
+    props: true,
     component: () => import("@/views/home/learn/page-learn-content")
   } // 学习内容页
 ];

+ 13 - 6
src/views/home/learn/page-learn-child.vue

@@ -33,7 +33,6 @@
 </template>
 
 <script>
-import { pathParams } from "@/utils/tools";
 export default {
   name: "page-learn-child",
   components: {},
@@ -63,7 +62,7 @@ export default {
     "learnChildList.length": {
       handler(newValue, oldValue) {
         if (oldValue === 0 && newValue !== 0) {
-          this.getChildList();
+          this.getContentList();
         }
       }
     }
@@ -72,15 +71,20 @@ export default {
     childChange(index) {
       this.finished = false;
       this.choosedChildIndex = index;
-      this.getChildList();
+      this.getContentList();
     },
     //   查询子目录
-    getChildList() {
+    getContentList() {
       let path = {
         categoryId: this.learnChildList[this.choosedChildIndex].id
       };
       this.$_http
-        .get(pathParams(this.$_API.JTXT_GET_CATEGORIES_CATEGROYID, path))
+        .get(
+          this.$pathParams(
+            this.$_API.JTXT_GET_CATEGORIES_CATEGROYID_MATERIALS,
+            path
+          )
+        )
         .then(res => {
           this.contentList = res.data;
           //   移除第一个
@@ -94,7 +98,10 @@ export default {
     },
     onLoad() {},
     chooseContent(index) {
-      this.$router.push({ name: "learn-content" });
+      this.$router.push({
+        name: "learn-content",
+        params: { materialId: this.contentList[index].id }
+      });
     }
   }
 };

+ 23 - 3
src/views/home/learn/page-learn-content.vue

@@ -1,23 +1,43 @@
 <template>
   <div>
     <van-nav-bar title="学习" left-arrow @click-left="onClickLeft" />
+    <div>{{ contentObj.contents }}</div>
   </div>
 </template>
 
 <script>
-// import { pathParams } from "@/utils/tools";
 export default {
   name: "page-learn-content",
+  props: {
+    materialId: [Number, String]
+  },
   components: {},
   data() {
-    return {};
+    return {
+      contentObj: null
+    };
   },
   computed: {},
   created() {},
   mounted() {
-    console.log("======学习页面");
+    this.getContent();
   },
   methods: {
+    //   查询具体内容
+    getContent() {
+      let path = {
+        materialId: this.materialId
+      };
+      this.$_http
+        .get(this.$pathParams(this.$_API.JTXT_GET_MATERIAL_MATERIALID, path))
+        .then(res => {
+          this.contentObj = res.data;
+          console.log("--content--" + JSON.stringify(this.contentObj));
+        })
+        .catch(() => {
+          this.$store.commit("toggleLoading", false);
+        });
+    },
     onClickLeft() {
       this.$router.back();
     }