// 旧版 // const SYSTEM_INFO = uni.getSystemInfoSync(); const SYSTEM_INFO = uni.getWindowInfo(); // 获取状态栏高度 // const systemInfo = uni.getSystemInfoSync() // statusBarHeight.value = systemInfo.statusBarHeight || 0 // 计算导航栏总高度 (状态栏 + 导航栏) // 通常导航栏高度在H5中是44px,小程序中是48px // const platform = systemInfo.platform // navbarHeight.value = statusBarHeight.value + (platform === 'ios' ? 44 : 48) //时间电量状态栏高度 export const getStatusBarHeight = ()=> SYSTEM_INFO.statusBarHeight; export const getTitleBarHeight = ()=>{ //关闭按钮胶囊 if(uni.getMenuButtonBoundingClientRect){ let {top,height} = uni.getMenuButtonBoundingClientRect(); return height + (top - getStatusBarHeight())*2 }else{ return 0; } } export const getNavBarHeight = () => getStatusBarHeight()+getTitleBarHeight(); export const getNavBarPaddingTop = () => { let h=0; if(uni.getMenuButtonBoundingClientRect){ let {top,height} = uni.getMenuButtonBoundingClientRect(); h = height + (top - getStatusBarHeight()); }else{ // #ifdef APP-PLUS h=22 // #endif // #ifndef APP-PLUS h=0 // #endif } // console.log("h=>",h) return h; }