var pagesize = 100; var page = 1 ; var patient = null; var docInfo; mui.init(); mui.plusReady(function() { plus.nativeUI.showWaiting(); self = plus.webview.currentWebview(); docInfo = JSON.parse(plus.storage.getItem("docInfo")); patient = self.patient; initPage(); }); //initTouch(); function initPage(){ bindEvents(); getEquipments(); } function getEquipments(){ var params = {}; params.page=page; params.pagesize = pagesize; params.patient = patient; sendGet("doctor/device/PatientDeviceList",params,queryListFailed,queryListSuccess); } function queryListSuccess(res){ plus.nativeUI.closeWaiting(); if(res.status==200){ if(res.data&&res.data.length>0){ // for(var i in res.data){ showList(res.data); // } page = page+1; //initTouch(); }else{ if(page==1){ sendGet("doctor/is_patient_signed",{patient:patient},function(res){ mui.toast("签约关系获取失败!"); },function(res){ if(res.status==200){ if(res.data==1){ $(".div-tishi-info").html("该居民还未绑定体征设备"); }else{ $(".div-tishi-info").html("您还未帮该居民绑定过体征设备"); } $(".div-no-info").show(); $(".main").hide(); }else{ if(res.msg){ mui.toast(res.msg); }else{ mui.toast("签约关系获取失败!"); } } }); }else{ mui.toast("无更多设备!"); } } $(".pullUp").hide(); }else{ queryListFailed(res); } } function showList(data){ // var img='xuetangyi_icon.png'; // if(rowData.categoryCode==2){ // img='xueyaji_icon.png'; // } var bindUser ="患者绑定"; // if(rowData.doctor){ // bindUser = rowData.doctorName; // } template.helper('getImgUrl', function(str, categoryCode){ var url = getImgUrl(str); if(url){ return url; }else{ if(categoryCode==2){ url='xueyaji_icon.png'; }else{ url = 'xuetangyi_icon.png'; } } return url; }); // var showDomLi = '
  • '+ // '
    '+ // ''+ // '
    '+ // '
    '+rowData.deviceName+'
    '+ // '
    绑定时间:'+rowData.czrq+'
    '+ // '
    绑定人:'+bindUser+'
    '+ // //'编辑'+ // //'解绑'+ // '
  • '; var html = template('list-tmp', {list: data, bindUser: bindUser}); $(".c-list").empty().append(html); $(".div-no-info").hide(); $(".main").show(); } function queryListFailed(res) { alert("Failed") plus.nativeUI.closeWaiting(); if (res && res.msg) { mui.toast(res.msg); } else { mui.toast("加载设备列表失败!"); } } //绑定事件 function bindEvents(){ //绑定编辑和删除事件 $(".c-list").on("click","li div",function(){ var code = $(this.parentElement).attr("data-id"); var deviceId = $(this.parentElement).attr("device-id"); var type = $(this.parentElement).attr("data-type"); var role = $(this.parentElement).attr("data-role"); var params = {}; params.deviceId = deviceId; params.dataId = code; params.patient = patient; params.role = role; if(type==1){ openWebviewExtras("view-xuetangyi.html",params); }else if(type==2){ openWebviewExtras("view-xueyaji.html",params); } }); function deleteSn(code){ sendPost("doctor/device/DeletePatientDevice?id="+code,{},function(res){ if (res && res.msg) { mui.toast(res.msg); } else { mui.toast("解绑设备失败!"); } },function(res){ if(res.status==200){ $(".c-list").html(""); page=1; getEquipments(); mui.toast("解绑设备成功!"); }else{ mui.toast("解绑设备失败!"); } },"DELETE") } //新增按钮事件 $(".div-add-btn").on("click",function(){ $(this).hide(); if($(this).hasClass("active")){ $(".modal-overlay").trigger("click"); }else{ $(this).addClass("active"); $(".modal-overlay").addClass("modal-overlay-visible"); $(".div-dialog-content").show(); } }); //点击遮罩事件 $(".modal-overlay").on("click",function(){ $(".modal-overlay").removeClass("modal-overlay-visible"); $(".div-dialog-content").hide(); $(".div-add-btn").removeClass("active"); $(".div-add-btn").show(); }); //取消事件 $(".quxiao").on("click",function(){ $(".modal-overlay").trigger("click"); }); //点击血糖仪事件 $(".xuetangyi-icon").on("click",function(){ // $(this).addClass("active"); var params = {}; params.category_code = 1; params.patient = patient; $(".quxiao").click(); if(docInfo.hospital.indexOf("350205") == 0){ dialog({ content: "绑定设备请前往首页->设备管理->扫码", okValue: "知道了", ok: function(){ } }).showModal(); }else openWebviewExtras("list-xuetangyi.html",params); }); //点击血压计事件 $(".xueyaji-icon").on("click",function(){ // $(this).addClass("active"); var params = {}; params.category_code = 2; params.patient = patient; $(".quxiao").click(); if(docInfo.hospital.indexOf("350205") == 0){ dialog({ content: "绑定设备请前往首页->设备管理->扫码", okValue: "知道了", ok: function(){ } }).showModal(); }else openWebviewExtras("list-xueyaji.html",params); }); } //页面局部刷新 window.addEventListener("refreshEquipment", function(){ console.log("refreshEquipment"); page=1; getEquipments() })