123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- <template>
- <div class="alarm-wrap">
- <div class="alarm-t">
- <div class="alarm-tag">
- <img src="@/assets/images/warningHome/alarm-bg.png" />
- </div>
- <div class="alarm-item-wrap">
- <div class="item-wrap">
- <div
- class="alarm-item"
- v-for="(item, index) in alarmList"
- :key="index"
- @click="toggleAlarm(item, 1)"
- :class="{ active: activeAlarm === item.id }"
- >
- {{ item.name }}
- <div class="active-arrow" v-if="activeAlarm === item.id">
- <img src="@/assets/images/warningHome/alarm-active-arrow.png" />
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="alarm-t alarm-b">
- <div class="alarm-tag">
- <img src="@/assets/images/warningHome/alarm-bg2.png" />
- </div>
- <div class="alarm-item-wrap">
- <div class="item-wrap">
- <div
- class="alarm-item"
- v-for="(item, index) in alarmFactorList"
- :key="index"
- @click="toggleAlarm(item, 2)"
- :class="{ active: activeAlarm === item.id }"
- >
- {{ item.name }}
- <div class="active-arrow" v-if="activeAlarm === item.id">
- <img src="@/assets/images/warningHome/alarm-active-arrow.png" />
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script setup>
- import eventBus from "@/api/eventBus";
- import { onMounted, ref } from "vue";
- const alarmList = ref([
- { name: "低温冻害", id: 1 },
- { name: "干旱缺水", id: 2 },
- { name: "冲梢风险", id: 3 },
- { name: "病虫风险", id: 4 },
- ]);
- const alarmFactorList = ref([
- { name: "日间温度", id: 21 },
- { name: "夜间温度", id: 22 },
- { name: "土壤水分", id: 23 },
- ]);
- const mapLayerList = ref({})
- onMounted(() => {
- VE_API.warning.fetchWarningLayer({
- k: "risk_map",
- resultType: "json",
- }).then(({data}) => {
- mapLayerList.value = data
- eventBus.emit("alarmList:warningLayers", data)
- toggleAlarm(alarmList.value[0], 1)
- })
- eventBus.on("warningHome:toggleArea", (id) => {
- activeAlarm.value = null
- })
- });
- const activeAlarm = ref(1);
- const toggleAlarm = (item, type) => {
- activeAlarm.value = item.id;
- // eventBus.emit("alarmList:changeMapLayer", {name: item.name, url: mapLayerList.value[item.name]})
- eventBus.emit("alarmList:changeMapLayer", {url: mapLayerList.value[item.name], type, name: item.name})
- };
- </script>
- <style lang="scss" scoped>
- .alarm-wrap {
- background: rgba(255, 255, 255, 0.1);
- border: 1px solid #9f9f9f;
- border-radius: 8px;
- width: 87px;
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- .alarm-t {
- width: 100%;
- padding-top: 18px;
- .alarm-tag {
- position: relative;
- left: -8px;
- }
- .alarm-item-wrap {
- padding: 0 12px;
- .item-wrap {
- padding: 12px 0 24px 0;
- border-bottom: 1px solid rgba(255, 255, 255, 0.3);
- .alarm-item {
- cursor: pointer;
- background: #232323;
- width: 62px;
- padding: 7px 10px;
- box-sizing: border-box;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 20px;
- font-family: "PangMenZhengDao";
- border-radius: 4px;
- &.active {
- margin-bottom: 34px;
- position: relative;
- color: #ffd489;
- background: url("@/assets/images/warningHome/alarm-active.png") no-repeat center center / cover;
- }
- .active-arrow {
- position: absolute;
- bottom: -30px;
- }
- &:last-child {
- &.active {
- margin-bottom: 14px;
- }
- }
- }
- .alarm-item + .alarm-item {
- margin-top: 8px;
- }
- }
- }
- }
- }
- </style>
|