tanyanfei 4 vuotta sitten
vanhempi
commit
8c30bb4de0
1 muutettua tiedostoa jossa 14 lisäystä ja 7 poistoa
  1. 14 7
      pages/post/post.js

+ 14 - 7
pages/post/post.js

@@ -118,14 +118,22 @@ Page({
                 }
                 //获取班级列表
                 wx.request({
-                  url: host + '/api/wx/class/list?subject_item0=' + list[0].name,
+                  url: host + '/api/wx/class/list' ,
                   method: 'GET',
+                  data:{
+                    subject_item0: subject_item[0],
+                    subject_item1: subject_item[1],
+                    subject_item2: subject_item[2]
+                  },
                   success: res => {
-                    let classes = res.data.data[0].classes, class_=0
-                    for(let i=0;i<classes.length;i++){
-                      if (classes[i].cid == data.class_id){
-                        class_=i
-                        }
+                    let class_ = 0;
+                    if (res.data.data.length>0){
+                      let classes = res.data.data[0].classes;
+                      for(let i=0;i<classes.length;i++){
+                        if (classes[i].cid == data.class_id){
+                          class_=i
+                          }
+                      }
                     }
                     this.setData({
                       classList: classes,
@@ -166,7 +174,6 @@ Page({
       
   },
   getClass(){
-    console.log()
     let category = this.data.category>=0 ? this.data.categoryArray[this.data.category].name:'',
       subject = this.data.subject >= 0 ? this.data.subjectArray[this.data.subject].name : ''
     wx.request({