Parcourir la source

优化课程分类-音频展示效果

cgp il y a 15 heures
Parent
commit
9f22e3b95e
1 fichiers modifiés avec 13 ajouts et 0 suppressions
  1. 13 0
      src/views/course/userCourseCategory/index.vue

+ 13 - 0
src/views/course/userCourseCategory/index.vue

@@ -226,10 +226,23 @@ export default {
       this.loading = true;
       listUserCourseCategory(this.queryParams).then(response => {
         this.userCourseCategoryList = this.handleTree(response.data, "cateId", "pid");
+        this.fillType(this.userCourseCategoryList);
         this.total = response.total;
         this.loading = false;
       });
     },
+    /** type 只在顶级分类维护,子分类为空时继承父级的 type */
+    fillType(nodes, parentType) {
+      if (!nodes || !nodes.length) return
+      nodes.forEach(node => {
+        if ((node.type === null || node.type === undefined || node.type === '') && parentType != null) {
+          node.type = parentType
+        }
+        if (node.children && node.children.length) {
+          this.fillType(node.children, node.type)
+        }
+      })
+    },
     /** 转换课程分类数据结构 */
     normalizer(node) {
       if (node.children && !node.children.length) {