var pagetype = 47, userAgent, patient, xueyaLoaded = false; //标记是否已经加载过血压值 var d = dialog({ contentType: 'load', skin: 'bk-popup' }); checkUserAgent(); //封装好的入口函数 function queryInit() { userAgent = window.localStorage.getItem(agentName) patient = JSON.parse(userAgent).uid;; getPatientInfo(); getWeekXTInfo(0);//获得近一周血糖血压数据 getTrackPatientInfo();//获得运动情况和检测方案等信息 getControlObjectives();//获取控制目标,血压,血糖 bindEvents(); } function getPatientInfo(){ var url = "/patient/scheme/patient", params = { patient: patient }; sendPost(url, params, 'JSON', 'GET', queryFailed, function(res) { if(res.status == 200) { if( res.data && res.data.photo){ var photo = res.data.photo; var reg=/group1\//g; photo = photo.replace(reg,imgUrlDomain+ 'group1/'); res.data.photo = photo; } var html = template('patientInfo-tmp', res.data); $("#patientInfo").append(html); } else { queryFailed(res); } }); } function getWeekXTInfo(type){ var sdate = new Date(), edate = new Date(); sdate.setDate(edate.getDate() - 6); var url = "/patient/scheme/getPatientHealthIndex", params = { patient: patient, startDate: sdate.Format('yyyy-MM-dd'), endDate: edate.Format('yyyy-MM-dd'), type: type //0:血糖, 1:血压 }; if(type == 1){ xueyaLoaded = true; } sendPost(url, params, 'JSON', 'GET', queryFailed, function(res) { if(res.status == 200) { var html = template('xt-tmp', res.data); if(type == 0){ $("#xtPanel").empty().append(html); }else{ $(".xueya-info").empty().append(html); } } else { queryFailed(res); } }); } function getTrackPatientInfo(){ var url = "/patient/scheme/getTrackPatientInfo", params = { patient: patient }; sendPost(url, params, 'JSON', 'GET', queryFailed, function(res) { if(res.status == 200) { var html = template('trackPatientInfo-tmp', res.data); $("#trackPatientInfo").append(html); } else { queryFailed(res); } }); } function getControlObjectives(){ var url = "/patient/scheme/getControlObjectives", params = { patient: patient }; sendPost(url, params, 'JSON', 'GET', queryFailed, function(res) { if(res.status == 200) { var html = template('controlObjectives-tmp', res.data); $("#controlObjectives").append(html); } else { queryFailed(res); } }); } function queryFailed(res) { d.close(); if(res && res.msg) { dialog({ contentType: 'tipsbox', skin: 'bk-popup', content: res.msg }).show(); } else { dialog({ contentType: 'tipsbox', skin: 'bk-popup', content: '加载失败' }).show(); } } function bindEvents(){ //点击“智能测量”跳转”健康记录——体征设备“页。 $("#patientInfo").on("tap",'.zhinengceliang',function(){ window.location.href ="../../jkjl/html/health-record.html?charType=5&tagType=1"; }) //点击“最近一周血糖”跳转 血糖情况页。 $("#xtPanel").on("tap",'.ui-col-1',function(){ var dat = new Date(); window.location.href ="../../jkjl/html/xuetang-view.html?type=0&dateT=" + (dat.Format("yyyy-MM-dd")); }) //点击“最近一周血压”跳转 血压情况页。 $("#xyPanel").on("tap",'.ui-col-1',function(){ var dat = new Date(); window.location.href ="../../jkjl/html/xueya-view.html?type=0&dateT=" + (dat.Format("yyyy-MM-dd")); }) //点击“今日运动情况”跳转 运动情况页。 $("#trackPatientInfo").on("tap",'.sportSituation',function(){ window.location.href = '../html/sports.html'; }) //点击“身高体重”跳转 运动情况页。 $("#trackPatientInfo").on("tap",'.tizhong',function(){ var dat = new Date(); window.location.href = '../../jkjl/html/tizhong-view.html?dateT=' + (dat.Format("yyyy-MM-dd")); }) //点击“血压/血糖监测方案”跳转到相应的监测方案。 $("#trackPatientInfo").on("tap",'.jc-method',function(){ var $this = $(this), val = $this.data("val"); if(val == 'xt'){ selectedTab = 1 }else{ selectedTab = 2 } window.location.href = '../html/monitor-program.html?selectedTab='+(selectedTab); }) //点击“控制目标”跳转 控制目标页。 $("#controlObjectives").on("tap",function(){ window.location.href = '../html/control-target.html'; }) //点击“处方记录”跳转 处方记录页。 $(".cfjl").on("tap",function(){ window.location.href = '../../prescription/html/prescription_records.html'; }) //点击“疾病社区”跳转 疾病社区页。 $(".jbsq").on("tap",function(){ window.location.href = '../html/disease-community.html'; }) //点击“热量查询”跳转 热量查询页。 $(".rlcx").on("tap",function(){ window.location.href = '../../rlcx/html/serach-index.html'; }) //血压血糖按钮切换 $("body").on('tap', ".switch-box span", function(){ var $this = $(this), val = $this.attr("data-val"), index = $this.index(); if($this.hasClass("active")){ return false; } $this.siblings().removeClass("active"); $this.addClass("active"); mui('.mui-slider').slider().gotoItem(parseInt(index)); if(val == "xt"){ $("#xtName").text("血糖"); }else if(val == "xy"){ if(!xueyaLoaded){ getWeekXTInfo(1); } $("#xtName").text("血压"); } }); //监听血压,血糖情况滚动切换 document.querySelector('.mui-slider').addEventListener('slide', function(event) { if (event.detail.slideNumber === 0) { $(".switch-box span").eq(0).addClass("active"); $(".switch-box span").eq(1).removeClass("active"); $("#xtName").text("血糖"); } else if (event.detail.slideNumber === 1) { if(!xueyaLoaded){ getWeekXTInfo(1); } $(".switch-box span").eq(0).removeClass("active"); $(".switch-box span").eq(1).addClass("active"); $("#xtName").text("血压"); } }); } function templateHelper(){ template.helper("getImgUrl", function(str){ if(str){ return getImgUrl(str); } return ""; }) }