DeviceCard.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <view class="device-card__body">
  3. <view class="device-card">
  4. <view :class=" dataSource.status == 1 ?'online-status':'offline-status'">{{ dataSource.status === 1 ? '在线' : '离线' }}</view>
  5. <view class="device-card__title">设备ID</view>
  6. <view class="device-card__content">
  7. <text class="device-id-text">{{ dataSource.id }}</text>
  8. <img class="copy-icon" :src="copy" @click="copyDeviceId"/>
  9. </view>
  10. </view>
  11. <view class="device-card">
  12. <view class="device-card__title">上报时间</view>
  13. <view class="device-card__content">{{ dataSource.uptime | timeFormat()}}</view>
  14. </view>
  15. <view class="device-card">
  16. <view class="device-card__title">设备位置</view>
  17. <view class="device-card__content address">{{ dataSource.address || '-' }}</view>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. props: {
  24. dataSource: {
  25. type: Object,
  26. default: () => ({})
  27. }
  28. },
  29. data() {
  30. return {
  31. copy:'https://s3.hnyfwlw.com/webstaticimg/bigdata_app/newImg/home/copy.png',
  32. title: ''
  33. }
  34. },
  35. methods: {
  36. copyDeviceId() {
  37. uni.setClipboardData({
  38. data: this.dataSource.id,
  39. success: () => {
  40. uni.showToast({
  41. title: '复制成功',
  42. icon: 'success'
  43. })
  44. }
  45. })
  46. }
  47. }
  48. }
  49. </script>
  50. <style scoped lang="scss">
  51. .device-card__body {
  52. display: flex;
  53. padding: 16px 12px;
  54. flex-direction: column;
  55. align-items: flex-start;
  56. gap: 8px;
  57. border-radius: 8px;
  58. background: linear-gradient(180deg, #EFF 0%, #FFF 23.56%);
  59. margin-top: 34rpx;
  60. position: relative;
  61. .device-card {
  62. display: flex;
  63. gap: 16px;
  64. .device-card__title {
  65. width: 120rpx;
  66. color: #4E5969;
  67. font-size: 14px;
  68. font-style: normal;
  69. font-weight: 400;
  70. text-align: right;
  71. display: flex;
  72. align-items: center;
  73. justify-content: flex-end;
  74. }
  75. .online-status {
  76. width: 136rpx;
  77. height: 56rpx;
  78. line-height: 56rpx;
  79. position: absolute;
  80. text-align: center;
  81. top: 0;
  82. right: 0;
  83. background: url('https://s3.hnyfwlw.com/webstaticimg/bigdata_app/newImg/home/online1.png') no-repeat center center;
  84. background-size: 100% 100%;
  85. color: #0bbc58;
  86. font-family: "Source Han Sans CN VF";
  87. font-size: 28rpx;
  88. }
  89. .offline-status{
  90. width: 136rpx;
  91. height: 56rpx;
  92. line-height: 56rpx;
  93. position: absolute;
  94. text-align: center;
  95. top: 0;
  96. right: 0;
  97. background: url('https://s3.hnyfwlw.com/webstaticimg/bigdata_app/newImg/home/offline.png') no-repeat center center;
  98. background-size: 100% 100%;
  99. color: #ff3546;
  100. font-family: "Source Han Sans CN VF";
  101. font-size: 28rpx;
  102. }
  103. .device-card__content {
  104. color: #4E5969;
  105. font-size: 14px;
  106. font-style: normal;
  107. font-weight: 400;
  108. display: flex;
  109. align-items: center;
  110. gap: 8rpx;
  111. .device-id-text {
  112. flex: 1;
  113. }
  114. .copy-icon {
  115. font-family: 'iconfont';
  116. font-size: 32rpx;
  117. color: #86909C;
  118. cursor: pointer;
  119. width: 28rpx;
  120. height: 28rpx;
  121. &:active {
  122. opacity: 0.6;
  123. }
  124. }
  125. }
  126. .address {
  127. overflow: hidden;
  128. text-overflow: ellipsis;
  129. white-space: nowrap;
  130. }
  131. }
  132. }
  133. </style>