|
|
@@ -54,6 +54,46 @@ export default {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ // #ifdef H5
|
|
|
+ let baseLayoutHeight = window.innerHeight || document.documentElement.clientHeight || 0
|
|
|
+
|
|
|
+ const setKeyboardOffset = () => {
|
|
|
+ const vv = window.visualViewport
|
|
|
+ if (!vv) {
|
|
|
+ document.documentElement.style.setProperty('--keyboard-offset', '0px')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ const currentLayoutHeight = window.innerHeight || document.documentElement.clientHeight || 0
|
|
|
+ baseLayoutHeight = Math.max(baseLayoutHeight, currentLayoutHeight)
|
|
|
+
|
|
|
+ const vvHeight = vv.height
|
|
|
+ const offsetTop = vv.offsetTop || 0
|
|
|
+ const keyboardHeight = Math.max(0, baseLayoutHeight - vvHeight - offsetTop)
|
|
|
+ document.documentElement.style.setProperty('--keyboard-offset', `${keyboardHeight}px`)
|
|
|
+ }
|
|
|
+
|
|
|
+ this.__keyboardOffsetHandler = setKeyboardOffset
|
|
|
+
|
|
|
+ if (window.visualViewport) {
|
|
|
+ window.visualViewport.addEventListener('resize', setKeyboardOffset)
|
|
|
+ window.visualViewport.addEventListener('scroll', setKeyboardOffset)
|
|
|
+ }
|
|
|
+
|
|
|
+ window.addEventListener('resize', () => {
|
|
|
+ const h = window.innerHeight || document.documentElement.clientHeight || 0
|
|
|
+ baseLayoutHeight = Math.max(baseLayoutHeight, h)
|
|
|
+ setKeyboardOffset()
|
|
|
+ })
|
|
|
+
|
|
|
+ window.addEventListener('focusin', setKeyboardOffset)
|
|
|
+ window.addEventListener('focusout', () => {
|
|
|
+ document.documentElement.style.setProperty('--keyboard-offset', '0px')
|
|
|
+ })
|
|
|
+
|
|
|
+ setKeyboardOffset()
|
|
|
+ // #endif
|
|
|
+
|
|
|
},
|
|
|
|
|
|
onShow: function() {
|
|
|
@@ -107,6 +147,25 @@ page {
|
|
|
|
|
|
}
|
|
|
|
|
|
+/* H5环境下固定底部tabBar位置 */
|
|
|
+/* #ifdef H5 */
|
|
|
+uni-tabbar,
|
|
|
+.uni-tabbar,
|
|
|
+.uni-tabbar__container,
|
|
|
+.uni-tabbar-bottom {
|
|
|
+ position: fixed !important;
|
|
|
+ bottom: 0 !important;
|
|
|
+ left: 0 !important;
|
|
|
+ right: 0 !important;
|
|
|
+ z-index: 999 !important;
|
|
|
+ transform: translateY(var(--keyboard-offset, 0px)) !important;
|
|
|
+}
|
|
|
+
|
|
|
+body {
|
|
|
+ padding-bottom: constant(safe-area-inset-bottom) !important;
|
|
|
+ padding-bottom: env(safe-area-inset-bottom) !important;
|
|
|
+}
|
|
|
+/* #endif */
|
|
|
|
|
|
|
|
|
.container {
|