const app = getApp() Page({ data: { discussionType: 'issue', completeInfoDialogVisible: false, infoCompleted: 0, gridName: '', typeList: [{ //排名方式:0-周,1-月 type: '0', name: '议题', select: true }, { type: '1', name: '项目', select: false } ], }, onLoad () { this.setData({ infoCompleted: app.globalData.infoCompleted }) const gridName = wx.getStorageSync('topGridName') this.setData({ gridName }) }, onTabItemTap () { if (this.data.discussionType === 'issue') { this.issuelist.getIssueList() } else if (this.data.discussionType === 'project') { this.projectlist.getProjectList() } }, onPageScroll (e) { if (this.data.discussionType === 'issue') { this.issuelist.onPageScroll(e) } else if (this.data.discussionType === 'project') { this.projectlist.onPageScroll(e) } }, // 议题、项目切换 changeDiscussionType (e) { if (e.currentTarget.dataset.type === 'issue') { this.setData({ discussionType: 'issue' }) } else if (e.currentTarget.dataset.type === 'project') { console.log(this.projectlist) this.setData({ discussionType: 'project' }) } }, // 议题、项目切换 v2 onButtonChange: function(e) { const list = this.data.typeList let that = this; list.forEach(item => { if (item.type === e.currentTarget.dataset.type) { item.select = true } else { item.select = false } }) that.setData({ typeList: list, }) if(e.currentTarget.dataset.type == 0){ this.setData({ discussionType: 'issue' }) }else{ this.setData({ discussionType: 'project' }) } }, // 触底函数 onReachBottom () { if (this.data.discussionType === 'issue') { this.issuelist.onReachBottom() } else if (this.data.discussionType === 'project') { this.projectlist.onReachBottom() } }, // 跳转 我有事说 addIssue () { if (this.verifyCompleteInfo()) { return false } wx.navigateTo({ url: '/subpages/discussion/pages/addIssue/addIssue' }) }, // 获取 项目组件实例 getProjectComponent () { this.projectlist = this.selectComponent('#projectlist') }, // 获取 议题组件实例 getIssueComponent () { this.issuelist = this.selectComponent('#issuelist') }, // 检查 是否完善信息 verifyCompleteInfo () { if (this.data.infoCompleted == 0) { this.setData({ completeInfoDialogVisible: !this.data.completeInfoDialogVisible }) return true } else { return false } } })