deviceList.vue 8.8 KB

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