var app = getApp() var that; Page({ data: { activeIndex: 1, page: 1, hall_type: 'waiting', list: [], userId: '', }, onLoad() { that = this; dd.setNavigationBar({ title: "悬赏任务大厅" }); this.setData({ userId: app.globalData.userData.id }) }, onShareAppMessage() { return { title: '悬赏任务大厅', desc: '有新的悬赏任务发布啦,大家快来抢!', path: 'pages/statistics/getTask/getTask' }; }, onShow() { if (app.globalData.userData) { if (that.data.page == 1) { dd.hideLoading(); that.getData(); } } else { app.login(app.globalData.corpId, function (is) { if (is) { if (that.data.page == 1) { dd.hideLoading(); that.getData(); } that.setData({ userId: app.globalData.userData.id }) } else { dd.reLaunch({ url: '../../noJurisdiction/noJurisdiction' }) } },function(){}) } }, getData(is) { var data = { page: that.data.page, page_size: 20, hall_type: this.data.hall_type } app.$get('api/integral/task/hall', data).then((res) => { var data = res.data.data.list; var list = that.data.list; data.forEach(element => { if (element.pt_id) { element.pt_name = app.getTypesItem(element.pt_id).name } }); if (is) { if (data.length < 20) { this.setData({ list: list.concat(data), isData: true }) } else { this.setData({ list: list.concat(data) }) } } else { this.setData({ list: data, isData: false }) } }) }, activeItem(e) { var index = e.target.dataset.index; this.setData({ activeIndex: index, page: 1, list: [], sxObj: [], hall_type: index == 1 ? 'waiting' : 'catch' }) this.getData(); }, openDetail(e) { var id = e.target.dataset.item.id; dd.navigateTo({ url: '../taskDetail/taskDetail?id=' + id }) }, //上啦加载 onScrollToLower() { if (!that.data.isData) { this.setData({ page: ++that.data.page }) this.getData(true); } }, });