// subpages/understandJs/pages/archives/archives.js const api = require('../../../../utils/understandJs') Page({ /** * 页面的初始数据 */ data: { searchContent: '', pageIndex: 1, pageSize: 10, deptList: [], nodata: false, loadMoreType: 'none', loadMoreVisible: false }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.archivedepts() }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { this.setData({ searchContent: '' }) }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { this.setData({ loadMoreVisible: true }) if (this.data.loadMoreType === 'loading') { this.setData({ pageIndex: this.data.pageIndex + 1, pageSize: this.data.pageSize, }) this.archivedepts() } }, bindInputValue (e) { this.setData({ searchContent: e.detail.value }) }, searchFile () { console.log(this.data.searchContent) if(!this.data.searchContent.length) { wx.showToast({ title: '不能为空', icon: 'loading', duration: 2000 }) return; } let that = this wx.navigateTo({ url: `../archivesDept/archivesDept?dept=锦水档案&deptId=&searchContent=${that.data.searchContent}` }) }, archivedepts () { const parmas = { pageIndex:this.data.pageIndex, pageSize:this.data.pageSize } api.archivedepts(parmas).then(res => { console.log(res) this.setData({ deptList: [...this.data.deptList,...res.data], loadMoreType: res.data.length === this.data.pageSize ? 'loading' : 'none', loadMoreVisible: res.data.length === this.data.pageSize ? false : true }) if (this.data.deptList.length == 0) {//没有值 this.setData({ nodata: true, loadMoreType: 'none', loadMoreVisible: false, }) } }).catch(err => { this.setData({ deptList: [], nodata: true, loadMoreType: 'none', loadMoreVisible: false, }) console.log(err) }) }, /** * 跳转到档案归属部门 */ navigateToDept (e) { this.setData({ searchContent: '' }) let that = this wx.navigateTo({ url: `../archivesDept/archivesDept?dept=${e.currentTarget.dataset.dept}&deptId=${e.currentTarget.dataset.deptId}&searchContent=${that.data.searchContent}` }) } })