
var gdt_tracker=gdt_tracker||[],__gdt_tracker_global_container=__gdt_tracker_global_container||{};(function(){var init=function(){var slice=Array.prototype.slice;var extend=function(r){r=r||{};for(var i=1;i<arguments.length;i++){var s=arguments[i];if(s){for(var j in s){r[j]=s[j];}}}
return r;};var each=function(d,a,b){if(typeof d.length=="number"){for(var f=0,n=d.length;f<n;f++){a.call(b,d[f],f);}}else if(typeof d=="number"){for(f=0;f<d;f++){a.call(b,f,f);}}else{for(f in d){a.call(b,d[f],f);}}};var map=function(d,a){var b=[];each(d,function(f,n){b.push(a(f,n));});return b;};var getObjectToStringFn=function(assign_token,pair_separator,need_last,need_encode){var encode=need_encode?encodeURIComponent:function(k){return k;};return function(o){return map(o,function(v,k){if(k!=null){return k+assign_token+encode(v);}}).join(pair_separator)+(need_last?pair_separator:'');};};var getType=function(obj){return obj===null?'null':(obj===undefined?'undefined':Object.prototype.toString.call(obj).slice(8,-1).toLowerCase());};var escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;var meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'};function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}
var JsonToString=function(obj){if(typeof JSON!='undefined'&&JSON.stringify){return JSON.stringify(obj);}else{var str='',arr=[],type;var otype=getType(obj);var bstart=(otype=='array')?'[':'{';var bend=(otype=='array')?']':'}';str+=bstart;each(obj,function(v,k){var substr="";if(otype!='array'){substr="\""+k+"\":";}
type=getType(v);if(type=='string'){substr+=quote(v);}else if(type=='number'){substr+=v;}else if(type=='undefined'){substr+=type;}else if(type=='object'||type=='array'){substr+=JsonToString(v);}
arr.push(substr);});str+=arr.join(',');str+=bend;return str;}};var emsgnum=0;var _postdata=function(url,data){emsgnum++;var frameId='_gdt_tracker_POST_SENDER_'+emsgnum,cntid="_GDTTRACK_SENDER_"+emsgnum,doc=document,wrapFrm,frameEl,formEl,df,tmp;wrapFrm=doc.createElement('div');wrapFrm.id=cntid;wrapFrm.style.display='none';wrapFrm.innerHTML='<iframe id="'+frameId+'" name="'+frameId+'" onload="" width="1px" height="1px" style="display:none"></iframe>';formEl=doc.createElement('form');formEl.method='post';formEl.target=frameId;formEl.style.cssText='display:none';doc.body.appendChild(wrapFrm);wrapFrm.appendChild(formEl);var clear=(function(cntid,doc){return function(){var cnt=doc.getElementById(cntid);cnt.parentNode.removeChild(cnt);};})(cntid,doc);frameEl=doc.getElementById(frameId);if(frameEl.attachEvent){frameEl.attachEvent("onload",function(){clear();});}else{frameEl.onload=function(){clear();};}
df=doc.createDocumentFragment();for(var k in data){tmp=doc.createElement('input');tmp.name=k;tmp.type='hidden';tmp.value=data[k];df.appendChild(tmp);}
formEl.appendChild(df);formEl.action=url;try{formEl.submit();}catch(e){}
formEl=frameEl=null;};var JSONGetter=(function(){var counter=0;function load(url,callback,ecb,opts){var script=document.createElement('script'),head,doc=document,global=window,_ecb,charset,clear,timer,_gcname,done=false;head=doc.head||doc.getElementsByTagName("head")[0]||doc.body;opts=opts||{};charset=opts.charset||'GB2312';_gcname=opts.uniqueName;if(opts.timeout){timer=setTimeout(function(){opts.onTimeout(999);clear();},opts.timeout);}
global[_gcname]=function(data){done=true;callback(data);};_ecb=function(code){ecb&&ecb(code);};clear=function(){done=true;global[_gcname]=null;try{delete global[_gcname];}catch(e){}
if(timer){clearTimeout(timer);timer=null;}
script.onload=script.onreadystatechange=script.onerror=null;head.removeChild(script);script=null;};script.onerror=function(ex){_ecb(998);clear();};script.onload=script.onreadystatechange=function(evt){if(!script){return;}
var rs=script.readyState,ready;ready=(typeof rs==='undefined'||rs==="loaded"||rs==="complete");if(done&&ready){clear();}
if(!done&&ready){_ecb(999);clear();}};script.type='text/javascript';script.charset=charset;script.async=true;script.src=url;head.appendChild(script);}
function encode(str){return encodeURIComponent(str);}
function jsonp(url,params,callback,ecb,opts){var cbname,cbnameKey,query=(url||'').indexOf('?')===-1?'?':'&',key;opts=opts||{};cbname=opts.callbackName||'callback';cbnameKey=opts.cbnameKey||'callback';var uniqueName=cbname+"_gdttrackerjson"+(++counter);params=params||{};for(key in params){if(params.hasOwnProperty(key)){query+=encode(key)+"="+encode(params[key])+"&";}}
opts.uniqueName=uniqueName;setTimeout(function(){load(url+query+cbnameKey+'='+uniqueName,callback,ecb,opts);},1);return uniqueName;}
return jsonp;}());var Util={serializeQuery:getObjectToStringFn('=','&',false,true),__imgs:[],isPageHttps:function(){return location.protocol=="https:"},pingreq:function(url){setTimeout(function(){var img=new Image();img.src=url;Util.__imgs.push(img);},0);}};(function(q){var commurl='http://c.isdspeed.qq.com/code.cgi',httpsCommUrl='https://huatuocode.weiyun.com/code.cgi',collector=[],timer,duration=1000;function valueStat(domain,cgi,type,code,time,rate,exts){var param=[];param.push('key='+'domain,cgi,type,code,time,rate','r='+Math.random());if(typeof exts.unshift=='function'){var i=0;while(exts.length){if(param.join('&').length>1000){break;}
var c=exts.shift();param.push([i+1,1].join('_')+'='+c[0]);param.push([i+1,2].join('_')+'='+c[1]);param.push([i+1,3].join('_')+'='+c[2]);param.push([i+1,4].join('_')+'='+c[3]);param.push([i+1,5].join('_')+'='+c[4]);param.push([i+1,6].join('_')+'='+c[5]);i++;}}
if(i>0){var urlHeader=!Util.isPageHttps()?commurl:httpsCommUrl;Util.pingreq(urlHeader+'?'+param.join('&'),1000);}}
var urlParse=/^(http:)?\/\/([\s\S]*?)(\/[\s\S]*?)(?:\?|$)/;q.parseUrl=function(req){var mtch=req.match(urlParse),url,domain;if(mtch){url=mtch[3];domain=mtch[2];}
return[domain,url];};q.valueStat=function(req,type,code,time,rate,conf){var pUrl=q.parseUrl(req),domain,url;conf=conf||{};domain=pUrl[0];url=pUrl[1];conf.urlext&&(url+=conf.urlext);_valueStat(domain,url,type,code,time,rate);};function _valueStat(domain,cgi,type,code,time,rate){if(Math.random()<1/rate){collector.push([domain,cgi,type,code,time,rate]);}}
function _r(){if(collector.length){valueStat('','','','','','',collector);}
timer=setTimeout(_r,duration);duration*=1.1;}
_r();})(Util);var CONST={maxUrlLength:2E3,MAXQUEUECOUNT:3,OPTFIELD:'optionfields'};var GDT;GDT={config:{actionCgi:'http://tubi.gdt.qq.com/track.cgi',securityActionCgi:'https://track.gdt.qq.com/track.cgi',maxUrlLength:CONST.maxUrlLength,SIDPLACEMENT:'{sid}',MAXQUEUECOUNT:CONST.MAXQUEUECOUNT,trackConversionCgi:'//t.gdt.qq.com/conv/web/'},CONST:CONST,run:function(config){GDT.dealActionConf(config);},__setSourceId:function(config){if(config[1]){GDT.config._currentSourceId=config[1];}},__setAccountId:function(config){if(config[1]){GDT.config._currentAccountId=config[1];}},trimQueueData:function(dq){var actions=[];each(dq,function(queue,action){actions.push(action);});each(actions,function(action){var queue=dq[action];if(!queue){return;}
if(queue.action==="order"||queue.action==="orderinfo"){var queuebyvalue=queue.queuebyvalue,data,otherqueue,otherkey=((queue.action=="order")?"orderinfo":"order")+queuebyvalue;otherqueue=dq[otherkey];var dqueue=(queue.action==="orderinfo")?queue:otherqueue;data=dqueue&&dqueue.list&&dqueue.list[0]||{};extend(queue.data,data);if(queue.action==="orderinfo"){queue.list=otherqueue&&otherqueue.list||[];}
queue.action="order";delete dq[otherkey];}});},__reportNow:function(){var dq=GDT.queueActionData;GDT.trimQueueData(dq);each(dq,function(queue,action){GDT.multiActionReq(queue.action,queue);});GDT.queueActionData={};var sid=GDT.config._currentSourceId,accountId=GDT.config._currentAccountId,placement=GDT.config.SIDPLACEMENT,req;if(!sid&&!accountId){return;}
while(req=GDT._reqQueue.shift()){if(req.data.sid===placement&&sid){req.data.sid=sid;}
GDT.sendReq(req);}},_reqQueue:[],enqueueReq:function(req){GDT._reqQueue.push(req);},pushCmd:function(config){GDT.dealActionCmd(config);},queueActionData:{},dealActionConf:function(pageconfig){each(pageconfig,function(config){GDT.dealActionCmd(config);});},dealActionCmd:function(config){var action=config[0],curActionMap=GDT.actionMap[action];if(!curActionMap){return;}
if(curActionMap.fn){GDT[curActionMap.fn](config);}},__addAction:function(config){config=config.slice(1);var action=config[0],curActionMap=GDT.actionMap[action],actionData={},listname,isMulti=false;if(!curActionMap){return;}
curActionMap.type=='multi'&&(isMulti=true)&&(listname=curActionMap.listname);var keyStep=1;each(curActionMap.list,function(field,key){var fieldconfig=field.split(":");var setValue=function(field,fieldconfig,key){key=key+keyStep;if(fieldconfig.length==2){var tmpVal='';if(fieldconfig[0]==='url'){tmpVal=config[key]||location.href;}else if(fieldconfig[0]=='href'){tmpVal=location.href;keyStep--;}
actionData[fieldconfig[1]]=tmpVal;}else if(field===CONST.OPTFIELD){var opts=config[key];if(getType(opts)==='object'){each(opts,function(ov,ok){actionData[ok]=ov;});}}else if(field==="custom_info"){var opts=config[key];if(getType(opts)==='object'){actionData["custom_info"]=JsonToString(opts);}else{console.error();}}
else{actionData[field]=config[key]||"";}};setValue(field,fieldconfig,key);});if(action.toLowerCase()==='track_conversion'){GDT.sendTrackConversionReq(actionData);return;}
actionData.action=curActionMap.action;if(!isMulti){GDT.sendActionReq(actionData);}else{var queuekey,dq=GDT.queueActionData;queuekey=actionData.action+((curActionMap.multiqueue)?actionData[curActionMap.queueby]:"");dq[queuekey]=dq[queuekey]||{};var cq=dq[queuekey];cq.list=cq.list||[];cq.data=cq.data||{};cq.queueby=curActionMap.queueby;cq.queuebyvalue=actionData[cq.queueby];cq.listname=listname;cq.action=curActionMap.action;delete actionData.action;cq.list.push(actionData);}},actionMap:{set_source_id:{fn:"__setSourceId",list:["sourceId"]},set_account_id:{fn:"__setAccountId"},send:{fn:'__reportNow'},add_action:{fn:'__addAction'},GENERAL:{action:"general",list:["type","url:pageurl"]},ITEM_VIEW:{action:"itemview",list:["itemid","url:itemurl","categoryid","categoryname","brandid","shopid",CONST.OPTFIELD]},ADD_TO_CART:{action:"addtocart",type:"multi",listname:"itemlist",list:["itemid","url:itemurl","categoryid","categoryname","brandid","shopid"]},ORDER:{action:"orderinfo",type:"multi",multiqueue:true,queueby:"orderid",listname:"itemlist",list:["orderid","cost"]},ORDER_ITEM:{action:"order",type:"multi",multiqueue:true,queueby:"orderid",listname:"itemlist",list:["orderid","itemid","url:itemurl","categoryid","categoryname","brandid","shopid"]},SHOP_VIEW:{action:"shopview",list:["shopid","url:shopurl","shopname"]},CATEGORY_VIEW:{action:"categoryview",list:["categoryid","categoryname","url:categoryurl"]},SEARCH:{action:"search",list:["query","categoryid","categoryname","url:queryurl"]},REGISTER:{action:"register",list:["name","sex","age","height","weight",CONST.OPTFIELD]},USERINFO:{action:"userview",list:["userid","name","sex","age","height","weight",CONST.OPTFIELD]},DOWNLOAD:{action:"download",list:["appname","appid","appsize","appurl"]},APPOINT:{action:"appointment",list:["appoint_time",CONST.OPTFIELD]},TRACK_CONVERSION:{action:"track_conversion",list:["href:url","conv_id","custom_info"]}},multiActionReq:function(action,queue){var data;queue=queue||{};data=queue.data;data.action=action;data[queue.listname]=queue.list;data[queue.queueby]=queue.queuebyvalue;GDT.sendActionReq(data);},sendActionReq:function(actionData){var url=Util.isPageHttps()?GDT.config.securityActionCgi:GDT.config.actionCgi,data,sid=GDT.config._currentSourceId||GDT.config.SIDPLACEMENT;actionData.timestamp=GDT.reqTime();data=JsonToString(actionData);var qdata={sid:sid,data:data};GDT.enqueueReq({url:url,data:qdata});},reqTime:function(){return Math.ceil((+new Date())/1000)},sendTrackConversionReq:function(actionData){var accountId=GDT.config._currentAccountId,url=GDT.config.trackConversionCgi+accountId+'/conv';actionData=actionData||{};actionData.conv_time=GDT.reqTime();if(!actionData.conv_id&&(typeof actionData.conv_id!=="undefined")){delete actionData.conv_id;}
GDT.enqueueReq({url:url,data:actionData});},sendReq:function(req){var query,url;query=Util.serializeQuery(req.data);url=req.url+"?"+query;if(url.length<GDT.config.maxUrlLength){var r=Math.random()*100;if(r<100){GDT.jsonpActionReq(req);}else{Util.pingreq(url);}}else{GDT.postActionReq(req);}},jsonpCallback:function(o,req){var code=0,type=1;if(o.ret===0){type=1;code=11;}else if(o.ret>500){type=2;code=o.ret;}else{type=3;code=o.ret+50;}
Util.valueStat(req.url,type,code,1,1,{urlext:'?sid_'+GDT.config._currentSourceId});},jsonpActionReq:function(req){var data=req.data||{};data.datatype="jsonp";JSONGetter(req.url,req.data,function(o){GDT.jsonpCallback(o,req)},function(ret){GDT.jsonpCallback({ret:ret},req);});},postActionReq:function(req){_postdata(req.url,req.data);},init:function(){var pageConfig=gdt_tracker;pageConfig.length&&this.run(pageConfig);gdt_tracker={push:GDT.pushCmd};}};GDT.init();};if(!__gdt_tracker_global_container.init){init();__gdt_tracker_global_container.init=true;}})();