Files
apt15e/src/pages/shells/index.vue

211 lines
6.5 KiB
Vue
Raw Normal View History

2025-06-26 17:47:20 +08:00
<template>
2025-06-27 17:07:21 +08:00
<div class="zbox body-container" :class="{'enClass': $i18n.locale === 'en-us'}">
2025-06-26 17:47:20 +08:00
<el-row type="flex" class="header-container" justify="space-between" align="middle">
<el-col :span="3">
2025-06-27 18:16:47 +08:00
<el-button type="primary" icon="el-icon-s-home" class="button-home" @click="$router.push('/index/home')">{{ $t('index') }}</el-button>
2025-06-26 17:47:20 +08:00
</el-col>
<el-col :span="12">
<el-row type="flex" justify="end" align="middle">
<div class="state-item">自动模式</div>
2025-07-14 16:46:51 +08:00
<div v-if="JSON.stringify(topInfo) !== '{}'" class="state-item">{{ topInfo.state }}</div>
<div v-if="JSON.stringify(topInfo) !== '{}'" class="relative elec-qty-wrap" :class="{'elec-wraning': topInfo.batteryPower <= 40}">
<div class="absolute elec-qty" :style="{ width: topInfo.batteryPower !== -1 ? `calc(100% - ${topInfo.batteryPower}%)` : '100%' }"></div>
2025-06-27 14:37:06 +08:00
<div class="absolute elec-qty-border"></div>
2025-07-14 17:52:37 +08:00
<div class="elec-txt">{{topInfo.batteryPower !== -1 ? `${topInfo.batteryPower}%` : '0'}}</div>
2025-07-14 16:46:51 +08:00
</div>
<div v-else class="relative elec-qty-wrap elec-wraning">
<div class="absolute elec-qty" style="width: 100%"></div>
<div class="absolute elec-qty-border"></div>
<div class="elec-txt"></div>
2025-06-26 17:47:20 +08:00
</div>
2025-07-04 17:52:10 +08:00
<i class="el-icon-user-solid icon-user" :style="{'color': $store.getters.userInfo === 'true' ? '#00ff29' : '#737f92'}" @click="loginModalHandle"></i>
2025-06-26 17:47:20 +08:00
<i class="el-icon-s-tools icon-tools" @click="configModalHandle"></i>
</el-row>
</el-col>
</el-row>
<div class="error-tips" ref="scrollContainer" @click="$router.push('/index/warning')">
<div class="zbox scroll-text" ref="scrollText">
<i class="el-icon-warning icon-warning"></i>
<div class="error-tips-t">错误提示1.障碍物告警 2.定位丢失</div>
</div>
</div>
<el-row type="flex" class="relative main-conatiner">
<div class="absolute hud_left"></div>
<div class="absolute hud_left hud_right"></div>
<router-view></router-view>
</el-row>
<div class="task-tips">
2025-07-04 17:52:10 +08:00
<div class="task-tips-t">A<i class="el-icon-right"></i>B<i class="el-icon-right"></i>C<i class="el-icon-right"></i>D</div>
2025-06-26 17:47:20 +08:00
</div>
2025-07-04 17:52:10 +08:00
<login-modal v-if="loginVisible" ref="loginModal"/>
2025-06-26 17:47:20 +08:00
<config-modal v-if="configVisible" ref="configModal"/>
</div>
</template>
<script>
import LoginModal from './login-modal.vue'
import ConfigModal from './config-modal.vue'
2025-07-14 16:46:51 +08:00
import { sendWebsocket, closeWebsocket } from '@/config/websocket.js'
2025-06-26 17:47:20 +08:00
export default {
components: {
LoginModal,
ConfigModal
},
data () {
return {
2025-07-14 16:46:51 +08:00
timer: null,
topInfo: {},
2025-06-26 17:47:20 +08:00
loginVisible: false,
configVisible: false
}
},
2025-07-14 16:46:51 +08:00
created () {
this._queryHead()
},
2025-06-26 17:47:20 +08:00
mounted () {
this.checkTextOverflow()
window.addEventListener('resize', this.checkTextOverflow)
},
beforeDestroy () {
window.removeEventListener('resize', this.checkTextOverflow)
2025-07-14 16:46:51 +08:00
clearTimeout(this.timer)
closeWebsocket(true)
},
destroyed () {
clearTimeout(this.timer)
2025-06-26 17:47:20 +08:00
},
methods: {
// 滚动区域
checkTextOverflow () {
const container = this.$refs.scrollContainer
const text = this.$refs.scrollText
if (!container || !text) return
const containerWidth = container.offsetWidth
const textWidth = text.scrollWidth
if (textWidth > containerWidth) {
// 如果文字超出容器宽度,启动滚动动画
const duration = (textWidth / containerWidth) * 10
text.style.animation = `scrollText ${duration}s linear infinite`
} else {
// 如果文字没有超出容器宽度,停止滚动动画
text.style.animation = 'none'
}
},
// 管理员登录
loginModalHandle () {
this.loginVisible = true
this.$nextTick(() => {
this.$refs.loginModal.init()
})
},
// 配置
configModalHandle () {
this.configVisible = true
this.$nextTick(() => {
this.$refs.configModal.init()
})
2025-07-14 16:46:51 +08:00
},
_queryHead () {
let url = this.$store.getters.baseUrl
url = url.substring(7)
let sid = this.$store.getters.userInfo === 'true' ? 1 : 2
sendWebsocket(`ws://${url}/webSocket/VehicleInfo/${sid}`, {}, this.wsMessage, this.wsErr)
},
wsMessage (res) {
clearTimeout(this.timer)
this.topInfo = res.data
},
wsErr () {
this.timer = setTimeout(() => {
this._queryHead()
}, 10000)
2025-06-26 17:47:20 +08:00
}
}
}
</script>
<style lang="stylus" scoped>
@import '~@style/mixin'
.header-container
_wh(100%, .48rem)
padding 0 2%
background top center / 100% 84px url(../../images/new/header_bg_1.png) no-repeat
.button-home
background linear-gradient(0deg, #E64F29, rgba(230, 79, 41, 0.5))
border-color rgba(230, 79, 41, 0.7)
.state-item
_wh(.72rem, .3rem)
_font(.14rem,.3rem,#fff,,center)
font-family 'Adobe Heiti Std'
margin-right .04rem
background center / 100% 100% url(../../images/new/state-item_bg.png) no-repeat
.elec-qty-wrap
2025-06-27 14:37:06 +08:00
_wh(.5rem, .25rem)
2025-06-26 17:47:20 +08:00
margin-right .04rem
2025-06-27 14:37:06 +08:00
background center / 100% 100% url(../../images/new/elec.png) no-repeat
border 1px solid #5ADFBC
2025-06-26 17:47:20 +08:00
z-index 151
.elec-qty
2025-06-27 14:37:06 +08:00
right 0
2025-06-26 17:47:20 +08:00
z-index 152
2025-06-27 14:37:06 +08:00
height 100%
background-color #0d2d59
.elec-qty-border
_wh(100%, 100%)
2025-06-26 17:47:20 +08:00
z-index 152
2025-06-27 14:37:06 +08:00
box-shadow inset 0px 0px 4px 2px rgba(90, 223, 188, 70%)
.elec-wraning
border-color #ffe600
background center / 100% 100% url(../../images/new/elec_y.png) no-repeat
.elec-qty-border
box-shadow inset 0px 0px 4px 2px rgba(192, 176, 28, 70%)
2025-06-26 17:47:20 +08:00
.elec-txt
position relative
z-index 153
2025-06-27 14:37:06 +08:00
_font(.15rem, .25rem, #fff,,center)
2025-06-26 17:47:20 +08:00
font-family 'Adobe Heiti Std'
.icon-user
font-size .24rem
margin-right .04rem
.icon-tools
font-size .24rem
color #fff
cursor pointer
.error-tips
width 100%
height .3rem
line-height .3rem
overflow hidden
white-space nowrap
background-color rgba(253, 246, 236, .4)
.scroll-text
display inline-block
text-align center
animation none
.icon-warning
font-size .18rem
color #e6a23c
.error-tips-t
display inline-block
font-size .16rem
color #e6a23c
.task-tips
width 100%
height .4rem
line-height .4rem
padding 0 2%
background linear-gradient(90deg, #1DB8FF,#1DC5E1, #27C8B0,#819269, #E46355)
.task-tips-t
_font(.2rem, .4rem, #fff, ,center)
.hud_left
position absolute
left 0
top 0
_wh(2%, 100%)
background center / 100% auto url(../../images/new/hud_left.png) no-repeat
.hud_right
left auto
right 0
background-image url(../../images/new/hud_right.png)
</style>