referral.html 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Jump</title>
  6. <!--<script src="http://code.jquery.com/jquery-2.2.4.min.js"></script>
  7. <script>
  8. $(function () {
  9. var search = window.location.search.replace('?', '');
  10. var params = search.split("&");
  11. var id = "";
  12. var type = "";
  13. var channel_id = "";
  14. $.each(params, function (index, item) {
  15. var param = item.split('=');
  16. if (param[0] == 't') {
  17. id = param[1]
  18. }
  19. if(param[0] == 'type'){
  20. type = 'code'
  21. }
  22. if(param[0] == 'channel_id'){
  23. channel_id = param[1]
  24. }
  25. });
  26. //var url = "/api/referral/getreferralshort?id=" + id + "&type=" + type;
  27. var url = "/api/referral/getreferralshort";
  28. $.ajax({
  29. url: url,
  30. type: "POST",
  31. data:{
  32. 'id':id,
  33. 'type':type
  34. },
  35. success: function (data) {
  36. var url = data.data.url;
  37. if (url) {
  38. window.location.href = url;
  39. } else {
  40. alert('跳转链接为空');
  41. }
  42. }
  43. });
  44. })
  45. </script>-->
  46. <script>
  47. window.onload = function(){
  48. var search = window.location.search.replace('?', '');
  49. var params = search.split("&");
  50. var id = "";
  51. var type = "";
  52. var channel_id = "";
  53. params.forEach(function(item, idx){
  54. var param = item.split('=');
  55. if (param[0] == 't') {
  56. id = param[1]
  57. }
  58. if(param[0] == 'type'){
  59. type = 'code'
  60. }
  61. if(param[0] == 'channel_id'){
  62. channel_id = param[1]
  63. }
  64. });
  65. var url_post = "/api/referral/getreferralshort";
  66. doPost(url_post, id, type);
  67. }
  68. function doPost(url, id, type)
  69. {
  70. var xmlhttp;
  71. if (window.XMLHttpRequest)
  72. {
  73. // IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
  74. xmlhttp=new XMLHttpRequest();
  75. }
  76. else
  77. {
  78. // IE6, IE5 浏览器执行代码
  79. xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  80. }
  81. xmlhttp.onreadystatechange=function()
  82. {
  83. if (xmlhttp.readyState==4 && xmlhttp.status==200)
  84. {
  85. var jsonData = JSON.parse(xmlhttp.responseText);
  86. var url = jsonData.data.url;
  87. if (url) {
  88. window.location.href = url;
  89. } else {
  90. alert('跳转链接为空');
  91. }
  92. }
  93. }
  94. xmlhttp.open("POST", url, true);
  95. xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  96. xmlhttp.send("id=" + id + "&type=" + type);
  97. }
  98. </script>
  99. </head>
  100. </html>