Procházet zdrojové kódy

默认中文匹配

谢杰标 před 2 roky
rodič
revize
52ce1316b9
1 změnil soubory, kde provedl 34 přidání a 15 odebrání
  1. 34 15
      pages/course/index.vue

+ 34 - 15
pages/course/index.vue

@@ -395,7 +395,6 @@ export default {
           name: "直播课",
         },
       ],
-      // array:['全部','建设工程施工管理','机电全科','机电工程管理与实','机电全科','全科'],
       current: 0,
       menuIndex: 0,
       menuIndex1: 0,
@@ -443,6 +442,8 @@ export default {
       },
       imgwidth: 0,
       imgheight: 0,
+      ename: "",
+      bname: "",
     };
   },
   onPullDownRefresh() {
@@ -452,17 +453,17 @@ export default {
     }, 500);
   },
   onLoad(option) {
-    uni.hideTabBar()
+    uni.hideTabBar();
     let eduStr = null;
     // 小程序分享跳转
     if (option.scene) {
       let arrs = decodeURIComponent(option.scene).split("&");
       for (let i = 0; i < arrs.length; i++) {
-        option[arrs[i].split("=")[0]] = arrs[i].split("=")[1]*1;
+        option[arrs[i].split("=")[0]] = arrs[i].split("=")[1] * 1;
       }
     }
     // 默认值
-    let { bid, pid, eid, cur } = option;
+    let { bid, pid, eid, cur, ename, bname } = option;
     if (bid && pid && eid) {
       uni.setStorageSync(
         "eduObj",
@@ -474,6 +475,12 @@ export default {
       );
     }
     cur && (this.current = cur);
+    if (ename && bname) {
+      this.ename = ename;
+      this.bname = bname;
+      this.initList();
+      return;
+    }
     eduStr = uni.getStorageSync("eduObj");
     if (eduStr) {
       this.selObj = JSON.parse(eduStr);
@@ -514,7 +521,7 @@ export default {
         }
       });
     },
-    active2(item) {
+    active2(item, isI = true) {
       // console.log('item', item)
       if (item.topicId) {
         uni.navigateTo({
@@ -534,14 +541,21 @@ export default {
       });
       this.mergeBusiness();
       //初始化
-      this.initList();
+      isI && this.initList();
     },
     businessList(data) {
-      var self = this;
-      // /app/common/course/business/list
       this.$api.businessList(data).then((res) => {
         if (res.data.code == 200) {
-          self.bList = res.data.rows;
+          this.bList = res.data.rows;
+          if (this.bname) {
+            const item = this.bList.find((e) => e.aliasName == this.bname);
+            this.bname = "";
+            if (item) {
+              this.active2(item, false);
+            } else {
+              this.show = true;
+            }
+          }
         }
       });
     },
@@ -550,15 +564,20 @@ export default {
       this.businessList({ educationId: item.id });
     },
     educationList() {
-      var self = this;
-      // /app/common/course/educationType/list
       this.$api.educationTypeList().then((res) => {
         if (res.data.code == 200) {
-          self.eList = res.data.rows;
-          if (self.selObj.eId) {
-            self.businessList({ educationId: self.selObj.eId });
+          this.eList = res.data.rows;
+          if (this.ename) {
+            const item = this.eList.find((e) => e.educationName == this.ename);
+            this.ename = "";
+            if (item) {
+              this.selObj.eId = item.id;
+            }
+          }
+          if (this.selObj.eId) {
+            this.businessList({ educationId: this.selObj.eId });
           } else {
-            this.active1(self.eList[0]);
+            this.active1(this.eList[0]);
           }
         }
       });