alarmList.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <div class="alarm-wrap">
  3. <div class="alarm-t">
  4. <div class="alarm-tag">
  5. <img src="@/assets/images/warningHome/alarm-bg.png" />
  6. </div>
  7. <div class="alarm-item-wrap">
  8. <div class="item-wrap">
  9. <div
  10. class="alarm-item"
  11. v-for="(item, index) in alarmList"
  12. :key="index"
  13. @click="toggleAlarm(item, 1)"
  14. :class="{ active: activeAlarm === item.id }"
  15. >
  16. {{ item.name }}
  17. <div class="active-arrow" v-if="activeAlarm === item.id">
  18. <img src="@/assets/images/warningHome/alarm-active-arrow.png" />
  19. </div>
  20. </div>
  21. </div>
  22. </div>
  23. </div>
  24. <div class="alarm-t alarm-b">
  25. <div class="alarm-tag">
  26. <img src="@/assets/images/warningHome/alarm-bg2.png" />
  27. </div>
  28. <div class="alarm-item-wrap">
  29. <div class="item-wrap">
  30. <div
  31. class="alarm-item"
  32. v-for="(item, index) in alarmFactorList"
  33. :key="index"
  34. @click="toggleAlarm(item, 2)"
  35. :class="{ active: activeAlarm === item.id }"
  36. >
  37. {{ item.name }}
  38. <div class="active-arrow" v-if="activeAlarm === item.id">
  39. <img src="@/assets/images/warningHome/alarm-active-arrow.png" />
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. </template>
  47. <script setup>
  48. import eventBus from "@/api/eventBus";
  49. import { onMounted, ref } from "vue";
  50. const alarmList = ref([
  51. { name: "低温冻害", id: 1 },
  52. { name: "干旱缺水", id: 2 },
  53. { name: "冲梢风险", id: 3 },
  54. { name: "病虫风险", id: 4 },
  55. ]);
  56. const alarmFactorList = ref([
  57. { name: "日间温度", id: 21 },
  58. { name: "夜间温度", id: 22 },
  59. { name: "土壤水分", id: 23 },
  60. ]);
  61. const mapLayerList = ref({})
  62. onMounted(() => {
  63. VE_API.warning.fetchWarningLayer({
  64. k: "risk_map",
  65. resultType: "json",
  66. }).then(({data}) => {
  67. mapLayerList.value = data
  68. eventBus.emit("alarmList:warningLayers", data)
  69. toggleAlarm(alarmList.value[0], 1)
  70. })
  71. eventBus.on("warningHome:toggleArea", (id) => {
  72. activeAlarm.value = null
  73. })
  74. });
  75. const activeAlarm = ref(1);
  76. const toggleAlarm = (item, type) => {
  77. activeAlarm.value = item.id;
  78. // eventBus.emit("alarmList:changeMapLayer", {name: item.name, url: mapLayerList.value[item.name]})
  79. eventBus.emit("alarmList:changeMapLayer", {url: mapLayerList.value[item.name], type, name: item.name})
  80. };
  81. </script>
  82. <style lang="scss" scoped>
  83. .alarm-wrap {
  84. background: rgba(255, 255, 255, 0.1);
  85. border: 1px solid #9f9f9f;
  86. border-radius: 8px;
  87. width: 87px;
  88. display: flex;
  89. flex-direction: column;
  90. justify-content: center;
  91. align-items: center;
  92. .alarm-t {
  93. width: 100%;
  94. padding-top: 18px;
  95. .alarm-tag {
  96. position: relative;
  97. left: -8px;
  98. }
  99. .alarm-item-wrap {
  100. padding: 0 12px;
  101. .item-wrap {
  102. padding: 12px 0 24px 0;
  103. border-bottom: 1px solid rgba(255, 255, 255, 0.3);
  104. .alarm-item {
  105. cursor: pointer;
  106. background: #232323;
  107. width: 62px;
  108. padding: 7px 10px;
  109. box-sizing: border-box;
  110. display: flex;
  111. align-items: center;
  112. justify-content: center;
  113. font-size: 20px;
  114. font-family: "PangMenZhengDao";
  115. border-radius: 4px;
  116. &.active {
  117. margin-bottom: 34px;
  118. position: relative;
  119. color: #ffd489;
  120. background: url("@/assets/images/warningHome/alarm-active.png") no-repeat center center / cover;
  121. }
  122. .active-arrow {
  123. position: absolute;
  124. bottom: -30px;
  125. }
  126. &:last-child {
  127. &.active {
  128. margin-bottom: 14px;
  129. }
  130. }
  131. }
  132. .alarm-item + .alarm-item {
  133. margin-top: 8px;
  134. }
  135. }
  136. }
  137. }
  138. }
  139. </style>