var d = dialog({ contentType: 'load', skin: 'bk-popup' }); var pagetype = 0; var userAgent = window.localStorage.getItem(agentName); var Request = new Object(); Request = GetRequest(); //这个页面兼作为绑卡成功后的回调页面,所以在此将url中的参数缓存起来 var request_info = window.localStorage.getItem('request_info'); var signInfo; $(function(){ if(request_info){ request_info = JSON.parse(request_info); $.extend(true, Request, request_info); window.localStorage.removeItem("request_info"); }else{ //拿不到缓存的签约信息,即页面是从我的社保卡的页面中跳转过来的,直接链接跳转去我的信息页 window.location.replace(server + 'wx/html/grzx/html/my-detail.html'); return false; } getSignInfo(); }); //获取签约信息,计算缴费金额 function getSignInfo(){ d.show(); var url = "/patient/sign/signInfo", params ={code: Request['signCode']}; sendPost(url, params, 'JSON', 'get', queryFailed, function(res){ if(res.status == 200){ signInfo = res.data; checkBindStatus(); //获取绑卡状态,来校验之前绑卡是否成功 }else{ queryFailed(res); } }); } //判断是否有绑卡 function checkBindStatus(){ var url = "/patient/bindCard"; sendPost(url, {}, 'json', 'post', queryFailed, function(res){ d.close(); if(res.data.bindStatus == '000000'){ //已绑卡 //跳转去支付页面 charge(); }else if(res.data.bindStatus == '030007'){//未绑卡 d.close(); //跳转去绑卡链接 var bindUrl = res.data.sicardUrl; // window.location.href = bindUrl; //绑卡失败 document.write("绑卡失败"); } }); } //发起缴费申请 function charge(data){ var url = "/patient/charge", params = { orgCode: signInfo.hospital, chargeType: 1, //签约类型,1-家庭签约 chargeRelation: signInfo.code, //签约的code totalAmount: 12000 //固定值 }; sendPost(url, params, 'json', 'post', queryFailed, function(res){ d.close(); if(res.status == 200){ //跳转去缴费页面 window.location.href = res.data; }else{ queryFailed(res); } }); } function queryFailed(res){ d.close(); var msg = "请求失败"; if(res.msg){ msg = res.msg; } dialog({ contentType:'tipsbox', bottom:true, skin:'bk-popup' , content: msg }).show(); }