var self; //当前页面对象 var patiCode; //居民标识 var currDays = 7; //默认日期类型 var indexType = "1"; //指标类型 var currIndexCode = "" //当前要显示的指标类型 var docType=""//医生类别 var signType = ""; var date_begin = getDateBefore(6); var date_end = getNowDate(); var oPatiInfo =null; var iscroller = null; var doctorCode = null; var qyRelation; var overdue; //判断患者与医生的签约状态是否已过期 var currService; var jtServerCode=[];//服务类型名称 var jtAdminTeamId; // 标记患者的签约团队id mui.plusReady(function() { self = plus.webview.currentWebview(); patiCode = self.patiCode; console.log(patiCode) doctorCode = JSON.parse(plus.storage.getItem("docInfo")).code; overdue = self.overdue; $("#pati_info").attr("code",patiCode); localStorage.removeItem('updateService'); getPatientAllLabels(); getPatiInfo(); initScroller(); }); mui.back = function(){ // self.opener().reload(true); //如果父窗口为im, 更新im if(self.opener().id=='p2dzixun'){ mui.fire(self.opener(), 'update'); } self.close(); } //获取病人信息 function getPatiInfo(){ sendPost("/doctor/patient_label_info/patient", {patient: patiCode}, null, function(res){ if(res.status == 200){ oPatiInfo = res.data; bindEvents(); dealPatiInfoTmpl(oPatiInfo); $(".div-dianhua").attr("data-mobile",oPatiInfo.mobile).attr("data-phone",oPatiInfo.phone); } else { mui.toast("获取病人信息失败"); } },'POST','',true); } //获取病人所有标签信息 function getPatientAllLabels(){ sendPost("/doctor/patient_label/patientAllLabels", {patient: patiCode}, null, function(res){ console.error(JSON.stringify(res)) if(res.status == 200){ if(res.data){ var str = '' res.data.map(function(v,i){ str+=v.labelName; if(i+1 != res.data.length)str+=',' }) $('#diseases').html(str) } } else { mui.toast("获取标签情况失败"); } },'POST','',true); } function sendWeixinRemind() { sendPost("doctor/family_contract/wechat_focus_remind", {patient: patiCode,isAll:0}, null, function(res){ if(res.status == 200){ oPatiInfo.wechatFocusRemind = 1; showRemindBtn(true); } else { oPatiInfo.wechatFocusRemind = 1; showRemindBtn(true); mui.toast(res.msg); } },'POST','',true); } function showRemindBtn(isReminded) { var $remind = $("#remind_gz"); $remind.show(); if(isReminded) { $remind.addClass("ytx"); $remind.find("a").text("已提醒关注"); } else { $remind.removeClass("ytx"); $remind.find("a").text("提醒关注微信"); } } function checkWeixinRemind(data) { return new Promise(function(resolve, reject) { sendPost("doctor/family_contract/is_patient_remind_focus", {patient: patiCode}, null, function(res){ if(res.status == 200){ if(res.data==0) { // 0: 当日未提醒 isWeiXinRemind(data); } } else { mui.toast(res.msg); } },'POST','',true) }); } function isWeiXinRemind (data) { if(data) { var isReminded = data.wechatFocusRemind=="1"? true: false, // 签约类型: 1-->三师 2-->家庭 3-->三师 、家庭两者都有 signType = data.signType, // 缴费状态: 2-->已退费 1-->已缴费 0-->未交费 expensesStatus = data.expensesStatus, openid = data.openid; if(!openid) { // 有签约家庭医生,但未交费,则有该悬浮按钮 if((signType=="2" || signType=="3") && expensesStatus=="1") { showRemindBtn(isReminded); } // 2、如只有三师签约,但无openid,则有该悬浮按钮 else if(signType == "1") { showRemindBtn(isReminded); } } } } // 滚动条实例初始化 function initScroller() { //阻尼系数 var deceleration = mui.os.ios?0.003:0.0009; mui('.mui-scroll-wrapper').scroll({ bounce: false, indicators: true, //是否显示滚动条 deceleration:deceleration }); iscroller = mui(".mui-scroll").pullToRefresh({ down: { callback: function() { var self = this; setTimeout(function() { refreshPage(); self.endPullDownToRefresh(); }, 1000); } } }); } /* * 拼接居民信息模板 */ function dealPatiInfoTmpl(patiInfoObj) { $("#pati_info_wrap").html(template("pati_info_tmpl", patiInfoObj)); $('#view_wrap').show(); } /* * 查看居民资料 */ function toInfo() { var $el = $(this); mui.openWindow("huanzeziliao.html", "huanzeziliao", { extras: { patiPhoto: $el.find('.doc-avatar img').attr('src'), patiCode: patiCode, signType: signType, teamCode: self.teamCode, //添加续签状态值 qyRelation: qyRelation, renewable: oPatiInfo.isRenewable } }) } function openwdsb(){ // var params={}; // params.patient = patiCode; // openWebviewExtras("../../wdsb/html/my-equipments.html",params); mui.openWindow('../../jkjl/html/health-record.html', 'health-record', { extras: { patientCode: patiCode, patientName: oPatiInfo.name, qyRelation: qyRelation } }) } /* * 服务记录 */ function fwjl() { mui.openWindow('fuwujilu.html', 'fuwujilu', { extras: { patientCode: patiCode, patientName: oPatiInfo.name, qyRelation: qyRelation } }); } /* * 健康指导 */ function jkzd() { // diaAdd.close(); mui.openWindow('../../hzzd/html/guidance_list.html', 'jkzd', { extras: { code: patiCode } }); } /* * 体征预警 */ function tzyj() { // diaAdd.close(); mui.openWindow('tzyj.html', 'tzyj', { extras: { code: patiCode } }); } /* * 健康记录点击事件 */ /* * 药物记录 */ function ywjl(dom) { var text = $(dom).find("p").eq(0).text(); if(text == "-") { mui.toast("暂无健康记录"); return; } mui.openWindow('../../hzgl/html/health-record-drug.html', 'health-record-drug', { extras: { pCode: patiCode } }); } /* * 饮食记录 */ function ysjl(dom) { var text = $(dom).find("p").eq(0).text(); if(text == "-") { mui.toast("暂无健康记录"); return; } mui.openWindow('../../hzgl/html/health-record-diet.html', 'health-record-diet', { extras: { pCode: patiCode } }); } /* * 运动记录 */ function ydjl(dom) { var text = $(dom).find("p").eq(0).text(); if(text == "-") { mui.toast("暂无健康记录"); return; } mui.openWindow('../../hzgl/html/health-record-sport.html', 'health-record-sport', { extras: { pCode: patiCode } }); } /* * 分组 */ function fz() { mui.openWindow('../../zxyy/html/xuanzeyiyuan.html', 'xuanzeyiyuan', { extras: { pCode: patiCode } }); } function toSelectJb(){ debugger var self = plus.webview.currentWebview(); var update = localStorage.getItem('updateService'); var oldData = jtServerCode.join(','); mui.openWindow({ url: 'disease-label-edit.html', id: 'disease-label-edit', extras: { patientCode: patiCode, viewId: self.id, signCode:oPatiInfo.signCode,//变更服务类型用 serviceCode: update?update:oldData, isChange:$("#smallTipSev").is(":hidden")?false:true//判断是否处于变更 } }); } var labelName =[]; function queryFailed(res){ if(res.msg){ if (res.msg != '查询失败') { mui.toast(res.msg); } }else{ mui.toast("标签加载失败!"); } } $('#more_event').on('tap',function() { openWebview("jiuzhenjilu.html",{patiInfo: oPatiInfo}) }); $('.fix-adds').on('tap', function() { $(".div-dialog-content").show(); $(".modal-overlay").addClass("modal-overlay-visible"); }); $('.div-dialog-content').on('tap',"div", function() { if(!$(this).hasClass("quxiao")){ hideBing(); if($(this).hasClass("addjkzd")){//健康指导 jkzd(); }else if($(this).hasClass("addfzgl")){//分组管理 fz(); }else if($(this).hasClass("addtzyj")){//体征预警 tzyj(); }else if($(this).hasClass("addtzsb")){//体征设备 openwdsb(); }else if($(this).hasClass("addjtcy")){//家庭成员 jtcy(); } }else if($(this).hasClass("quxiao")){//取消 $('.fix-adds').show(); $(".div-dialog-content").hide(); $(".modal-overlay").removeClass("modal-overlay-visible"); } }); function hideBing(){ $('.fix-adds').show(); $(".div-dialog-content").hide(); $(".modal-overlay").removeClass("modal-overlay-visible"); } $(".modal-overlay").on('tap', function() { hideBing(); }); $('#recent_events').on('tap','li',function() { var data = JSON.parse($(this).attr("data-json")); openWebview("health-profile.html",{eventInfo: data,patiInfo: oPatiInfo}); }); /* * 家庭成员 */ function jtcy() { mui.openWindow('jiatingchengyuan.html', 'jiatingchengyuan', { extras: { code: patiCode, patiInfo: oPatiInfo, qyRelation: qyRelation } }); } /* * 咨询记录 */ function zxjl() { mui.openWindow('zixunjilu.html', 'zixunjilu', { extras: { code: patiCode, qyRelation: qyRelation } }); } /* * 指导记录 */ function zdjl() { mui.openWindow('zhidaojilu.html', 'zhidaojilu', { extras: { code: patiCode, qyRelation: qyRelation } }); } /* * 代预约记录 */ function dyyjl(){ mui.openWindow('../../wdyy/html/my-appointment.html', 'my-appointment', { extras: { patient: patiCode, qyRelation: qyRelation } }); } /* * 代预约 */ function dyy() { mui.openWindow('../../wdyy/html/appointment-register.html', 'appointment-register', { extras: { patient: patiCode } }); } //拨打电话 $(".div-dianhua").on("tap",function(){ var moblie = $(this).attr("data-mobile"); var phone = $(this).attr("data-phone"); //观察者模式下,不可以拨打被观察者患者的电话 var userAgent = plus.navigator.getUserAgent(), index = userAgent.indexOf("}"), s = userAgent.substr(0, index+1), item = JSON.parse(s); if(item.observer){ mui.toast("观察者模式无法拨打患者电话"); }else{ if(moblie){ dialog({ content: moblie, okValue:'立即拨号', ok: function (){ window.location.href = "tel:"+moblie; }, cancelValue: '不了,谢谢', cancel: function () { return; } }).showModal(); }else{ if(phone){ dialog({ content: "对不起,"+$(".patient-name").html()+"未绑定手机号码,是否拨打联系人电话?", okValue:'立即拨号', ok: function (){ window.location.href = "tel:"+phone; }, cancelValue: '不了,谢谢', cancel: function () { return; } }).showModal(); }else{ dialog({ content: "对不起,"+$(".patient-name").html()+"未绑定手机号码,无法电话联系", okValue:'我知道了', ok: function (){ return; }, }).showModal(); } } } }) function refreshPage () { labelName =[]; jtServerCode = []; localStorage.removeItem('updateService'); getPatiInfo(); } window.addEventListener("refresh1", function(){ refreshPage(); var xxWv = plus.webview.getWebviewById("huanzhe-by-type"); // 如果有打开分组列表也要刷新列表 if(xxWv){ mui.fire(xxWv, "refresh"); } var xxindex = plus.webview.getWebviewById("huanzhe.html"); // 如果有打开分组列表也要刷新列表 if(xxindex){ mui.fire(xxindex, "refresh"); } }) window.addEventListener("setDiseaseTypes", function(e){ $('#diseases').html(e.detail.names); oPatiInfo.diseases = e.detail.diseases; }) //门诊记录 $(".div-menzhen-btn").on("tap",function(){ // openWebview(templateServer,{itemIndex:0,name:"就诊记录", idcard: "362321199703137824"}) }) //住院记录 $(".div-zhuyuan-btn").on("tap",function(){ // openWebview(templateServer,{itemIndex:0,name:"就诊记录", idcard: oPatiInfo.idcard}) }) //就诊记录 $(".div-jiuzhen-btn").on("tap",function(){ var url = profileServer+'/wx/html/profile/html/index_0.html?target=app&demographic_id='+oPatiInfo.idcard mui.openWindow({ id: "index_0.html", url: url }) }) //检查检验记录 $(".div-jianche-btn").on("tap",function(){ // openWebview(templateServer,{itemIndex:1,name:"检查检验", idcard: oPatiInfo.idcard}) var url = profileServer+'/wx/html/profile/html/index_1.html?target=app&demographic_id='+oPatiInfo.idcard mui.openWindow({ id: "index_1.html", url: url }) }) //用药记录 $(".div-yongyao-btn").on("tap",function(){ // openWebview(templateServer,{itemIndex:2,name:"用药记录", idcard: oPatiInfo.idcard}) var url = profileServer+'/wx/html/profile/html/index_2.html?target=app&demographic_id='+oPatiInfo.idcard mui.openWindow({ id: "index_2.html", url: url }) }) //健康体检 $(".div-jiankangtijian-btn").on("tap",function(){ openWebview("jiankangtijian.html",{patiInfo: oPatiInfo}) }) /* * 健康教育 */ function jkjy() { // mui.openWindow('../../jkjy/html/jiankangjiaoyu.html', 'jiankangjiaoyu', { mui.openWindow('../../jkjy/html/article-store.html', 'jiankangjiaoyu', { extras: { patient: patiCode, patientName: oPatiInfo.name, teamCode: jtAdminTeamId } }); } function xfjl() { mui.openWindow('../../prescription/html/juminxufangjilu.html', 'juminxufangjilu', { extras: { teamCode:oPatiInfo.jtAdminTeam, patiCode: patiCode, patiName: oPatiInfo.name } }) } function fybj() { mui.openWindow('../../fybj/html/yunjianjihua.html', 'yunjianjihua', { extras: { patiCode: patiCode, doctorCode:doctorCode } }) } function myjl() { mui.openWindow('../../fybj/html/mianyijihua.html', 'mianyijihua', { extras: { patiCode: patiCode } }) } /* 事件绑定*/ function bindEvents(){ //服务记录 $("#fwjl").on('tap', fwjl); //健康记录 $("#tzsb").on('tap', openwdsb); //家庭成员 $("#family").on('tap', jtcy); //提醒关注 $("#remind_gz").on('tap', function(){ mui("#sheet1").popover('toggle'); if($(this).hasClass("ytx")){//今日已提醒 mui.toast("居民今天已经收到过提醒了哦,不可再次提醒"); }else{//今日未提醒 sendWeixinRemind(); } }); //健康指导 $("#jkzd").on('tap', jkzd); //体征预警 $("#tzyj").on('tap', tzyj); //分组 $("#fz").on('tap', fz); //干预 $("#gy").on('tap', gy); $("#pati_info_wrap").on('tap', '#pati_info', toInfo); $("#view_scroller").on('tap', "#diseasesWrap", toSelectJb); //健康教育 $(".div-jkjy-btn").on('tap', jkjy); //新增指导 $(".div-add-guide-btn").on('tap', jkzd); //随访 $(".div-suifang-btn").on('tap',function(){ // openWebview("../../suifang/html/choose_suifang.html", {patiCode: oPatiInfo.code}); openWebview("../../suifang/html/suifang_list.html", {patientCode: oPatiInfo.code}); }); //显示更过操作 $(".header-link").on('tap', function(){ mui('#sheet1').popover('toggle'); }); }