Gwwwj
Gwwwj
  • 发布:2019-04-04 17:02
  • 更新:2023-02-12 10:53
  • 阅读:2150

【报Bug】IOS 打开相机拍照 之后闪退

分类:MUI

详细问题描述

苹果6p,版本12.0.1,打开相机之后,会直接闪退

重现步骤

附件里边有视频

IDE运行环境说明

HBuilder

9.1.29.201811231920

win10
家庭版

mui-app运行环境说明

运行端是IOS的

App运行环境说明

IOS
版本12.0.1

附件

<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title>更改头像</title>
<link href="../../css/mui.min.css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="../../js/cropper/css/cropper.min.css" />
<style type="text/css">
.mui-bar {
background-color: #CC0000;
}

        .mui-title {  
            color: #FFFFFF;  
        }  

        #imgBox {  
            height: 300px !important;  
            width: 300px !important;  
            margin: 30px auto;  
            background: url('../../js/cropper/images/bg.png');  
        }  

        .mui-btn-red {  
            background-color: #CC0000;  
        }  

        * {  
            touch-action: pan-y;  
        }  
    </style>  
</head>  
<body>  
    <header class="mui-bar mui-bar-nav">  
        <a href="###" class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" style="color: #FFFFFF;"></a>  
        <h1 class="mui-title">上传头像</h1>  
        <a id="moreMenus" href="###" class="mui-icon mui-icon-compose mui-pull-right" style="color:white;font-weight: bold;"></a>  
    </header>  
    <div class="mui-content">  
        <div id="imgBox">  
            <img id="userImage_id" width="300" height="300" />  
        </div>  
        <table align="center">  
            <tr>  
                <td style="padding:2px 5px;"><button type="button" disabled id="scaleX_id" class="mui-btn mui-btn-blue toolbutton">左右变换</button></td>  
                <td style="padding:2px 5px;"><button type="button" disabled id="scaleY_id" class="mui-btn mui-btn-blue toolbutton">上下变换</button></td>  
                <td style="padding:2px 5px;"><button type="button" disabled id="rotateMax_id" class="mui-btn mui-btn-blue toolbutton">旋转90°</button></td>  
            </tr>  
            <tr>  
                <td colspan="3" style="padding:5px 5px;"><button type="button" disabled id="confirm_id" class="mui-btn mui-btn-red mui-btn-block toolbutton">确定并保存</button>  
                </td>  
            </tr>  
        </table>  

    </div>  
    <script src="../../js/mui.min.js"></script>  
    <script type="text/javascript" src="../../js/jquery-3.1.1.slim.min.js"></script>  
    <script type="text/javascript" src="../../js/cropper/js/cropper.min.js"></script>  
    <script src="../../js/djy.js"></script>  
    <script type="text/javascript" charset="utf-8">  
        mui.init({  
            beforeback: function() {  
                var set = plus.webview.getWebviewById('setting');  
                mui.fire(set, 'Txrefresh');  
                var current = plus.webview.currentWebview();  
                // 关闭侧滑返回功能    
                current.reload(true);  

                return true;  
            }  
        });  

        mui.plusReady(function() {  
            console.log("更换头像");  
            var self = plus.webview.currentWebview();  
            // 关闭侧滑返回功能    
            self.setStyle({  
                'popGesture': 'none'  
            });  

            //plus.navigator.setStatusBarBackground( "#CC0000" );//设置状态栏的颜色  
            document.getElementById("moreMenus").addEventListener("tap", function() {  
                var editButtons = new Array();  
                editButtons.push({  
                    title: "拍照上传",  
                    style: "default"  
                });  
                editButtons.push({  
                    title: "从相册选择",  
                    style: "default"  
                });  
                plus.nativeUI.actionSheet({  
                    cancel: "取消",  
                    buttons: editButtons  
                }, function(e) {  
                    var index = e.index;  
                    switch (index) {  
                        case 1:  
                            captureImage(); //拍照  
                            break;  
                        case 2:  
                            selectImage(); //相册选择  
                            break;  
                    }  
                });  
            });  
            document.getElementById("scaleX_id").addEventListener("tap", function() {  
                window._scaleX = window._scaleX * -1;  
                $("#userImage_id").cropper("scaleX", window._scaleX);  

            });  
            document.getElementById("scaleY_id").addEventListener("tap", function() {  
                window._scaleY = window._scaleY * -1;  
                $("#userImage_id").cropper("scaleY", window._scaleY);  
            });  
            document.getElementById("rotateMax_id").addEventListener("tap", function() {  
                $("#userImage_id").cropper("rotate", 90);  
            });  
            //确定裁切  
            document.getElementById("confirm_id").addEventListener("tap", function(e) {  
                var dataURL = $("#userImage_id").cropper("getCroppedCanvas", {  
                    width: 400,  
                    height: 400  
                });  
                var imgUrl = dataURL.toDataURL("image/png", 1);  
                //      $("#userImage_id").attr("src" , imgUrl);  
                $("#userImage_id").cropper("replace", imgUrl);  
                $("#userImage_id").cropper("clear"); //裁切完成取消显示裁切框  
                $("#userImage_id").cropper("disable");  
                //确定裁切后销毁裁切组件,标记一下,下次继续裁切时需要初始化一下裁切组件  
                window.imageDisable = true;  
                //禁用几个功能按钮  
                $("button.toolbutton").prop("disabled", true);  
                //向后台提供数据  
                uploadFile(imgUrl);  
            });  
            //初始化裁切组件  
            initImageCropper();  
        });  

        //拍照  
        function captureImage() {  
            console.log("tx1111111111111111");  
            var cmr = plus.camera.getCamera(2);  
            cmr.captureImage(  
                function(path) {  
                    //将图片地址转换  
                    console.log("111111" + path);  
                    plus.io.resolveLocalFileSystemURL(path, function(entry) {  
                        var newPath = entry.toLocalURL() + "?version=" + Math.random();  
                        loadImage(newPath);  
                    });  
                },  
                function(error) {  
                    mui.toast("您取消了拍照");  
                    console.log(error.message);  
                }, {  
                    filename: "_documents/"  
                }  
            );  

        }  

        //文件上传  
        function uploadFile(image) {  

            /*在这里调用上传接口*/  

            djy.post('/djy/app/changeTx', {  
                img: image  
            }, function(data) {  

                if (data.result == 'true') {  

                    mui.toast(data.message);  
                    // plus.storage.setItem('changeTx',image);  
                    localStorage.setItem("txUrl", image);  
                } else {  
                    mui.toast(data.message);  
                }  

            }, function(xhr, type, errorThrown) {  
                mui.toast("网络出现错误");  
                console.log(xhr);  
            }, 'json', true);  

        }  

        function initImageCropper() {  
            //初始化组件  
            $("#userImage_id").cropper({  
                aspectRatio: 3 / 3,  
                autoCropArea: 1,  
                dragMode: "move", //设置移动图片、重新绘制选图区域  
                cropBoxResizable: false,  
                //movable: true,//是否允许移动裁切框  
                zoomable: true, //是否允许放大图片  
                guides: true, //取消显示裁切线中间的虚线网格  
                minContainerWidth: 300,  
                minContainerHeight: 300,  
                minCanvasWidth: 300,  
                minCanvasHeight: 300,  
                crop: function(data) {  
                    //初始化  
                    window._scaleX = data.scaleX;  
                    window._scaleY = data.scaleY;  
                }  
            });  
        }  

        //选择图片  
        function selectImage() {  
            plus.gallery.pick(function(path) {  
                loadImage(path);  
            }, function(e) {  
                mui.toast("没有选择图片.");  
            });  
        }  

        //确定选择图片  
        function loadImage(path) {  
            var img = document.getElementById("userImage_id");  
            console.log("222222222222222222222222");  
            img.src = path;  
            if (window.imageDisable == true) {  
                console.log("3333333333333333333333333");  
                $("#userImage_id").cropper("enable");  
            }  
            $("#userImage_id").cropper("replace", path);  
            //启用几个功能按钮  
            $("button.toolbutton").prop("disabled", false);  
            console.log("24444444444444444444422");  
            document.getElementById("userImage_id").onclick = function() {  
                plus.runtime.openFile(path);  
            }  
        }  
    </script>  
</body>  

</html>

联系方式

[QQ] 287095418

2019-04-04 17:02 负责人:无 分享
已邀请:
Gwwwj

Gwwwj (作者)

没有人碰见吗?

n***@nbheyi.com

n***@nbheyi.com

请问后来怎么解决的

z***@126.com

z***@126.com - QQ:212329852

请问后来怎么解决的

要回复问题请先登录注册