Request = GetRequest(); var d = dialog({contentType:'load', skin:'bk-popup'}); var id = Request["id"]; var photo = Request["photo"]; var toUser = Request["toUser"]; var openid = Request["openid"]; var pagetype=25; var type; var doctorCode; var userAgent = window.localStorage.getItem(agentName); var scroller1 = new IScrollPullUpDown('wrapper',{ probeType:2, bounceTime: 250, bounceEasing: 'quadratic', mouseWheel:false, click:true, scrollbars:true, fadeScrollbars:true, interactiveScrollbars:false },null,null); $(function(){ if(!userAgent) { localStorage.setItem("toUser",toUser); localStorage.setItem("id",id); window.location.href = server + "wx/html/home/html/login.html?openid=" + openid+"&type="+pagetype; return false; } if(toUser){ var userInfo = JSON.parse(userAgent); if(userInfo && toUser!=userInfo.uid){ var toName = decodeURIComponent(Request["toName"]); dialog({ content:'对不起,该消息是发送给'+toName+'的,如需查看,请切换'+toName+'账号登录', okValue:'切换账号', ok: function() { window.localStorage.setItem(pageName, JSON.stringify({pageurl: location.href})) window.location.href = "../../grzx/html/change-login.html?type=0&openid="+ Request["openid"]; }, cancelValue: '我不看了', cancel: function () { wx.closeWindow(); } }).showModal(); return false; } } // 判断是否登录 checkUserAgent(); // 点击咨询详情 $("#detail").on("tap", function () { querySignType(); // window.location.href = "add-consult.html?id=" + id + "&type=0&doctorCode=" + doctorCode; }); }); // 禁止拖动 document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false); /** * 界面数据初始化 */ function queryInit() { d.show(); var data = {}; data.id = id; sendPost("patient/health/guidance/id", data, "json", "post", queryListFailed, queryAppoListSuccesss); } function queryListFailed(res) { d.close(); if (res && res.msg) { var d1 = dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}); } else { var d2 = dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载失败'}); } } function queryAppoListSuccesss(res) { if (res.status == 200) { var data = res.data; if (data) { doctorCode = data.doctor; // type = data.del; window.localStorage.setItem("guidance",data.content); var $detail = document.querySelector("#detailBox"); var $li = document.createElement("li"); var content = '
'+data.czrq+'
'+ ''; $li.innerHTML = content; $detail.appendChild($li); } d.close(); scroller1.myScroll.refresh(); } else { //非200则为失败 queryListFailed(res); } } function querySignType(){ d.show(); sendPost('patient/sign_doctors', {}, 'json', 'post', querySignTypeFailed, querySignTypeSuccess); } function querySignTypeFailed(res) { d.close(); if (res && res.msg) { dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show(); } else { dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'获取咨询类型失败'}).show(); } } function querySignTypeSuccess(data) { if (data.status == 200) { var doctors = data.familyDoctors; var docInfo,docQkInfo; $.each(doctors, function(i, v) { if(v.teamlevel){ if(v.teamlevel == 3){ docInfo = v; } if(v.teamlevel == 2){ docQkInfo = v; } }else{ if(v.level == 3){ docInfo = v; } if(v.level == 2){ docQkInfo = v; } } }); if(!docInfo){ docInfo = docQkInfo; } sendPost('patient/consult/is_consult_unfinished', {doctor: docInfo ? docInfo.code : docQkInfo.code}, 'json', 'post', function(res){ d.close(); if (res && res.msg) { dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show(); } else { dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'获取是否存在咨询失败'}).show(); } }, function(res){ if(res.status == 200){ if(res.data == ""){ //不存在 // window.location.href = "add-consult.html?id=" + id + "&type=0&doctorCode=" + doctorCode; checkDocInWork(0, doctorCode, id); } else { d.close(); dialog({ content: '十分抱歉,您与'+ docInfo.name +'医生还有
未结束咨询,无法发起新的咨询', okValue:'前往查看', ok: function (){ var userInfo = JSON.parse(userAgent); window.location.href = "../../yszx/html/consulting-doctor.html?consult=" + res.data +"&toUser="+userInfo.uid; }, cancelValue: '我知道了', cancel: function () { return; } }).showModal(); } } else { dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show(); } } ); } else { querySignTypeFailed(res); } } function checkDocInWork(type, doctor, id){ sendPost('patient/consult/is_doctor_working', {doctor:doctor}, 'json', 'get', queryFailed, function(res){ if(res.status==200){ d.close(); if(res.data==2){ dialog({ content: '您好,由于您的签约医生工作繁忙,设置了每日回复咨询的时间段,所以,在该时间段外的时间,您的咨询将不会马上获得医生的回复。', okValue:'查看医生工作时间', ok: function (){ window.location.href = "../../yszx/html/doctor-work-hours.html?doctor=" + doctor; }, cancelValue: '继续新增咨询', cancel: function () { window.location.href = "add-consult.html?id=" + id + "&type="+ type +"&doctorCode=" + doctor; } }).showModal(); }else if(res.data==0){//医生不接受咨询 dialog({ content: '对不起,该医生暂时关闭了咨询功能,
暂时无法咨询该医生', cancelValue: '我知道了', cancel: function () { wx.closeWindow(); } }).showModal(); }else{ //三师咨询或家庭签约咨询,跳转到新增咨询页面 window.location.href = "add-consult.html?id=" + id + "&type="+ type +"&doctorCode=" + doctor; } }else{ queryFailed(res); } }) } //查询失败 function queryFailed(res) { d.close(); if (res && res.msg) { dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show(); } else { dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'查询失败'}).show(); } }