var d = dialog({ contentType: 'load', skin: 'bk-popup' }); var d1 = dialog({ contentType: 'load', skin: 'bk-popup', content: '提交中...' }); var doctor = ""; var isQr = ""; var waitSign; // 链接中是否有openid var openidInLink = false; // 存储链接中携带的wlyyPatientInviteLogCode参数,用来判断是否是从推送消息进入处理“签约邀请” var signInvitationInLink; var pagetype = 18; $(function() { var userAgent = window.localStorage.getItem(agentName); Request = GetRequest(); var openid = Request["openid"]; var code = Request["code"]; isQr = Request["isQr"]; openidInLink = openid!==undefined?true:false; signInvitationInLink = Request["wlyyPatientInviteLogCode"]; if(!userAgent) { if(!openid) { sendPost("weixin/getOpenidByCode", { "code": code }, 'JSON', 'GET', function(res) { queryFailed(res); }, function(res) { if(res.status == 200) { openid = res.openid; window.localStorage.setItem(pageName, "{\"pageurl\":\"" + window.location.href + "\"}"); window.location.href = "../../home/html/login.html?type=0&openid=" + openid; } else { queryFailed(res); } }); } } // 获取微信授权 closeWindow(); queryInit(); }); function popThanksDialog() { dialog({ content: '
感谢您签约家庭医生,您可将家庭医生推荐给更多好友,让大家一起享受家庭医生全方位的服务~
', okValue:'前往分享', ok: function (){ location.href = 'signing-share.html' }, cancelValue: '我知道了', cancel: function () { return; } }).showModal(); } function closeWindow() { var Request = new Object(); Request = GetRequest(); var code = Request["code"]; //从后台那边获取签名等信息 var params = {}; params.pageUrl = window.location.href; $.ajax(server + "weixin/getSign", { data: params, dataType: "json", type: "post", success: function(res) { if(res.status == 200) { var t = res.data.timestamp; var noncestr = res.data.noncestr; var signature = res.data.signature; wx.config({ //debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 appId: appId, // 必填,公众号的唯一标识 timestamp: t, // 必填,生成签名的时间戳 nonceStr: noncestr, // 必填,生成签名的随机串 signature: signature, // 必填,签名,见附录1 jsApiList: [ 'closeWindow' ] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2 }); } } }); } function popOverlay(flag) { var height = document.body.scrollHeight, $pop = $('#overlay_pop'); $('#introduce_guide').hide(); $('#introduce_text').hide(); if(flag) { $pop.one('click',function() { $('.btn-main img').attr('src','../images/geduoxuanfu_icon.png'); $('.btn-item').hide(); $('.btn-main').addClass('close'); $('#introduce_guide').hide(); $('#introduce_text').hide(); $pop.hide(); }); $pop.height(height).show(); } else { $pop.hide(); } } function queryInit() { d.show(); var data = {}; var Request = new Object(); Request = GetRequest(); doctor = Request["state"]; waitSign = Request["waitSign"]; data.doctor = doctor; if(waitSign) { popThanksDialog(); } sendPost('patient/family_contract/homepage', data, 'json', 'post', queryFailed, querySuccess); } 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 querySuccess(res) { // TODO 示例数据 // res = { // "msg": "医生主页查询成功!", // "data": { // "doctor": "D20160322000002", // "jobName": "主任医师", // "intro": "慢性阻塞性肺疾病、支气管扩张等能够较为熟练地结合中医辨证与西医辨病两套方法进", // "name": "聂青", // "sign": -1, // "photo": "http://172.19.103.85:8882/res/images/2016/07/27/20160727010854_298.jpeg", // "dept": "呼吸内科", // "services": [], // "job": "", // "hospital": "金山社区医疗服务中心", // "expertise": "及实验研究工作十年余,先后参加国家级、省部级多项课题的研究,在科室积极开展的中医特色疗法如穴位注射和敷贴、中药雾化等,疗效显著,对疑难疾病的诊治能坚持自己的观点,和科室同仁一道成功抢救许多肺心病、肺性脑病和呼吸衰竭等危重患。", // "group": "0" // }, // "status": 200 // }; if(res.status == 200) { var name = res.data.name; var jobName = res.data.job; var hospitalName = res.data.hospital; var deptName = res.data.dept; var photo = res.data.photo; var expertise = res.data.expertise; var introduce = res.data.intro; var sign = Number(res.data.sign); var group = Number(res.data.group); var url2 = photo; var sex = res.data.sex; if(!photo){ if(sex==1){ url2 = "d-male.png"; }else if(sex==2){ url2 = "d-female.png"; }else{ url2 = "noSexDoctor.jpg"; } } if(!jobName) jobName = ""; if(!deptName) deptName = ""; if(!expertise) expertise = "无"; if(!introduce) introduce = "无"; document.getElementById("photo").src = url2; document.getElementById("name").innerHTML = name; document.getElementById("jobName").innerHTML = jobName; document.getElementById("hospitalName").innerHTML = hospitalName; document.getElementById("deptName").innerHTML = deptName; document.getElementById("expertise").innerHTML = expertise; document.getElementById("introduce").innerHTML = introduce; document.getElementById("doctor_name").innerHTML = name; if(group == 1) { $("#ul-health").show(); } else if(group == 2) { $("#ul-disease").show(); } else if(group == 3) { $("#ul-sixfive").show(); } else { $("#ul-common").show(); } if(sign == 0) { // 待签约 document.getElementById("btnSign").innerHTML = '取消申请'; $('#btnSign').show(); } else if(sign == 1) { // 已签约 //document.getElementById("btnSign").innerHTML = '申请解约'; $('#btnSign').hide(); $('#btnMenu').show(); $('.btn-main>img').on('click',function() { if($(this).hasClass('close')) { popOverlay(true); $('.btn-main img').attr('src','../images/xuanfuguanbi_icon.png'); $('.btn-item').show(); $(this).removeClass('close'); } else { popOverlay(false); $('.btn-main img').attr('src','../images/geduoxuanfu_icon.png'); $('.btn-item').hide(); $(this).addClass('close'); } }); $('#btnMenu').on('click','.btn-item>img',function () { var type = $(this).attr('data-type'); switch(type) { case 'break': overSign(); $('.btn-main>img').click(); break; case 'introduce': $('.btn-main img').attr('src','../images/geduoxuanfu_icon.png'); $('.btn-item').hide(); $('.btn-main').addClass('close'); $('#introduce_guide').show(); $('#introduce_text').show(); break; case 'consultation': break; } }); } else if(sign == -1) { // 患者解约 // 有openid显示“申请签约”按钮 if(openidInLink) { document.getElementById("btnSign").innerHTML = '申请签约'; $('#btnSign').show(); } // 邀请签约时显示 else if(signInvitationInLink) { document.getElementById("sign_invitation").innerHTML = '
' +'
忽略签约邀请
' +'
同意与其签约
' +'
'; } // 否则显示医生二维码 else { $('#doctor_qrcode').show(); } $("#divAgree").hide(); } else if(sign == 2) { // 待解约 document.getElementById("btnSign").innerHTML = '您已申请了解约,流程审核中,请等待!!'; $('#btnSign').show(); } else { document.getElementById("btnSign").innerHTML = '医生申请与您解约,流程审核中,请等待!!'; $('#btnSign').show(); } d.close(); } else { queryFailed(res); } } //申请签约 function startSign() { if(isQr != false) { // sendPost('patient/family_contract/checkOpenid', {}, 'json', 'post', queryFailed, openidSuccess2); // 2016.08.31 yezehua 取消“无效的openid”错误提示 sendPost('patient/family_contract/checkOpenid', {}, 'json', 'post', function() {}, openidSuccess2); } else { var doctorName = encodeURI(document.getElementById("name").innerHTML); var hospitalName = encodeURI(document.getElementById("hospitalName").innerHTML); window.location.href = "sign-agreement.html?doctor=" + doctor + "&doctorName=" + doctorName + "&hospitalName=" + hospitalName; } } function changeAgreement() { window.location.href = "sign-agreement1.html"; } function cancelSign() { dialog({ title: '提示', content: '您确定继续取消和' + document.getElementById("name").innerHTML + '医生的签约吗?', ok: function() { d1.showModal(); var data = {}; data.doctor = doctor; sendPost('patient/family_contract/unsign', data, 'json', 'post', submitFailed, submitSuccess); }, cancel: function() { return; } }).showModal(); } function overSign() { $("#txtInfo").hide(); dialog({ title: '申请解约', skin: "ui-dialog ax-popup pror", content: $("#xf-artd").get(0), ok: function() { var data = {}; data.doctor = doctor; data.doctorName = document.getElementById("name").innerHTML; data.reason = $("#textReason").val(); if(data.reason == "" || data.reason == null) { $("#txtInfo").show(); return false; } else { $("#txtInfo").hide(); d1.showModal(); sendPost('patient/family_contract/surrender', data, 'json', 'post', submitFailed, submitSuccess2); return; } }, cancel: function() { return; } }).showModal(); } function submitFailed(res) { d1.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 submitSuccess(res) { if(res.status == 200) { d1.close(); window.location.href = "choose-region.html"; } else { submitFailed(res); } } function submitSuccess2(res) { if(res.status == 200) { document.getElementById("btnSign").innerHTML = '您已申请了解约,流程审核中,请等待!!'; d1.close(); dialog({ contentType: 'tipsbox', skin: 'bk-popup', content: '解约申请成功' }).show(); window.scrollTo(0, 0); //window.location.href = "doctor-home-page.html?doctor=" + doctor; } else { submitFailed(res); } } //判断是否有三师信息 function checkTeacter() { var data = {}; sendPost('patient/teachers', data, 'json', 'post', queryFailedTeacter, querySuccessTeacter); } function querySuccessTeacter(res) { if(res.status == 200) { d.close(); var list = res.data.list; if(list.length > 0) { var doctorTemp = ""; var doctorName = ""; for(var i = 0; i < list.length; i++) { var data = list[i]; if(Number(data.type) == 2) { doctorTemp = data.code; doctorName = data.name; } } var doctorNameTemp = document.getElementById("name").innerHTML; if(doctorNameTemp != doctorName) { dialog({ title: '提示', content: '您已存在三师签约,签约医生为' + doctorName + '医生,继续与' + doctorName + '医生签约家庭医生服务吗?', ok: function() { window.location.href = "doctor-home-page.html?doctor=" + doctorTemp; } }).showModal(); } else { familyDoctor(); } } else { familyDoctor(); } } else if(res.status == 1 || res.status == 2) { d.close(); familyDoctor(); } else { queryFailedTeacter(res); } } //成功 function openidSuccess2(res) { if(res.status == 200) { if(res.data == null || res.data == "") { checkTeacter(); } else { queryDoctor(res); } } else { // 2016.08.31 yezehua 取消“无效的openid”错误提示 // queryFailed(res); } } //获取家庭签约的医生信息 function queryDoctor(res) { var data = {}; data.doctor = res.data; sendPost('patient/family_contract/homepage', data, 'json', 'post', queryFailed, querySuccess3); } function querySuccess3(res) { if(res.status == 200) { var doctorName = document.getElementById("name").innerHTML; if(res.data.name != doctorName) { dialog({ title: '提示', content: '您已存在家庭签约,签约医生为' + res.data.name + '医生,只可以签约一个家庭医生', ok: function() { wx.closeWindow(); } }).showModal(); } else { familyDoctor(); } } else { queryFailed(res); } } function familyDoctor(querystr) { var doctorName = encodeURI(document.getElementById("name").innerHTML); var hospitalName = encodeURI(document.getElementById("hospitalName").innerHTML); window.location.href = "agreement.html?doctor=" + doctor + "&doctorName=" + doctorName + "&hospitalName=" + hospitalName+(querystr||""); } function queryFailedTeacter(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 ignoreSignInvitation() { sendPost('patient/family/updatePatientInviteLog', {patientInviteLogCode:signInvitationInLink,type:2}, 'json', 'post', function(){ dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请求失败'}).show(); }, function(req) { if(req.status==200) { // 关闭页面,返回公众号 wx.closeWindow(); } else { dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'处理失败'}).show(); } }); } // 同意与其签约 function agreeSignInvitation() { sendPost('patient/family/updatePatientInviteLog', {patientInviteLogCode:signInvitationInLink,type:1}, 'json', 'post', function(){ dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请求失败'}).show(); }, function(req) { if(req.status==200) { // 跳转到协议页面 familyDoctor("&signInvitationCode="+signInvitationInLink); } else { dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'处理失败'}).show(); } }); }