博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
手机QQ浏览器和微信内置webview对input type="file" 的change事件不灵
阅读量:6847 次
发布时间:2019-06-26

本文共 3376 字,大约阅读时间需要 11 分钟。

hot3.png

做一个H5页面,选中图片后上传,遇到手机QQ浏览器时   不能及时识别change事件,真是日了狗了,下面是针对这一现象的解决办法,不用change事件:

                    
        
        
        
        
        
        
        
            
                
                    
                    
车辆档案                                
                    
                    
个人资料                                
                    
                    
证件照片                                
                    
                    
提交审核                                        
            
                
您即将成为益驾好教练,请先完善证件照

                
                    

驾驶证正面照

                    
                    
                        
                        
                                                    
                    

教练证正面照

                    
                    
                        
                        
                                                    
                
                    

身份证正面照

                    
                    
                        
                        
                                                    
                    

行驶证正面照

                    
                    
                        
                        
                                                    
                                
    $(document).ready(function(){        $.get(BASE_URL+"/basic/user/reload",{        },function(result){            if(result && result.success==true){                if(result.userInfo.lisence.coach){                    // $(".addCode[title='coach']").css("display","none");                    var lisenceType="coach";                    $.get(BASE_URL+"/basic/user/lisenceGettoken",{                        lisenceType:lisenceType                    },function(result){                        if(result && result.success==true){                            var downloadUrl=result.downloadUrl;                            $("
").appendTo('.forInput[title="coach"]');                        }                    })                }                if(result.userInfo.lisence.drive){                    // $(".addCode[title='drive']").css("display","none");                    var lisenceType="drive";                    $.get(BASE_URL+"/basic/user/lisenceGettoken",{                        lisenceType:lisenceType                    },function(result){                        if(result && result.success==true){                            var downloadUrl=result.downloadUrl;                            $("
").appendTo('.forInput[title="drive"]');                        }                    })                }                if(result.userInfo.lisence.driving){                    // $(".addCode[title='driving']").css("display","none");                    var lisenceType="driving";                    $.get(BASE_URL+"/basic/user/lisenceGettoken",{                        lisenceType:lisenceType                    },function(result){                        if(result && result.success==true){                            var downloadUrl=result.downloadUrl;                            $("
").appendTo('.forInput[title="driving"]');                        }                    })                }                if(result.userInfo.lisence.identity){                    // $(".addCode[title='identity']").css("display","none");                    var lisenceType="identity";                    $.get(BASE_URL+"/basic/user/lisenceGettoken",{                        lisenceType:lisenceType                    },function(result){                        if(result && result.success==true){                            var downloadUrl=result.downloadUrl;                            $("
").appendTo('.forInput[title="identity"]');                        }                    })                }            }else{                if(result && result.errorInfo=="请先登录"){                    location.href="/index.html";                }            }        })    })    function showPhoto(ele,type){        var files=ele.files,               file=files[0];         var reader = new FileReader();        reader.onload=function(){            $("
").appendTo('.forInput[title'+'='+'"'+type+'"'+']');        }        reader.readAsDataURL(file);        var lisenceType=type;        $.get(BASE_URL+"/basic/user/lisenceUpToken",{                lisenceType:lisenceType        },function(result){            if(result && result.success == true){                var upToken=result.upToken;                var env = result.env;                var oMyForm = new FormData();                var href=location.href;                var id=href.replace(/^.+?id\=/,'');                var key=env+"/"+id;                oMyForm.append("token",upToken);                  oMyForm.append("key", key);                oMyForm.append("file",file);                var oReq = new XMLHttpRequest();                  oReq.open("POST", "http://upload.qiniu.com/");                  oReq.send(oMyForm);                oReq.onreadystatechange = function (){                    if(oReq.readyState==4 && oReq.status==200){                        $('.driveCode[title'+'='+'"'+type+'"'+']').replaceWith('
');                       $.post(BASE_URL+"/basic/user/lisence",{                            lisenceType:lisenceType                        },function(result){                            if(result.success==true){                                                            }                        })                    }                }            }        })    }    function getPhoto(type){        $('.driveCode[title="'+type +'"]').trigger("click");    }    $('.forInput').on('click','.addedImg',function(){        var type=$(this).attr("title");        $(this).remove();        $('.driveCode[title="'+type +'"]').trigger("click");    });    $(".validated").on("click",function(){        if("img[title='coach'] && img[title='drive'] && img[title='identity'] && img[title='driving']"){            //资料上传            location.href="/complate.html"        }else{            alert("请等待图片上传完成");        }    })

转载于:https://my.oschina.net/fuckBAT/blog/492887

你可能感兴趣的文章