import { getSectionByAllList } from "@/api/chat"; const app = getApp(); // pages/scene.ts Component({ /** * 页面的初始数据 */ data: { sectionList: [], iconList: ['bengzhan1', 'sanweiditu', 'jiankong'] }, methods:{ sectionBClick(e){ const item = e.currentTarget.dataset.item; console.log('this.data.sectionList',this.data.sectionList); const foundA = this.data.sectionList.find(sectionItem=>sectionItem.childrenChunkList?.some(childrenItem=>childrenItem.some(subItem=>subItem.section_id===item.section_id)) ); if(!foundA ) return; // 前一个页面传递参数 const jumpUrl = '/pages/question/question'; wx.switchTab({ url: jumpUrl, }); app.globalData.sectionAId = foundA.section_id; app.globalData.sectionB = item; } }, lifetimes: { async attached() { const res = await getSectionByAllList(); if(!res?.json_ok)return; this.setData({ sectionList: res?.sections?.map(item => { item.childrenChunkList = wx.$_.chunk(item.children, 3); Reflect.deleteProperty(item, 'children'); return item; }) }) }, detached(){ app.globalData.sectionAId = ''; } }, pageLifetimes: { show() { if (typeof this.getTabBar === 'function' && this.getTabBar()) { this.getTabBar().setData({ selected: 1 }) } } } })