展示页面修改为按钮刷新数据

pull/7/head
孙萌 2023-10-08 10:38:08 +08:00
parent dd5db517d8
commit fdd43c9bdd
4 changed files with 39 additions and 28 deletions

View File

@ -19,5 +19,8 @@ import 'videojs-contrib-hls'; // 引入支持HLS的插件
new Vue({ new Vue({
router, router,
store, store,
render: h => h(App) render: h => h(App),
beforeCreate(){
Vue.prototype.$bus=this
},
}).$mount('#app') }).$mount('#app')

View File

View File

@ -5,6 +5,7 @@
<div> <div>
<div class="return-btn" @click="returnRouter()"></div> <div class="return-btn" @click="returnRouter()"></div>
<div class="return-btn" @click="refreshData()"></div>
<!-- <div class="router-list" @click="toRouter(item)" :class="routerAct == item.router ? 'active' : ''" <!-- <div class="router-list" @click="toRouter(item)" :class="routerAct == item.router ? 'active' : ''"
v-for="item, index in routerList" :key="index"> v-for="item, index in routerList" :key="index">
{{ item.name }} {{ item.name }}
@ -14,6 +15,7 @@
</div> </div>
<div class="header-center" v-if="deviceDetail">{{ deviceDetail.deviceTypeName }}</div> <div class="header-center" v-if="deviceDetail">{{ deviceDetail.deviceTypeName }}</div>
<div class="header-right"> <div class="header-right">
<div class="time" v-if="time"> <div class="time" v-if="time">
{{ time.year.year }}-{{ time.year.month }}-{{ time.year.date }}<span>{{ time.time }}</span> {{ time.year.year }}-{{ time.year.month }}-{{ time.year.date }}<span>{{ time.time }}</span>
<div>{{ time.week }}</div> <div>{{ time.week }}</div>
@ -53,6 +55,10 @@ export default {
} }
}, },
methods: { methods: {
refreshData(){
this.getEqbyid()
this.$bus.$emit('refreshData')
},
getEqbyid() { getEqbyid() {
var store=this.$store.state var store=this.$store.state
var userInfo = JSON.parse(localStorage.getItem('userInfo')) var userInfo = JSON.parse(localStorage.getItem('userInfo'))
@ -105,7 +111,22 @@ export default {
background: url(../assets/image/background.jpg) no-repeat; background: url(../assets/image/background.jpg) no-repeat;
background-size: 1920px 1080px; background-size: 1920px 1080px;
background-position: center top; background-position: center top;
.return-btn {
width: 120px;
margin: 0 8px;
padding: 0 20px;
border-radius: 3px;
height: 40px;
display: flex;
align-items: center;
justify-content: center;
font-size: 16px;
font-family: Microsoft YaHei;
font-weight: bold;
color: #FFFFFF;
cursor: pointer;
background: #00BB88;
}
.header { .header {
display: flex; display: flex;
align-items: center; align-items: center;
@ -124,25 +145,10 @@ export default {
flex-shrink: 0; flex-shrink: 0;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; // justify-content: space-between;
width: 500px; width: 500px;
.return-btn {
width: 120px;
margin: 0 8px;
padding: 0 20px;
border-radius: 3px;
height: 40px;
display: flex;
align-items: center;
justify-content: center;
font-size: 16px;
font-family: Microsoft YaHei;
font-weight: bold;
color: #FFFFFF;
cursor: pointer;
background: #00BB88;
}
} }
.router-list { .router-list {

View File

@ -281,23 +281,25 @@ export default {
// //
beforeDestroy(){ beforeDestroy(){
const that = this; const that = this;
that.pageTimer&&clearInterval(that.pageTimer) this.$bus.$off('refreshData')
// that.pageTimer&&clearInterval(that.pageTimer)
}, },
mounted() { mounted() {
const that = this; const that = this;
if (localStorage.getItem('token')) { if (localStorage.getItem('token')) {
setTimeout(() => {
that.getEqbyid(); that.getEqbyid();
that.pageTimer&&clearInterval(that.pageTimer) // setTimeout(() => {
that.pageTimer= setInterval(() => { // that.pageTimer&&clearInterval(that.pageTimer)
that.getEqbyid(); // that.pageTimer= setInterval(() => {
}, 5000); // that.getEqbyid();
}, 0); // }, 5000);
// }, 0);
} else { } else {
// this.$router.push({ name: 'login' }) // this.$router.push({ name: 'login' })
} }
this.$bus.$on('refreshData',(res)=>{
that.getEqbyid();
})
}, },
methods: { methods: {
//countType //countType