deviceList.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <view class="container">
  3. <view class="list-item">
  4. <view class="item" v-for="item in chargeList" :key="item.id">
  5. <view class="item-header">
  6. <view class="item-title">
  7. {{i18('设备编号')}}:{{ item.qrcode }}
  8. </view>
  9. <view class="item-status">
  10. <uni-tag type="success" :text="i18('在线中')" v-if="item.status === 1"></uni-tag>
  11. <uni-tag type="default" :text="i18('已离线')" v-if="item.status === 0"></uni-tag>
  12. </view>
  13. </view>
  14. <view class="item-body">
  15. <view style="font-size: 12px; margin: 5px 0;position: relative">
  16. <view class="item-detail-btn" @click="unbind(item.qrcode)">
  17. {{i18('解绑设备')}}
  18. </view>
  19. </view>
  20. </view>
  21. <view class="item-body" style ="height: 10vh;line-height: 10vh">
  22. <view style="font-size: 12px; margin: 5px 0;position: relative">
  23. {{i18('创建时间')}}:{{ item.createTime }}
  24. <view class="item-detail-btn" @click="detail(item)">
  25. {{i18('设备控制')}}
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import { deviceList,unBind } from '@/api/device/device.js';
  35. import i18 from '@/utils/i18.js'
  36. export default {
  37. data() {
  38. return {
  39. startText:"more",
  40. search:{
  41. pageNum:1,
  42. pageSize:6,
  43. reasonable:true,
  44. },
  45. contentText: {
  46. contentdown: i18('点击查看更多'),
  47. contentrefresh: i18('加载中'),
  48. contentnomore: i18('没有更多'),
  49. },
  50. chargeList: [],
  51. };
  52. },
  53. onShow(){
  54. uni.setNavigationBarTitle({
  55. title: this.$t('page.deviceList')
  56. })
  57. },
  58. methods: {
  59. unbind(qrcode){
  60. let self = this;
  61. this.$modal.confirm("确认解绑该设备?").then(res=>{
  62. unBind(qrcode).then(res=>{
  63. if(res.data){
  64. self.deviceList();
  65. }else{
  66. this.$modal.showToast("Device is offline.");
  67. }
  68. });
  69. })
  70. },
  71. i18(text){
  72. return i18(text)
  73. },
  74. getMore(){
  75. this.search.pageNum++;
  76. this.deviceList();
  77. },
  78. async deviceList() {
  79. deviceList().then(res=>{
  80. this.startText = "more"
  81. this.chargeList = res.data;
  82. if(this.chargeList.length == 1 && this.chargeList[0] == 1){
  83. this.detail(this.chargeList[0])
  84. }
  85. })
  86. },
  87. detail(item){
  88. if(item.status == 0){
  89. this.$modal.showToast("Device is offline.");
  90. return;
  91. }
  92. let qrcode = item.qrcode;
  93. let imei = item.imei;
  94. let ccid = item.ccid;
  95. uni.navigateTo({
  96. url: '/pages/weitiandi/device/status?qrcode='+qrcode+'&id='+imei+'&ccid='+ccid
  97. });
  98. },
  99. },
  100. created() {
  101. this.deviceList();
  102. },
  103. };
  104. </script>
  105. <style>
  106. .container {
  107. background: rgb(249, 252, 255);
  108. inset: 0;
  109. position: absolute;
  110. }
  111. .list-item {
  112. margin: 0vw;
  113. }
  114. .item {
  115. box-shadow: 0px 5px 27px 0px rgba(195, 195, 195, 0.4);
  116. border-radius: 4px;
  117. background: #FFFFFF;
  118. margin: 4vw;
  119. padding: 4vw;
  120. }
  121. .item-title {
  122. display: inline-block;
  123. float: left;
  124. }
  125. .item-status {
  126. display: inline-block;
  127. float: right;
  128. }
  129. .item-header {
  130. border-bottom: 1px solid lightgray;
  131. height: 4vh;
  132. font-size: 12px;
  133. }
  134. .item-body {
  135. padding-top: 4vw;
  136. line-height: 3vh;
  137. }
  138. .item-time {
  139. color: #545454;
  140. font-size: 12px;
  141. margin-bottom: 4px
  142. }
  143. .item-detail-btn{
  144. position: absolute;
  145. right: 0px;
  146. top:0px;
  147. text-decoration: underline;
  148. }
  149. </style>