mui.init(); var patient, isManbing = false, //标记是否是慢病病人 oPatiInfo, isTrack, //标记是否关注 xueyaLoaded = false; //标记是否已经加载过血压值 mui.plusReady(function(){ var self = plus.webview.currentWebview(); patient = self.patient; getPatientInfo(); getWeekXTInfo(0); //获得近一周血糖血压数据 //获得运动情况和检测方案等信息 getSection3Info(); //获得控制目标信息 getTargetInfo(); bindEvents(); templateHelper(); }) function getPatientInfo(){ var url = "/doctor/patient_label_info/patient", params = {patient: patient}; plus.nativeUI.showWaiting(); sendGet(url, params, null, function(res){ plus.nativeUI.closeWaiting(); if(res.status == 200){ oPatiInfo = res.data; $("#header-title").text(res.data.name+"_慢病档案"); //TODO 判断是否关注现实隐藏”取消关注“按钮 isTrack = res.data.isTrack; if(isTrack == '1'){ $(".header-link a").attr("data-val", '1').text("取消关注"); }else{ $(".header-link a").attr("data-val", '0').text("重点关注"); } //判断居民类型 如果是慢病病人 则续方管理模块出现否则隐藏 for(var i in res.data.serverTypes){ var type = res.data.serverTypes[i]; if(type.server_type == 4 || type.server_type == 5){ isManbing = true; break; } } if(isManbing){ $("#xfjl").show(); } var html = template("pati_info_tmp", res.data); $(".patiInfo-section").append(html); }else if(res.status == -1){ mui.toast(res.msg); } }, true); } //获得近一周血糖血压数据 function getWeekXTInfo(type){ var sdate = new Date(), edate = new Date(); sdate.setDate(edate.getDate() - 6); var url = "/doctor/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; } sendGet(url, params, null, function(res){ if(res.status == 200){ var html = template('xt-tmp', res.data); if(type == 0){ $(".xuetang-info .mui-loading").remove(); $(".xuetang-info").append(html); }else{ $(".xueya-info .mui-loading").remove(); $(".xueya-info").append(html); } }else{ mui.toast(res.msg); } }, true); } function getSection3Info(){ var url = "/doctor/scheme/getTrackPatientInfo", params = {patient: patient}; plus.nativeUI.showWaiting(); sendGet(url, params, null, function(res){ if(res.status == 200){ var html = template('section3-tmp', res.data); $(".mb-info").empty().append(html); }else{ mui.toast(res.msg); } plus.nativeUI.closeWaiting(); }, true); } function getTargetInfo(){ var url = "/doctor/scheme/getControlObjectives", params = {patient: patient}; plus.nativeUI.showWaiting(); sendGet(url, params, null, function(res){ if(res.status == 200){ var html = template("target-tmp", res.data); $("#targetInfo").empty().append(html); }else{ mui.toast(res.msg); } plus.nativeUI.closeWaiting(); }, true); } //添加重点关注 function setTrack(state){ var url = '/doctor/patient_label_info/setTrackPatient', params = { patient: patient, state: state // 1:开启, 0:删除 }; plus.nativeUI.showWaiting(); sendPost(url, params, null, function(res){ if(res.status == 200){ if(state == 1){ $(".track-flag").show(); $(".header-link a").attr("data-val", '1').text("取消关注"); }else{ $(".track-flag").hide(); $(".header-link a").attr("data-val", '0').text("重点关注"); } mui.toast("设置成功"); }else{ mui.toast(res.msg); } plus.nativeUI.closeWaiting(); }); } function templateHelper(){ template.helper("getImgUrl", function(str){ if(str){ return getImgUrl(str); } if(str.length == 0){ return "../../../images/p-female.png"; } }) } function bindEvents(){ //重点关注和取消关注控制 $(".header-link").on('click', function(){ var $a = $(this).find("a"), val = $a.attr("data-val"); if(val == '1'){ //即当前已关注,点击调用取消关注接口 setTrack(0); }else{//即当前未关注,点击调用关注接口 setTrack(1); } }) $(".patiInfo-section").on('click', ".sbbind-flag", function(e){ e.stopPropagation(); mui.openWindow('../../jkjl/html/health-record.html', 'health-record', { extras: { patientCode: patient, tagType: 1 } }) }); $(".patiInfo-section").on('click', "#patiInfo", function(){ openWebview("../../huanzhe/html/huanzhexinxi.html", { patiCode: patient }); }); //血压血糖按钮切换 $(".switch-box").on('click', "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("血压"); } }); //查看血糖情况 $("body").on('tap', ".xuetang-info .cycle-div", function(){ var dat = new Date(); mui.openWindow('../../jkjl/html/xuetang-view.html', 'xuetang-view.html', { extras: { code: patient, dateT: dat.format("yyyy-MM-dd"), } }); }); //查看血压情况 $("body").on('tap', ".xueya-info .cycle-div", function(){ var dat = new Date(); mui.openWindow('../../jkjl/html/xueya-view.html', 'xueya-view.html', { extras: { code: patient, dateT: dat.format("yyyy-MM-dd") } }); }); //查看体重信息 $("body").on('click', ".tizhong", function(){ var dat = new Date(); mui.openWindow('../../jkjl/html/tizhong-view.html', 'tizhong-view.html', { extras: { code: patient, dateT: dat.format("yyyy-MM-dd") } }); }); //查看监测方案 $("body").on('click', ".jc-method", function(){ var $this = $(this), val = $this.data("val"), xtCode = $(".jc-method[data-val=xt]").data("code"), xyCode = $(".jc-method[data-val=xy]").data("code"); openWebview("jc-xuanzefangan.html",{ pCodes: [patient], selectedTab: val=='xy' ? 2 : 1, xtCode: xtCode, xyCode: xyCode, comeFrom: 'jumindangan' }) }); //查看控制目标 $("#targetInfo").on('click', function(){ openWebview("control-goal.html",{pCodes: patient, pName: oPatiInfo.name}); }); //查看运动情况 $('.mb-info').on('click', ".sports", function(){ openWebview("sports.html", {patient: patient}); }); //用药记录 $("#yyjl").on('click', function(){ openWebview("../../huanzhe/html/yongyaojilu.html",{patiInfo: {code: patient}}) }); $("#xfjl").on('click', function(){ mui.openWindow('../../prescription/html/juminxufangjilu.html', 'juminxufangjilu', { extras: { teamCode:oPatiInfo.jtAdminTeam, patiCode: patient, patiName: oPatiInfo.name } }) }); window.addEventListener("reloadJiance", function(e){ //刷新检测方案内容 getSection3Info(); }); window.addEventListener('refreshTargetData', function(e){ //刷新控制目标内容 getTargetInfo(); }); }