123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 |
- 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<res.data.prescriptionDt.length; i++){
- var item = res.data.prescriptionDt[i];
- disease += item.healthProblemName+ ' ';
- }
- $("#diagnosis").text(disease); //填充诊断结果
- var drugsList = res.data.prescriptionInfo,
- html = "";
- html = template('drug_tmp', {list: drugsList});
- $("#drugsList").append(html);
- $("#changeDrugPanel").show();
- }else{
- $("#changeDrugPanel").hide();
- }
-
- //填充审核记录信息
- var checkInfo = res.data.reviewed,
- checkInfoHtml = "";
- checkInfoHtml = template('checkInfo_tmp', checkInfo);
- $('#checkInfo').empty().append(checkInfoHtml);
- //根据审核状态,控制底部按钮的显示
-
- var checkStatus = res.data.reviewed.status; //1审核通过,0待审核,-1审核不通过,-2无效的审核
- if(checkStatus == 0){
- //待审核,判断续方的状态
- //(-3 支付过期 -2 患者自己取消 )续方取消,
- if(rePreInfo.status == '-3' || rePreInfo.status == '-2'){
- $("#cancel").hide();
- }else{
- $("#cancel").show();
- }
- }else if(checkStatus == 1){
- if(rePreInfo.status == 40 || rePreInfo.status == 41){
- $("#cancel").show();
- }else{
- $("#cancel").hide();
- }
- }else{
- $("#applyAgain").show();
- }
- }else{
- queryFailed(res);
- }
- });
- }
- /**
- * 获得剩余时间
- * @param {string} sT 续方审核通过的时间
- */
- function getRemainTime(st){
- //审核通过后,患者有24小时的时间来支付
- var arr = st.split(/[- : \/]/);
- var d = new Date(arr[0], arr[1]-1, arr[2], arr[3], arr[4], arr[5]),
- now = new Date(),
- us = parseInt((now.getTime() - d.getTime()) / 1000);
- //24小时对应的时间戳是 24*3600=86400
- return 86400 - us;
- }
- //创建计时器
- function createTimer(time){
- var timer;
- //原始储存值
- var setOri = time;
- //原始系统时间值
- var timeOri = (new Date()).getTime();
- //现在所剩时间值
- var setNow;
- cancelAnimationFrame(timer);
- timer = requestAnimationFrame(function fn(){
- //当前系统时间值
- var timeNow = (new Date()).getTime();
- //使系统时间的差值与设置时间的差值相等,来获得正常的时间变化
- setNow = setOri - Math.floor((timeNow - timeOri)/1000);
- var h = Math.floor(setNow/3600)
- m = Math.floor((setNow%3600)/60),
- s = Math.floor(setNow%60);
- var ms = m < 10 ? '0'+m : m,
- ss = s < 10 ? '0'+s : s;
- if(h > 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:'<div id="zhifu_div">\
- 需使用实名且与医保卡同名的微信公众号进行绑卡及支付,如为家人代支付,需先到市行政服务中心申请家庭共济关系后,才可以绑定家人的医保卡并支付哟~</div></br>\
- <div class="c-t-center mtb10">\
- <label class="input-group-checkbox" style="color: #40AFFE">\
- <div class="input-group-pack">\
- <input id="input_1" type="checkbox">\
- <span class="tick"></span>\
- </div>\
- 下次不再提醒\
- </label>\
- </div>',
- btn: ['<div id="jiaofei">开始支付</div>', '<div id="bujiaofei">暂不支付</div>'],
- 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
- });
- }
- }
- });
- }
|