common.js 2.2 KB

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