DeviceCard.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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">设备ID</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 class="ntoNative" @tap="toNavigation">
  33. <image :src="location" class="icon"></image>
  34. </view> -->
  35. </view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. export default {
  41. name: 'DeviceCard',
  42. props: {
  43. dataSource: {
  44. type: Object,
  45. default() {
  46. return {};
  47. },
  48. },
  49. },
  50. data() {
  51. return {
  52. location:
  53. 'https://s3.hnyfwlw.com/webstaticimg/bigdata_app/image/zhongshui/location.svg',
  54. successImg:
  55. 'https://s3.hnyfwlw.com/webstaticimg/bigdata_app/image/zhongshui/success.png',
  56. errorImg:
  57. 'https://s3.hnyfwlw.com/webstaticimg/bigdata_app/image/zhongshui/error.png',
  58. };
  59. },
  60. methods: {
  61. handleClick() {},
  62. toNavigation() {
  63. this.$emit('navigation');
  64. },
  65. },
  66. };
  67. </script>
  68. <style lang="scss" scoped>
  69. .device-card {
  70. background: linear-gradient(180deg, #8ae4c93d 0%, #14a47800 25.54%), #fff;
  71. position: relative;
  72. padding: 28rpx;
  73. border-radius: 16rpx;
  74. background-color: #fff;
  75. margin-bottom: 32rpx;
  76. margin: 0 auto;
  77. &__status {
  78. position: absolute;
  79. right: 0;
  80. top: 0;
  81. width: 150rpx;
  82. height: 56rpx;
  83. display: flex;
  84. align-items: center;
  85. justify-content: center;
  86. .img {
  87. position: absolute;
  88. width: 100%;
  89. height: 100%;
  90. right: 0;
  91. top: 0;
  92. overflow: hidden;
  93. }
  94. .status-text {
  95. font-size: 28rpx;
  96. color: #14a478;
  97. &.online {
  98. color: #14a478;
  99. }
  100. &.offline {
  101. color: #ff3546;
  102. }
  103. }
  104. }
  105. &__title {
  106. align-items: center;
  107. line-height: 48rpx;
  108. display: flex !important;
  109. .name {
  110. width: 140rpx;
  111. color: #9ba6a3;
  112. margin-right: 32rpx;
  113. // 超出隐藏
  114. white-space: nowrap;
  115. overflow: hidden;
  116. text-overflow: ellipsis;
  117. text-align: left;
  118. font-family: 'Source Han Sans CN VF';
  119. }
  120. .tips {
  121. width: 410rpx;
  122. // 超出隐藏
  123. white-space: nowrap;
  124. overflow: hidden;
  125. text-overflow: ellipsis;
  126. text-align: left;
  127. }
  128. }
  129. &__body {
  130. padding: 16rpx 0;
  131. background-color: #fff;
  132. border-radius: 12rpx;
  133. }
  134. &__row {
  135. display: flex;
  136. align-items: center;
  137. margin-bottom: 16rpx;
  138. position: relative;
  139. &:last-child {
  140. margin-bottom: 0;
  141. }
  142. .ntoNative {
  143. position: absolute;
  144. right: 16rpx;
  145. width: 80rpx;
  146. height: 80rpx;
  147. display: flex;
  148. align-items: center;
  149. justify-content: flex-end;
  150. .icon {
  151. width: 30rpx;
  152. height: 30rpx;
  153. }
  154. }
  155. }
  156. &__label {
  157. width: 140rpx;
  158. color: #9ba6a3;
  159. text-align: left;
  160. margin-right: 32rpx;
  161. }
  162. &__value {
  163. width: 420rpx;
  164. text-align: left;
  165. white-space: nowrap;
  166. overflow: hidden;
  167. text-overflow: ellipsis;
  168. }
  169. }
  170. </style>