common.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. $(function () {
  2. if ($('.carousel').length > 0) {
  3. $('.carousel').carousel({
  4. interval: 5000
  5. });
  6. }
  7. if ($(".qrcode").length > 0) {
  8. $(".qrcode").qrcode({width: 250, height: 250, text: $(".qrcode").data("text")});
  9. }
  10. var si, xhr;
  11. if (typeof queryParams != 'undefined') {
  12. var queryResult = function () {
  13. xhr && xhr.abort();
  14. xhr = $.ajax({
  15. url: "",
  16. type: "post",
  17. data: queryParams,
  18. dataType: 'json',
  19. success: function (ret) {
  20. if (ret.code == 1) {
  21. var data = ret.data;
  22. if (typeof data.status != 'undefined') {
  23. var status = data.status;
  24. if (status == 'SUCCESS' || status == 'TRADE_SUCCESS') {
  25. $(".scanpay-qrcode .paid").removeClass("hidden");
  26. $(".scanpay-tips p").html("支付成功!<br><span>3</span>秒后将自动跳转...");
  27. var sin = setInterval(function () {
  28. $(".scanpay-tips p span").text(parseInt($(".scanpay-tips p span").text()) - 1);
  29. }, 1000);
  30. setTimeout(function () {
  31. clearInterval(sin);
  32. location.href = queryParams.returnurl;
  33. }, 3000);
  34. clearInterval(si);
  35. } else if (status == 'REFUND' || status == 'TRADE_CLOSED') {
  36. $(".scanpay-tips p").html("请求失败!<br>请返回重新发起支付");
  37. clearInterval(si);
  38. } else if (status == 'NOTPAY' || status == 'TRADE_NOT_EXIST') {
  39. } else if (status == 'CLOSED' || status == 'TRADE_CLOSED') {
  40. $(".scanpay-tips p").html("订单已关闭!<br>请返回重新发起支付");
  41. clearInterval(si);
  42. } else if (status == 'USERPAYING' || status == 'WAIT_BUYER_PAY') {
  43. } else if (status == 'PAYERROR') {
  44. clearInterval(si);
  45. }
  46. }
  47. }
  48. }
  49. });
  50. };
  51. si = setInterval(function () {
  52. queryResult();
  53. }, 3000);
  54. queryResult();
  55. }
  56. });