|
|
@ -1,5 +1,7 @@ |
|
|
|
const api = require('../../../../utils/api') |
|
|
|
|
|
|
|
let leftHeight = 0 |
|
|
|
let rightHeight = 0 |
|
|
|
let query = '' |
|
|
|
Page({ |
|
|
|
data: { |
|
|
|
loadMoreType: 'none', |
|
|
@ -8,9 +10,12 @@ Page({ |
|
|
|
pageSize: 10, |
|
|
|
deptName: '', |
|
|
|
deptIntro: '', |
|
|
|
griderList: [] |
|
|
|
griderList: [], |
|
|
|
griderLeftList: [], |
|
|
|
griderRightList: [] |
|
|
|
}, |
|
|
|
onLoad() { |
|
|
|
query = wx.createSelectorQuery() |
|
|
|
this.getDeptInfo() |
|
|
|
this.getMemberList() |
|
|
|
}, |
|
|
@ -23,6 +28,19 @@ Page({ |
|
|
|
this.loadMoreMemberList() |
|
|
|
} |
|
|
|
}, |
|
|
|
getBoxHeight(griderLeftList, griderRightList) { //获取左右两边高度
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
this.setData({ griderLeftList, griderRightList }, () => { |
|
|
|
query.select('#left').boundingClientRect() |
|
|
|
query.select('#right').boundingClientRect() |
|
|
|
query.exec((res) => { |
|
|
|
leftHeight = res[0].height //获取左边列表的高度
|
|
|
|
rightHeight = res[1].height //获取右边列表的高度
|
|
|
|
resolve() |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 社区介绍
|
|
|
|
getDeptInfo() { |
|
|
|
api.getDeptInfo().then(res => { |
|
|
@ -45,14 +63,17 @@ Page({ |
|
|
|
wx.showLoading({ |
|
|
|
title: '加载中...' |
|
|
|
}) |
|
|
|
api.getMemberList(params).then(res => { |
|
|
|
api.getMemberList(params).then(async (res) => { |
|
|
|
wx.hideLoading() |
|
|
|
const arr = [] |
|
|
|
// res.data.forEach()
|
|
|
|
this.setData({ |
|
|
|
griderList: res.data, |
|
|
|
loadMoreType: res.data.length === this.data.pageSize ? 'loading' : 'none' |
|
|
|
}) |
|
|
|
const { griderList, griderLeftList, griderRightList } = this.data |
|
|
|
for (const item of griderList) { |
|
|
|
leftHeight <= rightHeight ? griderLeftList.push(item) : griderRightList.push(item) //判断两边高度,来觉得添加到那边
|
|
|
|
await this.getBoxHeight(griderLeftList, griderRightList) |
|
|
|
} |
|
|
|
}).catch(err => { |
|
|
|
wx.hideLoading() |
|
|
|
this.setData({ |
|
|
@ -70,12 +91,17 @@ Page({ |
|
|
|
wx.showLoading({ |
|
|
|
title: '加载中...' |
|
|
|
}) |
|
|
|
api.getMemberList(params).then(res => { |
|
|
|
api.getMemberList(params).then(async (res) => { |
|
|
|
wx.hideLoading() |
|
|
|
this.setData({ |
|
|
|
griderList: this.data.griderList.concat(res.data), |
|
|
|
loadMoreType: res.data.length === this.data.pageSize ? 'loading' : 'none' |
|
|
|
}) |
|
|
|
const { griderList, griderLeftList, griderRightList } = this.data |
|
|
|
for (const item of griderList) { |
|
|
|
leftHeight <= rightHeight ? griderLeftList.push(item) : griderRightList.push(item) //判断两边高度,来觉得添加到那边
|
|
|
|
await this.getBoxHeight(griderLeftList, griderRightList) |
|
|
|
} |
|
|
|
}).catch(err => { |
|
|
|
wx.hideLoading() |
|
|
|
console.error(err) |
|
|
|