chengjie před 3 měsíci
rodič
revize
e7a8894063
1 změnil soubory, kde provedl 31 přidání a 5 odebrání
  1. 31 5
      pages_test/knowledge/library.js

+ 31 - 5
pages_test/knowledge/library.js

@@ -6,8 +6,11 @@ const app = getApp();
6 6
 Page({
7 7
   data: {
8 8
     Menu1:0,
9
+    Menu2Index:-1,
9 10
     Menu2:0,
10
-    Menu2Array:[],
11
+    Menu2Array1:[{ID:0,Name:"全部",CSS:""},{ID:1,Name:"小学",CSS:""},{ID:2,Name:"初中",CSS:""},{ID:3,Name:"高中",CSS:""},{ID:4,Name:"大学",CSS:""}],
12
+    Menu2Array2:[{ID:0,Name:"全部",CSS:""},{ID:1,Name:"课本",CSS:""},{ID:2,Name:"课外拓展",CSS:""}],
13
+    IsShowMenu:false,
11 14
   },
12 15
   onPullDownRefresh: function () {
13 16
     wx.stopPullDownRefresh();
@@ -38,11 +41,11 @@ Page({
38 41
     var category=e.currentTarget.dataset.category;
39 42
     var menu1;
40 43
     if (category=="语文"){
41
-      that.data.Menu2Array=[{ID:0,Name:"全部",CSS:"Selected"},{ID:1,Name:"小学",CSS:""},{ID:2,Name:"初中",CSS:""},{ID:3,Name:"课外拓展",CSS:""}];
44
+      that.data.Menu2Array=[{ID:0,Name:"全部",CSS:""},{ID:1,Name:"小学",CSS:""},{ID:2,Name:"初中",CSS:""},{ID:3,Name:"高中",CSS:""},{ID:4,Name:"大学",CSS:""}];
42 45
       menu1=0;
43 46
     }
44 47
     else{
45
-      that.data.Menu2Array=[{ID:0,Name:"全部",CSS:"Selected"},{ID:1,Name:"小学",CSS:""},{ID:2,Name:"初中",CSS:""},{ID:3,Name:"高中",CSS:""},{ID:4,Name:"大学",CSS:""}];
48
+      that.data.Menu2Array=[{ID:0,Name:"全部",CSS:""},{ID:1,Name:"课本",CSS:""},{ID:2,Name:"课外拓展",CSS:""}];
46 49
       menu1=1;
47 50
     }
48 51
     for(var j=0;j<that.data.List.length;j++){
@@ -70,8 +73,15 @@ Page({
70 73
             that.data.List[j].GradeSelected=1;
71 74
           else{
72 75
             that.data.List[j].GradeSelected=0;
73
-            if (that.data.List[j].Grade.indexOf(menu)>=0){
74
-              that.data.List[j].GradeSelected=1;
76
+            if (that.data.Menu2Index==0){
77
+              if (that.data.List[j].Grade.indexOf(menu)>=0){
78
+                that.data.List[j].GradeSelected=1;
79
+              }
80
+            }
81
+            else if (that.data.Menu2Index==1){
82
+              if (that.data.List[j].Category2.indexOf(menu)>=0){
83
+                that.data.List[j].GradeSelected=1;
84
+              }
75 85
             }
76 86
           }
77 87
         }
@@ -81,14 +91,30 @@ Page({
81 91
       Menu2:index,
82 92
       Menu2Array:list,
83 93
       List:that.data.List,
94
+      IsShowMenu:false,
84 95
     });
85 96
   },
97
+  showMenu2:function(e){
98
+    let index=e.currentTarget.dataset.index;
99
+    let menu2Array=this.data.Menu2Array1;
100
+    if (index==1)
101
+      menu2Array=this.data.Menu2Array2;
102
+    this.setData({
103
+      IsShowMenu:true,
104
+      Menu2Index:index,
105
+      Menu2Array:menu2Array,
106
+    })
107
+  },
86 108
   goto: function (e) {
87 109
     var url = e.currentTarget.dataset.url;
88 110
     wx.navigateTo({
89 111
       url: url,
90 112
     });
91 113
   },
114
+  catchTouchMove:function(e) {
115
+    // 这个函数不需要做任何事情,只需要捕获事件防止冒泡
116
+    return false;
117
+  },
92 118
   onShareAppMessage: function () {
93 119
     return {
94 120
       title: app.globalData.ShareTitle,