Commit 650194ce authored by zjz1994's avatar zjz1994

city代码暂存

parent 5657e609
......@@ -600,7 +600,7 @@ export default class MainBase extends eui.UILayer {
]);
if(GFun.isIOS){
}else{
console.log("苏宁安卓开始准备");
if(!window['baseApi']){
......
......@@ -1463,6 +1463,7 @@ export class NetManager extends ABNetManager {
public hc_advert(callback: Function): void {
var deviceId:string = '';
var cityCode:string = '';
const net: INetData = {
name: 'hc_advert',
uri: window['duiba'] + '/customActivity/happyclear/advert',
......@@ -1470,11 +1471,13 @@ export class NetManager extends ABNetManager {
dataType: 'json',
param: {
activityId: DataManager.ins.customCfgData.actId,
deviceId:deviceId
deviceId:deviceId,
city:cityCode
},
hideMsg: true,
callback: callback
};
// this.changeCookieCity("测试写入city");
try{
// console.log("苏宁原生测试",window['baseApi']);
if(window['baseApi']){
......@@ -1490,11 +1493,15 @@ export class NetManager extends ABNetManager {
}
if(GFun.isIOS){
deviceId = resdata.identifier||'';
cityCode = resdata.cityCode||'';
}else{
deviceId = resdata.imei||'';
cityCode = resdata.cityCode||'';
}
}
console.log('新增deviceId',deviceId);
//检查修改cookie
net.param.deviceId = deviceId;
this.send(net);
}.bind(this));
......@@ -1506,6 +1513,57 @@ export class NetManager extends ABNetManager {
this.send(net);
}
}
//获取广告时手动修改cookie
changeCookieCity(citycode:string){
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));
for(var i=0;i<cookiedata.length;i++){
var icookie = cookiedata[i].trim();
if(icookie.length<1){
console.log("cookie-----------空删");
cookiedata.splice(i,1);
i--;
continue;
}
var icookieinfo = icookie.split("=");
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-----------城市一致不用动");
}else{
citydatarr[1] = citycode;
console.log("cookie-----------重设cookie");
var cityval = citydatarr.join("_");
cookiedata[i] = cookie_name+"="+cityval+";path=/";;
changecookie = true;
}
break;
}
}
if(!havecity){
console.log("cookie-----------手动加cookie");
var citycookie = "100_"+citycode+";path=/";;
cookiedata.push(cookie_name+"="+citycookie);
changecookie = true;
}
if(changecookie){
var newcookie = cookiedata.join(";");
console.log("修改cookie",newcookie);
document.cookie = newcookie
}
}
}
public doSign(callback: Function, signActivityId: number): void {
const net: INetData = {
......
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