// pages/pbService/wbdw/index.js import commonApi from "../../../utils/https/common" Page({ /** * 页面的初始数据 */ data: { areas:[], areaIndex:0, levels:[], levelIndex:0, name:"", page_no:1, list:[], total:1 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.getArea() this.getLevels(); this.getList(); }, changeKeyword:function(e){ this.setData({ name:e.detail.value }) }, search:function(){ this.setData({ page_no:1, list:[], total:1 }) this.getList(); }, changeArea:function(e){ this.setData({ areaIndex:e.detail.value }) this.search(); }, changeLevel:function(e){ this.setData({ levelIndex:e.detail.value }) this.search(); }, getArea:function(){ commonApi._post("pbservice/Other/getSuzhouAreas",{}).then(res=>{ res.data.unshift({ area_code:"", area_name:"全部区域" }) this.setData({ areas:res.data }) }) }, getLevels:function(){ commonApi._post("pbservice/Relicunit/getRelicunitLevel",{}).then(res=>{ res.data.unshift("全部级别") this.setData({ levels:res.data }) }) }, getList:function(){ let list = this.data.list; if(list.length>=this.data.total) return; commonApi._post("pbservice/Relicunit/getList",{ name:this.data.name, area:this.data.areaIndex>0?this.data.areas[this.data.areaIndex].area_code:"", level_name:this.data.levelIndex>0?this.data.levels[this.data.levelIndex]:"", page_no:this.data.page_no, page_num:10 }).then(res=>{ this.setData({ list:list.concat(res.data.rows), total:res.data.total, page_no:this.data.page_no+1 }) }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { this.getList(); }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })