You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
125 lines
2.4 KiB
JavaScript
125 lines
2.4 KiB
JavaScript
2 years ago
|
// pages/group/group.js
|
||
|
import {
|
||
|
getUserList
|
||
|
} from '../../api/api'
|
||
|
const app = getApp();
|
||
|
|
||
|
Page({
|
||
|
|
||
|
/**
|
||
|
* 页面的初始数据
|
||
|
*/
|
||
|
data: {
|
||
|
users: [],
|
||
|
keyword: '',
|
||
|
select: {
|
||
|
page: 1,
|
||
|
size: 10,
|
||
|
isEnd: false
|
||
|
},
|
||
|
role: ''
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面加载
|
||
|
*/
|
||
|
onLoad(options) {
|
||
|
// this.getData()
|
||
|
this.data.role = app.globalData.currentUser.jtRoleCode
|
||
|
},
|
||
|
|
||
|
edit(e) {
|
||
|
wx.navigateTo({
|
||
|
url: '/pages/user-edit/user-edit?id='+(e.target.dataset.id || ''),
|
||
|
})
|
||
|
},
|
||
|
|
||
|
handleSearch(e) {
|
||
|
this.data.select = {
|
||
|
page: 1,
|
||
|
size: 10,
|
||
|
isEnd: false
|
||
|
}
|
||
|
this.data.users = [];
|
||
|
this.getData()
|
||
|
},
|
||
|
|
||
|
getData() {
|
||
|
if (this.data.select.isEnd) {
|
||
|
return
|
||
|
}
|
||
|
const param = {
|
||
|
keyword: this.data.keyword,
|
||
|
pageNo: this.data.select.page,
|
||
|
teamId: this.data.role == 'leader' ? app.globalData.currentUser.jtTeamId : undefined
|
||
|
}
|
||
|
getUserList(param).then(res => {
|
||
|
const arr = [...this.data.users]
|
||
|
if (res.data && res.data.list && res.data.list.length > 0) {
|
||
|
this.data.select.page++
|
||
|
} else {
|
||
|
this.data.select.isEnd = true
|
||
|
}
|
||
|
const datas = arr.concat(res.data.list || [])
|
||
|
this.setData({
|
||
|
users: datas
|
||
|
})
|
||
|
})
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面初次渲染完成
|
||
|
*/
|
||
|
onReady() {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面显示
|
||
|
*/
|
||
|
onShow() {
|
||
|
this.data.users = [],
|
||
|
this.data.select = {
|
||
|
page: 1,
|
||
|
size: 10,
|
||
|
isEnd: false
|
||
|
},
|
||
|
this.getData()
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面隐藏
|
||
|
*/
|
||
|
onHide() {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面卸载
|
||
|
*/
|
||
|
onUnload() {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 页面相关事件处理函数--监听用户下拉动作
|
||
|
*/
|
||
|
onPullDownRefresh() {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 页面上拉触底事件的处理函数
|
||
|
*/
|
||
|
onReachBottom() {
|
||
|
console.log(111)
|
||
|
this.getData()
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 用户点击右上角分享
|
||
|
*/
|
||
|
onShareAppMessage() {
|
||
|
|
||
|
}
|
||
|
})
|