<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>NewAgent</title>
<meta name="viewport" content="width=device-width, initial-scale=1,minimum-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">
<link rel="stylesheet" type="text/css" href="../../css/app.css" />
<style>
html,
body {
background-color: #FFFFFF;
}
#service img{
width: 1.5rem;
height: 1.5rem;
margin-right: 1rem;
}
.mui-table-view-cell img{
margin-top: 13px;
height: 8.625rem;
}
.mui-table-view::before{
height: 0rem;
}
.mui-table-view-cell::after{
height: 0rem;
}
.mui-table-view::after {
height: 0rem;
}
.mui-bar-nav~.mui-content {
padding-top: 64px;
}
#title{
color:rgba(0,0,0,0.87);
font-size: 1.25rem;
font-weight: 500;
}
.mui-button-row button{
box-shadow:0px 1px 3px 0px rgba(0,0,0,0.2),0px 2px 1px -1px rgba(0,0,0,0.12),0px 1px 1px 0px rgba(0,0,0,0.14);
}
.mui-bar-nav {
box-shadow:0px 1px 3px 0px rgba(0,0,0,0.05),0px 2px 1px -1px rgba(0,0,0,0.03),0px 1px 1px 0px rgba(0,0,0,0.04);
}
</style>
</head>
<body>
<header id="header" class="mui-bar mui-bar-nav bg-fff">
<button class="mui-action-back mui-btn mui-btn-blue mui-btn-link mui-btn-nav mui-pull-left" style="padding-left: 6px;display: flex;justify-content: center;align-items: center;height: 2.75rem;"><img
src="../../images/mui_back.png" style="height: 1.5rem;width: 1.5rem;"></button>
<h1 id="title" class="mui-title " style="color:rgba(0,0,0,0.87);font-size: 1.25rem;">上传身份证</h1>
</header>
<div id="contentMui" class="mui-content bg-fff mui-text-center">
<ul id="table" class="mui-table-view">
<li id="front" class="mui-table-view-cell">
<img id="identityFrontPhoto" src="../../images/front_id.png">
<h5 class="mui-text-center" style="font-size: 0.75rem;margin-top: 0.5rem;">点击上传身份证人面像</h5>
</li>
<li id="back" class="mui-table-view-cell">
<img id="identityBackPhoto" src="../../images/back_id.png">
<h5 class="mui-text-center" style="font-size: 0.75rem;margin-top: 0.5rem;">点击上传身份证国徽照</h5>
</li>
<li id="hand" class="mui-table-view-cell">
<img id="handIdentityCardPhoto" src="../../images/hold_id.png">
<h5 class="mui-text-center" style="font-size: 0.75rem;margin-top: 0.5rem;">点击上传手持身份证正面照</h5>
</li>
</ul>
<div class="mui-button-row" style="margin: 1rem 2.5rem;padding: 0rem;">
<button id="nextBtn" type="button" class="mui-btn mui-btn-block color-profit-background color-fff" style="font-size: 0.9375rem;padding: 11px;font-weight: 500;border: none;">确定</button>
</div>
</div>
<script src="../../js/mui.min.js"></script>
<script src="../../js/app.js" type="text/javascript" charset="utf-8"></script>
<script src="../../js/ajax.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
(function($, doc) {
$.init({
swipeBack: true //启用右滑关闭功能
});
var identityFrontPhoto = doc.getElementById('identityFrontPhoto');
var identityBackPhoto = doc.getElementById('identityBackPhoto');
var handIdentityCardPhoto = doc.getElementById('handIdentityCardPhoto');
var nextBtn = doc.getElementById('nextBtn');
$.plusReady(function() {
var id_card_side = 'front';
var name = '';
var identityNo = '';
var identityStartDate = '';
var identityEndDate = '';
var self = plus.webview.currentWebview();
var frontSrc = plus.storage.getItem('identityFrontPhoto');
var backSrc = plus.storage.getItem('identityBackPhoto');
var handSrc = plus.storage.getItem('handIdentityCardPhoto');
var identityStartDateProfit = plus.storage.getItem('identityStartDateProfit');
var identityEndDateProfit = plus.storage.getItem('identityEndDateProfit');
var nameProfit = plus.storage.getItem('nameProfit');
var identityNoProfit = plus.storage.getItem('identityNoProfit');
if (!mui.isEmptyObject(identityStartDateProfit)) {
identityStartDate = identityStartDateProfit;
}
if (!mui.isEmptyObject(identityEndDateProfit)) {
identityEndDate = identityEndDateProfit;
}
if (!mui.isEmptyObject(nameProfit)) {
name = nameProfit;
}
if (!mui.isEmptyObject(identityNoProfit)) {
identityNo = identityNoProfit;
}
if (!mui.isEmptyObject(frontSrc)) {
identityFrontPhoto.src = frontSrc;
}
if (!mui.isEmptyObject(backSrc)) {
identityBackPhoto.src = backSrc;
}
if (!mui.isEmptyObject(handSrc)) {
handIdentityCardPhoto.src = handSrc;
}
$('.mui-table-view').on('tap', 'li', function() {
var id = this.getAttribute('id');
id_card_side = id;
getImage();
});
// 拍照
function getImage() {
var cmr = plus.camera.getCamera();
cmr.captureImage(function(p) {
console.log('成功:' + p);
plus.io.resolveLocalFileSystemURL(p, function(entry) {
var path = entry.toLocalURL();
compressImage(path);
}, function(e) {
console.log('读取拍照文件错误:' + e.message);
});
}, function(e) {
console.log('失败:' + e.message);
}, {
filename: '_doc/camera/',
index: 1
});
}
function getBase64Image(url, removeFormate, callBack) {
plus.io.resolveLocalFileSystemURL(url, function(entry) {
// 可通过entry对象操作test.html文件
entry.file(function(file) {
var fileReader = new plus.io.FileReader();
console.log("getFile:" + JSON.stringify(file));
fileReader.readAsDataURL(file)
fileReader.onloadend = function(evt) {
var dataURL = evt.target.result;
if ($.isFunction(callBack)) {
if (removeFormate) {
callBack(dataURL.replace(/^data:image\/(png|jpg|jpeg);base64,/, ""));
} else {
callBack(dataURL);
}
}
}
});
}, function(e) {
alert("Resolve file URL failed: " + e.message);
});
}
function compressImage(e) {
//图片压缩
var size = 0;
var name = e.substr(e.lastIndexOf('/') + 1);
plus.zip.compressImage({
src: e,
dst: '_doc/' + name,
overwrite: true,
quality: 50,
overwrite: true,
format: 'jpg',
width: "80%",
},
function(zip) {
size += zip.size;
if (zip.size > (500 * 1024)) {
compressImage(zip.target);
} else {
if (id_card_side == 'hand') {
handIdentityCardPhoto.src = zip.target;
plus.storage.setItem('handIdentityCardPhoto', zip.target);
} else {
getidCard(zip.target);
}
}
console.log(size);
},
function(zipe) {
mui.toast('压缩失败!')
}
);
}
function getidCard(imgeURl) {
getBase64Image(imgeURl, true, function(base64Image) {
var option = {
id_card_side: id_card_side,
image: base64Image,
}
var requestUrl = 'https://aip.baidubce.com/rest/2.0/ocr/v1/idcard';
/* ajax_uploadBase64Image(requestUrl, option, function(data) {
if (data.image_status == 'normal') {
if (id_card_side == 'front') {
name = data.words_result['姓名'].words;
identityNo = data.words_result['公民身份号码'].words;
identityFrontPhoto.src = zip.target;
plus.storage.setItem('identityFrontPhoto', zip.target);
plus.storage.setItem('nameProfit', name);
plus.storage.setItem('identityNoProfit', identityNo);
} else {
identityBackPhoto.src = zip.target;
plus.storage.setItem('identityBackPhoto', zip.target);
var issueDate = data.words_result['签发日期'].words;
var expirationDate = data.words_result['失效日期'].words;
identityStartDate = issueDate.substr(0, 4) + '-' + issueDate.substr(4, 2) + '-' + issueDate.substr(
issueDate.length - 2);
identityEndDate = expirationDate.substr(0, 4) + '-' + expirationDate.substr(4, 2) + '-' +
expirationDate.substr(expirationDate.length - 2);
plus.storage.setItem('identityStartDateProfit', identityStartDate);
plus.storage.setItem('identityEndDateProfit', identityEndDate);
}
} else {
plus.nativeUI.toast('识别失败,请重试');
}
}, function(err) {
plus.nativeUI.toast(err);
}); */
});
}
nextBtn.addEventListener('tap', function() {
var lastPage = null;
if (!lastPage) {
lastPage = plus.webview.currentWebview().opener();
}
var obj = new Object();
var table = doc.getElementById('table');
var images = table.querySelectorAll('img');
var checked = false;
$.each(images, function(index, item) {
var e = item.src;
var imagPath = e.substr(e.lastIndexOf('.') + 1);
if (imagPath == 'png') {
//如果某个图片没有添加进来,则这个图片为空值
plus.nativeUI.toast('请添加' + item.parentElement.innerText);
// console.log(item.parentElement.nodeName);
checked = true;
return false;
}
});
if (checked) {
return false;
}
$.fire(lastPage, 'id_data', {
identityFrontPhoto: identityFrontPhoto.src,
identityBackPhoto: identityBackPhoto.src,
handIdentityCardPhoto: handIdentityCardPhoto.src,
identityStartDate: identityStartDate,
identityEndDate: identityEndDate,
name: name,
identityNo: identityNo,
});
$.back();
});
});
})(mui, document);
</script>
</body>
</html>
ios离线打包,用最新的库,iphone 6plus上面运行会白屏,手机modal A1524,其他如iphoeX等手机不会出现白屏,用hbuilder运行在iphone 6plus上面,也不会白屏。白屏时出现:ProcessAssertion() Unable to acquire assertion for process with PID 9949