doorAnimate.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. <template>
  2. <view style="width: 100%; height: 100%">
  3. <div class="door-container">
  4. <div style="display: flex" v-show="doorcount == 1">
  5. <div class="door1" v-show="doorcount == 1" :style="{ height: height }">
  6. <div
  7. class="left_door"
  8. v-bind:class="
  9. gatestate1 == '1' ||
  10. gatestate1 == '开启' ||
  11. gatestate1 == '打开' ||
  12. gatestate1 == 'true'
  13. ? 'open_left'
  14. : 'close_left'
  15. "
  16. id="leftdoor1"
  17. ></div>
  18. <div
  19. class="right_door"
  20. v-bind:class="
  21. gatestate1 == '1' ||
  22. gatestate1 == '开启' ||
  23. gatestate1 == '打开' ||
  24. gatestate1 == 'true'
  25. ? 'open_right'
  26. : 'close_right'
  27. "
  28. id="rightdoor1"
  29. ></div>
  30. </div>
  31. <div>
  32. <video
  33. v-if="item.type == 'flv'"
  34. :id="'cameraElement' + item.id"
  35. muted
  36. autoplay
  37. controls
  38. width="100%"
  39. height="100%"
  40. style="width: 100%"
  41. ></video>
  42. </div>
  43. </div>
  44. <div style="" v-show="doorcount == 2">
  45. <div class="door2" v-show="doorcount == 2" :style="{ height: height }">
  46. <div
  47. class="left_door"
  48. v-bind:class="
  49. gatestate1 == '1' ||
  50. gatestate1 == '开启' ||
  51. gatestate1 == '打开' ||
  52. gatestate1 == 'true'
  53. ? 'open_left'
  54. : 'close_left'
  55. "
  56. id="leftdoor2"
  57. ></div>
  58. <div
  59. class="right_door"
  60. v-bind:class="
  61. gatestate1 == '1' ||
  62. gatestate1 == '开启' ||
  63. gatestate1 == '打开' ||
  64. gatestate1 == 'true'
  65. ? 'open_right'
  66. : 'close_right'
  67. "
  68. id="rightdoor2"
  69. ></div>
  70. </div>
  71. <div class="door2" v-show="doorcount == 2" :style="{ height: height }">
  72. <div
  73. class="left_door"
  74. v-bind:class="
  75. gatestate2 == '1' ||
  76. gatestate2 == '开启' ||
  77. gatestate2 == '打开' ||
  78. gatestate2 == 'true'
  79. ? 'open_left'
  80. : 'close_left'
  81. "
  82. id="leftdoor3"
  83. ></div>
  84. <div
  85. class="right_door"
  86. v-bind:class="
  87. gatestate2 == '1' ||
  88. gatestate2 == '开启' ||
  89. gatestate2 == '打开' ||
  90. gatestate2 == 'true'
  91. ? 'open_right'
  92. : 'close_right'
  93. "
  94. id="rightdoor3"
  95. ></div>
  96. </div>
  97. <div>
  98. <video
  99. v-if="item.type == 'flv'"
  100. :id="'cameraElement' + item.id"
  101. muted
  102. autoplay
  103. controls
  104. width="100%"
  105. height="100%"
  106. style="width: 100%"
  107. ></video>
  108. </div>
  109. </div>
  110. <div style="" v-show="doorcount == 3">
  111. <div class="door3" v-show="doorcount == 3" :style="{ height: height }">
  112. <div
  113. class="left_door"
  114. v-bind:class="
  115. gatestate1 == '1' ||
  116. gatestate1 == '开启' ||
  117. gatestate1 == '打开' ||
  118. gatestate1 == 'true'
  119. ? 'open_left'
  120. : 'close_left'
  121. "
  122. id="leftdoor4"
  123. ></div>
  124. <div
  125. class="right_door"
  126. v-bind:class="
  127. gatestate1 == '1' ||
  128. gatestate1 == '开启' ||
  129. gatestate1 == '打开' ||
  130. gatestate1 == 'true'
  131. ? 'open_right'
  132. : 'close_right'
  133. "
  134. id="rightdoor4"
  135. ></div>
  136. </div>
  137. <div class="door3" v-show="doorcount == 3" :style="{ height: height }">
  138. <div
  139. class="left_door"
  140. v-bind:class="
  141. gatestate2 == '1' ||
  142. gatestate2 == '开启' ||
  143. gatestate2 == '打开' ||
  144. gatestate2 == 'true'
  145. ? 'open_left'
  146. : 'close_left'
  147. "
  148. id="leftdoor5"
  149. ></div>
  150. <div
  151. class="right_door"
  152. v-bind:class="
  153. gatestate2 == '1' ||
  154. gatestate2 == '开启' ||
  155. gatestate2 == '打开' ||
  156. gatestate2 == 'true'
  157. ? 'open_right'
  158. : 'close_right'
  159. "
  160. id="rightdoor5"
  161. ></div>
  162. </div>
  163. <div class="door3" v-show="doorcount == 3" :style="{ height: height }">
  164. <div
  165. class="left_door"
  166. v-bind:class="
  167. gatestate3 == '1' ||
  168. gatestate3 == '开启' ||
  169. gatestate3 == '打开' ||
  170. gatestate3 == 'true'
  171. ? 'open_left'
  172. : 'close_left'
  173. "
  174. id="leftdoor6"
  175. ></div>
  176. <div
  177. class="right_door"
  178. v-bind:class="
  179. gatestate3 == '1' ||
  180. gatestate3 == '开启' ||
  181. gatestate3 == '打开' ||
  182. gatestate3 == 'true'
  183. ? 'open_right'
  184. : 'close_right'
  185. "
  186. id="rightdoor6"
  187. ></div>
  188. </div>
  189. <div>
  190. <video
  191. v-if="item.type == 'flv'"
  192. :id="'cameraElement' + item.id"
  193. muted
  194. autoplay
  195. controls
  196. width="100%"
  197. height="100%"
  198. style="width: 100%"
  199. ></video>
  200. </div>
  201. </div>
  202. <div style="" v-show="doorcount == 4">
  203. <div class="door4" v-show="doorcount == 4" :style="{ height: height }">
  204. <div
  205. class="left_door"
  206. v-bind:class="
  207. gatestate1 == '1' ||
  208. gatestate1 == '开启' ||
  209. gatestate1 == '打开' ||
  210. gatestate1 == 'true'
  211. ? 'open_left'
  212. : 'close_left'
  213. "
  214. id="leftdoor7"
  215. ></div>
  216. <div
  217. class="right_door"
  218. v-bind:class="
  219. gatestate1 == '1' ||
  220. gatestate1 == '开启' ||
  221. gatestate1 == '打开' ||
  222. gatestate1 == 'true'
  223. ? 'open_right'
  224. : 'close_right'
  225. "
  226. id="rightdoor7"
  227. ></div>
  228. </div>
  229. <div class="door4" v-show="doorcount == 4" :style="{ height: height }">
  230. <div
  231. class="left_door"
  232. v-bind:class="
  233. gatestate2 == '1' ||
  234. gatestate2 == '开启' ||
  235. gatestate2 == '打开' ||
  236. gatestate2 == 'true'
  237. ? 'open_left'
  238. : 'close_left'
  239. "
  240. id="leftdoor8"
  241. ></div>
  242. <div
  243. class="right_door"
  244. v-bind:class="
  245. gatestate2 == '1' ||
  246. gatestate2 == '开启' ||
  247. gatestate2 == '打开' ||
  248. gatestate2 == 'true'
  249. ? 'open_right'
  250. : 'close_right'
  251. "
  252. id="rightdoor8"
  253. ></div>
  254. </div>
  255. <div class="door4" v-show="doorcount == 4" :style="{ height: height }">
  256. <div
  257. class="left_door"
  258. v-bind:class="
  259. gatestate3 == '1' ||
  260. gatestate3 == '开启' ||
  261. gatestate3 == '打开' ||
  262. gatestate3 == 'true'
  263. ? 'open_left'
  264. : 'close_left'
  265. "
  266. id="leftdoor9"
  267. ></div>
  268. <div
  269. class="right_door"
  270. v-bind:class="
  271. gatestate3 == '1' ||
  272. gatestate3 == '开启' ||
  273. gatestate3 == '打开' ||
  274. gatestate3 == 'true'
  275. ? 'open_right'
  276. : 'close_right'
  277. "
  278. id="rightdoor9"
  279. ></div>
  280. </div>
  281. <div class="door4" v-show="doorcount == 4" :style="{ height: height }">
  282. <div
  283. class="left_door"
  284. v-bind:class="
  285. gatestate4 == '1' ||
  286. gatestate4 == '开启' ||
  287. gatestate4 == '打开' ||
  288. gatestate4 == 'true'
  289. ? 'open_left'
  290. : 'close_left'
  291. "
  292. id="leftdoor10"
  293. ></div>
  294. <div
  295. class="right_door"
  296. v-bind:class="
  297. gatestate4 == '1' ||
  298. gatestate4 == '开启' ||
  299. gatestate4 == '打开' ||
  300. gatestate4 == 'true'
  301. ? 'open_right'
  302. : 'close_right'
  303. "
  304. id="rightdoor10"
  305. ></div>
  306. </div>
  307. <div>
  308. <video
  309. v-if="item.type == 'flv'"
  310. :id="'cameraElement' + item.id"
  311. muted
  312. autoplay
  313. controls
  314. width="100%"
  315. height="100%"
  316. style="width: 100%"
  317. ></video>
  318. </div>
  319. </div>
  320. </div>
  321. </view>
  322. </template>
  323. <script>
  324. import flvjs from "flv.js";
  325. export default {
  326. data() {
  327. return {
  328. height: "200px",
  329. flvPlayer: [], // flv 播放地址
  330. };
  331. },
  332. props: [
  333. "gatestate1",
  334. "gatestate2",
  335. "gatestate3",
  336. "gatestate4",
  337. "doorcount",
  338. "cameralist",
  339. ],
  340. methods: {
  341. initData() {
  342. if (this.cameralist.devicekind == "flv") {
  343. // 根据id设置每个播放摄像头的地址
  344. this.setVideoUrl(this.cameralist.addr, this.cameralist.deviceid);
  345. }
  346. },
  347. setVideoUrl(url, id) {
  348. if (flvjs.isSupported()) {
  349. this.flvPlayer = [];
  350. var videoElement = document.getElementById("cameraElement" + id);
  351. // 控件设置地址信息
  352. var vdo = flvjs.createPlayer({
  353. type: "flv",
  354. url: url,
  355. });
  356. // 控件绑定
  357. vdo.attachMediaElement(videoElement);
  358. vdo.load();
  359. // 播放
  360. vdo.play();
  361. this.flvPlayer.push(vdo);
  362. }
  363. },
  364. },
  365. watch: {
  366. doorcount(val) {
  367. if (val == 1) {
  368. this.height = "180px";
  369. }
  370. if (val == 2) {
  371. this.height = "180px";
  372. }
  373. if (val == 3) {
  374. this.height = "110px";
  375. }
  376. if (val == 4) {
  377. this.height = "180px";
  378. }
  379. },
  380. cameralist(val) {
  381. this.initData();
  382. },
  383. },
  384. onUnload() {
  385. this.flvPlayer.forEach((element) => {
  386. element.pause();
  387. element.unload();
  388. element.detachMediaElement();
  389. element.destroy();
  390. element = null;
  391. });
  392. },
  393. };
  394. </script>
  395. <style scoped>
  396. /*门里面*/
  397. div.door1 {
  398. width: 50%;
  399. float: left;
  400. margin-left: 20%;
  401. background-image: url(/static/door.png);
  402. background-size: 100% 100%;
  403. perspective: 800px;
  404. }
  405. div.door2 {
  406. width: 50%;
  407. float: left;
  408. background-image: url(/static/door.png);
  409. background-size: 100% 100%;
  410. perspective: 800px;
  411. }
  412. div.door3 {
  413. width: 33.3%;
  414. float: left;
  415. background-image: url(/static/door.png);
  416. background-size: 100% 100%;
  417. perspective: 400px;
  418. }
  419. div.door4 {
  420. width: 50%;
  421. float: left;
  422. background-image: url(/static/door.png);
  423. background-size: 100% 100%;
  424. perspective: 800px;
  425. }
  426. /*左门/右门*/
  427. div.left_door {
  428. top: 12%;
  429. left: 10%;
  430. width: 40.5%;
  431. height: 78%;
  432. box-sizing: border-box;
  433. float: left;
  434. z-index: 1;
  435. position: absolute;
  436. transition: all 2s ease;
  437. background-image: url(/static/left.png);
  438. background-size: 100% 100%;
  439. }
  440. div.right_door {
  441. top: 12%;
  442. right: 10%;
  443. width: 40.2%;
  444. height: 78%;
  445. box-sizing: border-box;
  446. float: left;
  447. z-index: 1;
  448. position: absolute;
  449. transition: all 2s ease;
  450. background-image: url(/static/left.png);
  451. background-size: 100% 100%;
  452. }
  453. div.left_door {
  454. transform-origin: left center;
  455. border-right: 1px solid rgb(8, 8, 8);
  456. }
  457. div.right_door {
  458. transform-origin: right center;
  459. border-left: 1px solid rgb(8, 8, 8);
  460. }
  461. .open_left {
  462. transform: rotateY(100deg);
  463. }
  464. .open_right {
  465. transform: rotateY(-100deg);
  466. }
  467. .close_left {
  468. transform: rotateY(0);
  469. }
  470. .close_right {
  471. transform: rotateY(0deg);
  472. }
  473. /*使用css变形功能
  474. div.door:hover div.left_door{
  475. transform:rotateY(100deg);
  476. }
  477. div.door:hover div.right_door{
  478. transform:rotateY(-100deg);
  479. }*/
  480. </style>