alarmList.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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 { nextTick, 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. // { name: "干热风险", id: 1 },
  56. { name: "阴雨沤花", id: 2 },
  57. { name: "阴天寡照", id: 3 },
  58. ]);
  59. const alarmFactorList = ref([
  60. { name: "日间温度", id: 21 },
  61. { name: "夜间温度", id: 22 },
  62. { name: "土壤水分", id: 23 },
  63. ]);
  64. const mapLayerList = ref({})
  65. onMounted(() => {
  66. VE_API.warning.fetchWarningLayer({
  67. k: "risk_map",
  68. resultType: "json",
  69. }).then(({data}) => {
  70. mapLayerList.value = data
  71. eventBus.emit("alarmList:warningLayers", data)
  72. setTimeout(() => {
  73. toggleAlarm(alarmList.value[0], 1)
  74. }, 500)
  75. })
  76. eventBus.on("warningHome:toggleArea", (id) => {
  77. activeAlarm.value = null
  78. })
  79. });
  80. const activeAlarm = ref(1);
  81. const toggleAlarm = (item, type) => {
  82. activeAlarm.value = item.id;
  83. // eventBus.emit("alarmList:changeMapLayer", {name: item.name, url: mapLayerList.value[item.name]})
  84. if (type === 1) {
  85. // 种植风险
  86. eventBus.emit("chat:showMapLayer", {name: item.name, mapName: item.name, isHome: true})
  87. } else {
  88. eventBus.emit("alarmList:changeMapLayer", {url: mapLayerList.value[item.name], type, name: item.name})
  89. }
  90. };
  91. </script>
  92. <style lang="scss" scoped>
  93. .alarm-wrap {
  94. background: rgba(255, 255, 255, 0.1);
  95. border: 1px solid #9f9f9f;
  96. border-radius: 8px;
  97. width: 87px;
  98. display: flex;
  99. flex-direction: column;
  100. justify-content: center;
  101. align-items: center;
  102. .alarm-t {
  103. width: 100%;
  104. padding-top: 18px;
  105. .alarm-tag {
  106. position: relative;
  107. left: -8px;
  108. img{
  109. width: 94px;
  110. height: 32px;
  111. }
  112. }
  113. .alarm-item-wrap {
  114. padding: 0 12px;
  115. .item-wrap {
  116. padding: 12px 0 24px 0;
  117. border-bottom: 1px solid rgba(255, 255, 255, 0.3);
  118. .alarm-item {
  119. cursor: pointer;
  120. background: #232323;
  121. width: 62px;
  122. padding: 7px 10px;
  123. box-sizing: border-box;
  124. display: flex;
  125. align-items: center;
  126. justify-content: center;
  127. font-size: 20px;
  128. font-family: "PangMenZhengDao";
  129. border-radius: 4px;
  130. &.active {
  131. margin-bottom: 34px;
  132. position: relative;
  133. color: #ffd489;
  134. background: url("@/assets/images/warningHome/alarm-active.png") no-repeat center center / cover;
  135. }
  136. .active-arrow {
  137. position: absolute;
  138. bottom: -30px;
  139. }
  140. &:last-child {
  141. &.active {
  142. margin-bottom: 14px;
  143. }
  144. }
  145. }
  146. .alarm-item + .alarm-item {
  147. margin-top: 8px;
  148. }
  149. }
  150. }
  151. }
  152. }
  153. </style>