pay-result.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. var d = dialog({
  2. contentType: 'load',
  3. skin: 'bk-popup'
  4. });
  5. var payParams = JSON.parse(window.localStorage.getItem("payParams"));
  6. if(!payParams){
  7. payParams = {};
  8. }
  9. var expensesStatus = payParams.exstatus,
  10. code = payParams.code,
  11. teamCode = payParams.teamCode,
  12. type = payParams.type,
  13. doctorHealth = payParams.doctorHealth,
  14. status = payParams.status,
  15. renew = payParams.renew,
  16. showResult = payParams.showResult; //标记直接根据交易码获取缴费信息,区别在线支付回调
  17. var request = GetRequest(); //获取支付成功后回调回来的参数
  18. $(function(){
  19. queryInit();
  20. });
  21. function queryInit(){
  22. getInfo();
  23. bindEvents();
  24. }
  25. function getInfo(){
  26. d.show();
  27. if(showResult && expensesStatus == 1){
  28. var url = "/patient/chargeQuery",
  29. params = {code: payParams.payCode};
  30. sendPost(url, params, "json", "post", queryFailed, payokSuccess);
  31. }else{
  32. //支付成功后回调处理
  33. var url = "/patient/returnUrl",
  34. params = request;
  35. d.close();
  36. //将支付成功回调返回的参数显示到页面中
  37. params.userName = decodeURI(params.userName);
  38. var content = params.responseContent;
  39. params.responseContent = content?JSON.parse(decodeURIComponent(content)):''
  40. var html = template("ok_tmp", {data: params});
  41. $("#signList").append(html);
  42. sendPost(url, params, "json", "post", function(res){
  43. //不处理
  44. }, function(res){
  45. console.log(res);
  46. });
  47. }
  48. }
  49. function queryFailed(res){
  50. d.close();
  51. if(res && res.msg) {
  52. dialog({
  53. contentType: 'tipsbox',
  54. skin: 'bk-popup',
  55. content: res.msg
  56. }).show();
  57. } else {
  58. dialog({
  59. contentType: 'tipsbox',
  60. skin: 'bk-popup',
  61. content: '加载失败'
  62. }).show();
  63. }
  64. }
  65. function payokSuccess(res){
  66. if(res.status == 200){
  67. d.close();
  68. res.data.responseContent = res.data.responseContent?JSON.parse(res.data.responseContent):''
  69. var html = template("ok_tmp", {data:res.data});
  70. $("#signList").append(html);
  71. }else{
  72. payfailSuccess(res);
  73. }
  74. }
  75. function payfailSuccess(res){
  76. d.close();
  77. var html = template("fail_tmp", res);
  78. $("#signList").append(html);
  79. }
  80. function bindEvents(){
  81. $('body').on('tap','.start-sever',function(){
  82. if(showResult && (type != 1)){
  83. //非三师签约的才能跳转(在signing_management.js页面也有这个判断)
  84. window.location.href ="sign_info.html?code="+code+"&teamCode="+teamCode+"&type="+type+"&doctor="+doctorHealth+"&status="+status+"&isRenew="+renew;
  85. }else{
  86. window.location.href = "signing_management.html";
  87. }
  88. })
  89. }
  90. template.helper('formatDate', function(str){
  91. if(str && str.length > 0){
  92. return str.substr(0,4)+"-"+str.substr(4,2)+"-"+str.substr(6,2)+' '+str.substr(8, 2)+":"+str.substr(10, 2);
  93. }else{
  94. return '';
  95. }
  96. });
  97. template.helper('formatMoney', function(str){
  98. if(str && str.length > 0){
  99. return (parseInt(str) / 100).toFixed(2);
  100. }else{
  101. return '0.00';
  102. }
  103. });