| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- import props from "../../miniprogram_npm/tdesign-miniprogram/action-sheet/props";
- import Tabbar from "../../miniprogram_npm/tdesign-miniprogram/tab-bar/tab-bar";
- Component({
- data: {
- 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) {
- // console.log(this.data.patientId, "patientId", page);
- if (!this.data?.patientId) {
- wx.showModal({
- title: "出错了",
- content: "错误,请重试",
- showCancel: false,
- });
- return;
- }
- wx.redirectTo({
- url: `${page}?component=guide&isShowGuide=true`,
- });
- wx.setStorageSync("isAnalysis", 3);
- },
- onChange(e) {
- // console.log(e, "e");
- 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(options: string) {
- // console.log(options,"tabbar")
- // console.log(this.data.tabbarValue, "tabbarValuetabbarValue");
- this.setData({
- value: this.data.tabbarValue,
- });
- this.calculatePageHeight();
- },
- },
- });
|