123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239 |
- var pagesize = 15;
- var id = 0 ;
- var d = dialog({contentType:'load', skin:'bk-popup'});
- var scroller1 = null;
- var pagetype = 6;
- var prescriptionCode;//续方咨询跳转过来绑定
- $(function() {
- checkUserAgent();
- Request = GetRequest();
- var openid = Request["openid"];
- prescriptionCode = Request["prescriptionCode"];
- scroller1= new IScrollPullUpDown('wrapper',{
- probeType:2,
- bounceTime: 250,
- bounceEasing: 'quadratic',
- mouseWheel:true,
- scrollbars:true,
- click:true,
- fadeScrollbars:true,
- interactiveScrollbars:false
- },pullDownAction,pullUpAction);
- bindEvents();
- getEquipments();
-
- //下拉刷新
- function pullDownAction(theScrollerTemp) {
- // $(".pullUp").show();
- // setTimeout(function () {
- // $(".c-list").html("");
- // id=0;
- // getEquipments();
- // }, 1000);
- }
-
- //上拉加载数据
- function pullUpAction(theScrollerTemp) {
- // $(".pullUp").show();
- // setTimeout(function () {
- // getEquipments();
- // }, 1000);
- }
- })
- appendFamilyMember($('#memberContainer'),function(){
- $(".c-list").html("");
- $(".div-no-info").hide();
- $(".main").show();
- id=0;
- getEquipments()
- },function(){
- //判断有授权家人,修改样式
- if($('#memberContainer').is(':hidden')){
- $('#wrapper').css('top','0px');
- }else{
- $('#wrapper').css('top','90px');
- $('.div-no-info').css('padding-top','150px');
- }
- });
- function getEquipments(){
- var params = {};
- params.id=id;
- params.pagesize = pagesize;
- d.show();
- sendPost("patient/device/PatientDeviceList",params,"JSON","GET",queryListFailed,queryListSuccess);
- }
- function queryListSuccess(res){
- d.close();
- if(res.status==200){
- if(res.data&&res.data.length>0){
- for(var i in res.data){
- showList(res.data[i]);
- }
- id = res.data[res.data.length-1].id;
- console.log(id)
- scroller1.myScroll.refresh();
- }else{
- if(id==0){
- $(".div-no-info").show();
- $(".main").hide();
- }else{
- dialog({contentType:'tipsbox', skin:'bk-popup',bottom:true , content:'无更多设备!'}).show();
- }
- }
- $(".pullUp").hide();
- }else{
- queryListFailed(res);
- }
- }
- function showList(rowData){
- var img='xuetangyi_icon.png';
- if(rowData.categoryCode==2){
- img='xueyaji_icon.png';
- }
- var bindUser ="自己绑定";
- if(rowData.doctor){
- bindUser = "医生绑定";
- }else if(rowData.agent){
- bindUser = "家人绑定";
- }
- var showDomLi = '<li device-id="'+rowData.deviceId+'" data-type="'+rowData.categoryCode+'" data-id="'+rowData.id+'">'+
- '<div class="icon-div">'+
- '<img src="../images/'+img+'">'+
- '</div>'+
- '<div style="width: calc(100% - 90px);"><div class="div-content">'+rowData.deviceName+'</div>'+
- '<div class="div-sn"><span class="bullspan">• </span>绑定时间:'+rowData.czrq+'</div>'+
- '<div class="div-name"><span class="bullspan">•</span> '+bindUser+'</div></div>'+
- '</li>';
- $(".c-list").append(showDomLi);
- }
- function queryListFailed(res) {
- d.close();
- if (res && res.msg) {
- dialog({contentType:'tipsbox', skin:'bk-popup',bottom:true , content:res.msg}).show();
- } else {
- dialog({contentType:'tipsbox', skin:'bk-popup',bottom:true , content:'加载设备列表失败'}).show();
- }
- }
- //绑定事件
- 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");
- if(type==1){
- location.href="view-xuetangyi.html?deviceId="+deviceId+"&id="+code;
- }else if(type==2){
- location.href="view-xueyaji.html?deviceId="+deviceId+"&id="+code;
- }
- })
-
-
- function deleteSn(code){
- sendPost("patient/device/DeletePatientDevice?id="+code,{},"JSON","DELETE",function(res){
- if (res && res.msg) {
- dialog({contentType:'tipsbox', skin:'bk-popup',bottom:true , content:res.msg}).show();
- } else {
- dialog({contentType:'tipsbox', skin:'bk-popup',bottom:true , content:'删除设备失败'}).show();
- }
- },function(res){
- if(res.status==200){
- $(".c-list").html("");
- id=0;
- getEquipments();
- }else{
- dialog({contentType:'tipsbox', skin:'bk-popup',bottom:true , content:'删除设备失败'}).show();
- }
- })
- }
-
- //新增按钮事件
- $(".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");
- window.location.href = "list-xuetangyi.html?category_code=1&prescriptionCode="+prescriptionCode;
- });
-
- //点击血压计事件
- $(".xueyaji-icon").on("click",function(){
- $(this).addClass("active");
- window.location.href = "list-xueyaji.html?category_code=2&prescriptionCode="+prescriptionCode;
- });
- }
- //初始化左滑/右滑事件
- function initTouch(){
- //滑动事件
- $(function(){
- $.extend({CycTounch:function(EV,X,Y){
- var valx=50;
- console.log(EV.target)
- if((Math.abs(X)>Math.abs(Y))&& Math.abs(X)>50){
- var obj=$(EV.target).closest("li");
- if(X>0){
- obj.removeClass("on")
- obj.animate({"left":"0"})
- obj.find(".c-arrow-r").animate({"right":"10px"})
- obj.find(".del").animate({"right":"-75px"})
- console.log('右滑');
- }else{
- obj.addClass("on")
- obj.animate({"left":"-75px"})
- obj.find(".c-arrow-r").animate({"right":"10px"})
- obj.find(".del").animate({"right":"-75px"})
- console.log('左滑');
- }
- }
-
- }})
- })
-
- window.addEventListener('load',load, false);
- }
- function pushHistory() {
- var state = {
- title: "title",
- url: "#"
- };
- setTimeout(function (){
- window.history.pushState(state, "title", "#");
- },1000);
- }
- pushHistory();
- setTimeout( function () {
- window.addEventListener("popstate", function(e) {
- WeixinJSBridge.call('closeWindow');
- }, false);
- }, 300);
-
|