(function() {
try {
if (window.aplusPageIdSetComplete || /AliApp/i.test(navigator.userAgent)) {
return;
}
var get_cookie = function (sName) {
var sRE = '(?:; )?' + sName + '=([^;]*);?';
var oRE = new RegExp(sRE);
if (oRE.test(document.cookie)) {
var str = decodeURIComponent(RegExp['$1']) || '';
if (str.trim().length > 0) {
return str;
} else {
return '-';
}
} else {
return '-';
}
};
var getRand = function () {
var page_id = get_cookie('cna') || '001';
page_id = page_id.toLowerCase().replace(/[^a-z\d]/g, '');
page_id = page_id.substring(0, 16);
var d = (new Date()).getTime();
var randend = [
page_id,
d.toString(16)
].join('');
for (var i = 1; i < 10; i++) {
var _r = parseInt(Math.round(Math.random() * 10000000000), 10).toString(16);
randend += _r;
}
randend = randend.substr(0, 42);
return randend;
};
var pageid = getRand();
var aq = (window.aplus_queue || (window.aplus_queue = []));
aq.push({
'action':'aplus.appendMetaInfo',
'arguments':['aplus-cpvdata', {"pageid":pageid}]
});
aq.push({
'action':'aplus.appendMetaInfo',
'arguments':['aplus-exdata',{"st_page_id":pageid}]
});
// 兼容老版本aplus
var gq = (window.goldlog_queue || (window.goldlog_queue = []));
gq.push({
'action':'goldlog.appendMetaInfo',
'arguments':['aplus-cpvdata', {"pageid":pageid}]
});
gq.push({
'action':'goldlog.appendMetaInfo',
'arguments':['aplus-exdata',{"st_page_id":pageid}]
});
window.aplusPageIdSetComplete = true;
} catch(err) {
console.error(err);
}
})();
function generateUUID() {
var d = new Date().getTime();
var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(
c
) {
var r = ((d + Math.random() * 16) % 16) | 0;
d = Math.floor(d / 16);
return (c == 'x' ? r : (r & 0x7) | 0x8).toString(16);
});
return uuid;
}
var lzdDocCookies = {
getItem: function(sKey) {
return (
decodeURIComponent(
document.cookie.replace(
new RegExp(
'(?:(?:^|.*;)\\s*' +
encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, '\\$&') +
'\\s*\\=\\s*([^;]*).*$)|^.*$'
),
'$1'
)
) || null
);
},
setItem: function(sKey, sValue, vEnd, sPath, sDomain, bSecure) {
if (!sKey || /^(?:expires|max\-age|path|domain|secure)$/i.test(sKey)) {
return false;
}
var sExpires = '';
var exdate = new Date();
exdate.setDate(exdate.getDate() + vEnd);
sExpires = ';expires=' + exdate.toGMTString();
document.cookie =
encodeURIComponent(sKey) +
'=' +
encodeURIComponent(sValue) +
sExpires +
(sDomain ? '; domain=' + sDomain : '') +
(sPath ? '; path=' + sPath : '; path=/') +
(bSecure ? '; secure' : '');
return true;
},
hasItem: function(sKey) {
if (!sKey) {
return false;
}
return new RegExp(
'(?:^|;\\s*)' +
encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, '\\$&') +
'\\s*\\='
).test(document.cookie);
},
removeItem: function(sKey, sPath, sDomain) {
if (!this.hasItem(sKey)) {
return false;
}
document.cookie =
encodeURIComponent(sKey) +
'=; expires=Thu, 01 Jan 1970 00:00:00 GMT' +
(sDomain ? '; domain=' + sDomain : '') +
(sPath ? '; path=' + sPath : '; path=/');
return true;
}
};
var LZD_HOST_ARRAY = [
'.lazada.co.id',
'.lazada.com.my',
'.lazada.com.ph',
'.lazada.sg',
'.lazada.co.th',
'.lazada.vn',
'.daraz.com.bd',
'.daraz.lk',
'.shop.com.mm',
'.daraz.com.np',
'.daraz.pk',
'.lazada.test'
];
var currentDomain = '.lazada.sg';
var UUID = generateUUID();
var t_uid = lzdDocCookies.getItem('t_uid');
var anon_uid = lzdDocCookies.getItem('anon_uid');
for (var i = 0; i < LZD_HOST_ARRAY.length; i++) {
if (window.location.host.indexOf(LZD_HOST_ARRAY[i]) > -1) {
currentDomain = LZD_HOST_ARRAY[i];
}
}
if (!lzdDocCookies.getItem('lzd_cid')) {
lzdDocCookies.setItem('lzd_cid', UUID, 365, null, currentDomain);
}
if (!lzdDocCookies.getItem('t_uid')) {
if (anon_uid) {
lzdDocCookies.setItem('t_uid', anon_uid, 365, null, currentDomain);
} else {
lzdDocCookies.setItem('t_uid', UUID, 365, null, currentDomain);
}
}