简单的记录在页面中停留时间

var tongTime;
var me = 0;
var cheText = "";
var setImet = "";

function tongji(){
  clearInterval(tongTime);
  var liuTimes = $("#liuTime").val();//编码
  cheText = $("#newCpmc").text();
  console.log("监听返回事件成功--"+liuTimes+"--"+me+"--"+cheText);
  $.ajax({
    type:"post",
    url:"/weChat/seeLong/save",
    data:{
      "CAR_NAME":cheText,
      "CPDM":liuTimes,
      "SEE_TIME":me,
      "CAR_TYPE":'@carMap.get("CPMC")'
    },
    success:function(data){
      console.log("成功了"+data.status);
    }
  });
}

tongTime=setInterval(function(){
  for(i=0;i<me;i++){
    console.log(me);
  }
  if(me === 1800){
    clearInterval(tongTime)
  }else{
    me=me+1;
    return me;
  }
},1000)

window.addEventListener("popstate",function(e){
  tongji()
},false)

猜你喜欢

转载自www.cnblogs.com/wuzhaoyu/p/12173260.html