DeviceCard.vue 3.2 KB

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