|
@@ -1,5 +1,6 @@
|
|
|
|
|
|
const qs = require('qs');
|
|
|
+const $ = require('jquery');
|
|
|
const imageUrlPrefix = 'http://192.168.2.241:82' //后台图片地址
|
|
|
// const imageUrlPrefix = 'http://192.168.2.236:82' //后台图片地址
|
|
|
|
|
@@ -158,6 +159,57 @@ const moduleConfig = (config,modules) => {
|
|
|
// 替换输入框占位符
|
|
|
const patt = /\$\{[^\]]+\}/g;
|
|
|
|
|
|
+// 监听键盘是否弹起
|
|
|
+function fixedKeyboard() {
|
|
|
+ var win_h = $(window).height();
|
|
|
+ $(window).on("resize",function(){
|
|
|
+ if (/iphone|ipad/i.test(navigator.userAgent.toLowerCase())) {
|
|
|
+ //ios 什么都不用做
|
|
|
+ } else {
|
|
|
+ //安卓触发window.resize
|
|
|
+ if($(window).height() < win_h){
|
|
|
+ $('.detailBox-wrap').css('position','static') ;//详情页
|
|
|
+ $('.main').height((win_h)/100+'rem');
|
|
|
+ }else{
|
|
|
+ $('.detailBox-wrap').css('position','fixed');
|
|
|
+ // $('.main').css('height','100%;') ;
|
|
|
+ $('.main').height("100%") ;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ $(window).on("click",function(){
|
|
|
+ const { activeElement } = document;console.log(999,activeElement)
|
|
|
+ if (activeElement.tagName === 'INPUT' || activeElement.tagName === 'TEXTAREA') {
|
|
|
+ alert('5555')
|
|
|
+ setTimeout(() => {
|
|
|
+ activeElement.scrollIntoView(true);
|
|
|
+ let top = $('.main').scrollTop();
|
|
|
+ $('.main').scrollTop(top-30); //预留题目位置
|
|
|
+ }, 400);
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// 移动到可视区--选项中的输入框,因阻止了冒泡
|
|
|
+function scrollToV(e){
|
|
|
+ setTimeout(function() {
|
|
|
+ // e.target.scrollIntoView(false);
|
|
|
+ e.target.scrollIntoView(true); //true--元素顶部与可视区顶部对齐;false--元素底部与可视区底部对齐
|
|
|
+ let mainH = $('.main').height();
|
|
|
+ let top = $('.main').scrollTop();
|
|
|
+ $('.main').scrollTop(top-30); //预留题目位置
|
|
|
+ /*let HH = mainH-clientY;
|
|
|
+ if(clientY < 210 || (mainH-clientY)>88){
|
|
|
+ e.target.scrollIntoView(false); //底部对齐
|
|
|
+ }else if(HH < 200){
|
|
|
+ e.target.scrollIntoView(true);//顶部对齐
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ e.target.scrollIntoView();
|
|
|
+ }*/
|
|
|
+ }, 400)
|
|
|
+}
|
|
|
+
|
|
|
module.exports = {
|
|
|
imageUrlPrefix,
|
|
|
getUrlArgObject,
|
|
@@ -167,7 +219,9 @@ module.exports = {
|
|
|
moduleConfig,
|
|
|
patt,
|
|
|
moduleCP,
|
|
|
- getExpStr
|
|
|
+ getExpStr,
|
|
|
+ fixedKeyboard,
|
|
|
+ scrollToV
|
|
|
}
|
|
|
|
|
|
|