页面时长统计

This commit is contained in:
尹吉欢
2018-06-29 14:16:37 +08:00
parent 9a9438f8be
commit f001714527
10 changed files with 80 additions and 50 deletions
+42 -1
View File
@@ -84,13 +84,13 @@ w.clicked=function(id,wa,ns,ws, params,callback,callbackParams){
// return null;
// }
if(w.plus){
var startTime = new Date().getTime();
wa&&(waiting=plus.nativeUI.showWaiting());
ws=ws||{};
ws.scrollIndicator||(ws.scrollIndicator='none');
ws.scalable||(ws.scalable=false);
var pre='';//'http://192.168.1.178:8080/h5/';
openw=plus.webview.create(pre+id,id,ws,params);
ns||openw.addEventListener('loaded',function(){//页面加载完成后才显示
// setTimeout(function(){//延后显示可避免低端机上动画时白屏
openw.show(as);
@@ -103,6 +103,8 @@ w.clicked=function(id,wa,ns,ws, params,callback,callbackParams){
callback(callbackParams);
}
openw=null;
var endTime = new Date().getTime();
savePageLog(endTime - startTime, id);
},false);
return openw;
}else{
@@ -110,6 +112,45 @@ w.clicked=function(id,wa,ns,ws, params,callback,callbackParams){
}
return null;
};
/**
* 记录页面访问日志
*/
function savePageLog(residenceTime, page) {
var device = plus.device.uuid;
var model = plus.device.model;
var pushClientId = "";
var info = plus.push.getClientInfo();
if (info != null) {
pushClientId = info.clientid;
}
plus.geolocation.getCurrentPosition(function(p){
baidu_province = p.address.province;
baidu_city = p.address.city;
baidu_region = p.address.district;
baidu_lng = p.coords.longitude;
baidu_lat = p.coords.latitude;
baidu_address = p.address.street;
doSavePageLog({page:page, lng:baidu_lng, lat:baidu_lat, province:baidu_province, city:baidu_city, region:baidu_region, address:baidu_address, device:device, model:model, pushClientId:pushClientId,channel:YOUFANG_CHANNEL,residenceTime:residenceTime});
}, function(e){
doSavePageLog({page:page, device:device, model:model, pushClientId:pushClientId,channel:YOUFANG_CHANNEL,residenceTime:residenceTime});
},
{
provider:'baidu',
enableHighAccuracy:true,
coordsType:'bd09ll'
}
);
}
function doSavePageLog(data) {
axios.post("/rest/log/save", data).then(function (response) {
}).catch(function (error) {
console.log(error);
});
}
w.openDoc=function(t,c){
var d=plus.webview.getWebviewById('document');
if(d){