j***@163.com
j***@163.com
  • 发布:2017-09-29 14:48
  • 更新:2019-10-29 12:05
  • 阅读:16223

mui带搜索框的下拉列表

分类:MUI

做了一个带有搜索框的的列表,都是用的mui组件,现在的情况就是点击搜索输入框弹出软键盘后,子页面会整体下移,并且导致所有带有子页面的的页面显示都出现下移情况,这种情况只在安卓设备有,ios就没有。

//父页面  
<!DOCTYPE html>  
<html>  
    <head>  
        <meta charset="utf-8">  
        <title>路况信息查询main</title>  
        <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">  
        <meta name="apple-mobile-web-app-capable" content="yes">  
        <meta name="apple-mobile-web-app-status-bar-style" content="black">  

        <link rel="stylesheet" href="../../css/mui.min.css">  
        <style>  
            body{  
                font-family: "微软雅黑";  
                font-size: 14px;  
            }  
            .mui-bar{  
                background-color: #1E81D2;  
                color: #FFFFFF;  
                padding-left: 0;  
            }  
            .mui-title{  
                color: #FFFFFF;  
            }  
            input[type=color], input[type=date], input[type=datetime-local], input[type=datetime], input[type=email], input[type=month], input[type=number], input[type=password], input[type=search], input[type=tel], input[type=text], input[type=time], input[type=url], input[type=week], select, textarea{  
                height: 40px!important;  
            }  
            .mui-icon-search{  
                line-height: 45px;  
            }  
            .mui-input-row.mui-search .mui-icon-clear{  
                top: 10px;  
            }  
            input[type=search]{  
                background-color: #FFFFFF;  
                border-radius: 20px;  
            }  
            .mui-bar-nav~.mui-content .mui-pull-top-pocket{  
                top: 84px;  
            }  
            .mui-pull-bottom-pocket, .mui-pull-top-pocket{  
                height: 40px;  
            }  
        </style>  
    </head>  

    <body>  
        <header class="mui-bar mui-bar-nav" style="">  
            <div class="mui-action-back" style="float: left;width: 40px;height: 44px;padding-left: 10px;">  
                <img  src="../../resources/images/nav_back@2x@2x.png" style="width: 22px;height: 22px;margin-top: 10px;"/>  
            </div>  
            <h1 id="title" class="mui-title">路况信息</h1>  
        </header>  
        <div class="mui-content">  
            <div class="mui-input-row mui-search">  
                <input type="search" style="" class="mui-input-clear" placeholder="可输入多个关键字,以空格隔开">  
            </div>  
        </div>  
    </body>  
    <script src="../../js/mui.min.js"></script>  
    <script type="text/javascript">  
        //启用双击监听  
        mui.init({  
            gestureConfig:{  
                doubletap:true  
            },  
            subpages:[{   
                url:'search_sub.html',  
                id:'modules/illegalReport/search_sub.html',  
                styles:{  
                    top: '85px',  
                    bottom:'0px',  
                    softinputMode:'adjustResize'  
                }  
            }]   
        });  
        //console.log(plus.webview.defaultHardwareAccelerated());  
        var contentWebview = null;  
        document.querySelector('header').addEventListener('doubletap',function () {  
            if(contentWebview==null){  
                contentWebview = plus.webview.currentWebview().children()[0];  
            }  
            contentWebview.evalJS("mui('#pullrefresh').pullRefresh().scrollTo(0,0,100)");  
        });  
    </script>  

