//index.js import { getGroupListNew } from '../../api/index' import { getStorageSync, navigateTo } from '../../utils/util' Page({ data: { loading: true, mLoading: false, hideCityTip: false, showData: false, showNoDataTip: false, hasMoreData: false, cityName: '', listQuery: { page: 1, limit: 10, cityId: '' }, groupList: [] }, onLoad: function () { const citySelectObj = getStorageSync('citySelectObj') const { cityId, cityName } = citySelectObj this.data.listQuery.cityId = cityId this.setData({ cityName }) // 城市选择提示 setTimeout(() => { this.setData({ hideCityTip: true }) }, 4000) this.getGroups(); }, onShow: function () { }, onPullDownRefresh: function () { this.data.listQuery.page = 1 this.getGroups() }, onReachBottom: function (e) { if (this.data.hasMoreData) { this.data.listQuery.page += 1 this.getGroups() } }, /** * 用户点击右上角分享 */ onShareAppMessage: function() { return { title: "组织已经准备好,还不快来~", path: "/pages/index/index" } }, refresh: function () { this.data.listQuery.page = 1 this.getGroups() }, getGroups: function () { const listQuery = this.data.listQuery const groupList = this.data.groupList getGroupListNew(listQuery).then((result) => { const data = result.data || {} this.setData({ loading: false, showData: true, mLoading: false, groupList: listQuery.page > 1 ? groupList.concat(data.list) : data.list || [], showNoDataTip: listQuery.page > 1, hasMoreData: data.pages.totalCount > listQuery.page * listQuery.limit }) }).catch((err) => { this.setData({ loading: false, showData: true, mLoading: false }) }) }, onCityTap: function () { navigateTo('/pages/select/select') }, onSearchTap: function () { navigateTo('/pages/search/search') }, onJoin: function (e) { const { index } = e.detail const groupList = this.data.groupList navigateTo(`/pages/detail/detail?id=${groupList[index].id}`) } })