diff --git a/pages/index/category/two-catgory.vue b/pages/index/category/two-catgory.vue index dfed9c6..c328e3a 100644 --- a/pages/index/category/two-catgory.vue +++ b/pages/index/category/two-catgory.vue @@ -103,7 +103,10 @@ export default { options: [{ custom: true // 该栏目开启自定义模式 }], - selectedItem:{} + selectedItem:{}, + statusBarHeight: 20,/* 状态栏高度 */ + navBarHeight: 45,/* 导航栏高度 */ + windowWidth: 375,/* 窗口宽度 */ }; }, computed: {}, @@ -116,6 +119,20 @@ export default { created() { console.log('%c当前分类:二级分类', 'color:green;background:yellow'); this.getCategory(); + // 获取手机系统信息 + const info = uni.getSystemInfoSync() + // 设置状态栏高度(H5顶部无状态栏小程序有状态栏需要撑起高度) + this.statusBarHeight = info.statusBarHeight + this.windowWidth = info.windowWidth + // 除了h5 app mp-alipay的情况下执行 + // #ifndef H5 || APP-PLUS || MP-ALIPAY + // 获取胶囊的位置 + const menuButtonInfo = uni.getMenuButtonBoundingClientRect() + console.log(menuButtonInfo); + // (胶囊底部高度 - 状态栏的高度) + (胶囊顶部高度 - 状态栏内的高度) = 导航栏的高度 + this.navBarHeight = (menuButtonInfo.bottom - info.statusBarHeight) + (menuButtonInfo.top - info.statusBarHeight) + this.windowWidth = menuButtonInfo.left + // #endif }, methods: { showHandle(val){