<控项时,获得的"监控代码"
msg: 'PDP CSR MTOP API Success Rate', //你要上报的内容
w_succ: window.__pdpMtopStatus || 0, // 可选,若监控项需要监控率,则设置此字段可选为0、1
wl_avgv1: window.__pdpMtopEndTime ? window.__pdpMtopEndTime - window.__pdpMtopStartTime : 0, // 可选,若监控项需要监控均值,则设置次此字段,必须为数字
c1: window.__regionID__
})
}
}
function reportMtopData2() {
if (window.__wpk && window.__pdpTriggerCSR) {
window.__wpk.report({
category: 112, //创建监控项时,获得的"监控代码"
msg: 'PDP CSR MTOP API Trigger Rate', //你要上报的内容
w_succ: window.__pdpTriggerMtopStatus, // 可选,若监控项需要监控率,则设置此字段可选为0、1
c1: window.__regionID__
})
}
}
function reportMtopData3() {
if (window.__wpk) {
window.__wpk.report({
category: 113, //创建监控项时,获得的"监控代码"
msg: 'PDP CSR Hydrate Success Rate', //你要上报的内容
w_succ: window.__pdpHydrateStatus || 0, // 可选,若监控项需要监控率,则设置此字段可选为0、1
c1: window.__regionID__
})
}
}
function hydrate() {
var modulePath = '//g.lazcdn.com/g/lzdfe/pdp-platform/0.1.22/pc.js';
window.__pdpHydrateStatus = 0;
require([modulePath], function (app) {
try {
console.log('start run...')
app.run(__moduleData__, function() {
timings.render = Date.now();
// 蹦失打点
// window.goldlog && window.goldlog.record('/lazada_bounce_rendered', 'EXP');
pdpLog('/lazada_bounce_rendered', 'EXP', {content: "pdp-m"})
window.__pdpHydrateStatus = 1;
var loading = document.getElementById('pdp-skeleton-new');
if(loading) {
loading.style.display = 'none';
}
reportMtopData3();
})
} catch (e) {
console.error('render error', e);
reportMtopData3();
if (window._blReport) {
window._blReport('error', [
e,
{
file: 'page.html'
},
]);
}
// window.location.reload();
}
});
}
function fetchData(callback) {
var uriMatch = window.location.pathname.match(/\/([\w-]+)\.html/);
var uri = uriMatch ? uriMatch[1] : "";
var userAgent = navigator.userAgent;
var isAndroid = window.Env.isAndroid();
var isIOS = window.Env.isIos();
var deviceType = isAndroid ? "android" : isIOS ? "ios" : "pc";
var headerParams = {
"user-agent": userAgent,
};
var cookieParams = document.cookie.split("; ").reduce((obj, item) => {
var [k, v] = item.split("=");
obj[k] = v;
return obj;
}, {});
var params = new URLSearchParams(window.location.search);
var requestParams = {};
for (var p of params) {
var [k, v] = p;
requestParams[k] = v;
}
window.__pdpMtopStartTime = new Date().getTime();
window.__pdpTriggerMtopStatus = 0;
window.__pdpTriggerCSR = true;
if(window.Mtop) {
window.__pdpTriggerMtopStatus = 1;
window.Mtop.default.request(
{
data: {
deviceType: deviceType,
path: window.location.href,
uri: uri,
headerParams: JSON.stringify(headerParams),
cookieParams: JSON.stringify(cookieParams),
requestParams: JSON.stringify(requestParams),
},
type: "POST",
v: "1.0",
needLogin: false,
api: "mtop.global.detail.web.getDetailInfo",
},
function (res) {
window.__pdpMtopEndTime = new Date().getTime();
if (res.data && res.data.module) {
window.__pdpMtopStatus = 1;
reportMtopData();
var data = JSON.parse(res.data.module);
var msiteExperimentConfig = {}
if (__moduleData__.data && __moduleData__.data.root && __moduleData__.data.root.fields && __moduleData__.data.root.fields.globalConfig) {
msiteExperimentConfig = __moduleData__.data.root.fields.globalConfig.msiteExperimentConfig
}
if(data.globalConfig) {
data.globalConfig.msiteExperimentConfig = msiteExperimentConfig
}
__moduleData__.data.root.fields = data;
renderTpl(data);
callback && callback();
} else {
window.__pdpMtopStatus = 0;
reportMtopData();
}
},
function (err) {
window.__pdpMtopStatus = 0 ;
window.__pdpMtopEndTime = new Date().getTime();
reportMtopData();
console.log(err);
callback && callback();
}
)
}
reportMtopData2();
function renderTpl(data) {
if (deviceType === "pc" && data.Breadcrumb) {
window.LZD.updateBreadcrumb && window.LZD.updateBreadcrumb(data.Breadcrumb)
}
}
}
fetchData(hydrate);