锁屏状态用cookies存储(localStorage.getItem(),localStorage.setItem())
思路内容:
1.规定时间——需要定时器
2.无操作——监控页面上的点击、触摸、滑动等事件
3.返回首页——切换路由
进入页面时,开启定时器,当页面有点击、触摸、滑动等事件时重新设定定时器,时间一到自动唤起锁屏。
data:{
return{
timeout:''
}
},
created: function() {
this.isTimeOut();
},
methods:{
//锁屏定时器
startTimer() {
var that = this;
clearInterval(that.timeout);
that.timeout = setInterval(function() {
that.btnLockScreen();//打开锁屏
}, 1000 * 60 * 15)
},
//是否超时
isTimeOut() {
var that = this;
//监听鼠标、键盘\点击\触屏
document.body.onmouseup = that.startTimer;
document.body.onmousemove = that.startTimer;
document.body.onkeyup = that.startTimer;
document.body.onclick = that.startTimer;
document.body.ontouchend = that.startTimer;
}
}