// subpages/associationNew/pages/associationlist/associationlist.js import { getPartyGroupList, getJoinGroup, getImageUrl2 } from "../../utils/api" const app = getApp() Page({ data: { associationList: [], loadMoreVisible: false, loadMoreType: "none", pageNo: 1, pageSize: 10, imageUrlList: [], statusHeight: 0, // 自定义头部状态栏高度 navigationHeight: 0, // 自定义头部导航栏高度 }, onLoad: function () { // this.getPartyGroupList(); this.setData({ statusHeight: app.globalData.deviceInfo.statusHeight, navigationHeight: app.globalData.deviceInfo.navigationHeight, }) getImageUrl2().then(res => { this.setData({ imageUrlList: [...res.data] }) }) }, onShow: function () { this.setData({ associationList: [] }) this.getPartyGroupList() }, onReachBottom: function () { this.setData({ loadMoreVisible: true }) if (this.data.loadMoreType === "loading") { this.setData({ pageNo: this.data.pageNo + 1 }) this.getPartyGroupList() } }, _backhome () { wx.navigateBack() }, //获取党群列表 getPartyGroupList () { getPartyGroupList().then(res => { console.log("获取党群列表", res) // const groupNameList = ["进入玫瑰苑社群", "进入玫瑰湖社群", "进入锦水园社群", "进入锦祥园社群", "进入土楼社群", "进入子顺社群", "进入城西社群"] // res.data.forEach((item, index) => { // if (index <= 6) { // item.groupName = groupNameList[index] // } else { // item.groupName = "进入社群" // } // }) this.setData({ associationList: [...this.data.associationList, ...res.data], loadMoreType: res.data.length === this.data.pageSize ? "loading": "none" }) }).catch(err => { console.log(err) this.setData({ associationList: [], loadMoreType: "none" }) }) }, //加入党群 getJoinGroup (pid) { let parm = { partyGroupId: pid } getJoinGroup(parm).then(res => { console.log(res) }).catch(err => { console.log(err) }) }, joinGroupCallBack (e) { this.getJoinGroup(e.detail.partyGroupId); } })