// subpages/associationNew/pages/associationlist/associationlist.js import { getPartyGroupList, getJoinGroup, getImageUrl2 } from "../../utils/api" Page({ data: { associationList: [], loadMoreVisible: false, loadMoreType: "none", pageNo: 1, pageSize: 10, imageUrlList: [], }, onLoad: function () { // this.getPartyGroupList(); 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() } }, //获取党群列表 getPartyGroupList () { getPartyGroupList().then(res => { console.log("获取党群列表", res) const groupNameList = ["进入玫瑰苑社群", "进入玫瑰湖社群", "进入锦水园社群", "进入锦祥园社群"] res.data.forEach((item, index) => { if (index <= 3) { 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); } })