| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 | // pages/device-inner/index.jsimport http from '../../utils/http'import util from '../../utils/util'import api from '../../utils/api'Page({  /**   * 页面的初始数据   */  data: {    list: [],    page: 1,    touchBottom: false,    project_ids: [''],    work_point_ids: [''],    device: '',    device_name_id: '',    spec_id: '',    list: [],    number: '',    stat: null  },  /**   * 生命周期函数--监听页面加载   */  onLoad: function (options) {      },  getList: function () {    var data = this.data    var that = this    http({      url: 'inner-devices/search',      data: {        number: data.number,        project_ids: data.project_ids,        work_point_ids: data.work_point_ids,        device_id: data.device_id,        device_name_id: data.device_name_id,        spec_id: data.spec_id,        page: data.page,        stat: true      },      success: function (res) {        if (res.code == 0) {          var list = that.data.list          var touchBottom = that.data.touchBottom          list = list.concat(res.data);          if (res.data.length <= 0) {            touchBottom = true;          }          that.setData({            touchBottom,            list,            isSearch: false,            stat: res.stat          })        }      }    })  },  onChange: function(e) {    var name = e.currentTarget.dataset.name    this.setData({      [name]: e.detail    })  },  /**   * 生命周期函数--监听页面初次渲染完成   */  onReady: function () {  },  navigate: function(e) {    // this.saveFilter()    wx.navigateTo({      url: e.currentTarget.dataset.url,    })  },  saveFilter() {    var data = {      project_ids: this.data.project_ids,      work_point_ids: this.data.work_point_ids,      type: this.data.type,      name: this.data.name,      spec: this.data.spec    }    wx.setStorageSync('sg-device-filters', data)  },  /**   * 生命周期函数--监听页面显示   */  onShow: function () {    var data = wx.getStorageSync('sg-device-filters')    this.setData(data)    this.search()  },  search: function() {    this.setData({      touchBottom: false,      list: [],      page: 1    })    this.getList()  },  /**   * 生命周期函数--监听页面隐藏   */  onHide: function () {    // this.saveSearchOption()  },  /**   * 生命周期函数--监听页面卸载   */  onUnload: function () {  },  /**   * 页面相关事件处理函数--监听用户下拉动作   */  onPullDownRefresh: function () {  },  /**   * 页面上拉触底事件的处理函数   */  onReachBottom: function () {    if(!this.data.touchBottom) {      this.setData({        page: this.data.page + 1      })      this.getList()    } else {      util.error('没有更多数据了')    }  },  /**   * 用户点击右上角分享   */  onShareAppMessage: function () {  }})
 |