| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- import props from "../../miniprogram_npm/tdesign-miniprogram/action-sheet/props";
- import Tabbar from "../../miniprogram_npm/tdesign-miniprogram/tab-bar/tab-bar";
- Component({
- 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",
- },
- ],
- },
- 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();
- },
- },
- });
|