// pages/plan/plan.js const app = getApp() const host = app.globalData.host; Page({ data: { array1:['特种作业'], array2: [], array3: [], index1:-1, index2: -1, index3: -1, list:[] }, onLoad: function (options) { this.getData() wx.request({ url: host + '/api/wx/sujectitem', success: res => { this.setData({ array1: res.data.data }) } }) }, bindPickerChange:function(e){ if (e.target.dataset.id == 1) { let list = this.data.array1[e.detail.value].children console.log(list) this.setData({ index1: e.detail.value, array2:list, array3:[], index2:-1, index3: -1 }) }; if (e.target.dataset.id == 2) { let list = this.data.array2[e.detail.value].children this.setData({ index2: e.detail.value, array3: list, index3: -1 }) }; if (e.target.dataset.id == 3) { this.setData({ index3: e.detail.value }) }; this.getData(); }, getData:function(){ wx.showLoading({ title: '', }) var parm={} if (this.data.index1>=0){ parm.subject_item0 = this.data.array1[this.data.index1].name } if (this.data.index2 >= 0) { parm.subject_item1 = this.data.array2[this.data.index2].name } if (this.data.index3 >= 0) { parm.subject_item2 = this.data.array3[this.data.index3].name } wx.request({ url: host+'/api/wx/class/list', method:'GET', data: parm, success:res=>{ wx.hideLoading() this.setData({ list:res.data.data }) } }) }, onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })