centerAnalyse.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. <template>
  2. <div class="center_analyse">
  3. <!-- 靖安进出人流区域 -->
  4. <div class="center_analyse_left">
  5. <div class="left_title">
  6. <div class="title_name">靖安进出人流</div>
  7. <div class="title_detail" @click="morePeopleDetail">
  8. <div>查看详情</div>
  9. <div class="title_icon"></div>
  10. </div>
  11. </div>
  12. <div class="left_info">
  13. <div class="info_box">
  14. <div class="now">实时(人次)</div>
  15. <div class="box">
  16. <div class="num" ref="realDom">{{ realValue }}</div>
  17. </div>
  18. </div>
  19. <div class="info_box">
  20. <div class="now">累计(人次)</div>
  21. <div class="box">
  22. <div class="num" ref="addDom">{{ addValue }}</div>
  23. </div>
  24. </div>
  25. </div>
  26. </div>
  27. <!-- 公告区域 -->
  28. <div class="center_analyse_center">
  29. <div class="msg">
  30. <div class="msg_title">公告</div>
  31. <div class="msg_more" @click="handleMoreNews">查看更多</div>
  32. </div>
  33. <div class="info">
  34. <div class="info_icon"></div>
  35. <div class="info_detail">
  36. <div class="marquee" ref="marqueeDom">
  37. {{ noticeContent }}
  38. </div>
  39. </div>
  40. <div class="info_time">{{ noticeTime }}</div>
  41. </div>
  42. </div>
  43. <!-- 靖安景区人流区域 -->
  44. <div class="center_analyse_right">
  45. <div class="right_title">
  46. <div class="title_name">靖安景区人流</div>
  47. <div class="title_detail" @click="handleMoreScenic">
  48. <div class="title_icon"></div>
  49. <div>查看详情</div>
  50. </div>
  51. </div>
  52. <div class="right_info">
  53. <div class="info_box">
  54. <div class="now">累计(人次)</div>
  55. <div class="box">
  56. <div class="num" ref="addDom2">{{ addValue2 }}</div>
  57. </div>
  58. </div>
  59. <div class="info_box">
  60. <div class="now">实时(人次)</div>
  61. <div class="box">
  62. <div class="num" ref="realDom2">{{ realValue2 }}</div>
  63. </div>
  64. </div>
  65. </div>
  66. </div>
  67. <!-- 底部线条区域 -->
  68. <div class="bottom_line"></div>
  69. <!-- 靖安进出人流查看详情弹窗区域 -->
  70. <Transition name="fade">
  71. <PeopleDetailDialog
  72. v-if="showPeopleDetail"
  73. @changeShowClosePeople="changeShowClosePeople"
  74. />
  75. </Transition>
  76. <!-- 新闻列表弹窗区域 -->
  77. <Transition name="fade">
  78. <NewsListDialog v-if="showNewsList" @changeShowClose="changeShowClose" />
  79. </Transition>
  80. <!-- 靖安景区人流查看详情弹窗区域 -->
  81. <Transition name="fade">
  82. <ScenicDetailDialog
  83. v-if="showScenicDetail"
  84. @changeShowCloseScenic="changeShowCloseScenic"
  85. />
  86. </Transition>
  87. </div>
  88. </template>
  89. <script setup lang="ts">
  90. import { ref, onMounted, nextTick, onUnmounted } from "vue";
  91. import NewsListDialog from "./newsListDialog.vue";
  92. import ScenicDetailDialog from "./scenicDetailDialog.vue";
  93. import PeopleDetailDialog from "./peopleDetailDialog.vue";
  94. import { countUpNum } from "@/utils/countUpNum.ts";
  95. // 引入新闻相关的接口
  96. import { reqGetNewsList } from "@/api/news/index";
  97. // 引入路口相关的接口
  98. import { reqAllJtNumByDay, reqAllJtNumByTotal } from "@/api/junction/index";
  99. // 引入景区相关的接口
  100. import { reqGetAllNumByReal, reqGetAllNumByAdd } from "@/api/scenic/index";
  101. // 进出人流实时Dom元素
  102. const realDom = ref();
  103. // 进出人流实时数据
  104. const realValue = ref<number>(0);
  105. // 进出人流累计Dom元素
  106. const addDom = ref();
  107. // 进出人流累计数据
  108. const addValue = ref<number>(0);
  109. // 景区人流实时Dom元素
  110. const realDom2 = ref();
  111. // 景区人流实时数据
  112. const realValue2 = ref<number>(0);
  113. // 景区人流累计Dom元素
  114. const addDom2 = ref();
  115. // 景区人流累计数据
  116. const addValue2 = ref<number>(0);
  117. // 靖安进出人流查看详情弹窗显示隐藏控制
  118. const showPeopleDetail = ref<boolean>(false);
  119. // 新闻列表弹窗显示隐藏控制
  120. const showNewsList = ref<boolean>(false);
  121. // 靖安景区人流查看详情弹窗显示隐藏控制
  122. const showScenicDetail = ref<boolean>(false);
  123. // 公告内容
  124. const noticeContent = ref("");
  125. // 公告时间
  126. const noticeTime = ref("");
  127. // 滚动DOM元素
  128. const marqueeDom = ref();
  129. // 完成动画需要的时间
  130. const marqueeTime = ref();
  131. // 定时器标识
  132. const timer = ref();
  133. onMounted(() => {
  134. // 获取所有路口当日人数
  135. getAllJtNumByDay(true);
  136. // 获取所有路口累计人数
  137. getAllJtNumByTotal(true);
  138. // 获取公告数据
  139. getNotice();
  140. // 获取所有景区当日人数
  141. getAllNumByReal(true);
  142. // 获取所有景区累计人数
  143. getAllNumByAdd(true);
  144. // 每10秒刷新数据
  145. timer.value = setInterval(() => {
  146. getAllJtNumByDay(false);
  147. getAllJtNumByTotal(false);
  148. getNotice();
  149. getAllNumByReal(false);
  150. getAllNumByAdd(false);
  151. }, 10000);
  152. });
  153. onUnmounted(() => {
  154. // 页面卸载时清除定时器
  155. clearInterval(timer.value);
  156. });
  157. // 获取所有路口当日人数
  158. const getAllJtNumByDay = async (flag: boolean) => {
  159. const res = await reqAllJtNumByDay();
  160. // console.log(res);
  161. realValue.value = res.data[0].num;
  162. // 让数字跳动
  163. if (flag) {
  164. countUpNum(realDom.value, realValue.value);
  165. }
  166. };
  167. // 获取所有路口累计人数
  168. const getAllJtNumByTotal = async (flag: boolean) => {
  169. const res = await reqAllJtNumByTotal();
  170. // console.log(res);
  171. addValue.value = res.data[0].num;
  172. // 让数字跳动
  173. if (flag) {
  174. countUpNum(addDom.value, addValue.value);
  175. }
  176. };
  177. // 获取公告数据
  178. const getNotice = async () => {
  179. const res = await reqGetNewsList({
  180. curPage: 1,
  181. pageSize: 1,
  182. });
  183. // console.log(res);
  184. if (res.data.list.length) {
  185. // 公告内容
  186. noticeContent.value = res.data.list[0].content;
  187. // 公告时间
  188. noticeTime.value = res.data.list[0].publishTime;
  189. nextTick(() => {
  190. // 滚动速度,数字越小速度越慢
  191. const step = 100;
  192. // 计算出完成动画需要的时间
  193. marqueeTime.value = marqueeDom.value.offsetWidth / step + "s";
  194. });
  195. }
  196. };
  197. // 获取所有景区当日人数
  198. const getAllNumByReal = async (flag: boolean) => {
  199. const res = await reqGetAllNumByReal();
  200. // console.log(res);
  201. realValue2.value = res.data.num * 1;
  202. // 让数字跳动
  203. if (flag) {
  204. countUpNum(realDom2.value, realValue2.value);
  205. }
  206. };
  207. // 获取所有景区累计人数
  208. const getAllNumByAdd = async (flag: boolean) => {
  209. const res = await reqGetAllNumByAdd();
  210. // console.log(res);
  211. addValue2.value = res.data.num * 1;
  212. // 让数字跳动
  213. if (flag) {
  214. countUpNum(addDom2.value, addValue2.value);
  215. }
  216. };
  217. // 点击靖安进出人流查看详情按钮回调
  218. const morePeopleDetail = () => {
  219. showPeopleDetail.value = true;
  220. };
  221. // 公告区域点击查看更多按钮回调
  222. const handleMoreNews = () => {
  223. showNewsList.value = true;
  224. };
  225. // 点击靖安景区人流查看详情按钮回调
  226. const handleMoreScenic = () => {
  227. showScenicDetail.value = true;
  228. };
  229. // 子组件触发的自定义事件
  230. const changeShowClosePeople = (data: boolean) => {
  231. showPeopleDetail.value = data;
  232. };
  233. const changeShowClose = (data: boolean) => {
  234. showNewsList.value = data;
  235. };
  236. const changeShowCloseScenic = (data: boolean) => {
  237. showScenicDetail.value = data;
  238. };
  239. </script>
  240. <style lang="scss" scoped>
  241. .center_analyse {
  242. position: relative;
  243. display: flex;
  244. justify-content: space-evenly;
  245. margin-top: 103px;
  246. width: 4019px;
  247. height: 160px;
  248. color: #fff;
  249. background-image: url(@/assets/images/analyse-center-background.png);
  250. background-size: 100% 100%;
  251. .center_analyse_left {
  252. margin-top: -33px;
  253. width: 1140px;
  254. height: 255px;
  255. .left_title {
  256. display: flex;
  257. justify-content: space-between;
  258. width: 1140px;
  259. height: 61px;
  260. background-image: url(@/assets/images/analyse-center-title.png);
  261. background-size: 100% 100%;
  262. .title_name {
  263. margin-left: 55px;
  264. font-size: 31.5px;
  265. font-weight: bold;
  266. }
  267. .title_detail {
  268. display: flex;
  269. margin-left: auto;
  270. color: #a8d5ff;
  271. font-size: 26px;
  272. cursor: pointer;
  273. .title_icon {
  274. margin-top: -5px;
  275. margin-left: 23px;
  276. width: 39px;
  277. height: 39px;
  278. background-image: url(@/assets/images/right.png);
  279. background-size: 100% 100%;
  280. }
  281. }
  282. }
  283. .left_info {
  284. display: flex;
  285. justify-content: space-between;
  286. width: 1140px;
  287. height: 194px;
  288. .info_box {
  289. width: 543px;
  290. height: 194px;
  291. .now {
  292. display: flex;
  293. align-items: center;
  294. width: 543px;
  295. height: 92px;
  296. font-size: 24px;
  297. }
  298. .box {
  299. display: flex;
  300. justify-content: space-between;
  301. align-items: center;
  302. padding: 0 31px;
  303. width: 543px;
  304. height: 102px;
  305. font-weight: bold;
  306. background-color: rgba($color: #000000, $alpha: 0.3);
  307. .num {
  308. font-size: 50px;
  309. }
  310. }
  311. }
  312. }
  313. }
  314. .center_analyse_center {
  315. width: 1079px;
  316. height: 176px;
  317. .msg {
  318. display: flex;
  319. justify-content: space-between;
  320. align-items: center;
  321. width: 1079px;
  322. height: 88px;
  323. .msg_title {
  324. font-size: 32px;
  325. }
  326. .msg_more {
  327. font-size: 26px;
  328. color: #a8d5ff;
  329. cursor: pointer;
  330. }
  331. }
  332. .info {
  333. display: flex;
  334. justify-content: space-between;
  335. align-items: center;
  336. padding: 0 23px 0 40px;
  337. width: 1079px;
  338. height: 88px;
  339. background-image: url(@/assets/images/msg-background.png);
  340. background-size: 100% 100%;
  341. .info_icon {
  342. width: 51px;
  343. height: 51px;
  344. background-image: url(@/assets/images/msg-icon.png);
  345. background-size: 100% 100%;
  346. }
  347. .info_detail {
  348. width: 598px;
  349. font-size: 24px;
  350. overflow: hidden;
  351. .marquee {
  352. float: left;
  353. white-space: nowrap;
  354. animation: marqueeLeft v-bind(marqueeTime) 0.5s linear infinite;
  355. }
  356. }
  357. .info_time {
  358. font-size: 20px;
  359. }
  360. }
  361. }
  362. .center_analyse_right {
  363. margin-top: -33px;
  364. width: 1148px;
  365. height: 236px;
  366. .right_title {
  367. display: flex;
  368. justify-content: space-between;
  369. width: 1140px;
  370. height: 61px;
  371. background-image: url(@/assets/images/analyse-center-title.png);
  372. background-size: 100% 100%;
  373. transform: rotateY(180deg);
  374. .title_name {
  375. margin-left: 55px;
  376. font-size: 31.5px;
  377. font-weight: bold;
  378. transform: rotateY(180deg);
  379. }
  380. .title_detail {
  381. display: flex;
  382. color: #a8d5ff;
  383. font-size: 26px;
  384. cursor: pointer;
  385. transform: rotateY(180deg);
  386. .title_icon {
  387. margin-top: -5px;
  388. margin-right: 23px;
  389. width: 39px;
  390. height: 39px;
  391. background-image: url(@/assets/images/right.png);
  392. background-size: 100% 100%;
  393. transform: rotateY(180deg);
  394. }
  395. }
  396. }
  397. .right_info {
  398. display: flex;
  399. justify-content: space-between;
  400. width: 1140px;
  401. height: 194px;
  402. .info_box {
  403. width: 543px;
  404. height: 194px;
  405. .now {
  406. display: flex;
  407. justify-content: flex-end;
  408. align-items: center;
  409. width: 543px;
  410. height: 92px;
  411. font-size: 24px;
  412. }
  413. .box {
  414. display: flex;
  415. justify-content: flex-end;
  416. align-items: center;
  417. padding: 0 31px;
  418. width: 543px;
  419. height: 102px;
  420. font-weight: bold;
  421. background-color: rgba($color: #000000, $alpha: 0.3);
  422. .num {
  423. font-size: 50px;
  424. }
  425. }
  426. }
  427. }
  428. }
  429. .bottom_line {
  430. position: absolute;
  431. top: 200px;
  432. left: 30px;
  433. width: 4023px;
  434. height: 72px;
  435. background-image: url(@/assets/images/analyse-center-line.png);
  436. background-size: 100% 100%;
  437. }
  438. }
  439. </style>