DeviceCard.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <view class="device-card" @click="handleClick">
  3. <view class="device-card__status">
  4. <image
  5. class="img"
  6. :src="dataSource.devStatus == '1' ? successImg : errorImg"
  7. />
  8. <view
  9. class="status-text"
  10. :class="{ offline: dataSource.devStatus != '1' }"
  11. >{{ dataSource.devStatusName || '' }}</view
  12. >
  13. </view>
  14. <view class="device-card__header">
  15. <view class="device-card__title u-line-1">
  16. <view class="name">{{ dataSource.devName || '' }}</view>
  17. <view class="tips">{{ dataSource.devCode || '' }}</view>
  18. </view>
  19. </view>
  20. <view class="device-card__body">
  21. <view class="device-card__row">
  22. <view class="device-card__label">上报时间</view>
  23. <view class="device-card__value">{{ dataSource.devUpdateddate }}</view>
  24. </view>
  25. <view class="device-card__row">
  26. <view class="device-card__label">设备位置</view>
  27. <view class="device-card__value">{{
  28. `${dataSource.devProvincealign || dataSource.devProvince || ''} ${
  29. dataSource.devCityalign || dataSource.devCity || ''
  30. } ${dataSource.devDistrictalign || dataSource.devDistrict || ''}`
  31. }}</view>
  32. </view>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. export default {
  38. name: 'DeviceCard',
  39. props: {
  40. dataSource: {
  41. type: Object,
  42. default() {
  43. return {};
  44. },
  45. },
  46. },
  47. data() {
  48. return {
  49. successImg:
  50. 'https://webstaticimg.oss-cn-hangzhou.aliyuncs.com/bigdata_app/image/zhongshui/success.png',
  51. errorImg:
  52. 'https://webstaticimg.oss-cn-hangzhou.aliyuncs.com/bigdata_app/image/zhongshui/error.png',
  53. };
  54. },
  55. methods: {
  56. handleClick() {},
  57. },
  58. };
  59. </script>
  60. <style lang="scss" scoped>
  61. .device-card {
  62. background: linear-gradient(180deg, #8ae4c93d 0%, #14a47800 25.54%), #fff;
  63. position: relative;
  64. padding: 28rpx;
  65. border-radius: 16rpx;
  66. background-color: #fff;
  67. margin-bottom: 32rpx;
  68. margin: 0 auto;
  69. &__status {
  70. position: absolute;
  71. right: 0;
  72. top: 0;
  73. width: 150rpx;
  74. height: 56rpx;
  75. display: flex;
  76. align-items: center;
  77. justify-content: center;
  78. .img {
  79. position: absolute;
  80. width: 100%;
  81. height: 100%;
  82. right: 0;
  83. top: 0;
  84. overflow: hidden;
  85. }
  86. .status-text {
  87. font-size: 28rpx;
  88. color: #14a478;
  89. &.online {
  90. color: #14a478;
  91. }
  92. &.offline {
  93. color: #ff3546;
  94. }
  95. }
  96. }
  97. &__header {
  98. margin-bottom: 18rpx;
  99. }
  100. &__title {
  101. align-items: center;
  102. line-height: 48rpx;
  103. display: flex !important;
  104. .name {
  105. width: 140rpx;
  106. font-size: 32rpx;
  107. color: #042118;
  108. margin-right: 32rpx;
  109. // 超出隐藏
  110. white-space: nowrap;
  111. overflow: hidden;
  112. text-overflow: ellipsis;
  113. text-align: left;
  114. font-family: 'Source Han Sans CN VF';
  115. font-weight: 700;
  116. }
  117. .tips {
  118. width: 410rpx;
  119. font-size: 32rpx;
  120. color: #687a74;
  121. // 超出隐藏
  122. white-space: nowrap;
  123. overflow: hidden;
  124. text-overflow: ellipsis;
  125. text-align: left;
  126. }
  127. }
  128. &__body {
  129. padding: 16rpx 0;
  130. background-color: #fff;
  131. border-radius: 12rpx;
  132. }
  133. &__row {
  134. display: flex;
  135. align-items: center;
  136. margin-bottom: 16rpx;
  137. &:last-child {
  138. margin-bottom: 0;
  139. }
  140. }
  141. &__label {
  142. width: 140rpx;
  143. color: #9ba6a3;
  144. text-align: left;
  145. margin-right: 32rpx;
  146. }
  147. &__value {
  148. width: 470rpx;
  149. text-align: left;
  150. white-space: nowrap;
  151. overflow: hidden;
  152. text-overflow: ellipsis;
  153. }
  154. }
  155. </style>