| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 | 
							- var pagesize = 100;
 
- var page = 1 ;
 
- var patient = null;
 
- mui.init();
 
- mui.plusReady(function() {
 
- 	plus.nativeUI.showWaiting();
 
- 	self = plus.webview.currentWebview();
 
- 	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 = '<li class="inp" device-id="'+rowData.deviceId+'" data-type="'+rowData.categoryCode+'" data-id="'+rowData.id+'" data-role="'+rowData.role+'">'+
 
- //						'<div class="icon-div">'+
 
- //							'<img src="'+getImgUrl(rowData.devicePhoto)+'">'+
 
- //						'</div>'+
 
- //						'<div class="div-content">'+rowData.deviceName+'</div>'+
 
- //						'<div class="div-sn"><span class="bullspan">• </span>绑定时间:'+rowData.czrq+'</div>'+
 
- //						'<div class="div-sn" style="top: 72px;"><span class="bullspan">•</span> 绑定人:'+bindUser+'</div>'+
 
- //						//'<a href="javascript:void(0);" data-type="'+rowData.categoryCode+'" data-id="'+rowData.id+'" device-id="'+rowData.deviceId+'"  class="edit">编辑</a>'+
 
- //						//'<a href="javascript:void(0);" data-type="'+rowData.categoryCode+'" data-id="'+rowData.id+'" device-id="'+rowData.deviceId+'"  class="del">解绑</a>'+
 
- //					'</li>';
 
-     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();
 
-    		openWebviewExtras("list-xuetangyi.html",params);
 
-    	});
 
-    	
 
-    	 //点击血压计事件
 
-    $(".xueyaji-icon").on("click",function(){
 
- // 		$(this).addClass("active");
 
-    		var params = {};
 
-    		params.category_code = 2;
 
-    		params.patient = patient;
 
-    		$(".quxiao").click();
 
-    		openWebviewExtras("list-xueyaji.html",params); 		
 
-    });
 
- }
 
- //页面局部刷新
 
- window.addEventListener("refreshEquipment", function(){
 
-     console.log("refreshEquipment");
 
-     page=1;
 
- 	getEquipments()
 
- })
 
- 	
 
 
  |