common.js 2.9 KB

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