index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. <template>
  2. <view class="content">
  3. <view class="Dataview">
  4. <SubTitle title="数据概览" titleEng="DATA OVERVIEW"></SubTitle>
  5. <view class="datalist">
  6. <view class="datablcok">
  7. <view>今日换电次数</view>
  8. <view class="icon-data">
  9. <view>
  10. <image src="/static/index/icon1.png"></image>
  11. </view>
  12. <view class="number">{{dataView.todaySwap ||'0'}}</view>
  13. </view>
  14. <view class="positon p-left"></view>
  15. </view>
  16. <view class="datablcok">
  17. <view>累计换电次数</view>
  18. <view class="icon-data">
  19. <view>
  20. <image src="/static/index/icon2.png"></image>
  21. </view>
  22. <view class="number">{{dataView.totalSwap ||'0'}}</view>
  23. </view>
  24. <view class="positon p-left"></view>
  25. </view>
  26. <view class="datablcok">
  27. <view>今日告警次数</view>
  28. <view class="icon-data">
  29. <view>
  30. <image src="/static/index/icon3.png"></image>
  31. </view>
  32. <view class="number">{{dataView.todayAlarm ||'0'}}</view>
  33. </view>
  34. <view class="positon p-left"></view>
  35. </view>
  36. <view class="datablcok">
  37. <view>告警总数(次)</view>
  38. <view class="icon-data">
  39. <view>
  40. <image src="/static/index/icon4.png"></image>
  41. </view>
  42. <view class="number">{{dataView.totalAlarm ||'0'}}</view>
  43. </view>
  44. <view class="positon p-left"></view>
  45. </view>
  46. <view class="datablcok">
  47. <view>消防告警(次)</view>
  48. <view class="icon-data">
  49. <view>
  50. <image src="/static/index/icon5.png"></image>
  51. </view>
  52. <view class="number">{{dataView.fireAlarm ||'0'}}</view>
  53. </view>
  54. <view class="positon p-left"></view>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="equipment">
  59. <SubTitle title="设备状态" titleEng="DEVICE STATUS"></SubTitle>
  60. <view class="statusShow">
  61. <view class="positon p-left"></view>
  62. <view class="positon p-right"></view>
  63. <view class="positon p-b-left"></view>
  64. <view class="positon p-b-right"></view>
  65. <view class="title">
  66. <view class="first">
  67. <image src="/static/index/title-left.png"></image>
  68. </view>
  69. <view class="second">智能换电站</view>
  70. <view class="last">
  71. <image src="/static/index/title-right.png">
  72. </view>
  73. </view>
  74. <view class="line">
  75. <image src="/static/index/line.png"></image>
  76. </view>
  77. <view class="changeList">
  78. <view>
  79. <image :src="robotResult"></image>
  80. </view>
  81. <ChargerState v-for="item in stateList" :key="item.code" :chargerState="item.chargerState"></ChargerState>
  82. </view>
  83. <view class="borderList">
  84. <view></view>
  85. <view v-for="item in 8"></view>
  86. </view>
  87. <view class="batteryList">
  88. <view></view>
  89. <BatteryState v-for="item in stateList" :key="item.code" :batteryState="item.batteryState"></BatteryState>
  90. </view>
  91. </view>
  92. <view class="status-description">
  93. <view class="positon p-left"></view>
  94. <view class="positon p-right"></view>
  95. <view class="positon p-b-left"></view>
  96. <view class="positon p-b-right"></view>
  97. <view class="status-list">
  98. <view class="plc-row">
  99. <view class="plc-status">
  100. <view>
  101. <image src="/static/index/status1.png"></image>
  102. </view>
  103. <view>机器人状态</view>
  104. </view>
  105. <IndexStatus text="未就绪" color="default"></IndexStatus>
  106. <IndexStatus text="就绪" color="green"></IndexStatus>
  107. <IndexStatus text="运行中" color="orange"></IndexStatus>
  108. <IndexStatus text="完成" color="orange"></IndexStatus>
  109. <IndexStatus text="故障" color="yellow"></IndexStatus>
  110. <IndexStatus text="中止" color="pink"></IndexStatus>
  111. <IndexStatus text="离线" color="default"></IndexStatus>
  112. </view>
  113. <view class="plc-row">
  114. <view class="plc-status">
  115. <view>
  116. <image src="/static/index/status2.png"></image>
  117. </view>
  118. <view>充电机状态</view>
  119. </view>
  120. <IndexStatus text="空闲" color="green"></IndexStatus>
  121. <IndexStatus text="准备充电" color="orange"></IndexStatus>
  122. <IndexStatus text="充电中" color="orange"></IndexStatus>
  123. <IndexStatus text="充电结束" color="green"></IndexStatus>
  124. <IndexStatus text="充电失败" color="yellow"></IndexStatus>
  125. <IndexStatus text="故障" color="yellow"></IndexStatus>
  126. <IndexStatus text="离线" color="default"></IndexStatus>
  127. </view>
  128. <view class="plc-row">
  129. <view class="plc-status">
  130. <view>
  131. <image src="/static/index/status1.png"></image>
  132. </view>
  133. <view>电池状态</view>
  134. </view>
  135. <IndexStatus text="故障" color="yellow"></IndexStatus>
  136. <IndexStatus text="有电池" color="green"></IndexStatus>
  137. <IndexStatus text="无电池" color="default"></IndexStatus>
  138. </view>
  139. </view>
  140. <view class="status-img">
  141. <image src="/static/index/status-bg.png"></image>
  142. </view>
  143. </view>
  144. </view>
  145. </view>
  146. </template>
  147. <script>
  148. import ChargerState from './components/ChargerState'
  149. import BatteryState from './components/BatteryState'
  150. export default {
  151. components:{ChargerState,BatteryState},
  152. data() {
  153. return {
  154. dataView: {},
  155. robotState: 0,
  156. stateList: [],
  157. }
  158. },
  159. mounted() {
  160. this.InitWs()
  161. this.getDataView()
  162. },
  163. computed: {
  164. robotResult() {
  165. switch (this.robotState) {
  166. case 0:
  167. return '/static/index/plc-null.png'
  168. case 1:
  169. return '/static/index/plc-has.png'
  170. case 2:
  171. return '/static/index/plc-doing.png'
  172. case 3:
  173. return '/static/index/plc-doing.png'
  174. case 4:
  175. return '/static/index/plc-warn.png'
  176. case 5:
  177. return '/static/index/plc-over.png'
  178. }
  179. }
  180. },
  181. methods: {
  182. //数据概览
  183. getDataView() {
  184. this.$http.getoverview().then(res => {
  185. this.dataView = res.data
  186. })
  187. },
  188. InitWs() {
  189. if (this.ws != null) {
  190. this.ws.close()
  191. this.ws = null
  192. }
  193. if (this.timer != null) {
  194. clearInterval(this.timer)
  195. this.timer = null
  196. }
  197. let token = this.$storage.getJson('token');
  198. if (token == null) {
  199. uni.navigateTo({
  200. url: '/pages/login/index'
  201. })
  202. return false;
  203. }
  204. this.ws = uni.connectSocket({
  205. url: this.$config.web_socket_url + token,
  206. header: {
  207. 'content-type': 'application/json'
  208. },
  209. complete: () => {}
  210. })
  211. this.ws.onOpen(() => {
  212. // let msg = {
  213. // type: "subscribeExchange",
  214. // payLoad: {
  215. // exchangeNo: exchangeNo
  216. // }
  217. // }
  218. // this.ws.send({
  219. // data: JSON.stringify(msg)
  220. // })
  221. // uni.showLoading({
  222. // title: '数据加载中...'
  223. // });
  224. console.log('websocket连接成功')
  225. const wsMessage = {
  226. type: 'page',
  227. payload: 'PageIndex'
  228. }
  229. this.ws.send({
  230. data: JSON.stringify(wsMessage)
  231. })
  232. })
  233. this.ws.onMessage((res) => {
  234. let d = JSON.parse(res.data)
  235. // console.log(d)
  236. this.stateList = d.stateList
  237. this.robotState = d.robotState
  238. // uni.hideLoading()
  239. })
  240. // 监听WebSocket关闭事件
  241. this.ws.onClose(() => {
  242. console.log('WebSocket连接已关闭!');
  243. })
  244. this.ws.onError(() => {
  245. console.log("WebSocket连接错误")
  246. })
  247. if (this.timer == null) {
  248. this.timer = setInterval(() => {
  249. if (this.ws.readyState != 1) {
  250. clearInterval(this.timer)
  251. this.timer = null
  252. this.ws.close()
  253. this.InitWs()
  254. }
  255. }, 2000)
  256. }
  257. },
  258. },
  259. onLoad() {
  260. }
  261. }
  262. </script>
  263. <style lang="scss" scoped>
  264. .positon {
  265. position: absolute;
  266. width: 1px;
  267. height: 1px;
  268. background: #FFFFFF;
  269. }
  270. .p-left {
  271. left: -1px;
  272. top: -1px;
  273. }
  274. .p-right {
  275. right: -1px;
  276. top: -1px;
  277. }
  278. .p-b-left {
  279. left: -1px;
  280. bottom: -1px;
  281. }
  282. .p-b-right {
  283. right: -1px;
  284. bottom: -1px;
  285. }
  286. .content {
  287. width: 100%;
  288. display: flex;
  289. flex-direction: column;
  290. .Dataview {
  291. background-color: #111827;
  292. height: 129px;
  293. .datalist {
  294. margin: 20px;
  295. display: flex;
  296. justify-content: space-between;
  297. .datablcok {
  298. width: 180px;
  299. height: 60px;
  300. border: 1px solid #334568;
  301. color: rgba(153, 174, 197, 0.65);
  302. font-size: 12px;
  303. font-weight: 400;
  304. padding: 8px 12px;
  305. box-sizing: border-box;
  306. display: flex;
  307. flex-direction: column;
  308. position: relative;
  309. .icon-data {
  310. display: flex;
  311. margin-top: 6px;
  312. .number {
  313. font-size: 18px;
  314. font-weight: 600;
  315. color: #C7D2DF;
  316. line-height: 20px;
  317. text-indent: 5px;
  318. }
  319. image {
  320. width: 20px;
  321. height: 20px;
  322. }
  323. }
  324. }
  325. }
  326. }
  327. .equipment {
  328. display: flex;
  329. flex-direction: column;
  330. margin-top: 16px;
  331. height: 567px;
  332. overflow: hidden;
  333. background-color: #111827;
  334. .statusShow {
  335. margin: 16px 20px;
  336. height: 386px;
  337. border: 1px solid #334568;
  338. box-sizing: border-box;
  339. padding: 20px;
  340. position: relative;
  341. .title {
  342. display: flex;
  343. justify-content: space-between;
  344. align-items: center;
  345. .first {
  346. image {
  347. width: 304px;
  348. height: 70px;
  349. }
  350. }
  351. .second {
  352. width: 320px;
  353. height: 70px;
  354. background-image: url('/static/index/title.png');
  355. background-position: bottom;
  356. background-size: 100% 68px;
  357. font-weight: 600;
  358. color: #C7D2DF;
  359. font-size: 32px;
  360. letter-spacing: 1px;
  361. text-align: center;
  362. line-height: 70px;
  363. }
  364. .last {
  365. image {
  366. width: 305px;
  367. height: 70px;
  368. }
  369. }
  370. }
  371. .line {
  372. text-align: center;
  373. width: 100%;
  374. image {
  375. width: 889px;
  376. height: 56px;
  377. }
  378. }
  379. .changeList {
  380. display: flex;
  381. justify-content: space-between;
  382. margin-top: 8px;
  383. image {
  384. width: 70px;
  385. height: 70px;
  386. }
  387. }
  388. .batteryList {
  389. display: flex;
  390. justify-content: space-between;
  391. image {
  392. width: 70px;
  393. height: 70px;
  394. }
  395. view {
  396. width: 70px;
  397. height: 70px;
  398. }
  399. view:first-child {
  400. visibility: hidden;
  401. }
  402. }
  403. .borderList {
  404. margin: 16px 0px;
  405. display: flex;
  406. justify-content: space-between;
  407. view {
  408. width: 70px;
  409. height: 28px;
  410. position: relative;
  411. }
  412. view:before {
  413. content: "";
  414. width: 0px;
  415. height: 28px;
  416. opacity: 1;
  417. border: 1px solid #334568;
  418. position: absolute;
  419. left: 50%;
  420. }
  421. view:first-child {
  422. visibility: hidden;
  423. }
  424. }
  425. }
  426. .status-description {
  427. border: 1px solid #334568;
  428. box-sizing: border-box;
  429. text-align: center;
  430. margin: 0px 20px;
  431. padding: 12px 16px;
  432. display: flex;
  433. justify-content: space-between;
  434. position: relative;
  435. .status-list {
  436. flex: 1;
  437. font-size: 12px;
  438. font-weight: 400;
  439. color: #7681AD;
  440. display: flex;
  441. height: 75px;
  442. justify-content: space-between;
  443. flex-direction: column;
  444. image {
  445. width: 12px;
  446. height: 12px;
  447. }
  448. .plc-row {
  449. flex: 1;
  450. display: flex;
  451. }
  452. .plc-status {
  453. display: flex;
  454. height: 20px;
  455. line-height: 16px;
  456. align-items: center;
  457. width: 80px;
  458. image {
  459. margin-right: 4px;
  460. margin-top: 4px;
  461. }
  462. margin-right: 15px;
  463. }
  464. }
  465. .status-img {
  466. margin-top: 9px;
  467. image {
  468. width: 245px;
  469. height: 56px;
  470. }
  471. }
  472. }
  473. }
  474. }
  475. </style>