You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.7 KiB
67 lines
2.7 KiB
|
3 years ago
|
<!DOCTYPE html>
|
||
|
|
<html xmlns:th="http://www.w3.org/1999/xhtml">
|
||
|
|
<html xmlns:th="http://www.thymeleaf.org">
|
||
|
|
<head>
|
||
|
|
<meta charset="utf-8">
|
||
|
|
<title>扫码</title>
|
||
|
|
<link rel="stylesheet" href="/static/lib/layui-v2.6.3/css/layui.css" media="all">
|
||
|
|
<link rel="stylesheet" href="/static/css/layuimini.css?v=2.0.4.2" media="all">
|
||
|
|
<link rel="stylesheet" href="/static/css/themes/default.css" media="all">
|
||
|
|
<link rel="stylesheet" href="/static/lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
|
||
|
|
<!--[if lt IE 9]>
|
||
|
|
<script src="/static/js/html5.min.js"></script>
|
||
|
|
<script src="/static/js/respond.min.js"></script>
|
||
|
|
<![endif]-->
|
||
|
|
<!-- vue相关-->
|
||
|
|
<script src="../static/js/vue/vue.js"></script>
|
||
|
|
<script src="../static/js/vue/vue-router.js"></script>
|
||
|
|
<script src="../static/lib/http-vue-loader/src/httpVueLoader.js"></script>
|
||
|
|
<script src="../static/js/VueQrcodeReader.umd.min.js"></script>
|
||
|
|
<script src="/static/js/scanBarCode/html5-qrcode.min.js"></script>
|
||
|
|
</head>
|
||
|
|
<body>
|
||
|
|
<div style="width: 500px" id="reader">
|
||
|
|
|
||
|
|
</div>
|
||
|
|
<script src="/static/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
|
||
|
|
<script>
|
||
|
|
|
||
|
|
const html5QrCode = new Html5Qrcode("reader");
|
||
|
|
const qrCodeSuccessCallback = (decodedText, decodedResult) => {
|
||
|
|
/* 扫描成功 */
|
||
|
|
console.log(decodedText,decodedResult);
|
||
|
|
|
||
|
|
html5QrCode.stop().then((ignore) => {
|
||
|
|
// 暂停扫描
|
||
|
|
// 发送ajax请求去获取当前条码的数据
|
||
|
|
layui.$.ajax({
|
||
|
|
url: "/material/findMaterialByBarCode?barCode="+decodedText,
|
||
|
|
type: "get",
|
||
|
|
dataType: 'json',
|
||
|
|
contentType: "application/json;charset=utf-8",
|
||
|
|
success: function (d) {
|
||
|
|
var data = d.data;
|
||
|
|
// 将扫描结果赋值给父页面
|
||
|
|
layui.$("#barcode", window.parent.document).val(decodedText);
|
||
|
|
if(data === null || data === undefined){
|
||
|
|
// 如果没有查询到物料
|
||
|
|
}else{
|
||
|
|
layui.$("#mname", window.parent.document).val(data.mname);
|
||
|
|
layui.$("#code", window.parent.document).val(data.code);
|
||
|
|
}
|
||
|
|
var index = parent.layer.getFrameIndex(window.name);
|
||
|
|
parent.layer.close(index);
|
||
|
|
}
|
||
|
|
})
|
||
|
|
}).catch((err) => {
|
||
|
|
console.log(err)
|
||
|
|
// 停止失败,处理它。
|
||
|
|
});
|
||
|
|
};
|
||
|
|
const config = { fps: 10, aspectRatio: 2 };
|
||
|
|
|
||
|
|
// Select back camera or fail with `OverconstrainedError`.
|
||
|
|
html5QrCode.start({ facingMode: { exact: "environment"} }, config, qrCodeSuccessCallback);
|
||
|
|
</script>
|
||
|
|
</body>
|
||
|
|
</html>
|