deviceList.vue 7.9 KB

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