var d = dialog({ contentType: 'load', skin: 'bk-popup' }); //var pagetype = 42; var request = GetRequest(); var code = request.code; //从链接中获得处方code var toUser = request["toUser"]; var toName = decodeURIComponent(request["toName"]); var openid = request["openid"]; var represented = request["represented"]; var userAgent = window.localStorage.getItem(agentName); var userInfo; var patientCode, patientName, prescriptionInfo; $(function(){ isRepresent(function(){ getInfo(); bindEvents(); popover() }) userInfo = JSON.parse(userAgent); wxGetSign(); }) function popover() { var url = "/patient/prescription/pay/getPopups", params = { type: 1 }; sendPost(url, params, 'JSON', 'GET', queryFailed, function(res) { if(res.status == 200) { popoverData = res.data; } else { queryFailed(res); } }) } function getInfo(){ var url = "/patient/prescriptionInfo/getPrescriptionProcess", params = {code: code}; sendPost(url, params, 'json', 'get', queryFailed, function(res){ if(res.status == 200){ //填充居民信息 var patientInfo = res.data.patient, patientHtml = ""; patientCode = patientInfo.code; patientName = patientInfo.name; patientHtml = template('patientInfo_tmp', patientInfo); $("#patientInfo").empty().append(patientHtml); //填充续方信息 var rePreInfo = res.data.prescription, rePreHtml = ""; prescriptionInfo = res.data.prescription; rePreHtml = template('rePreInfo_tmp', rePreInfo); $("#rePreInfo").empty().append(rePreHtml); //如果已支付,则显示订单跟踪链接 if(rePreInfo.status >= 50){ $("#orderTracking").show(); } //填充原处方的code, 基卫那边的处方code $("#prescriptionInfo").attr("data-code", rePreInfo.jwCode); $("#applyAgain").attr("data-code", rePreInfo.jwCode); //如果是待缴费,则前端开启计时器,显示缴费剩余时间 if(rePreInfo.status == 40 || rePreInfo.status == 41){ var time = getRemainTime(res.data.reviewed.reviewedTime); //时间戳 createTimer(time); } //填充调整后处方的信息(先判断是否有调整后的处方记录) var isAdjust = res.data.isAdjust; if(isAdjust){ var disease = ""; for(var i=0; i 0){ $("#remainTime").text(h+"时"+ms+"分"+ss+"秒"); }else if(m > 0){ $("#remainTime").text(ms+"分"+ss+"秒"); }else if(s > 0){ $("#remainTime").text(ss+"秒"); } timer = requestAnimationFrame(fn); if(setNow==0){ cancelAnimationFrame(timer); timer = 0; $("#pay").find("a").remove(); $("#pay").find('span').text('超时取消'); //发送请求去取消续方申请 // cancelPrescription(); } }) } function cancelPrescription(){ var url = '/patient/prescriptionInfo/cancelPrescriotion', params = {code: code, reason: ''}; sendPost(url, params, 'json', 'post', queryFailed, function(res){ }); } //判断是否绑卡 function bindCard(){ d.show(); var url = "/patient/bindCard"; sendPost(url, {}, 'json', 'post', queryFailed, function(res){ d.close(); if(res.data.bindStatus == '000000'){ //已绑卡 checkBindMobile(function() { //跳转去支付页面 window.location.href = "payment.html?code="+code; }) }else if(res.data.bindStatus == '030007'){//未绑卡 //跳转去绑卡链接 var bindUrl = res.data.sicardUrl; window.location.href = bindUrl; } }); } function checkBindMobile(cb) { var url = "patient/prescription/pay/getPatientMobile" sendPost(url, {}, "json", "get", queryFailed, function(res) { if(res.status == 200) { if(res.data == 1) { cb && cb() } else { d.close(); dialog({ content: '您当前暂未绑定手机,无法在线缴费,请点击确认完成手机号码绑定', cancelValue: '取消', cancel: function() {}, okValue: '确认', ok: function() { window.location.href = "../../home/html/bind-mobile.html" } }).showModal(); } } else { queryFailed(res); } }) } function bindEvents(){ //点击跳转原处方页面 $("#prescriptionInfo").on('click', function(){ //需先获得原处方的id var code = $(this).attr("data-code"); window.location.href = "prescription_detail.html?code="+code; }); //订单跟踪 $("#orderTracking").on('click', function(){ window.location.href = "order_tracking.html?code="+code+"&toUser="+userInfo.uid; }); //待支付按钮 $("#rePreInfo").on('click', '#pay', function(){ // window.location.href = "payment.html?code="+code; if(popoverData == 1) { layer.open({ title:['温馨提示','font-weight:700;font-size:16px;height:40px;line-height:40px;'], content:'
\ 需使用实名且与医保卡同名的微信公众号进行绑卡及支付,如为家人代支付,需先到市行政服务中心申请家庭共济关系后,才可以绑定家人的医保卡并支付哟~

\
\ \
', btn: ['
开始支付
', '
暂不支付
'], shadeClose:false, yes:function(index){ var checkedValue = $("#input_1").prop("checked"), val; if(checkedValue) { val = 0; } else { val = 1; } var url = "/patient/prescription/pay/savePopups", params = { type: 1, status: val }; // alert(1) sendPost(url, params, 'JSON', 'POST', queryFailed, function(res){ layer.close(index); //判断患者是否绑卡,未绑卡则跳转去绑卡页面 bindCard(); }) }, no:function(index){ location.reload(); } }) }else { //判断患者是否绑卡,未绑卡则跳转去绑卡页面 bindCard(); } }); //再次申请 $("#applyAgain a").on('click', function(){ //跳转去新增续方咨询页面 var preCode = $("#applyAgain").attr("data-code"); window.location.href = "../../yszx/html/add-prescription-consult.html?patient="+patientCode+"&name="+patientName+"&prescriptionCode="+preCode; }); //跳转续方咨询页面 $("#xfzx").on('click', function(){ window.location.href = '../../yszx/html/prescription-consulting.html?consult='+prescriptionInfo.consult+'&type=8&toUser='+patientCode+'&doctor='+prescriptionInfo.doctor; }); //取消续方 $("#cancel a").on('click', function(){ window.location.href = "re-prescription_cancel.html?code="+code; }) window.onpageshow = function(){ var pageback = window.localStorage.getItem("pageback"); if(pageback && pageback == '1'){ window.localStorage.removeItem("pageback"); window.location.reload(); } } } 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(); } } template.helper("getStatusName", function(status){ return getStatusName(status); }); template.helper("getStatusColor", function(status){ return getStatusColor(status); }); template.helper('getCheckResult', function(status){ //1审核通过 0待审核 -1 审核不通过 -2无效审核 var name = ""; switch (status){ case 1: name = '审核通过'; break; case 0: name = '待审核'; break; case -1: name = '审核不通过'; break; case -2: name = "无效审核"; break; default: break; } return name; }); template.helper('getCheckResultColor', function(status){ //1审核通过 0待审核 -1 审核不通过 -2无效审核 var color = ""; switch (status){ case 1: color = 'c-success'; break; case 0: color = 'c-waiting'; break; case -1: case -2: color = 'c-error'; break; default: break; } return color; }) //获取微信信息,并配置微信api接口 function wxGetSign(){ 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 }); } } }); }