bind_return.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. var d = dialog({
  2. contentType: 'load',
  3. skin: 'bk-popup'
  4. });
  5. var pagetype = 0;
  6. var userAgent = window.localStorage.getItem(agentName);
  7. var Request = new Object();
  8. Request = GetRequest();
  9. //这个页面兼作为绑卡成功后的回调页面,所以在此将url中的参数缓存起来
  10. var request_info = window.localStorage.getItem('request_info');
  11. var signInfo;
  12. $(function(){
  13. if(request_info){
  14. request_info = JSON.parse(request_info);
  15. $.extend(true, Request, request_info);
  16. window.localStorage.removeItem("request_info");
  17. }else{
  18. //拿不到缓存的签约信息,即页面是从我的社保卡的页面中跳转过来的,直接链接跳转去我的信息页
  19. window.location.replace(server + 'wx/html/grzx/html/my-detail.html');
  20. return false;
  21. }
  22. getSignInfo();
  23. });
  24. //获取签约信息,计算缴费金额
  25. function getSignInfo(){
  26. d.show();
  27. var url = "/patient/sign/signInfo",
  28. params ={code: Request['signCode']};
  29. sendPost(url, params, 'JSON', 'get', queryFailed, function(res){
  30. if(res.status == 200){
  31. signInfo = res.data;
  32. checkBindStatus(); //获取绑卡状态,来校验之前绑卡是否成功
  33. }else{
  34. queryFailed(res);
  35. }
  36. });
  37. }
  38. //判断是否有绑卡
  39. function checkBindStatus(){
  40. var url = "/patient/bindCard";
  41. sendPost(url, {}, 'json', 'post', queryFailed, function(res){
  42. d.close();
  43. if(res.data.bindStatus == '000000'){ //已绑卡
  44. //跳转去支付页面
  45. charge();
  46. }else if(res.data.bindStatus == '030007'){//未绑卡
  47. d.close();
  48. //跳转去绑卡链接
  49. var bindUrl = res.data.sicardUrl;
  50. // window.location.href = bindUrl;
  51. //绑卡失败
  52. document.write("绑卡失败");
  53. }
  54. });
  55. }
  56. //发起缴费申请
  57. function charge(data){
  58. var url = "/patient/charge",
  59. params = {
  60. orgCode: signInfo.hospital,
  61. chargeType: 1, //签约类型,1-家庭签约
  62. chargeRelation: signInfo.code, //签约的code
  63. totalAmount: 12000 //固定值
  64. };
  65. sendPost(url, params, 'json', 'post', queryFailed, function(res){
  66. d.close();
  67. if(res.status == 200){
  68. //跳转去缴费页面
  69. window.location.href = res.data;
  70. }else{
  71. queryFailed(res);
  72. }
  73. });
  74. }
  75. function queryFailed(res){
  76. d.close();
  77. var msg = "请求失败";
  78. if(res.msg){
  79. msg = res.msg;
  80. }
  81. dialog({
  82. contentType:'tipsbox',
  83. bottom:true,
  84. skin:'bk-popup' ,
  85. content: msg
  86. }).show();
  87. }