170 lines
3.8 KiB
JavaScript
170 lines
3.8 KiB
JavaScript
// packageH/circleCommunity/circleMember/circleMember.js
|
|
var app = getApp();
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
page: 1, //分页数,当前页数
|
|
isLoadMore: true, //判断是否要加载更多的标志
|
|
total_page: 0, //总页数
|
|
listData:[],
|
|
networkLoading:false,
|
|
|
|
circleId:0,
|
|
searchText:''
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.data.circleId = options.circleId;
|
|
this.getListData();
|
|
},
|
|
|
|
initData(){
|
|
this.setData({
|
|
page:1,
|
|
total_page:0,
|
|
isLoadMore:true,
|
|
networkLoading:false
|
|
});
|
|
},
|
|
|
|
getListData(){
|
|
this.initData();
|
|
let urlStr = app.getNetAddresss('plugin.circle.frontend.circle-member.get-circle-memberList');
|
|
let {searchText} = this.data;
|
|
let json={nickname:searchText,circle_id:this.data.circleId,is_review:1};
|
|
app._postNetWork({
|
|
url: urlStr,
|
|
data:json,
|
|
success: (resdata) => {
|
|
var res = resdata.data;
|
|
if (res.result != 1) return app.tips(res.msg);
|
|
this.data.total_page = res.data.last_page;
|
|
if (!this.data.total_page) {
|
|
this.data.total_page = 0;
|
|
}
|
|
this.setData({
|
|
listData:res.data.data,
|
|
networkLoading:true
|
|
});
|
|
}
|
|
});
|
|
},
|
|
|
|
//加载更多数据
|
|
_getMoreData(){
|
|
this.data.isLoadMore = false; // 防止多次请求分页数据
|
|
if (this.data.page >= this.data.total_page) {
|
|
// that.loading = true;
|
|
return;
|
|
} else {
|
|
this.data.page += 1;
|
|
let urlStr = app.getNetAddresss('plugin.circle.frontend.circle-member.get-circle-memberList');
|
|
let {searchText} = this.data;
|
|
let json={nickname:searchText,page:this.data.page,circle_id:this.data.circleId,is_review:1};
|
|
|
|
app._postNetWork({
|
|
url: urlStr,
|
|
data:json,
|
|
success: (resdata) => {
|
|
let res = resdata.data;
|
|
this.data.isLoadMore = true;
|
|
if (res.result === 1) {
|
|
let listData = this.data.listData.concat(res.data.data);
|
|
this.setData({listData});
|
|
} else {
|
|
this.data.page = this.data.page - 1;
|
|
this.data.isLoadMore = false;
|
|
}
|
|
}
|
|
});
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
delMember(evt){
|
|
let index = evt.currentTarget.dataset.index;
|
|
let item = evt.currentTarget.dataset.item;
|
|
wx.showModal({
|
|
title: '是否删除该会员',
|
|
success :(res)=> {
|
|
console.log(res);
|
|
if (res.confirm) {
|
|
console.log("点击确定");
|
|
this.pushDelMember(item.id,index);
|
|
} else if (res.cancel) {
|
|
console.log('用户点击取消');
|
|
}
|
|
}
|
|
});
|
|
},
|
|
pushDelMember(id,index){
|
|
let urlStr = app.getNetAddresss('plugin.circle.frontend.circle.delete-circle-member');
|
|
app._postNetWork({
|
|
url: urlStr,
|
|
data:{circle_id:this.data.circleId,member_id:id},
|
|
success: (resdata) => {
|
|
var res = resdata.data;
|
|
if (res.result != 1) return app.tips(res.msg);
|
|
let listData = this.data.listData;
|
|
listData.splice(index,1);
|
|
this.setData({listData});
|
|
|
|
}
|
|
});
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareTimeline(){},
|
|
onShareAppMessage: function () {
|
|
|
|
}
|
|
}); |