pay-result.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. params.responseContent = params.responseContent?JSON.parse(params.responseContent):''
  39. var html = template("ok_tmp", {data: params});
  40. $("#signList").append(html);
  41. sendPost(url, params, "json", "post", function(res){
  42. //不处理
  43. }, function(res){
  44. console.log(res);
  45. });
  46. }
  47. }
  48. function queryFailed(res){
  49. d.close();
  50. if(res && res.msg) {
  51. dialog({
  52. contentType: 'tipsbox',
  53. skin: 'bk-popup',
  54. content: res.msg
  55. }).show();
  56. } else {
  57. dialog({
  58. contentType: 'tipsbox',
  59. skin: 'bk-popup',
  60. content: '加载失败'
  61. }).show();
  62. }
  63. }
  64. function payokSuccess(res){
  65. if(res.status == 200){
  66. d.close();
  67. res.data.responseContent = res.data.responseContent?JSON.parse(res.data.responseContent):''
  68. var html = template("ok_tmp", {data:res.data});
  69. $("#signList").append(html);
  70. }else{
  71. payfailSuccess(res);
  72. }
  73. }
  74. function payfailSuccess(res){
  75. d.close();
  76. var html = template("fail_tmp", res);
  77. $("#signList").append(html);
  78. }
  79. function bindEvents(){
  80. $('body').on('tap','.start-sever',function(){
  81. if(showResult && (type != 1)){
  82. //非三师签约的才能跳转(在signing_management.js页面也有这个判断)
  83. window.location.href ="sign_info.html?code="+code+"&teamCode="+teamCode+"&type="+type+"&doctor="+doctorHealth+"&status="+status+"&isRenew="+renew;
  84. }else{
  85. window.location.href = "signing_management.html";
  86. }
  87. })
  88. }
  89. template.helper('formatDate', function(str){
  90. if(str && str.length > 0){
  91. return str.substr(0,4)+"-"+str.substr(4,2)+"-"+str.substr(6,2)+' '+str.substr(8, 2)+":"+str.substr(10, 2);
  92. }else{
  93. return '';
  94. }
  95. });
  96. template.helper('formatMoney', function(str){
  97. if(str && str.length > 0){
  98. return (parseInt(str) / 100).toFixed(2);
  99. }else{
  100. return '0.00';
  101. }
  102. });