123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- (function($) {
- 'use strict';
- var cpid = getQueryString("cpid");
- var userid = getQueryString("userid");
- var usermob = getQueryString("usermob");
- var $iframe = null;
- if (userid != null) {
- openOrderLogQueryPage($iframe)
- }
- var OrderTrack = function(element, options) {
- this.options = $.extend({}, OrderTrack.DEFAULTS, options);
- }
- OrderTrack.DEFAULTS = {
- 'url': 'http://100.0.4.69:3344/ordertrackweb/#/pitaya'
- }
- OrderTrack.prototype = {
- init: function(element) {
- $(element).on('click', function() {
- if (userid != null) {
- openOrderLogQueryPage($iframe)
- return;
- }
- // 如果5分钟内获取过,则不需要重新进行取号
- var redirectOnekeyLoginTime = localStorage.getItem('redirectOnekeyLoginTime');
- if (redirectOnekeyLoginTime == null || new Date().getTime() - redirectOnekeyLoginTime > 1000 * 60 * 5) {
- var cbUrl = window.location.href;
- if (cbUrl.indexOf('cpid=') > 0) {
- cbUrl = cbUrl.substr(0, cbUrl.indexOf('cpid=') - 1)
- }
- if (window.location.href.indexOf('?') >= 0) {
- cbUrl += '&cpid=2017060800064876';
- } else {
- cbUrl += '?cpid=2017060800064876';
- }
- // 调用南研一键取号页面
- window.location.href = 'https://account.bol.wo.cn/login?clientId=directflow&redirectUrl=' + encodeURIComponent(cbUrl)
- return;
- }
- openOrderLogQueryPage($iframe)
- })
- }
- }
- $.fn.orderTrack = function(options) {
- return this.each(function() {
- var orderTrack = new OrderTrack(this, options);
- orderTrack.init(this);
- })
- };
- function openOrderLogQueryPage($iframe) {
- var orderLogQueryUrl = 'http://100.0.4.69:3344/ordertrackweb/#/pitaya';
- var orderLogQueryBase = 'http://100.0.4.69:3344/';
- if (window.location.href.indexOf('100.0.4.69:8282') >= 0) {
- orderLogQueryUrl = 'http://100.0.4.69:8282/ordertrackweb/#/pitaya';
- orderLogQueryBase = 'http://100.0.4.69:8282/';
- } else if (window.location.href.indexOf('localhost') >= 0) {
- orderLogQueryUrl = 'http://10.192.120.27:3001/#/pitaya';
- orderLogQueryBase = 'http://10.192.120.27:3001/';
- } else if (window.location.href.indexOf('https://800.wo.cn/festivalchannel/') >= 0) {
- orderLogQueryUrl = 'https://800.wo.cn/ordertrackweb/#/pitaya';
- orderLogQueryBase = 'https://800.wo.cn/ordertrackweb/';
- } else if (window.location.href.indexOf('https://800.wo.cn/orderchannel/') >= 0) {
- orderLogQueryUrl = 'https://800.wo.cn/ordertrackweb/#/pitaya';
- orderLogQueryBase = 'https://800.wo.cn/ordertrackweb/';
- }
- //console.log(this.options.url)
- $iframe = $('<iframe src="' + orderLogQueryUrl + '" frameborder="0" style="position:fixed;height:100%;width:100%;top:0;right:0;bottom:0"></iframe>')
- $('body').append($iframe);
- $iframe.on('load', function() {
- var param = {
- cpid: cpid,
- productid: '2018072301',
- userid: userid,
- usermob: usermob
- }
- $iframe[0].contentWindow.postMessage(JSON.stringify(param), orderLogQueryBase)
- });
- window.addEventListener('message', handleMessage)
- function handleMessage(event) {
- if (event.data == '0001') {
- $iframe.remove();
- }
- }
- }
- function getQueryString(name) {
- var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
- var r = window.location.search.substr(1).match(reg);
- if (r != null) return unescape(r[2]);
- return null;
- }
- })(jQuery)
|