alarm.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <!--
  2. * @LastEditors: gcz
  3. -->
  4. <template>
  5. <div class="alarm-wrap">
  6. <div class="alarm">
  7. <div class="alarm-con u-flex">
  8. <img src="../assets/img/gaojing.png" alt />
  9. <div class="g-container">
  10. <ul class="new-list" :class="{anim:animate}" @mouseenter="Stop()" @mouseleave="Up()">
  11. <li
  12. v-for="(item,index) in data"
  13. :key="index"
  14. @click="jumpMap(item)"
  15. >{{item.countyName}}{{item.townName}}{{item.villageName}}{{item.createTime.slice(5,16)}}发现[{{item.eventType|filterEventType}}],请尽快处理!</li>
  16. </ul>
  17. </div>
  18. </div>
  19. </div>
  20. </div>
  21. </template>
  22. <script>
  23. import { mapMutations, mapState, mapGetters } from 'vuex';
  24. export default {
  25. name: '',
  26. props: {
  27. data: {
  28. type: Array,
  29. default: null
  30. }
  31. },
  32. components: {},
  33. data() {
  34. return {
  35. alarmNum: this.data.length,
  36. animate: false,
  37. intNum: undefined,
  38. alarData: {}
  39. };
  40. },
  41. created() {
  42. console.log(this.data);
  43. this.ScrollUp();
  44. },
  45. computed: {
  46. ...mapGetters(['vuexCityList', 'vuexDistrictList', 'vuexStreetList'])
  47. },
  48. watch: {
  49. '$store.state.addr.mapLevel': {
  50. handler(val) {
  51. console.log(val);
  52. if (val === 'city') {
  53. // console.log('aowfk');
  54. let _this = this;
  55. this.jumpDistrict();
  56. // setTimeout(() => {
  57. // console.log('321');
  58. // _this.jumpDistrict();
  59. // }, 800);
  60. }
  61. }
  62. }
  63. },
  64. methods: {
  65. ...mapMutations([
  66. 'changeSelectCity',
  67. 'changeSelectDistrict',
  68. 'changeSelectStreet'
  69. ]),
  70. jumpMap(item) {
  71. this.alarData = item;
  72. this.vuexCityList.forEach((element) => {
  73. if (item.cityId === element.areaId) {
  74. this.changeSelectCity({
  75. value: element.areaCode,
  76. label: item.cityName,
  77. areaId: element.areaId
  78. });
  79. console.log(element.areaCode.substring(0, 6));
  80. console.log(item.cityName);
  81. this.$store.dispatch('searchArea', {
  82. parentId: element.areaCode.substring(0, 6),
  83. name: item.cityName,
  84. mapLevel: 'city'
  85. });
  86. }
  87. });
  88. },
  89. jumpDistrict() {
  90. if (this.vuexDistrictList) {
  91. this.vuexDistrictList.forEach((element) => {
  92. if (this.alarData.countyId === element.areaId) {
  93. this.changeSelectDistrict({
  94. value: element.areaCode,
  95. label: this.alarData.cityName,
  96. areaId: element.areaId
  97. });
  98. this.$store.dispatch('searchArea', {
  99. parentId: element.areaCode.substring(0, 6),
  100. name: element.areaName,
  101. mapLevel: 'district'
  102. });
  103. }
  104. });
  105. }
  106. },
  107. ScrollUp() {
  108. this.intNum = setInterval(() => {
  109. this.animate = true; // 向上滚动的时候需要添加css3过渡动画
  110. setTimeout(() => {
  111. this.data.push(this.data[0]); // 将数组的第一个元素添加到数组的
  112. this.data.shift(); //删除数组的第一个元素
  113. this.animate = false;
  114. }, 500);
  115. }, 5000);
  116. },
  117. //鼠标移上去停止
  118. Stop() {
  119. clearInterval(this.intNum);
  120. },
  121. Up() {
  122. this.ScrollUp();
  123. }
  124. }
  125. };
  126. </script>
  127. <style lang='scss' scoped>
  128. .new-list {
  129. // line-height: 28px;
  130. transition: top 0.5s;
  131. }
  132. .anim {
  133. transition: all 0.5s;
  134. margin-top: calc(var(--h) * -1px); //高度等于行高
  135. }
  136. .alarm-wrap {
  137. pointer-events: none;
  138. & > * {
  139. pointer-events: auto;
  140. }
  141. position: fixed;
  142. left: 0;
  143. right: 0;
  144. top: calc(var(--header-height) + 34px + 50px);
  145. }
  146. .alarm {
  147. position: relative;
  148. width: 32vw;
  149. margin: 0 auto;
  150. transform: translateX(10%);
  151. border: 1px solid rgba(186, 25, 25, 0.17);
  152. height: 2.998501rem;
  153. background: rgba(186, 25, 25, 0.17);
  154. backdrop-filter: blur(6px);
  155. &::before {
  156. position: absolute;
  157. top: 0;
  158. left: 0;
  159. content: '';
  160. width: 10px;
  161. height: 10px;
  162. border-top: 2px solid #f33c52;
  163. border-left: 2px solid #f33c52;
  164. }
  165. &::after {
  166. position: absolute;
  167. top: 0;
  168. right: 0;
  169. content: '';
  170. width: 10px;
  171. height: 10px;
  172. border-top: 2px solid #f33c52;
  173. border-right: 2px solid #f33c52;
  174. }
  175. .alarm-con {
  176. position: absolute;
  177. left: 0;
  178. bottom: 0;
  179. width: 100%;
  180. height: 100%;
  181. img {
  182. width: 100px;
  183. border-radius: unset;
  184. cursor: default;
  185. pointer-events: auto;
  186. animation-name: imageAnimation;
  187. animation-iteration-count: infinite;
  188. animation-timing-function: linear;
  189. animation-duration: 2s;
  190. animation-delay: 0s;
  191. -webkit-user-drag: none;
  192. filter: brightness(120%);
  193. }
  194. &::before {
  195. position: absolute;
  196. bottom: 0;
  197. left: 0;
  198. content: '';
  199. width: 10px;
  200. height: 10px;
  201. border-bottom: 2px solid #f33c52;
  202. border-left: 2px solid #f33c52;
  203. }
  204. &::after {
  205. position: absolute;
  206. bottom: 0;
  207. right: 0;
  208. content: '';
  209. width: 10px;
  210. height: 10px;
  211. border-bottom: 2px solid #f33c52;
  212. border-right: 2px solid #f33c52;
  213. }
  214. }
  215. }
  216. @keyframes imageAnimation {
  217. 0% {
  218. opacity: 1;
  219. transform: none;
  220. }
  221. 50% {
  222. opacity: 0.3;
  223. transform: none;
  224. }
  225. 100% {
  226. opacity: 1;
  227. transform: none;
  228. }
  229. }
  230. .g-container {
  231. width: 100%;
  232. // margin: auto;
  233. height: calc(var(--h) * 1px);
  234. line-height: calc(var(--h) * 1px);
  235. // font-size: 20px;
  236. background: transparent;
  237. color: #fff;
  238. overflow: hidden;
  239. }
  240. ul {
  241. display: flex;
  242. flex-wrap: nowrap;
  243. flex-direction: column;
  244. margin: 0;
  245. padding: 0;
  246. }
  247. ul li {
  248. flex-shrink: 0;
  249. width: 100%;
  250. padding-left: 10px;
  251. box-sizing: border-box;
  252. list-style: none;
  253. margin: 0;
  254. padding: 0;
  255. }
  256. ul {
  257. display: flex;
  258. flex-wrap: nowrap;
  259. flex-direction: column;
  260. }
  261. ul li {
  262. flex-shrink: 0;
  263. width: 100%;
  264. // padding-left: 10px;
  265. box-sizing: border-box;
  266. text-align: left;
  267. overflow: hidden;
  268. text-overflow: ellipsis;
  269. font-size: 15px;
  270. }
  271. ul {
  272. animation: move calc(var(--speed) * var(--s)) steps(var(--s)) infinite;
  273. }
  274. ul li {
  275. white-space: nowrap;
  276. cursor: pointer;
  277. animation: liMove calc(var(--speed)) infinite;
  278. }
  279. // @keyframes move {
  280. // 0% {
  281. // transform: translate(0, 0);
  282. // }
  283. // 100% {
  284. // transform: translate(0, calc(var(--s) * var(--h) * -1px));
  285. // }
  286. // }
  287. // @keyframes liMove {
  288. // 0% {
  289. // transform: translate(0, 0);
  290. // }
  291. // 60%,
  292. // 100% {
  293. // transform: translate(0, calc(var(--h) * -1px));
  294. // }
  295. // }
  296. @media only screen and (max-width: 1200px) {
  297. .alarm {
  298. width: 35vw;
  299. ul {
  300. li {
  301. font-size: 14px;
  302. }
  303. }
  304. }
  305. }
  306. </style>