common.js 2.7 KB

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