<template> <div> </div> </template> <script> export default { data() { return { lastTime: null,//鏈€鍚庝竴娆$偣鍑讳簨浠� currentTime: null,//褰撳墠鏃堕棿 sys_timeout: 15 * 60 * 1000, // 瓒呮椂鏃堕棿, 濡傛灉瑙勫畾鏃堕棿15鍒嗛挓閮芥病鏈夌偣鍑婚〉闈㈠氨绠楄秴鏃� 15 * 60* 1000, check_time: 5 * 60 * 1000,// 妫€鏌ョ殑鏃堕棿锛屾瘡闅�5鍒嗛挓妫€鏌ヤ竴娆℃湁娌℃湁瓒呮椂 5 * 60 * 1000, whole_timer: null,// 璁℃椂鍣� } }, mounted() { this.getLock()//閿佸睆 this.isLoginOut()//鍚姩杩欎釜瀹氭椂鍣� }, methods: { isLoginOut() { clearInterval(this.whole_timer); let that = this; this.whole_timer = setInterval(() => { try { if (that.isTimeOut()) { setTimeout(() => { that.lockScreen()//閿佸睆 clearInterval(that.whole_timer) }, 1000) } } catch (error) { } }, that.check_time); }, isTimeOut() {// 鍒ゆ柇鏄惁瓒呮椂 this.lastTime = this.$store.state.lastTime; this.currentTime = new Date().getTime(); if ((this.currentTime - this.lastTime) > this.sys_timeout) { return true } else { return false } }, //瑙i櫎閿佸睆 unlockScreen() { let that = this if (!this.password) { this.nullPrompt = this.$t('e_password') this.isPasswordError = 'true'; setTimeout(() => { this.isPasswordError = ''; }, 2000) } else { this.$api.isLock( this.$getCodeRSA(this.password),//this.$getCodeRSA { onSucess: res => { console.log(res) if (res == undefined) { that.isPasswordError = 'true'; // that.$message({type:'warning',message:'瀵嗙爜閿欒',customClass: 'message-override'}) return } this.nullPrompt = ''; if (res.data.status == 200) { that.isLock = 'false'; sessionStorage.setItem('screenLock', 'false'); res.data.data && localStorage.setItem('token', res.data.data) that.isLoginOut()//鎴愬姛閲嶆柊鍚姩杩欎釜瀹氭椂鍣� } else { that.isLock = 'true'; that.isPasswordError = 'true'; setTimeout(() => { that.isPasswordError = ''; }, 2000) } }, catch: error => { console.log('error1', error) } } ) } }, //瑙e喅杈撳叆妗嗘棤娉曡緭鍏� changePassword() { this.$forceUpdate() }, } } </script> <style> .message-override { z-index: 999999 !important; } </style>