/* * 手太欠 * 愿这世界都如故事里一样 美好而动人~ */ Page({ data: { categoriesArr : [], // 健康分类 categoryId : '', // 分类id listsArr : [], // 列表 page : {}, // 分页信息 lodingStats : false,// 加载状态 }, onLoad(options) { // 获取健康分类 this.categoriesInfo(); }, /** * 健康分类 */ categoriesInfo() { wx.$api.health.healthNav().then(res => { this.setData({ categoriesArr : res.data, categoryId : res.data[0].category_id }) // 获取健康列表 this.healthInfo(); }).catch(err => {}) }, /** * 分类选择 */ tabsTap(e) { this.setData({ categoryId: e.currentTarget.dataset.id }) // 获取健康分类 this.healthInfo(); }, /** * 健康列表 */ healthInfo(page) { wx.$api.health.healthList({ category_id: this.data.categoryId, page : page || 1 }).then(res => { let listArr = this.data.listsArr, newData = [] if(page == 1 || page == undefined) listArr = [] newData = listArr.concat(res.data.data) this.setData({ listsArr : newData, page : res.data.page, lodingStats : false }) wx.stopPullDownRefresh() }).catch(err => {}) }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { // 获取健康列表 this.healthInfo(); }, /** * 上拉加载 */ onReachBottom(){ this.setData({ lodingStats: true }) let pageNumber = this.data.page.current if(this.data.page.has_more){ pageNumber++ // 获取健康列表 this.healthInfo(pageNumber); } } })