Commit e593d4f3 authored by “yiyousong”'s avatar “yiyousong”

pref:添加返回倒计时显示

parent b5caa7a7
<template> <template>
<div class="header flex aic jcc main-title-bg-img"> <div class="header flex aic jcc main-title-bg-img">
<div class="count-down">
系统将在 <span>{{ times }}</span> 秒后返回首页
</div>
<slot name="title" class="title"> <slot name="title" class="title">
<div></div> <div></div>
</slot> </slot>
...@@ -13,10 +16,14 @@ ...@@ -13,10 +16,14 @@
</template> </template>
<script> <script>
import { mapGetters } from "vuex";
export default { export default {
data() { data() {
return {}; return {};
}, },
computed: {
...mapGetters(["times"]),
},
created() {}, created() {},
methods: { methods: {
handleBack() { handleBack() {
...@@ -37,6 +44,16 @@ export default { ...@@ -37,6 +44,16 @@ export default {
background-size: 100% 100%; background-size: 100% 100%;
// background: var(--main-theme-color); // background: var(--main-theme-color);
box-shadow: 0px 2px 6px 6px #ccc; box-shadow: 0px 2px 6px 6px #ccc;
.count-down {
position: absolute;
left: 40px;
// color: var(--main-h1-color);
color: #fff;
font-size: 24px;
// span {
// color: var(--main-theme-color);
// }
}
.right-box { .right-box {
position: absolute; position: absolute;
right: 40px; right: 40px;
......
...@@ -5,21 +5,29 @@ ...@@ -5,21 +5,29 @@
</template> </template>
<script> <script>
import { mapMutations, mapGetters } from "vuex";
export default { export default {
data() { data() {
return {}; return {};
}, },
computed: {
...mapGetters(["times", "defaultTimes"]),
},
created() { created() {
this.isTimeOut(); this.isTimeOut();
}, },
methods: { methods: {
...mapMutations(["SET_times"]),
// 返回首页 // 返回首页
startTimer() { startTimer() {
let that = this; clearInterval(this.timeOut);
clearInterval(that.timeOut); this.SET_times(this.defaultTimes);
this.timeOut = setTimeout(function () { this.timeOut = setInterval(() => {
that.$router.push({ path: "/" }); if (this.times == 0) {
}, 1000 * 60 * 5); this.$router.push({ path: "/" });
}
this.SET_times(this.times - 1);
}, 1000);
}, },
// 无任何操作返回首页 // 无任何操作返回首页
isTimeOut() { isTimeOut() {
...@@ -40,7 +48,7 @@ export default { ...@@ -40,7 +48,7 @@ export default {
document.body.removeEventListener("keyup", this.startTimer); document.body.removeEventListener("keyup", this.startTimer);
document.body.removeEventListener("click", this.startTimer); document.body.removeEventListener("click", this.startTimer);
document.body.removeEventListener("touchend", this.startTimer); document.body.removeEventListener("touchend", this.startTimer);
clearTimeout(this.timeOut); clearInterval(this.timeOut);
}, },
}; };
</script> </script>
......
...@@ -12,11 +12,19 @@ export default new Vuex.Store({ ...@@ -12,11 +12,19 @@ export default new Vuex.Store({
datumList: [], // 首页材料 datumList: [], // 首页材料
matterList: [], // 首页事项 matterList: [], // 首页事项
deviceCode: "", // 设备编码 deviceCode: "", // 设备编码
times: 300, // 倒计时时间
defaultTimes: 300, // 倒计时时间
}, },
getters: { getters: {
deviceCode(state) { deviceCode(state) {
return state.deviceCode; return state.deviceCode;
}, },
times(state) {
return state.times;
},
defaultTimes(state) {
return state.defaultTimes;
},
}, },
mutations: { mutations: {
SET_devicenum(state, devicenum) { SET_devicenum(state, devicenum) {
...@@ -34,6 +42,9 @@ export default new Vuex.Store({ ...@@ -34,6 +42,9 @@ export default new Vuex.Store({
SET_deviceCode(state, deviceCode) { SET_deviceCode(state, deviceCode) {
state.deviceCode = deviceCode; state.deviceCode = deviceCode;
}, },
SET_times(state, times) {
state.times = times;
},
}, },
actions: {}, actions: {},
modules: {}, modules: {},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment