HomeView.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <div class="home">
  3. <div class="top">
  4. <div class="time"><span class="iconfont icon-riqi"></span>&nbsp;&nbsp;{{ currentTime }}</div>
  5. </div>
  6. <div class="content">
  7. <div class="left">
  8. <div class="klfx modulbox leftbox1">
  9. <KLFX />
  10. </div>
  11. <div class="xsfx modulbox leftbox2">
  12. <XSFX />
  13. </div>
  14. <div class="fqyw modulbox leftbox3">
  15. <FQYW />
  16. </div>
  17. </div>
  18. <div class="middle">
  19. <div class="cztj modulbox middlebox1">
  20. <CZTJ />
  21. </div>
  22. <div class="kyfx modulbox middlebox2">
  23. <KYFX />
  24. </div>
  25. <div class="jcpm modulbox middlebox3">
  26. <JCPM />
  27. </div>
  28. </div>
  29. <div class="right">
  30. <div class="bxcb modulbox rightbox1">
  31. <BXCBHB />
  32. </div>
  33. <div class="kcfx modulbox rightbox2">
  34. <KCFX />
  35. </div>
  36. <div class="bkfx modulbox rightbox3">
  37. <BKFX />
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. </template>
  43. <script>
  44. import KLFX from "../components/HomeChart/KLFX.vue";
  45. import XSFX from "../components/HomeChart/XSFX.vue";
  46. import FQYW from "../components/HomeChart/FQYW.vue";
  47. import CZTJ from "../components/HomeChart/CZTJ.vue";
  48. import KYFX from "../components/HomeChart/KYFX.vue";
  49. import JCPM from "../components/HomeChart/JCPM.vue";
  50. import BXCBHB from "../components/HomeChart/BXCBHB.vue";
  51. import KCFX from "../components/HomeChart/KCFX.vue";
  52. import BKFX from "../components/HomeChart/BKFX.vue"
  53. export default {
  54. name: 'HomeView',
  55. data () {
  56. return {
  57. currentTime: '',//当前时间
  58. }
  59. },
  60. mounted () {
  61. this.updateTime()//时间
  62. },
  63. beforeDestroy () {
  64. // 在组件销毁前清除定时器,避免内存泄漏
  65. clearInterval(this.timer);
  66. },
  67. methods: {
  68. //更新时间
  69. updateTime () {
  70. // 在组件挂载结束时启动定时器,每秒更新一次时间
  71. this.currentTime = this.getCurrentTime();
  72. //每秒更新一次
  73. this.timer = setInterval(() => {
  74. this.currentTime = this.getCurrentTime()
  75. }, 1000);
  76. },
  77. getCurrentTime () {
  78. const now = new Date();
  79. const year = now.getFullYear();
  80. const month = String(now.getMonth() + 1).padStart(2, "0");
  81. const day = String(now.getDate()).padStart(2, "0");
  82. const hours = String(now.getHours()).padStart(2, "0");
  83. const minutes = String(now.getMinutes()).padStart(2, "0");
  84. const seconds = String(now.getSeconds()).padStart(2, "0");
  85. return `${year}.${month}.${day} ${hours}:${minutes}:${seconds}`;
  86. }
  87. },
  88. components: {
  89. KLFX, XSFX, FQYW, CZTJ, KYFX, JCPM, BXCBHB, KCFX, BKFX
  90. }
  91. }
  92. </script>
  93. <style scoped lang="scss">
  94. .home {
  95. width: 100%;
  96. height: 100vh;
  97. color: white;
  98. padding: 1% 0 0 0;
  99. .top {
  100. display: flex;
  101. height: 7%;
  102. justify-content: flex-end;
  103. background-image: url(../assets/bargound/title.png);
  104. background-repeat: no-repeat;
  105. background-size: 100% 100%;
  106. box-sizing: border-box;
  107. .time {
  108. color: rgb(174, 201, 222);
  109. margin-right: 2%;
  110. font-size: 16px;
  111. overflow: hidden;
  112. max-width: 15%;
  113. white-space: nowrap;
  114. }
  115. }
  116. .content {
  117. width: 100%;
  118. height: 91%;
  119. display: flex;
  120. justify-content: space-evenly;
  121. .left {
  122. height: 100%;
  123. width: 32%;
  124. display: flex;
  125. flex-direction: column;
  126. justify-content: space-between;
  127. .leftbox1 {
  128. width: 100%;
  129. height: 32%;
  130. }
  131. .leftbox2 {
  132. width: 100%;
  133. height: 32%;
  134. min-height: 250px;
  135. }
  136. .leftbox3 {
  137. width: 100%;
  138. height: 32%;
  139. min-height: 150px;
  140. }
  141. }
  142. .middle {
  143. height: 100%;
  144. width: 32%;
  145. display: flex;
  146. flex-direction: column;
  147. justify-content: space-between;
  148. .middlebox1 {
  149. height: 48%;
  150. min-height: 320px;
  151. }
  152. .middlebox2 {
  153. height: 26%;
  154. min-height: 130px;
  155. }
  156. .middlebox3 {
  157. height: 22%;
  158. min-height: 150px;
  159. }
  160. }
  161. .right {
  162. height: 90vh;
  163. width: 32%;
  164. display: flex;
  165. flex-direction: column;
  166. justify-content: space-between;
  167. .rightbox1 {
  168. height: 25%;
  169. min-height: 170px;
  170. }
  171. .rightbox2 {
  172. height: 29%;
  173. min-height: 150px;
  174. }
  175. .rightbox3 {
  176. height: 42%;
  177. min-height: 280px;
  178. }
  179. }
  180. }
  181. }
  182. </style>