// pages/operIsp/operIsp.js const utils = require('../../utils/util.js') Page({ /** * 页面的初始数据 */ data: { list: [], pageNum: 1, pageSize: 20, pages: '', finish: false, keywords: '', }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.getList() }, //列表 getList(type) { let params = { mobile: utils.getInfo().mobile, pageNum: this.data.pageNum, pageSize: this.data.pageSize } if (this.data.keywords !== '') { params.name = this.data.keywords } utils.axios({ method: 'get', url: '/auth/isp/info/findPage', data: params, sendBefore() { wx.showNavigationBarLoading() }, complete() { wx.hideNavigationBarLoading() wx.stopPullDownRefresh() }, success: res => { let result = res.data if (type === 'toFresh') { this.setData({ list: result.records, pages: result.pages }) } else { let list = this.data.list list = list.concat(result.records) this.setData({ list, pages: result.pages }) } if (result.total <= this.data.pageSize) { this.setData({ finish: true }) } } }) }, toFresh() { this.setData({ pageNum: 1, pages: '', finish: false }) wx.pageScrollTo({ scrollTop: 0, duration: 300 }) this.getList('toFresh') }, //搜索 search(e) { let value = utils.trimAll(e.detail.value) this.setData({ keywords: value }) this.toFresh() }, //详情 toDetail(e) { let ispId = e.currentTarget.dataset.id wx.navigateTo({ url: '/pages/operIsp/detail?ispId=' + ispId }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { this.toFresh() }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { let pageNum = this.data.pageNum let pages = this.data.pages pageNum++ if (pageNum <= pages) { this.setData({ pageNum }) this.getList() } else { this.setData({ finish: true }) return } }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { return { title: '诺信云', path: '/pages/index/index' } } })