From f09fa7d583f6581f7c9d9b25aaf9fccc876ce360 Mon Sep 17 00:00:00 2001 From: liudan <18634735655@163.com> Date: Mon, 26 Jun 2023 02:21:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/category/two-catgory.vue | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) 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){