var rowData={}; var sn="";//记录sn码 var dataId = null; var type = null; var name = null; var photoUrl = null; var deviceId = null; var patient = null; var role = null; // 1.可删除编辑,0不可以删除编辑" var oldSn="";//旧sn var self; mui.init(); mui.plusReady(function() { plus.nativeUI.showWaiting(); self = plus.webview.currentWebview(); dataId = self.dataId; deviceId = self.deviceId; patient = self.patient; role = self.role; initPage(); }); $(function(){ //添加isrcoll var scroller1 = new IScrollPullUpDown('wrapper',{ probeType:2, bounceTime: 250, bounceEasing: 'quadratic', mouseWheel:false, scrollbars:true, click:true, fadeScrollbars:true, interactiveScrollbars:false },null,null); }) function initPage(){ getDeviceInfo(deviceId); bindEvents(); } function initData(dataId){ var params = {}; params.id=dataId; sendGet("doctor/device/PatientDeviceInfo",params, function(res){ if(res.msg){ mui.toast(res.msg); }else{ mui.toast("设备信息初始化失败!"); } }, function(res){ if(res.status==200){ rowData = res.data; docInfo= JSON.parse(plus.storage.getItem("docInfo")); // if(rowData.doctor==docInfo.code){ // $("#footer").show(); // } if(role=="1") { $("#footer").show(); } oldSn = rowData.deviceSn; $("#sncode").val(rowData.deviceSn); }else{ mui.toast("设备信息初始化失败!"); } }) } //绑定事件 function bindEvents(){ //保存方法 //保存方法 $("#del-btn").bind("click",function(){ mui.confirm("设备解绑后,将无法自动从设备获取相关数据。是否继续解绑?", "提示", ["继续解绑","不了,谢谢"], function(e) { if(e.index==0){ deleteSn(dataId); return; }else{ return; } }); }) $("#edit-btn").bind("click",function(){ editXuetangyi(); }) } function getDeviceInfo(deviceId){ sendGet("common/device/DeviceInfo?id="+deviceId,{}, function(res){ plus.nativeUI.closeWaiting(); mui.toast("设备信息获取失败!"); }, function(res){ plus.nativeUI.closeWaiting(); if(res.status==200){ var rowData1 = res.data; type = rowData1.categoryCode; name = rowData1.name; photoUrl = rowData1.photo; $(".deviceName").html(name); $(".div-xuetangyi-img img").attr("src",getImgUrl(photoUrl)); initData(dataId); }else{ mui.toast("设备信息获取失败!"); } }) } function editXuetangyi(){ var params = {}; params.deviceId = deviceId; params.dataId = dataId; params.patient = patient; openWebviewExtras("edit-xuetangyi.html",params); } function deleteSn(code){ plus.nativeUI.showWaiting(); sendPost("doctor/device/DeletePatientDevice?id="+code,{},function(res){ plus.nativeUI.closeWaiting(); if (res && res.msg) { mui.toast(res.msg); } else { mui.toast("解绑设备失败!"); } },function(res){ if(res.status==200){ $(".c-list").html(""); openwdsb(); mui.toast("解绑设备成功!"); }else{ plus.nativeUI.closeWaiting(); mui.toast("解绑设备失败!"); } },"GET") } function openwdsb(){ var page = plus.webview.getWebviewById("health-record"); if(page){ mui.fire(page,'refreshEquipment') } var page2 = plus.webview.getWebviewById("my-equipments"); if(page2){ mui.fire(page2,'refreshEquipment') } setTimeout(function(){ var pa1 = plus.webview.getWebviewById("list-xueyaji.html"); if(pa1){pa1.close()} var pa2 = plus.webview.getWebviewById("list-xuetangyi.html"); if(pa2){pa2.close()} var pa3 = plus.webview.getWebviewById("edit-xueyaji"); if(pa3){pa3.close()} var pa4 = plus.webview.getWebviewById("edit-xuetangyi"); if(pa4){pa4.close()} var pa5 = plus.webview.getWebviewById("view-xueyaji.html"); if(pa5){pa5.close()} var pa6 = plus.webview.getWebviewById("view-xuetangyi"); if(pa6){pa6.close()} plus.nativeUI.closeWaiting(); mui.back() },1000) }