418 lines
11 KiB
Vue
418 lines
11 KiB
Vue
<template>
|
|
<div class="header">
|
|
<ul class="nav-left">
|
|
<li
|
|
class="nav-left-item"
|
|
:style="{
|
|
backgroundImage: `url(${current === index && !isSkip ? title2Select : title2})`
|
|
}"
|
|
v-for="(item, index) in navLeft"
|
|
:key="index"
|
|
:title="item.name"
|
|
@click="handleNav(item, index)"
|
|
>
|
|
{{ item.name }}
|
|
</li>
|
|
<el-dropdown
|
|
v-if="
|
|
['/scenic', '/hotel'].includes(router.currentRoute.value.path) && otherLeftNav.length > 0
|
|
"
|
|
trigger="click"
|
|
@command="handleCommand"
|
|
>
|
|
<li
|
|
class="nav-left-item"
|
|
:style="{
|
|
backgroundImage: `url(${title2})`
|
|
}"
|
|
>
|
|
{{ otherLeftLabel }}
|
|
<img class="icon" src="@/assets/images/arrow-down-1.png" />
|
|
</li>
|
|
<template #dropdown>
|
|
<el-dropdown-menu>
|
|
<el-dropdown-item v-for="(item, index) in otherLeftNav" :key="index" :command="item">
|
|
<span class="label"> {{ item.name }}</span>
|
|
</el-dropdown-item>
|
|
</el-dropdown-menu>
|
|
</template>
|
|
</el-dropdown>
|
|
</ul>
|
|
<div class="title">
|
|
<span>{{ title }}</span>
|
|
</div>
|
|
<ul class="nav-right">
|
|
<li
|
|
class="nav-right-item"
|
|
v-for="(item, index) in navRight"
|
|
:key="index"
|
|
:title="item.name"
|
|
@click="handleNav(item, index)"
|
|
>
|
|
{{ item.name }}
|
|
</li>
|
|
</ul>
|
|
<div class="weather">
|
|
<span>{{ weatherData?.temperature }}-{{ weatherData?.skycon }}</span>
|
|
<span class="line">|</span>
|
|
<span>风速:{{ weatherData?.windSpeed }}</span>
|
|
<span class="line">|</span>
|
|
<span>空气质量:{{ weatherData?.airQuality }}</span>
|
|
</div>
|
|
<p class="date">{{ currentDate }}</p>
|
|
<div v-if="isBack" class="back" @click="handleBack">
|
|
<img class="icon" src="@/assets/images/back.png" alt="" /> 返回
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { useRouter } from 'vue-router'
|
|
|
|
import title2 from '@/assets/images/title-2.png'
|
|
import title2Select from '@/assets/images/title-2-select.png'
|
|
|
|
import { getWeatherApi } from '@/api/home'
|
|
import { getSpotListApi } from '@/api/sentiment'
|
|
import { getHotelListApi } from '@/api/hotel'
|
|
|
|
import pubSub from 'pubsub-js'
|
|
|
|
const router = useRouter()
|
|
|
|
let currentDate = ref('')
|
|
let weatherData = ref({})
|
|
let title = ref('')
|
|
let navLeft = ref([])
|
|
let navRight = ref([])
|
|
let isSkip = ref(true)
|
|
let isBack = ref(false)
|
|
let current = ref(0)
|
|
let otherLeftLabel = ref('')
|
|
let otherLeftNav = ref([])
|
|
let spotList = ref([])
|
|
|
|
// 补零
|
|
const fillZero = (value) => {
|
|
return value < 10 ? `0${value}` : value
|
|
}
|
|
|
|
// 获取当前日期
|
|
const getCurrentDate = () => {
|
|
var time = new Date()
|
|
var year = time.getFullYear()
|
|
var month = time.getMonth() + 1
|
|
var day = time.getDate()
|
|
var second = time.getSeconds()
|
|
var hour = time.getHours()
|
|
var minute = time.getMinutes()
|
|
var second = time.getSeconds()
|
|
currentDate.value = `${year}-${fillZero(month)}-${fillZero(day)} ${hour}:${fillZero(
|
|
minute
|
|
)}:${fillZero(second)}`
|
|
}
|
|
// 返回首页
|
|
const handleBack = () => {
|
|
router.push('/home')
|
|
}
|
|
const handleCommand = (item) => {
|
|
current.value = ''
|
|
otherLeftLabel.value = item.name
|
|
switch (router.currentRoute.value.path) {
|
|
case '/scenic':
|
|
pubSub.publish('scenicChange', item)
|
|
break
|
|
case '/monitor':
|
|
pubSub.publish('monitorChange', item)
|
|
break
|
|
case '/hotel':
|
|
pubSub.publish('hotelChange', item)
|
|
break
|
|
}
|
|
}
|
|
// 点击导航
|
|
const handleNav = (item, index) => {
|
|
if (isSkip.value) {
|
|
router.push(item.path)
|
|
} else {
|
|
if (current.value === index) return
|
|
otherLeftLabel.value = '其他酒店'
|
|
current.value = index
|
|
title.value = item.name
|
|
switch (router.currentRoute.value.path) {
|
|
case '/scenic':
|
|
pubSub.publish('scenicChange', item)
|
|
break
|
|
case '/monitor':
|
|
pubSub.publish('monitorChange', item)
|
|
break
|
|
case '/hotel':
|
|
pubSub.publish('hotelChange', item)
|
|
break
|
|
}
|
|
}
|
|
}
|
|
|
|
// 获取天气数据
|
|
const getWeather = async () => {
|
|
let res = await getWeatherApi()
|
|
weatherData.value = res.data
|
|
}
|
|
// 获取景区列表
|
|
const getSpotList = async () => {
|
|
let res = await getSpotListApi()
|
|
spotList.value = res.data
|
|
}
|
|
// 设置当前路由导航栏
|
|
const setNav = async () => {
|
|
navLeft.value = []
|
|
navRight.value = []
|
|
switch (router.currentRoute.value.path) {
|
|
case '/home':
|
|
title.value = '奉节县旅游指挥调度中心'
|
|
isSkip.value = true
|
|
isBack.value = false
|
|
navLeft.value = [
|
|
{ name: '监控', path: '/monitor' },
|
|
{ name: '景区', path: '/scenic' },
|
|
{ name: '交通', path: '/traffic' }
|
|
]
|
|
navRight.value = [
|
|
{ name: '工单', path: '/workOrder' },
|
|
{ name: '舆情', path: '/sentiment' },
|
|
{ name: '酒店', path: '/hotel' }
|
|
]
|
|
break
|
|
case '/scenic':
|
|
otherLeftLabel.value = '其他景区'
|
|
isSkip.value = false
|
|
isBack.value = true
|
|
let res = await getSpotListApi()
|
|
navLeft.value = res.data
|
|
current.value = 0
|
|
title.value = navLeft.value[current.value].name
|
|
pubSub.publish('scenicChange', navLeft.value[current.value])
|
|
otherLeftNav.value = [
|
|
{
|
|
name: '大窝景区'
|
|
},
|
|
{
|
|
name: '天坑景区'
|
|
},
|
|
{
|
|
name: '旅游环线'
|
|
}
|
|
]
|
|
break
|
|
case '/sentiment':
|
|
title.value = '舆情监测'
|
|
isBack.value = true
|
|
break
|
|
case '/workOrder':
|
|
title.value = '工单消息'
|
|
isBack.value = true
|
|
break
|
|
case '/traffic':
|
|
title.value = '交通大屏'
|
|
isBack.value = true
|
|
break
|
|
case '/monitor':
|
|
title.value = '监控大屏'
|
|
isSkip.value = false
|
|
current.vlaue = ''
|
|
isBack.value = true
|
|
let res1 = await getSpotListApi()
|
|
navLeft.value = [
|
|
{
|
|
name: '奉节县',
|
|
scenicSpotId: ''
|
|
},
|
|
...res1.data
|
|
]
|
|
break
|
|
case '/sceneTesting':
|
|
title.value = '三峡之巅-安全检测'
|
|
navLeft.value = [
|
|
{
|
|
name: '奉节县',
|
|
path: '/sceneTesting'
|
|
},
|
|
{
|
|
name: '三峡之巅',
|
|
path: '/sceneTesting'
|
|
},
|
|
{
|
|
name: '白帝城',
|
|
path: '/sceneTesting'
|
|
},
|
|
{
|
|
name: '龙河桥',
|
|
path: '/sceneTesting'
|
|
}
|
|
]
|
|
navRight.value = [
|
|
{
|
|
name: '路段',
|
|
path: '/roadTesting'
|
|
},
|
|
{
|
|
name: '路段',
|
|
path: '/roadTesting'
|
|
},
|
|
{
|
|
name: '路段',
|
|
path: '/roadTesting'
|
|
},
|
|
{
|
|
name: '路段',
|
|
path: '/roadTesting'
|
|
}
|
|
]
|
|
isBack.value = true
|
|
break
|
|
case '/hotel':
|
|
title.value = '酒店场馆'
|
|
otherLeftLabel.value = '其他酒店'
|
|
isSkip.value = false
|
|
current.vlaue = ''
|
|
isBack.value = true
|
|
let hotelRes = await getHotelListApi({ hotelStadiumType: 1 })
|
|
navLeft.value = hotelRes.data.slice(0, 3)
|
|
pubSub.publish('hotelChange', hotelRes.data[0])
|
|
otherLeftNav.value = hotelRes.data.slice(3, hotelRes.data.length - 1)
|
|
break
|
|
}
|
|
}
|
|
watch(
|
|
() => router.currentRoute.value,
|
|
() => {
|
|
setNav()
|
|
},
|
|
{ immediate: true }
|
|
)
|
|
onMounted(() => {
|
|
getWeather()
|
|
getSpotList()
|
|
getCurrentDate()
|
|
setInterval(() => {
|
|
getCurrentDate()
|
|
}, 1000)
|
|
})
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
.header {
|
|
position: absolute;
|
|
left: vw(326);
|
|
.weather {
|
|
position: absolute;
|
|
right: 0;
|
|
top: vh(10);
|
|
font-weight: 400;
|
|
font-size: vw(18);
|
|
color: #ffffff;
|
|
.line {
|
|
margin: 0 vw(10);
|
|
}
|
|
}
|
|
.date {
|
|
position: absolute;
|
|
left: 0;
|
|
top: vh(10);
|
|
font-weight: 400;
|
|
font-size: vw(18);
|
|
color: #ffffff;
|
|
}
|
|
.back {
|
|
position: absolute;
|
|
right: 0;
|
|
top: vh(50);
|
|
width: vw(130);
|
|
height: vh(36);
|
|
font-weight: 600;
|
|
font-size: vw(20);
|
|
color: #ffffff;
|
|
cursor: pointer;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
border-radius: vw(60);
|
|
border: 1px solid rgba(0, 114, 220, 0.3);
|
|
background: linear-gradient(270deg, rgba(8, 41, 86, 0.16) 0%, #0b61b4 100%);
|
|
.icon {
|
|
margin-right: vw(10);
|
|
width: vw(24);
|
|
height: auto;
|
|
}
|
|
}
|
|
.title {
|
|
width: vw(3170);
|
|
height: vh(120);
|
|
line-height: vh(90);
|
|
text-align: center;
|
|
letter-spacing: vw(10);
|
|
box-sizing: border-box;
|
|
background-image: url('@/assets/images/title.png');
|
|
background-size: 100% 100%;
|
|
& > span {
|
|
font-size: vw(48);
|
|
font-weight: 800;
|
|
font-family: 'MicrosoftYaHeiBold';
|
|
color: transparent;
|
|
letter-spacing: vw(10);
|
|
-webkit-background-clip: text;
|
|
background-clip: text;
|
|
-webkit-text-fill-color: transparent;
|
|
text-shadow: 0 4px 7px rgba(0, 150, 255, 0.75);
|
|
background-image: linear-gradient(to bottom, #ffffff 0%, #87c9ff 100%);
|
|
}
|
|
}
|
|
.nav-left {
|
|
position: absolute;
|
|
right: vw(2120);
|
|
top: vh(34);
|
|
display: flex;
|
|
&-item {
|
|
cursor: pointer;
|
|
margin-left: vh(-16);
|
|
width: vw(210);
|
|
height: vh(56);
|
|
line-height: vh(46);
|
|
font-weight: 600;
|
|
font-size: vw(28);
|
|
text-align: center;
|
|
padding: 0 vw(30);
|
|
color: rgba(208, 236, 255, 0.9);
|
|
background-size: 100% 100%;
|
|
text-overflow: ellipsis;
|
|
overflow: hidden;
|
|
word-break: break-all;
|
|
white-space: nowrap;
|
|
.icon {
|
|
width: vw(18);
|
|
height: vw(18);
|
|
}
|
|
}
|
|
}
|
|
.nav-right {
|
|
position: absolute;
|
|
left: vw(2130);
|
|
top: vh(34);
|
|
display: flex;
|
|
&-item {
|
|
cursor: pointer;
|
|
margin-right: vh(-16);
|
|
width: vw(210);
|
|
height: vh(56);
|
|
line-height: vh(46);
|
|
font-weight: 600;
|
|
font-size: vw(28);
|
|
text-align: center;
|
|
color: rgba(208, 236, 255, 0.9);
|
|
background-image: url('@/assets/images/title-3.png');
|
|
background-size: 100% 100%;
|
|
}
|
|
}
|
|
}
|
|
</style>
|