ordertrack.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. (function($) {
  2. 'use strict';
  3. var cpid = getQueryString("cpid");
  4. var userid = getQueryString("userid");
  5. var usermob = getQueryString("usermob");
  6. var $iframe = null;
  7. if (userid != null) {
  8. openOrderLogQueryPage($iframe)
  9. }
  10. var OrderTrack = function(element, options) {
  11. this.options = $.extend({}, OrderTrack.DEFAULTS, options);
  12. }
  13. OrderTrack.DEFAULTS = {
  14. 'url': 'http://100.0.4.69:3344/ordertrackweb/#/pitaya'
  15. }
  16. OrderTrack.prototype = {
  17. init: function(element) {
  18. $(element).on('click', function() {
  19. if (userid != null) {
  20. openOrderLogQueryPage($iframe)
  21. return;
  22. }
  23. // 如果5分钟内获取过,则不需要重新进行取号
  24. var redirectOnekeyLoginTime = localStorage.getItem('redirectOnekeyLoginTime');
  25. if (redirectOnekeyLoginTime == null || new Date().getTime() - redirectOnekeyLoginTime > 1000 * 60 * 5) {
  26. var cbUrl = window.location.href;
  27. if (cbUrl.indexOf('cpid=') > 0) {
  28. cbUrl = cbUrl.substr(0, cbUrl.indexOf('cpid=') - 1)
  29. }
  30. if (window.location.href.indexOf('?') >= 0) {
  31. cbUrl += '&cpid=2017060800064876';
  32. } else {
  33. cbUrl += '?cpid=2017060800064876';
  34. }
  35. // 调用南研一键取号页面
  36. window.location.href = 'https://account.bol.wo.cn/cuuser/unity/redirectOnekeyLogin?clientId=directflow&redirectUrl=' + encodeURIComponent(encodeURIComponent(cbUrl))
  37. return;
  38. }
  39. openOrderLogQueryPage($iframe)
  40. })
  41. }
  42. }
  43. OrderTracks.prototype = {
  44. init: function(element) {
  45. $(element).on('click', function() {
  46. if (userid != null) {
  47. openOrderLogQueryPage($iframe)
  48. return;
  49. }
  50. // 如果5分钟内获取过,则不需要重新进行取号
  51. var redirectOnekeyLoginTime = localStorage.getItem('redirectOnekeyLoginTime');
  52. if (redirectOnekeyLoginTime == null || new Date().getTime() - redirectOnekeyLoginTime > 1000 * 60 * 5) {
  53. var cbUrl = window.location.href;
  54. if (cbUrl.indexOf('cpid=') > 0) {
  55. cbUrl = cbUrl.substr(0, cbUrl.indexOf('cpid=') - 1)
  56. }
  57. if (window.location.href.indexOf('?') >= 0) {
  58. cbUrl += '&cpid=2017060800064876';
  59. } else {
  60. cbUrl += '?cpid=2017060800064876';
  61. }
  62. // 调用南研一键取号页面
  63. window.location.href = 'https://account.bol.wo.cn/cuuser/unity/redirectOnekeyLogin?clientId=directflow&redirectUrl=' + encodeURIComponent(encodeURIComponent(cbUrl))
  64. return;
  65. }
  66. openOrderLogQueryPage($iframe)
  67. })
  68. }
  69. }
  70. $.fn.orderTrack = function(options) {
  71. return this.each(function() {
  72. var orderTrack = new OrderTrack(this, options);
  73. orderTrack.init(this);
  74. })
  75. };
  76. function openOrderLogQueryPage($iframe) {
  77. var orderLogQueryUrl = 'http://100.0.4.69:3344/ordertrackweb/#/pitaya';
  78. var orderLogQueryBase = 'http://100.0.4.69:3344/';
  79. if (window.location.href.indexOf('100.0.4.69:8282') >= 0) {
  80. orderLogQueryUrl = 'http://100.0.4.69:8282/ordertrackweb/#/pitaya';
  81. orderLogQueryBase = 'http://100.0.4.69:8282/';
  82. } else if (window.location.href.indexOf('localhost') >= 0) {
  83. orderLogQueryUrl = 'http://10.192.120.27:3001/#/pitaya';
  84. orderLogQueryBase = 'http://10.192.120.27:3001/';
  85. } else if (window.location.href.indexOf('https://800.wo.cn/festivalchannel/') >= 0) {
  86. orderLogQueryUrl = 'https://800.wo.cn/ordertrackweb/#/pitaya';
  87. orderLogQueryBase = 'https://800.wo.cn/ordertrackweb/';
  88. } else if (window.location.href.indexOf('https://800.wo.cn/orderchannel/') >= 0) {
  89. orderLogQueryUrl = 'https://800.wo.cn/ordertrackweb/#/pitaya';
  90. orderLogQueryBase = 'https://800.wo.cn/ordertrackweb/';
  91. }
  92. //console.log(this.options.url)
  93. $iframe = $('<iframe src="' + orderLogQueryUrl + '" frameborder="0" style="position:fixed;height:100%;width:100%;top:0;right:0;bottom:0"></iframe>')
  94. $('body').append($iframe);
  95. $iframe.on('load', function() {
  96. var param = {
  97. cpid: cpid,
  98. productid: '2018072301',
  99. userid: userid,
  100. usermob: usermob
  101. }
  102. $iframe[0].contentWindow.postMessage(JSON.stringify(param), orderLogQueryBase)
  103. });
  104. window.addEventListener('message', handleMessage)
  105. function handleMessage(event) {
  106. $iframe.remove();
  107. }
  108. }
  109. function getQueryString(name) {
  110. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  111. var r = window.location.search.substr(1).match(reg);
  112. if (r != null) return unescape(r[2]);
  113. return null;
  114. }
  115. })(jQuery)