Commit 6af514e1 authored by zjz1994's avatar zjz1994

代码暂存

parent c4c6f59b
......@@ -1478,14 +1478,14 @@ export class NetManager extends ABNetManager {
hideMsg: true,
callback: callback
};
console.log("开始获取广告");
// console.log("开始获取广告");
// this.changeCookieCity("测试写入city");
try{
// console.log("苏宁原生测试",window['baseApi']);
if(window['baseApi']){
console.log("苏宁原生测试",GFun.isIOS);
// console.log("苏宁原生测试",GFun.isIOS);
window['baseApi'].getClientInfo(function(res){
console.log("啦啦啦baseApi----info",res);
// console.log("啦啦啦baseApi----info",res);
if(res){
var resdata;
if(typeof res =="string"){
......@@ -1501,7 +1501,7 @@ export class NetManager extends ABNetManager {
cityCode = resdata.cityCode||'';
}
}
console.log('新增deviceId',deviceId);
// console.log('新增deviceId',deviceId);
//检查修改cookie
// this.changeCookieCity(cityCode);
net.param.deviceId = deviceId;
......@@ -1509,45 +1509,45 @@ export class NetManager extends ABNetManager {
this.send(net);
}.bind(this));
}else{
console.log("没有baseApi");
// console.log("没有baseApi");
this.send(net);
}
}catch(e){
console.log('一般获取');
// console.log('一般获取');
this.send(net);
}
}
//获取广告时手动修改cookie
changeCookieCity(citycode:string){
console.log("cookie-----------测试写入cookie");
// console.log("cookie-----------测试写入cookie");
if(citycode&&citycode.length>0){
var changecookie:boolean = false;
var havecity:boolean = false;
var allcookies = document.cookie;
var cookie_name = "SN_CITY";
var cookiedata = allcookies.split(";");
console.log("cookie-----------",JSON.stringify(cookiedata));
// console.log("cookie-----------",JSON.stringify(cookiedata));
for(var i=0;i<cookiedata.length;i++){
var icookie = cookiedata[i].trim();
if(icookie.length<1){
console.log("cookie-----------空删");
// console.log("cookie-----------空删");
cookiedata.splice(i,1);
i--;
continue;
}
var icookieinfo = icookie.split("=");
console.log("cookie-----------",JSON.stringify(icookieinfo));
// console.log("cookie-----------",JSON.stringify(icookieinfo));
if(icookieinfo[0]==cookie_name){
havecity = true;
var citycookie = icookieinfo[1];
var citydatarr = citycookie.split("_");
var citycode1 = citydatarr[1];
if(citycode1==citycode){
console.log("cookie-----------城市一致不用动");
// console.log("cookie-----------城市一致不用动");
}else{
citydatarr[1] = citycode;
console.log("cookie-----------重设cookie");
// console.log("cookie-----------重设cookie");
var cityval = citydatarr.join("_");
cookiedata[i] = cookie_name+"="+cityval+";domain=.cnsuning.com;path=/";;
changecookie = true;
......@@ -1556,14 +1556,14 @@ export class NetManager extends ABNetManager {
}
}
if(!havecity){
console.log("cookie-----------手动加cookie");
// console.log("cookie-----------手动加cookie");
var citycookie = "100_"+citycode+";domain=.cnsuning.com;path=/";;
cookiedata.push(cookie_name+"="+citycookie);
changecookie = true;
}
if(changecookie){
var newcookie = cookiedata.join(";");
console.log("修改cookie",newcookie);
// console.log("修改cookie",newcookie);
document.cookie = newcookie
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment