NowData.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <div
  3. class="NowData"
  4. :class="[screenType==='hor' ? 'horizontalClass' : 'verticalClass verticalNowData' ]"
  5. >
  6. <div class="head-title">
  7. <span>实时数据</span>
  8. <div class="normal-explain">
  9. <span class="title-right-icon"></span>
  10. <span>正常范围</span>
  11. </div>
  12. </div>
  13. <div class="subhead-title">主动式空调,会呼吸的写字楼</div>
  14. <div class="contain">
  15. <div
  16. class="item"
  17. v-for="(item, index) in horScreenImg"
  18. :key="index"
  19. >
  20. <div class="item_content">
  21. <img
  22. :class="[screenType==='hor' ? '' : 'vert' ]"
  23. :src="item.img"
  24. alt=""
  25. >
  26. <div class="content_value">
  27. <span>{{item.value}}</span><span>{{item.unit}}</span>
  28. </div>
  29. <div class="content_name">
  30. <span>{{item.name}}</span>
  31. </div>
  32. <div
  33. class="content_level"
  34. :style="{backgroundColor: selectColor(item.value,item.id)}"
  35. :class="item.level"
  36. >
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. </template>
  43. <script>
  44. import icon_temp from '@/assets/icon_temp.png'
  45. import icon_humidity from '@/assets/icon_humidity.png'
  46. import icon_CO2 from '@/assets/icon_CO2.png'
  47. import icon_formaldehyde from '@/assets/icon_formaldehyde.png'
  48. import icon_PM2d5 from '@/assets/icon_PM2d5.png'
  49. import { selectColor } from '@/utils/publicMethod'
  50. export default {
  51. props: {
  52. screenType: {
  53. type: String,
  54. default: () => { return 'hor' } //hor 横屏 vert 竖屏
  55. }
  56. },
  57. data() {
  58. return {
  59. horScreenImg: [
  60. { id: 'temp', name: '温度', img: icon_temp, value: 24.5, unit: '℃', level: 'low' },
  61. { id: 'shidu', name: '湿度', img: icon_humidity, value: 33, unit: '%', level: 'middle' },
  62. { id: 'co2', name: 'CO2', img: icon_CO2, value: 2399, unit: 'ppm', level: 'low' },
  63. { id: 'jiaquan', name: '甲醛', img: icon_formaldehyde, value: 0.12, unit: 'mg/m³', level: 'low' },
  64. { id: 'pm25', name: 'PM2.5', img: icon_PM2d5, value: 100, unit: 'ug/m³', level: 'low' }
  65. ]
  66. }
  67. },
  68. mounted() {
  69. console.log("selectColor", selectColor);
  70. },
  71. methods: {
  72. selectColor: selectColor
  73. }
  74. }
  75. </script>
  76. <style lang="less" scoped>
  77. .NowData {
  78. &.horizontalClass {
  79. //width: 1508px;
  80. height: 498px;
  81. }
  82. .head-title {
  83. justify-content: space-between;
  84. }
  85. .title-right-icon {
  86. display: inline-block;
  87. padding: 0;
  88. width: 12px;
  89. height: 12px;
  90. margin-right: 8px;
  91. border-radius: 50%;
  92. background: rgba(126, 216, 116, 1);
  93. }
  94. .contain {
  95. display: flex;
  96. padding-top: 47px;
  97. }
  98. .item {
  99. width: calc(100% / 5);
  100. .item_content {
  101. // height: 100%;
  102. display: flex;
  103. flex-direction: column;
  104. justify-content: center;
  105. align-items: center;
  106. text-align: center;
  107. img {
  108. width: 150px;
  109. height: 150px;
  110. &.vert {
  111. width: 130px;
  112. height: 130px;
  113. }
  114. }
  115. .content_value {
  116. font-family: Persagy;
  117. font-size: 42px;
  118. font-weight: 700;
  119. margin-top: 10px;
  120. color: rgba(59, 53, 88, 1);
  121. }
  122. .content_name {
  123. margin-top: 8px;
  124. font-family: PingFang SC;
  125. font-size: 24px;
  126. font-weight: 400;
  127. line-height: 34px;
  128. }
  129. }
  130. }
  131. .content_level {
  132. margin-top: 8px;
  133. margin-right: 8px;
  134. box-sizing: border-box;
  135. width: 16px;
  136. height: 16px;
  137. border-radius: 50%;
  138. background: rgba(126, 216, 116, 1);
  139. &.middle {
  140. background: rgba(239, 214, 46, 1);
  141. }
  142. }
  143. .normal-explain {
  144. display: flex;
  145. align-items: center;
  146. font-size: 14px;
  147. }
  148. &.verticalNowData {
  149. height: 460px;
  150. .item {
  151. .item_content {
  152. .content_value {
  153. font-size: 32px;
  154. }
  155. .content_name {
  156. margin-top: 12px;
  157. font-size: 20px;
  158. }
  159. .content_level {
  160. margin-top: 12px;
  161. }
  162. }
  163. }
  164. }
  165. }
  166. </style>