import I18nBehavior from "../../i18n/behavior"; import props from "../../miniprogram_npm/tdesign-miniprogram/action-sheet/props"; import Tabbar from "../../miniprogram_npm/tdesign-miniprogram/tab-bar/tab-bar"; Component({ behaviors: [I18nBehavior], data: { tabbarHeight: 0, pageHeight: "100vh", value: "/pages/home/home", list: [ { value: "/pages/home/home", label: "首页", icon: "home", path: "/pages/home/home", }, { value: "/module/chats/pages/index/index", label: "", icon: "app", path: "/module/chats/pages/index/index", }, { value: "/pages/mine/mine", label: "我的", icon: "chat", path: "/pages/mine/mine", }, ], i18n: { common: { title: '生活助理' } } }, properties: { tabbarValue: { type: String, value: "", }, patientId: { type: Number, value: 0, }, }, methods: { calculatePageHeight() { const systemInfo = wx.getSystemInfoSync(); const windowHeight = systemInfo.windowHeight; // 屏幕可用高度 // 获取 tabbar 高度 const query = wx.createSelectorQuery(); query .select(".t-tabbar") .boundingClientRect((rect) => { if (rect) { const tabbarHeight = rect.height; const contentHeight = windowHeight - tabbarHeight; this.setData({ pageHeight: `${contentHeight}px`, }); } }) .exec(); }, toChatsPage(page: string) { wx.redirectTo({ url: `${page}?component=guide&isShowGuide=true`, }); wx.setStorageSync("isAnalysis", 3); }, onChange(e: any) { this.setData({ value: e.detail.value, }); if (e.detail.value === "/module/chats/pages/index/index") { this.toChatsPage(e.detail.value); } else { wx.redirectTo({ url: `${e.detail.value}`, fail: (error) => { console.error('Navigation failed:', error); wx.showToast({ title: '页面跳转失败,请重试', icon: 'none' }); } }); } }, }, lifetimes: { attached() { // 赋值 this.setData({ value: this.data.tabbarValue, }); this.calculatePageHeight(); }, }, });