| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 | 
							- var isManage;
 
- // 扩展API加载完毕后调用onPlusReady回调函数
 
- document.addEventListener("plusready", onPlusReady, false);
 
- // 扩展API加载完毕,现在可以正常调用扩展API
 
- function onPlusReady() {
 
-     var self = plus.webview.currentWebview();
 
-     isManage = self.isManage;
 
-     setTimeout(function() {
 
-         startRecognize();//创建扫描控件
 
-         startScan();//开始扫描
 
-     }, 300);
 
-     
 
-     bindEvents();
 
- }
 
- var scan = null;
 
- function onmarked(type, result) {
 
-     // 扫码成功后的结果
 
-     if(result) {
 
-         var arr = result.split(" ");
 
-         //判断设备是否已经绑定了其他用户
 
-         if(arr.length > 1){
 
-             //云湃血压计 sim + sn
 
-             checkSnBind(arr[1]);
 
-         }else{
 
-             checkSnBind(arr[0]);
 
-         }
 
-         
 
-     } else {
 
-         mui.toast("扫码失败")
 
-     }
 
- }
 
- function startRecognize() {
 
-     scan = new plus.barcode.Barcode('bcid', [plus.barcode.QR, plus.barcode.CODE128, plus.barcode.EAN13, plus.barcode.EAN8], {
 
-         frameColor: '#4dcd70',
 
-         scanbarColor: '#4dcd70' 
 
-     });
 
-     scan.onmarked = onmarked;
 
- }
 
- function startScan() {
 
-     scan.start();
 
- }
 
- function cancelScan() {
 
-     scan.cancel();
 
- }
 
- function setFlash() {
 
-     scan.setFlash();
 
- }
 
- function bindEvents(){
 
-     $(".input-btn").on('click', function(){
 
-         openWebview("keydown-SN.html", {isManage: isManage});
 
-     });
 
-     
 
-     $(".header-link").on('click', function(){
 
-         openWebview("../../device/html/device-management.html");
 
-     })
 
- }
 
- function checkSnBind(code){
 
-     console.log(code);
 
-     plus.nativeUI.showWaiting();
 
-     var url = "doctor/device/getDeviceInfoByDeviceSn",
 
-         params = {
 
-             deviceSn: code, 
 
-         };
 
-     sendGet(url, params, null, function(res){
 
-         plus.nativeUI.closeWaiting();
 
-         console.log(JSON.stringify(res));
 
-         if(res.status == 200){
 
-             var isMultiUser = res.data.isMultiUser, //0-只有一个键,1-多个键
 
-                 bindLength = res.data.bindingInfo.length; //获取绑定信息的长度
 
-             if((!isMultiUser && bindLength == 1) || (isMultiUser && bindLength > 1)){
 
-                 //默认最多只有两个键
 
-                 mui.confirm("设备已被绑定,是否更换绑定居民?", "识别提示", ["是", "否"], function(e){
 
-                     if(e.index == 0){
 
-                         openWebview("device-bind-info.html", {info: res.data, sn: code, isManage: isManage});
 
-                     }else{
 
-                         plus.webview.currentWebview().reload();
 
-                     }
 
-                 });
 
-             }else{
 
-                 openWebview("device-bind-info.html", {info: res.data, sn: code, isManage: isManage});
 
-             }
 
-         }else{
 
-             console.log(res.msg);
 
- //          mui.toast(res.msg);
 
-             mui.alert(res.msg, "识别提示", "我知道了", function(){
 
-                 plus.webview.currentWebview().reload();
 
-             })
 
-         }
 
-     }, true);
 
- }
 
- window.addEventListener("reload", function(e){
 
-     plus.webview.currentWebview().reload();
 
- })
 
 
  |