Explorar el Código

feat: 金额输入框软键盘高度问题修正

zhangyuhan hace 3 años
padre
commit
cb2cb27787
Se han modificado 1 ficheros con 27 adiciones y 15 borrados
  1. 27 15
      src/web/staticres/common-module/collection/js/money-mobile.js

+ 27 - 15
src/web/staticres/common-module/collection/js/money-mobile.js

@@ -171,6 +171,15 @@ var moneyComponent = {
   },
   mounted () {
     $('head').append(tempMoneyStyleComponent)
+    var _this = this
+    window.addEventListener('resize', function () {
+      if (document.activeElement.tagName == 'INPUT') {
+        if ($(document.activeElement).parents('.money-component-group').length) {
+          var isTall = $("#v-search-group .ent-search-pop").attr('data-height')
+          _this.changeViewForHeight(!isTall)
+        }
+      }
+    });
   },
   computed: {
     getShowDiyInput () {
@@ -222,25 +231,28 @@ var moneyComponent = {
         }
       }
     },
-    toggleInput (type) {
-      var parentDom = $("#v-search-group .more-popup-content")
-      var childDom = $("#v-search-group .more-popup-content .select-more-tag-group")
+    changeViewForHeight (type) {
+      $(".app-layout-content-b").scrollTop(0)
+      $("#v-search-group .popup-content").scrollTop(0)
+      var tempDom = $("#v-search-group .ent-search-pop")
       if (type) {
-        parentDom.css({
-          height: childDom.height() + 20,
-          overflow: 'hidden',
-          position: 'fixed',
-          top: '120px'
-        })
+        var minHeightList = [document.documentElement.clientHeight || 0, document.body.clientHeight || 0, $(".app-layout-content-b").height() || 0].sort()
+        tempDom.attr('data-height', tempDom.height())
+        tempDom.css({height: minHeightList[0] - 44})
       } else {
-        parentDom.css({
-          height: 'auto',
-          overflow: 'unset',
-          position: 'unset',
-          top: 'unset'
-        })
+        tempDom.css({height: tempDom.attr('data-height')})
+        tempDom.removeAttr('data-height')
       }
     },
+    toggleInput (type) {
+     this.changeViewForHeight(type)
+      document.activeElement.scrollIntoViewIfNeeded();
+      var _this = this
+      setTimeout(function (){
+        _this.changeViewForHeight(type)
+        document.activeElement.scrollIntoViewIfNeeded();
+      }, 120)
+    },
     selectInput (type) {
       if (this.radio) {
         this.resetSelected()