123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- @{
- Layout = null;
- }
- <!doctype html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title></title>
- <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
- <link href="~/Content/Scripts/plugins/mui/css/mui.css" rel="stylesheet" />
- <script src="~/Content/Scripts/plugins/mui/js/mui.js"></script>
- <style type="text/css">
- #bcid {
- width: 100%;
- height: 100%;
- position: absolute;
- background: #000000;
- }
- .fbt {
- color: #0E76E1;
- width: 50%;
- background-color: #ffffff;
- float: left;
- line-height: 44px;
- text-align: center;
- }
- .mui-bar {
- background-color: transparent;
- -webkit-box-shadow: none;
- box-shadow: none;
- }
- </style>
- </head>
- <body id="bcid" >
- <header class="mui-bar">
- <a class="mui-icon mui-icon-left-nav mui-pull-left mui-action-back" style="color:white"></a>
- <h1 class="mui-title" style="color:white;">扫码注册</h1>
- @*<span class="mui-icon mui-icon-spinner-cycle mui-spin mui-pull-right" style="color:white" id="turnTheLight"></span>*@
- <button class="mui-btn mui-btn-link mui-pull-right" style="color:white" onclick="scanPicture();">相册</button>
- </header>
- <div >
- <!--盛放扫描控件的div-->
- </div>
- @*<input type="file" capture="camera" accept="image/*" />*@
- @*<input type="file" accept="image/*" capture="camera">*@
- <script type="text/javascript">
- var scan = null;//扫描对象
- mui.plusReady(function () {
- mui.init({
- beforeback: function () {
- if (scan) {
- scan.close();
- }
- return true;
- }
- });
- startRecognize();
- });
- function startRecognize() {
- try {
- var filter;
- //自定义的扫描控件样式
- var styles = { frameColor: "#29E52C", scanbarColor: "#29E52C", background: "" }
- //扫描控件构造
- scan = new plus.barcode.Barcode('bcid', filter, styles);
- scan.onmarked = onmarked;
- scan.onerror = onerror;
- scan.start();
- ////打开关闭闪光灯处理
- //var flag = false;
- //document.getElementById("turnTheLight").addEventListener('tap', function () {
- // if (flag == false) {
- // scan.setFlash(true);
- // flag = true;
- // } else {
- // scan.setFlash(false);
- // flag = false;
- // }
- //});
- } catch (e) {
- mui.alert('扫描错误,请重新扫描:\n' + e, '提示');
- }
- };
- function onerror(e) {
- plus.nativeUI.alert(e);
- };
- function onmarked(type, result) {
- var text = '';
- switch (type) {
- case plus.barcode.QR:
- text = 'QR: ';
- break;
- case plus.barcode.EAN13:
- text = 'EAN13: ';
- break;
- case plus.barcode.EAN8:
- text = 'EAN8: ';
- break;
- }
- result = result.replace(new RegExp('"', 'g'), '');
- mui.openWindow({
- url: result,
- id: 'regist',
- preload: true,
- show: {
- aniShow: 'pop-in'
- },
- styles: {
- popGesture: 'hide'
- },
- waiting: {
- autoShow: false
- }
- });
- };
- // 从相册中选择二维码图片
- function scanPicture() {
- plus.gallery.pick(function (path) {
- plus.barcode.scan(path, onmarked, function (error) {
- plus.nativeUI.alert("无法识别此图片");
- });
- }, function (err) {
- plus.nativeUI.alert("无法识别此图片");
- });
- }
- </script>
- </body>
- </html>
|