DeviceCard.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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 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://webstaticimg.oss-cn-hangzhou.aliyuncs.com/bigdata_app/image/zhongshui/location.svg',
  54. successImg:
  55. 'https://webstaticimg.oss-cn-hangzhou.aliyuncs.com/bigdata_app/image/zhongshui/success.png',
  56. errorImg:
  57. 'https://webstaticimg.oss-cn-hangzhou.aliyuncs.com/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. &__header {
  106. margin-bottom: 18rpx;
  107. }
  108. &__title {
  109. align-items: center;
  110. line-height: 48rpx;
  111. display: flex !important;
  112. .name {
  113. width: 140rpx;
  114. font-size: 32rpx;
  115. color: #042118;
  116. margin-right: 32rpx;
  117. // 超出隐藏
  118. white-space: nowrap;
  119. overflow: hidden;
  120. text-overflow: ellipsis;
  121. text-align: left;
  122. font-family: 'Source Han Sans CN VF';
  123. font-weight: 700;
  124. }
  125. .tips {
  126. width: 410rpx;
  127. font-size: 32rpx;
  128. color: #687a74;
  129. // 超出隐藏
  130. white-space: nowrap;
  131. overflow: hidden;
  132. text-overflow: ellipsis;
  133. text-align: left;
  134. }
  135. }
  136. &__body {
  137. padding: 16rpx 0;
  138. background-color: #fff;
  139. border-radius: 12rpx;
  140. }
  141. &__row {
  142. display: flex;
  143. align-items: center;
  144. margin-bottom: 16rpx;
  145. position: relative;
  146. &:last-child {
  147. margin-bottom: 0;
  148. }
  149. .ntoNative {
  150. position: absolute;
  151. right: 16rpx;
  152. width: 80rpx;
  153. height: 80rpx;
  154. display: flex;
  155. align-items: center;
  156. justify-content: flex-end;
  157. .icon {
  158. width: 30rpx;
  159. height: 30rpx;
  160. }
  161. }
  162. }
  163. &__label {
  164. width: 140rpx;
  165. color: #9ba6a3;
  166. text-align: left;
  167. margin-right: 32rpx;
  168. }
  169. &__value {
  170. width: 420rpx;
  171. text-align: left;
  172. white-space: nowrap;
  173. overflow: hidden;
  174. text-overflow: ellipsis;
  175. }
  176. }
  177. </style>