</html>  
//子页面  
<!DOCTYPE html>  
<html>  

    <head>  
        <meta charset="utf-8">  
        <title>路况信息查询sub</title>  
        <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">  
        <meta name="apple-mobile-web-app-capable" content="yes">  
        <meta name="apple-mobile-web-app-status-bar-style" content="black">  
        <link rel="stylesheet" href="../../css/mui.min.css">  
        <style>  
            body{  
                font-family: "微软雅黑";  
                font-size: 14px;  
            }  
            p{  
                margin-bottom: 0;  
                color: #1f1f1f;  
            }  
            tr{  
                border-bottom: 1px solid #EEEEEE;  
            }  
            .mui-media-body{  
                height: 75px;  
            }  
            .mui-media-body p{  
                margin-top: 15px;  
                font-size: 12px;  
                color: #999999;  
            }  
            .mui-ellipsis-2{  
                font-size: 14px;  
                color: #222222;  
            }  
            .mui-table-view-chevron .mui-table-view-cell>a:not(.mui-btn){  
                margin-right: -20px;  
            }  
            #roadInfo{  
                margin-bottom: 10px;  
            }  
            #roadInfo img{  
                max-width: 100px;  
                width: 100px;  
                height: 75px;  
            }  
            #roadInfo li{  
                height: 90px;  
                padding: 11px 20px;  
            }  
            .mui-media-body img{  
                margin-top: 17px;  
            }  
            .mui-table-view-cell>a:not(.mui-btn){  
                margin: -11px -20px;  
                padding: 6px 20px;  
            }  
            .mui-table-view:after{  
                height: 0;  
            }  
            .mui-table-view-cell.mui-active{  
                background-color: #FFFFFF;  
            }  
            .mui-pull-bottom-pocket, .mui-pull-top-pocket{  
                height: 40px;  
            }  
        </style>  
    </head>  

    <body>  
        <!--下拉刷新容器-->  
        <div id="pullrefresh" class="mui-content mui-scroll-wrapper">  
            <div class="mui-scroll">  
                <!--数据列表-->  
                <ul class="mui-table-view mui-table-view-chevron" id="roadInfo">  
                    <li class="mui-table-view-cell mui-media" v-for="item in items">  
                        <a href="javascript:;" @tap="open_detail(item)" >  
                            <img class="mui-media-object mui-pull-left" :src="item.listimg">  
                            <div class="mui-media-body">  
                                <div class="mui-ellipsis-2">{{item.content}}</div>  
                                <template v-if="item.state==0">  
                                    <img src="../../resources/images/uncover@2x.png" style="max-width: 36px;width: 36px;height: 14px;"/>  
                                </template>  
                                <template v-else>  
                                    <img src="../../resources/images/recover@2x.png" style="max-width: 36px;width: 36px;height: 14px;"/>  
                                </template>  
                                <p style="float: right;">{{item.time}}</p>  
                            </div>  
                        </a>  
                    </li>  
                </ul>  
            </div>  
        </div>   
        <script src="../../js/mui.min.js"></script>  
        <script type="text/javascript" src="../../js/vue.min.js" ></script>  
        <script type="text/javascript" src="../../lib/Overall.js" ></script>  
        <script>  
            mui.init({  
                pullRefresh: {  
                    container: '#pullrefresh',  
                    down: {  
                        callback: pulldownRefresh  
                    },  
                    up: {  
                        contentrefresh: '正在加载...',  
                        callback: pullupRefresh  
                    }  
                }  
            });  

            var additem = [];  
            var roads = new Vue({  
                el: '#roadInfo',  
                data: {  
                    //banner: {}, //顶部banner数据  
                    items: []//列表信息流数据  
                },  
                methods:{  
                    add:function(){  
                        this.items.concat(additem);  
                    }  
                }  
            });   
            //获取列表数据  
            //document.addEventListener('getIllegalsJson', function(event) {  
                 mui.getJSON('../../data/roads.json', null, function(data) {  
                        console.log(JSON.stringify(data.roads));  
                        roads.items = data.roads;  
                    });  
            //});  
            //console.log(roads.items[0].state);  
            /*  
             * 打开详情  
             */  
            function open_detail(item) {  
                //触发子窗口变更新闻详情  
                mui.fire(webview_detail, 'get_detail', {  
                    listimg: item.listimg,  
                    section:item.section,  
                    place:item.place,  
                    direction:item.direction,  
                    time:item.time,  
                    shape:item.shape,  
                    reson:item.reson,  
                    recoverytime:item.recoverytime,  
                    state:item.state,  
                });  
                setTimeout(function () {  
                    webview_detail.show("slide-in-right", 300);  
                },150);  
            }  
            /**  
             * 下拉刷新具体业务实现  
             */  
            function pulldownRefresh() {  
                setTimeout(function() {  
                    var table = document.body.querySelector('.mui-table-view');  
                    var cells = document.body.querySelectorAll('.mui-table-view-cell');  
                    roads.items = roads.items.slice(0,4); //初始化数据  

                    mui('#pullrefresh').pullRefresh().endPulldownToRefresh(); //refresh completed  
                }, 1500);  
            }  
            var count = 0;  
            /**  
             * 上拉加载具体业务实现  
             */  
            function pullupRefresh() {  
                setTimeout(function() {  
                    mui('#pullrefresh').pullRefresh().endPullupToRefresh((++count > 2)); //参数为true代表没有更多数据了。  
                    var table = document.body.querySelector('.mui-table-view');  
                    var cells = document.body.querySelectorAll('.mui-table-view-cell');  
                    roads.items = roads.items.concat(additem); //增加数据  

                }, 1500);  
            }  
            if (mui.os.plus) {  
                mui.plusReady(function() {  
                    setTimeout(function() {  
                        //mui('#pullrefresh').pullRefresh().pullupLoading();  
                    }, 1000);  
                    //console.log(plus.webview.defaultHardwareAccelerated());  
                    //预加载详情页  
                    webview_detail = mui.preload({  
                        url: 'roadDetail.html',  
                        id: 'modules/roadQuery/roadDetail.html',  
                        styles: {  
                            statusbar:{background:$statusBarColor}  
                        }  
                    });  
                });  
            } else {  
                mui.ready(function() {  
                    //mui('#pullrefresh').pullRefresh().pullupLoading();  
                });  
            }  
        </script>  
    </body>  

</html>
2017-09-29 14:48 负责人:无 分享
已邀请:
j***@163.com

j***@163.com (作者)

@DCloud_MUI_CHB 能帮忙看看吗?

DCloud_UNI_CHB

DCloud_UNI_CHB

直接改用单webview下拉刷新是不是就OK了?

双webview下拉刷新耗费性能,不建议使用

  • j***@163.com (作者)

    单webview下拉没有这个样式好看啊,项目中有些列表不带搜索框就没啥问题,为了保持样式统一就都用的这个双webview的

    2017-09-29 15:25

j***@163.com

j***@163.com (作者)

@DCloud_MUI_CHB 我发现问题了,设置了沉浸式状态栏,这是应用级别的,所以所有页面都会是这个效果,http://ask.dcloud.net.cn/article/1150。输入框获取焦点后会导致子页面向下移动,而移动的距离刚好就是状态栏的高度。

张一三

张一三

也许可以这样

点击搜索框->显示新窗口->在新窗口内输入文字搜索

琴宝

琴宝

请问上面的双webview搜索事件如何触发

该问题目前已经被锁定, 无法添加新回复