deviceList.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <template>
  2. <view class="container">
  3. <view style="height: 0vh;place-items: center;display: grid;">
  4. <image style="height: 3vh;width: 15vh;margin-top: 5vh;top: 3vh;"
  5. src="../../static/images/new/starts/login/backImg2.png"></image>
  6. <text @click="clickRight()" style="color: #ffffff;font-size: 15px;margin: 0 0 0 31vh;font-weight: bold;">· · ·</text>
  7. <view>
  8. <uni-drawer @change="changeDrawer" style="top:20vh;height: 23vh" ref="showRight" mode="right"
  9. :mask-click="true">
  10. <scroll-view style="background: linear-gradient(#000000, #5a5a58);font-size: 20px;" scroll-y="true">
  11. <view class="prop-item" @click="handleLogout()">
  12. <!-- <view class="prop-item-image">
  13. <image :src="imgUrl+'/logout.png'" style="width: 30%;height:100%;" />
  14. </view> -->
  15. <view class="prop-item-right">{{i18('退出登录')}}</view>
  16. <view class="prop-item-left">
  17. <uni-icons type="forward" color="lightgray" size="16"></uni-icons>
  18. </view>
  19. </view>
  20. <u-divider/>
  21. <view class="prop-item" @click="skip(2)">
  22. <!-- <view class="prop-item-image">
  23. <image :src="imgUrl+'/logout.png'" style="width: 30%;height:100%;" />
  24. </view> -->
  25. <view class="prop-item-right">{{i18('关于我们')}}</view>
  26. <view class="prop-item-left">
  27. <uni-icons type="forward" color="lightgray" size="16"></uni-icons>
  28. </view>
  29. </view>
  30. <u-divider/>
  31. <view class="prop-item" @click="skip(3)">
  32. <!-- <view class="prop-item-image">
  33. <image :src="imgUrl+'/logout.png'" style="width: 30%;height:100%;" />
  34. </view> -->
  35. <view class="prop-item-right">{{i18('帮助')}}</view>
  36. <view class="prop-item-left">
  37. <uni-icons type="forward" color="lightgray" size="16"></uni-icons>
  38. </view>
  39. </view>
  40. <u-divider/>
  41. </scroll-view>
  42. </uni-drawer>
  43. </view>
  44. </view>
  45. <view class="list-item">
  46. <view class="item" v-for="item in chargeList" :key="item.id">
  47. <view class="item-header">
  48. <view class="item-title">
  49. {{i18('设备编号')}}:{{ item.qrcode }}
  50. </view>
  51. <view class="item-status">
  52. <uni-tag type="success" :text="i18('在线中')" v-if="item.status === 1"></uni-tag>
  53. <uni-tag type="default" :text="i18('已离线')" v-if="item.status === 0"></uni-tag>
  54. </view>
  55. </view>
  56. <view class="item-body">
  57. <view style="font-size: 12px; margin: 5px 0;position: relative">
  58. <view class="item-detail-btn" @click.stop="unbind(item.qrcode)">
  59. {{i18('解绑设备')}}
  60. </view>
  61. </view>
  62. </view>
  63. <view class="item-body" style ="height: 10vh;line-height: 10vh">
  64. <view style="font-size: 12px; margin: 5px 0;position: relative">
  65. {{i18('创建时间')}}:{{ item.createTime }}
  66. <view class="item-detail-btn" @click="detail(item)">
  67. {{i18('设备控制')}}
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. </template>
  75. <script>
  76. import { deviceList,unBind } from '@/api/device/device.js';
  77. import i18 from '@/utils/i18.js'
  78. export default {
  79. data() {
  80. return {
  81. startText:"more",
  82. search:{
  83. pageNum:1,
  84. pageSize:6,
  85. reasonable:true,
  86. },
  87. contentText: {
  88. contentdown: i18('点击查看更多'),
  89. contentrefresh: i18('加载中'),
  90. contentnomore: i18('没有更多'),
  91. },
  92. chargeList: [],
  93. clickRightTag: 0
  94. };
  95. },
  96. onShow(){
  97. uni.setNavigationBarTitle({
  98. title: this.$t('page.deviceList')
  99. })
  100. },
  101. methods: {
  102. changeDrawer(event) {
  103. if (event) {
  104. // 抽屉打开时的逻辑
  105. this.clickRightTag = 1
  106. } else {
  107. // 抽屉关闭时的逻辑
  108. this.clickRightTag = 0
  109. }
  110. },
  111. //自定义头右操作函数
  112. clickRight() {
  113. //打开抽屉
  114. if (this.clickRightTag == 0) {
  115. this.$refs.showRight.open();
  116. this.clickRightTag = 1
  117. } else {
  118. this.$refs.showRight.close()
  119. this.clickRightTag = 0
  120. }
  121. },
  122. unbind(qrcode){
  123. let self = this;
  124. this.$modal.confirm("确认解绑该设备?").then(res=>{
  125. unBind(qrcode).then(res=>{
  126. console.log('?>>>'+JSON.stringify(res))
  127. if(res.data){
  128. self.deviceList();
  129. }else{
  130. this.$modal.showToast("Device is offline.");
  131. }
  132. });
  133. })
  134. },
  135. i18(text){
  136. return i18(text)
  137. },
  138. getMore(){
  139. this.search.pageNum++;
  140. this.deviceList();
  141. },
  142. async deviceList() {
  143. deviceList().then(res=>{
  144. this.startText = "more"
  145. this.chargeList = res.data;
  146. if(this.chargeList.length == 1 && this.chargeList[0] == 1){
  147. this.detail(this.chargeList[0])
  148. }
  149. })
  150. },
  151. detail(item){
  152. if(item.status == 0){
  153. this.$modal.showToast("Device is offline.");
  154. return;
  155. }
  156. let qrcode = item.qrcode;
  157. let imei = item.imei;
  158. let ccid = item.ccid;
  159. uni.navigateTo({
  160. url: '/pages/weitiandi/device/status?qrcode='+qrcode+'&id='+imei+'&ccid='+ccid
  161. });
  162. },
  163. },
  164. created() {
  165. this.deviceList();
  166. },
  167. };
  168. </script>
  169. <style>
  170. .container {
  171. background-image: url('../../static/images/new/starts/bg1.jpg');
  172. background-size: cover;
  173. background-repeat: no-repeat;
  174. inset: 0;
  175. position: absolute;
  176. }
  177. .list-item {
  178. margin: 0vw;
  179. margin-top: 15vh;
  180. }
  181. .item {
  182. color: aliceblue;
  183. box-shadow: 0px 5px 27px 0px rgba(94, 94, 94, 0.4);
  184. border-radius: 4px;
  185. background: linear-gradient(#565656, #050609);
  186. margin: 4vw;
  187. padding: 4vw;
  188. }
  189. .item-title {
  190. display: inline-block;
  191. float: left;
  192. }
  193. .item-status {
  194. display: inline-block;
  195. float: right;
  196. }
  197. .item-header {
  198. border-bottom: 1px solid lightgray;
  199. height: 4vh;
  200. font-size: 12px;
  201. }
  202. .item-body {
  203. padding-top: 4vw;
  204. line-height: 3vh;
  205. }
  206. .item-time {
  207. color: #545454;
  208. font-size: 12px;
  209. margin-bottom: 4px
  210. }
  211. .item-detail-btn{
  212. position: absolute;
  213. right: 0px;
  214. top:0px;
  215. text-decoration: underline;
  216. }
  217. .prop-item {
  218. position: relative;
  219. display: flex;
  220. flex-direction: row;
  221. height: 40px;
  222. line-height: 40px;
  223. margin: 0 20rpx;
  224. }
  225. .prop-item-left {
  226. color: #BCBCBF;
  227. ;
  228. width: 30%;
  229. font-size: 14px;
  230. //margin-left: 36px;
  231. }
  232. .prop-item-image {
  233. width: 15px;
  234. height: 15px;
  235. position: absolute;
  236. left: 2vw;
  237. top: 0.5vh;
  238. }
  239. .prop-item-right {
  240. position: absolute;
  241. right: 10rpx;
  242. top: 5rpx;
  243. color: #BCBCBF;
  244. }
  245. </style>