锦水居民端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

107 lines
2.5 KiB

// subpages/understandJs/pages/archivesDept/archivesDept.js
const api = require('../../../../utils/understandJs')
Page({
/**
* 页面的初始数据
*/
data: {
pageindex: 1,
pagesize: 10,
searchContent: '',
deptId:'',
archivesList: [],
nodata: false,
loadMoreType: 'none',
loadMoreVisible: false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
console.log(options)
this.setData({
searchContent: options.searchContent,
deptId: options.deptId
})
wx.setNavigationBarTitle({
title: options.dept
})
this.search(this.data.deptId, this.data.searchContent)
},
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;
}
this.search(this.data.deptId, this.data.searchContent)
},
search(deptId, keywords) {
let params = {
pageindex: this.data.pageindex,
pagesize: this.data.pagesize,
deptId,
searchContent: keywords
}
api.archivelist(params).then(res => {
console.log('搜索接口', res);
this.setData({
archivesList: [...this.data.archivesList,...res.data],
loadMoreType: res.data.length === this.data.pageSize ? 'loading' : 'none',
loadMoreVisible: res.data.length === this.data.pageSize ? false : true
})
if (this.data.archivesList.length == 0) {//没有值
this.setData({
nodata: true,
loadMoreType: 'none',
loadMoreVisible: false,
})
}
}).catch(err => {
this.setData({
archivesList: [],
nodata: true,
loadMoreType: 'none',
loadMoreVisible: false,
})
console.log(err)
})
},
/**
* 跳转到档案详情
*/
goToArchivesDetail (e) {
console.log(e.currentTarget.dataset)
wx.navigateTo({
url: `../archivesDetail/archivesDetail?archiveId=${e.currentTarget.dataset.archiveId}`
})
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
this.setData({
loadMoreVisible: true
})
if (this.data.loadMoreType === 'loading') {
this.setData({
pageIndex: this.data.pageIndex + 1,
pageSize: this.data.pageSize,
})
this.search(this.data.deptId, this.data.searchContent)
}
}
})