【前端】智能库房综合管理系统前端项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

210 lines
5.8 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <div class="warehouse">
  3. <div class="warehouse-tab">
  4. <ul class="warehouse-nav">
  5. <li :class="{ 'active-nav': activeIndex == 0 }" @click="changeActiveTab(0)">
  6. <span />
  7. <p>全景图</p>
  8. </li>
  9. <li :class="{ 'active-nav': activeIndex == 1 }" @click="changeActiveTab(1)">
  10. <span />
  11. <p>档案库</p>
  12. </li>
  13. <li :class="{ 'active-nav': activeIndex == 2 }" @click="changeActiveTab(2)">
  14. <span />
  15. <p>整理室</p>
  16. </li>
  17. <li :class="{ 'active-nav': activeIndex == 3 }" @click="changeActiveTab(3)">
  18. <span />
  19. <p>阅览室</p>
  20. </li>
  21. </ul>
  22. <component :is="comName" />
  23. </div>
  24. <!-- 摄像头视频 -->
  25. <Video ref="camera" />
  26. </div>
  27. </template>
  28. <script>
  29. import fullView from './fullView/index.vue'
  30. import archivesStorage from './archivesStorage/index.vue'
  31. import collateRoom from './collateRoom/index.vue'
  32. import readRoom from './readRoom/index.vue'
  33. import Video from './module/video'
  34. export default {
  35. name: 'Warehouse3D',
  36. components: { fullView, archivesStorage, readRoom, collateRoom, Video },
  37. data() {
  38. return {
  39. activeIndex: 0
  40. }
  41. },
  42. computed: {
  43. comName: function() {
  44. if (this.activeIndex === 0) {
  45. return 'fullView'
  46. } else if (this.activeIndex === 1) {
  47. return 'archivesStorage'
  48. } else if (this.activeIndex === 2) {
  49. return 'collateRoom'
  50. } else if (this.activeIndex === 3) {
  51. return 'readRoom'
  52. }
  53. return 'fullView'
  54. }
  55. },
  56. mounted() {
  57. // 监听 iframe 传来的值
  58. window.addEventListener('message', this.handleMessageEvent)
  59. if (localStorage.getItem('isDeseCabinetPage')) {
  60. this.activeIndex = 1
  61. localStorage.removeItem('isDeseCabinetPage')
  62. }
  63. },
  64. created() {
  65. console.log(1111)
  66. this.initWebSocket()
  67. if (this.$route.params.roomId) {
  68. this.activeIndex = this.$route.params.roomId
  69. }
  70. },
  71. methods: {
  72. handleMessageEvent(event) {
  73. const _this = this
  74. if (event.data && event.data.data) {
  75. const data = event.data.data
  76. if (data === 'A区') {
  77. _this.activeIndex = 1
  78. } else if (data === 'B区') {
  79. _this.activeIndex = 2
  80. } else if (data === 'C区') {
  81. _this.activeIndex = 3
  82. }
  83. // 摄像头
  84. if (data.includes('CAM')) {
  85. _this.$nextTick(() => {
  86. this.$refs.camera.openVideoVisible = true
  87. // 后期看接口调试变化
  88. this.$refs.camera.videoSrc = 'https://qiniu.aiyxlib.com/1606275873000.mp4'
  89. this.$refs.camera.videoTitle = data
  90. })
  91. }
  92. }
  93. },
  94. changeActiveTab(data) {
  95. this.activeIndex = data
  96. },
  97. destroyed() {
  98. window.removeEventListener('message', this.handleMessageEvent)
  99. },
  100. initWebSocket() {
  101. // 初始化weosocket
  102. const url = 'ws://192.168.99.65:7070/webSocket/testname'
  103. const wsuri = url // ws地址
  104. this.websocket = new WebSocket(wsuri)
  105. this.websocket.onopen = this.websocketonopen
  106. this.websocket.onerror = this.websocketonerror
  107. this.websocket.onmessage = this.websocketonmessage
  108. this.websocket.onclose = this.websocketclose
  109. },
  110. websocketonopen() {
  111. console.log('WebSocket连接成功')
  112. // co data = {
  113. // type: 'user_init',
  114. // userid: 'xxx'
  115. // }
  116. // this.websocket.send(
  117. // // 发送数据
  118. // JSON.stringify(data)
  119. // )
  120. },
  121. websocketonerror(e) {
  122. // 错误
  123. // this.initWebSocket()
  124. console.log('WebSocket连接发生错误')
  125. },
  126. websocketonmessage(e) {
  127. // 数据接收
  128. var data = JSON.parse(e.data)
  129. this.$store.commit('SET_ws', data)
  130. console.log('接收数据')
  131. // 操作处理...
  132. },
  133. websocketsend(agentData) {
  134. // 数据发送
  135. this.websocket.send(agentData)
  136. },
  137. websocketclose(e) {
  138. // 关闭
  139. console.log('WebSocket关闭')
  140. console.log(JSON.stringify(e))
  141. }
  142. }
  143. }
  144. </script>
  145. <style lang="scss" scoped>
  146. .warehouse-tab {
  147. color: #3298fa;
  148. .warehouse-nav {
  149. display: flex;
  150. position: absolute;
  151. bottom: 20px;
  152. left: 20px;
  153. z-index: 11;
  154. // width: calc(100vw - 545px);
  155. width: calc(100vw - 800px);
  156. height: 90px;
  157. min-height: 90px;
  158. padding: 0;
  159. li {
  160. display: flex;
  161. flex-wrap: nowrap;
  162. align-items: center;
  163. align-content: center;
  164. justify-content: center;
  165. width: 25%;
  166. height: 90px;
  167. line-height: 90px;
  168. text-align: right;
  169. // padding-right: 20px;
  170. margin-right: 20px;
  171. font-size: 18px;
  172. position: relative;
  173. cursor: default;
  174. background: url("~@/assets/images/warehouse_tab_bg.png") no-repeat;
  175. background-size: 100% 100%;
  176. span {
  177. width: 72px;
  178. height: 52px;
  179. // position: absolute;
  180. // left: 60px;
  181. // top: 20px;
  182. }
  183. p {
  184. // flex: 1;
  185. text-align: left;
  186. }
  187. &:first-child span {
  188. background: url("~@/assets/images/tab_fullview_logo.png") no-repeat;
  189. }
  190. &:nth-child(2) span {
  191. background: url("~@/assets/images/tab_archives_logo.png") no-repeat;
  192. }
  193. &:nth-child(3) span {
  194. background: url("~@/assets/images/tab_collate_logo.png") no-repeat;
  195. }
  196. &:nth-child(4) span {
  197. background: url("~@/assets/images/tab_read_logo.png") no-repeat;
  198. }
  199. }
  200. .active-nav {
  201. color: #fff;
  202. background: url("~@/assets/images/warehouse_tab_active.png") no-repeat;
  203. background-size: 100% 100%;
  204. }
  205. }
  206. }
  207. </style>