(function(window,$){ //加密 (!window.RSAUtilszb && newurl("//static.to8to.com/gb_js/to8torsaszb.js")) function parseQuery(){ var url = url || location.href; var query = url ? (url.split('?')[1] || '') : location.search; var queryList = query.substr(0).split('&'); var parseRes = {}; if (queryList.length > 0) { for (var i = 0; i < queryList.length; i++) { var kv = queryList[i].split('='); parseRes[kv[0]] = catchCodeComponent(kv[1]).split('#')[0]; } } return parseRes; } function catchCodeComponent(str){ var result = ''; try { result = decodeURIComponent(str); } catch(e) { result = str; } return result; } var searchUrl = parseQuery(); //上报登记的跟踪 function require_register_info(){ var sendData = {}; sendData.source_type = window.location.href; sendData.to8to_landpage = getCookie('to8to_landpage') sendData.to8to_sourcepage = getCookie('to8to_sourcepage') sendData.to8tocookieid = getCookie('to8tocookieid') sendData.to8tosessionid = getCookie('to8tosessionid') sendData.issuepage_url = window.location.href; $.ajax({ type: "GET", url: '//www.to8to.com/api/registration_volume.php', dataType : "jsonp", data: sendData, jsonpCallback: "jsonpCallback", success: function (ret) { } }) } /**日志打印**/ function dataReportingRecordLog(datas) { $.ajax({ type: "GET", url: "//www.to8to.com/gb_php/ocpxUpReportLog.php", dataType: "jsonp", jsonpCallback: "jsonpCallback", data: datas, success: function (res) { console.log(res); } }) } /**引入js文件**/ function newurl(url) { var ma = document.createElement('script'); ma.type = 'text/javascript'; ma.async = true; ma.src = url; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ma, s); } /** * 给第三方上报 * @param callbackUrl * @param data */ function thirdReport(callbackUrl) { $.ajax({ type: "GET", url: '//www.to8to.com/api/third_party_api.php?callbackUrl=' + encodeURIComponent(callbackUrl), dataType: 'jsonp', jsonCallback: 'jsonpCallback', data: {}, success: function (res) { } }) } /** * 新增上报 * @param callbackUrl * @param data */ function apiReport(sendData){ //手机号加密 if(sendData && sendData.phone){ sendData.phone = getEncryptPhone(sendData.phone); } $.ajax({ type: "GET", url: '//www.to8to.com/api/landpage/app.php', dataType : "jsonp", data: sendData, jsonpCallback: "jsonpCallback", success: function (ret) { } }) } /** * 百度搜索上报 * @param user_id * @returns {boolean} */ function postBDOcpc(user_id){ if (user_id <= 0) { return false;} $.ajax({ type: "POST", url:"//secure.to8to.com/api/baiduapi/uploadECPAConvertData.php", dataType: "json", data: { user_id: user_id, url: location.href }, success: function() { } }) } function getEncryptPhone(phone){ if(!phone) return var phoneReg = /^(1[3456789])[\d]{9}$/ if(phone.length === 11 && phoneReg.test(phone)) { // 明文手机 return encodeURIComponent(RSAUtilszb.encryptfun(phone + "," + (Math.ceil(Math.random() * 10)) + "," + Math.random())) } else { // 此时是已加过密的手机号码 return phone } } //百度信息流上报部分 var utmSource = ['feeds_baiduss','report_status','feeds_baidussapp','feeds_baidussappo0625','feeds_baidussapp_zw_jh','feeds_baidussapp_zw_jh2','feeds_baidussapp_zw_jh3',]; function baiduReport(){ return false; } window.baiduReport = baiduReport; /** * 百度OCPC api上报 */ function baiduApiReport(dataPhone){ } window.baiduApiReport = baiduApiReport; /** * 搜狗埋码上报 */ function sogouReport(){ //深度上报的渠道编码 var sogouReport = ['sogou',]; var already_fabiao = getCookie('already_fabiao'); if(searchUrl.repeat == 1 || ((searchUrl.repeat == 0 || !searchUrl.repeat) && (!already_fabiao || already_fabiao.length <= 0))){ var channelCode = searchUrl.to8to_from ? searchUrl.to8to_from : (searchUrl.utm_source ? searchUrl.utm_source : ''); if(sogouReport.indexOf(channelCode) !== -1){ var sendData = {}; sendData.landPage = encodeURIComponent(window.location.href); sendData.m = 'channel'; sendData.a = 'sogouApi'; sendData.channelCode = channelCode; apiReport(sendData); } } } window.sogouReport = sogouReport; /** * 380埋码上报 */ function soReport(phone){ return true; } function channelReport(){baiduReport(); sogouReport(); soReport(); } window.channelReport = channelReport; })(window,jQuery);