forked from drone/command-center-dashboard

chenyao
2025-04-09 cc1aacf766bc902001f460fdfce20a9ec2ea097d
src/views/Home/Footer.vue
@@ -1,15 +1,20 @@
<template>
   <div class="footer">
      <img
         v-for="item in list"
         v-for="(item,index) in list.filter(i => !i.disable)"
         :class="item.className"
         :src="item.active ? item.activeImg : item.img"
         alt=""
         @click="imgClick(item)"
         @click="footAction(item,index)"
      />
   </div>
   <div class="intelligent-introduction-flying">
      <img class="orthophoto" src="@/assets/images/intelligent-introduction-flying.png" alt="" />
      <img
         class="orthophoto"
         src="@/assets/images/intelligent-introduction-flying.png"
         alt=""
         @click="footAction(list[5],5)"
      />
   </div>
</template>
@@ -27,6 +32,10 @@
import { useMapAggregation } from '@/views/Home/useMapAggregation/useMapAggregation'
import { useStore } from 'vuex'
import func from '@/utils/func'
const store = useStore()
const footActiveIndex = computed(() => store.state.home.footActiveIndex)
// 机巢聚合
const { init, removeAll } = useMapAggregation('device')
@@ -35,7 +44,7 @@
const list = ref([
   {
      name: 'event1',
      name: 'jc',
      img: img1,
      activeImg: activeImg1,
      active: true,
@@ -44,7 +53,7 @@
      removeAll: removeAll,
   },
   {
      name: 'event2',
      name: 'sj',
      img: img2,
      activeImg: activeImg2,
      active: false,
@@ -52,27 +61,28 @@
      init: eventInit,
      removeAll: eventRemove,
   },
   { name: 'event3', img: img3, activeImg: activeImg3, active: false, className: 'panorama' },
   { name: 'event4', img: img4, activeImg: activeImg4, active: false, className: 'threeD' },
   { name: 'event5', img: img5, activeImg: activeImg5, active: false, className: 'orthophoto' },
   { name: 'qj', img: img3, activeImg: activeImg3, active: false, className: 'panorama' },
   { name: 'sw', img: img4, activeImg: activeImg4, active: false, className: 'threeD' },
   { name: 'zs', img: img5, activeImg: activeImg5, active: false, className: 'orthophoto' },
   { name: 'zyjf', active: false, disable: true },
])
const store = useStore()
const imgClick = (toItem,index) => {
   index !== undefined && store.commit('setFootActiveIndex',index)
   const fromItem = list.value.find(item => item.active)
   if (fromItem.name === toItem.name) return
const footAction = (toItem, index) => {
   const fromItem = list.value.find(item => item.active)  //上一个激活item
   if (fromItem.name === toItem?.name) return  //是重复点击
   index !== undefined && store.commit('setFootActiveIndex', index) //是按钮点击得动作
   fromItem?.removeAll?.()
   nextTick(() => {
      toItem?.init?.()
   })
   list.value = list.value.map(item => ({ ...item, active: item.name === toItem.name }))
   nextTick(() => toItem?.init?.())
   list.value = list.value.map(item => ({ ...item, active: item.name === toItem?.name }))
}
const footActiveIndex = computed(() => store.state.home.footActiveIndex)
watch(footActiveIndex, val => {
   console.log(6666666)
   imgClick(list.value[val])
},{deep:true})
watch(
   footActiveIndex,
   val => {
      footAction(list.value[val])
   },
   { deep: true }
)
// 销毁前钩子
onBeforeUnmount(() => {
@@ -128,6 +138,7 @@
   bottom: 23px;
   img {
      cursor: pointer;
      width: 146px;
      height: 54px;
   }