deviceItem.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <view class="flex-row device-item" :class="{ dih164: showBtn }" :hover-class="showBtn ? 'none' : 'view-hover'" @click="goDeviceInfo">
  3. <image
  4. class="device-x1 ml32"
  5. :src="
  6. 'https://airsmart-photo1.oss-cn-shanghai.aliyuncs.com/wx/productModel/2X/' +
  7. device.ProdModel +
  8. '.png'
  9. "
  10. mode="aspectFit"
  11. />
  12. <battery :battery="device.Power" class="di-battery" :class="showBtn ? 'dimb26':'dimb62'"></battery>
  13. <view class="di-text-view" :class="showBtn ? 'dimb26':'dimb62'">
  14. <view class="flex-row di-product">
  15. <text class="gray-normal-24rpx">型号 {{ device.ProdModel }}</text>
  16. <text class="gray-normal-24rpx" :class="{ online: device.online }">{{
  17. device.online ? "在线" : "离线"
  18. }}</text>
  19. </view>
  20. <text class="black-mudium-30rpx" style="margin-bottom: 6rpx">{{
  21. device.devName
  22. }}</text>
  23. </view>
  24. <view v-if="!showBtn" class="line di-bottom-line"></view>
  25. <view class="di-right-view">
  26. <button v-if="showBtn" class="btn-mini di-release" plain='true' @click.self="releaseClick">注销设备</button>
  27. <image
  28. v-if="!showBtn"
  29. class="di-right-img"
  30. src="../../../static/common/right.svg"
  31. mode="aspectFit"
  32. />
  33. <view v-if="!showBtn && device.hasNewVer" class="di-red-point" />
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import battery from "../../battery/battery.vue";
  39. //MW-V(4G)
  40. export default {
  41. components: { battery },
  42. props: {
  43. // 设备信息的对象
  44. device: {
  45. type: Object,
  46. default: function () {
  47. return {
  48. devName: "猫王· 旅行者1号",
  49. ProdModel: "MW-V",
  50. Power: 50,
  51. };
  52. },
  53. },
  54. //是否显示右侧的注销按钮
  55. showBtn:{
  56. type:Boolean,
  57. default:false
  58. }
  59. },
  60. data: () => ({}),
  61. computed: {},
  62. methods: {
  63. //item点击
  64. goDeviceInfo() {
  65. this.$emit("onclick");
  66. },
  67. //注销按钮点击
  68. releaseClick(){
  69. this.$emit("onrelease");
  70. }
  71. },
  72. watch: {},
  73. // 组件周期函数--监听组件挂载完毕
  74. mounted() {},
  75. // 组件周期函数--监听组件激活(显示)
  76. activated() {},
  77. // 组件周期函数--监听组件停用(隐藏)
  78. deactivated() {},
  79. // 组件周期函数--监听组件销毁之前
  80. beforeDestroy() {},
  81. };
  82. </script>
  83. <style>
  84. .device-item {
  85. width: 100vw;
  86. height: 236rpx;
  87. justify-content: flex-start;
  88. align-items: center;
  89. position: relative;
  90. }
  91. .dih164{
  92. height: 164rpx
  93. }
  94. .dimb26{
  95. margin-bottom: 26rpx;
  96. }
  97. .dimb62{
  98. margin-bottom: 62rpx;
  99. }
  100. .ml32 {
  101. margin-left: 32rpx;
  102. }
  103. .di-battery {
  104. margin-left: 6rpx;
  105. align-self: flex-end;
  106. }
  107. .di-text-view {
  108. margin-left: 42rpx;
  109. align-self: flex-end;
  110. display: flex;
  111. flex-direction: column-reverse;
  112. }
  113. .di-product {
  114. width: 40vw;
  115. justify-content: space-between;
  116. }
  117. .online {
  118. color: #684bbe;
  119. }
  120. .di-bottom-line {
  121. position: absolute;
  122. bottom: 0;
  123. left: 4vw;
  124. width: 92vw;
  125. }
  126. .di-right-view {
  127. position: absolute;
  128. right: 0;
  129. height: 100%;
  130. display: flex;
  131. flex-direction: row-reverse;
  132. align-items: center;
  133. }
  134. .di-right-img {
  135. width: 13rpx;
  136. height: 21rpx;
  137. margin-right: 34rpx;
  138. }
  139. .di-red-point {
  140. width: 12rpx;
  141. height: 12rpx;
  142. background: #fb0202;
  143. border-radius: 8rpx;
  144. margin-right: 30rpx;
  145. }
  146. .di-release{
  147. background-color: #979797;
  148. color: #353535;
  149. align-self: flex-end;
  150. margin-right: 44rpx;
  151. margin-bottom: 30rpx;
  152. }
  153. </style>