锦水居民端小程序
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.
 

115 lines
2.6 KiB

import {
getPartyUserList,
postUserBanned,
postModifyIdentity
} from "../../utils/api"
Page({
/**
* 页面的初始数据
*/
data: {
currentUser: {},
gMembersList: [],
loadMoreVisible: false,
loadMoreType: "none",
preloadVisible: true,
pageNo: 1,
pageSize: 10,
partyGroupId: ""
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.data.partyGroupId = options.partyGroupId
this.getPartyUserList()
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
this.setData({
loadMoreVisible: true
})
if (this.data.loadMoreType === "loading") {
this.setData({
pageNo: this.data.pageNo + 1
})
this.getPartyUserList()
}
},
// 获取群成员列表
getPartyUserList () {
const para = {
pageIndex: this.data.pageNo,
pageSize: this.data.pageSize,
partyGroupId: this.data.partyGroupId
}
wx.showLoading({
title:""
})
getPartyUserList(para).then(res => {
console.log("获取群成员列表", res)
this.setData({
currentUser: {...res.data.currentUser},
gMembersList: [...this.data.gMembersList, ...res.data.otherUsers],
loadMoreType: res.data.otherUsers.length === this.data.pageSize ? "loading": "none",
preloadVisible: false
})
if (this.data.loadMoreType === "none" && this.data.gMembersList.length !== 0) {
this.setData({
loadMoreVisible: true
})
}
wx.hideLoading()
}).catch(err => {
console.log(err)
this.setData({
gMembersList: [],
loadMoreType: "none",
preloadVisible: false
})
})
},
bannedChangeCallBack (e) {
console.log(e.detail)
const para = {...e.detail}
postUserBanned(para).then(res => {
console.log("用户禁言", res)
this.data.gMembersList.forEach(item => {
if (item.id === e.detail.groupUserId) {
item.bannedFlag = e.detail.bannedFlag
}
})
this.setData({
gMembersList: this.data.gMembersList
})
}).catch(err => {
console.log(err)
})
},
modifyIdentityCallBack (e) {
console.log(e.detail)
const para = {...e.detail}
postModifyIdentity(para).then(res => {
console.log("修改用户身份", res)
this.setData({
gMembersList: [],
currentUser: {}
})
this.getPartyUserList();
}).catch(err => {
console.log(err)
})
}
})