mui.plusReady(function() {
webview_detail = mui.preload({
url: '../barcode/barcode_scan.html',
id: 'barcode_scan.html'
});
});
function open_detail() {
//若详情页尚未预加载完成,则延时等待再执行
if(!webview_detail) {
setTimeout(function() {
open_detail(salesorder);
}, 100);
}
//触发子窗口变更新闻详情
mui.fire(webview_detail, 'get_detail', {});
setTimeout(function () {
webview_detail.show("slide-in-right", 300);
},150);
}
mui('.mui-bar').on('tap', '[data-url]', function() {
open_detail();
});
<script type="text/javascript">
scan = null; //扫描对象
var blist = [];
mui.plusReady(function() {
document.addEventListener('get_detail', function(){
startRecognize();
});
});
mui.init({
beforeback: function() {
//获得列表界面的webview
var list = plus.webview.getWebviewById('deliveryDetail.html');
//触发列表界面的自定义事件(refresh),从而进行数据刷新
mui.fire(list, 'barcode', {
blist: blist
});
//返回true,继续页面关闭逻辑
return true;
},
});
function startRecognize() {
try {
var filter = [
plus.barcode.CODE128
];
//扫描控件构造
scan = new plus.barcode.Barcode('bcid', filter);
scan.onmarked = onmarked;
scan.onerror = onerror;
scan.start();
} catch(e) {
mui.toast("出现错误啦:\n" + e);
}
};
function onmarked(type, result) {
var w = plus.nativeUI.showWaiting("请等待,正在办理");
var n = 2;
var text = '';
switch(type) {
case plus.barcode.CODE128:
type = 'CODE128';
break;
}
barCodeJudge(result);
var t = setInterval(function() {
n--;
w.setTitle("请稍等\n" + n + "秒后可以重新扫描");
if (n <= 0) {
n = 2;
w.close();
scan.start();
}
}, 1000);
};
// 从相册中选择二维码图片
function scanPicture() {
plus.gallery.pick(function(path) {
plus.barcode.scan(path, onmarked, function(error) {
plus.nativeUI.alert("无法识别此图片");
});
}, function(err) {
mui.toast("用户取消操作");
});
}
function barCodeJudge(result){
if(blist.length < 1){
blist.push(result);
}else{
if($.inArray(result, blist) == -1){
blist.push(result);
}else{
mui.toast("条码重复,请重新扫描");
}
}
}
</script>
1 个回复
ChineGuo (作者) - ChineGuo
扫一扫的动画没有,但是扫码还是成功的。请问如何加载动画,我刷新页面都不行