index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  1. <template>
  2. <view :style="'padding-top:'+nvaHeight+'px;'">
  3. <view class="navbox">
  4. <uni-nav-bar color="#ffffff" leftWidth="200rpx" title="实时监控" :background-color="backgroundColor" :border="false" statusBar='true' fixed="true">
  5. <block slot="left">
  6. <picker range-key='name' :value="adridx" :range="adrlist" @change='bindDateChangea'>
  7. <view class="chekt">
  8. <view class="over">{{address|| ""}}</view>
  9. <image :src="upimg"></image>
  10. </view>
  11. </picker>
  12. </block>
  13. </uni-nav-bar>
  14. </view>
  15. <image :src="navbg" class="navbg"></image>
  16. <view class="zxmain">
  17. <view class="vidbox mb18">
  18. <!-- #ifdef APP-PLUS -->
  19. <video :src="videourl" id="myvideo" autoplay controls></video>
  20. <!-- #endif -->
  21. <!-- #ifdef H5 -->
  22. <view id="myPlayer" ref="myPlayer"></view>
  23. <!-- #endif -->
  24. <!-- #ifdef MP-WEIXIN -->
  25. <!-- #endif -->
  26. <!-- 监控 -->
  27. <view class="control">
  28. <view class="contop flexcc">
  29. <image :src="videoimg"></image>
  30. <view>监控切换</view>
  31. </view>
  32. <view class="flex1 overa conbox">
  33. <view class="contit over" :class="indexCode==ite.indexCode?'act':''" v-for="(ite,idx) in adrlist" :key="ite.indexCode" @click="getCodeFn(ite)">
  34. {{ite.name}}
  35. <image :src="videobg" v-if="indexCode==ite.indexCode" class="videobg"></image>
  36. </view>
  37. </view>
  38. </view>
  39. <!-- <image :src="mjimg"></image>
  40. <view class="vidfot flexc">
  41. <view class="flex1 vtit">2024/06/21 星期五 15:59:12</view>
  42. <view class="vimgs">
  43. <image :src="voiceimg" class="imga"></image>
  44. </view>
  45. <view class="vimgs">
  46. <image :src="bigimg" class="imgb"></image>
  47. </view>
  48. </view> -->
  49. </view>
  50. <view class="openbox flexcj">
  51. <view class="btns bga" @click="getOpenFn" v-if="checkPermi(['system:camera:openDz'])">
  52. <image :src="openimg"></image>
  53. 开门
  54. </view>
  55. <view class="btns bgb" @click="getCloseFn" v-if="checkPermi(['system:camera:closeDz'])">
  56. <image :src="openimg"></image>
  57. 关门
  58. </view>
  59. </view>
  60. <!-- 列表 -->
  61. <block v-if="checkPermi(['system:door:list'])">
  62. <view class="vlisttop flexcj">
  63. <view class="vlleft flexc" @click="getResetFn">
  64. <image :src="mjimg"></image>门禁记录
  65. </view>
  66. <picker mode="date" @change='bindDateChangeb'>
  67. <view class="rlleft flexc">
  68. <view>{{daytime||"请选择日期"}}</view>
  69. <image :src="hupimg"></image>
  70. </view>
  71. </picker>
  72. </view>
  73. <!-- 表格 -->
  74. <view class="table" :style="tabflag?'height:calc(100vh - '+tabscheight+'rpx)':''">
  75. <zb-table
  76. :show-header="true"
  77. :columns="column1"
  78. :stripe="true"
  79. :fit="true"
  80. :isShowLoadMore="reachflag"
  81. :parameter="parameter"
  82. :data="list"></zb-table>
  83. <!-- @rowClick="rowClick"
  84. @toggleRowSelection="toggleRowSelection"
  85. @toggleAllSelection="toggleAllSelection" -->
  86. </view>
  87. </block>
  88. </view>
  89. <!-- 第一道;手机号,发送验证码,门就开,记录车牌号,直接进
  90. 第二种:需要审核,预约
  91. 办公人员,配置进门区域,
  92. 访客配置 进门区域 -->
  93. <footers v-if="isfootflag" :footerindex="footerindex"></footers>
  94. </view>
  95. </template>
  96. <script>
  97. import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
  98. import self from '@/utils/location.js';
  99. import yList from "@/components/order/list.vue"
  100. let { calendar } = require("@/components/lunc-calendar/calendar.js");
  101. import {getCameraList,getCameraVideo,getVideoOpenDz,getVideoCloseDz,getDoorList} from "@/api/mine/order.js"
  102. import {column1} from '@/components/zb-table/all.js'
  103. import {getDictionaryFn} from "@/api/mine/register.js"
  104. import footers from '@/components/footer/footer.vue'
  105. import zbTable from "@/components/zb-table/zb-tables.vue"
  106. // #ifdef H5
  107. import flvjs from 'flv.js';
  108. // #endif
  109. export default {
  110. components:{yList,footers,zbTable},
  111. data(){
  112. return{
  113. column1,
  114. footerindex:'video',
  115. isfootflag:true,
  116. navbg:require("@/static/images/vibg.png"),
  117. upimg:require("@/static/images/order/up.png"),
  118. hupimg:require("@/static/images/order/hup.png"),
  119. mjimg:require("@/static/images/order/control.png"),
  120. bigimg:require("@/static/images/order/pre.png"),
  121. voiceimg:require("@/static/images/order/voice.png"),
  122. openimg:require("@/static/images/order/open.png"),
  123. closeimg:require("@/static/images/order/close.png"),
  124. resetimg:require('@/static/images/order/reset.png'),
  125. wresetimg:require('@/static/images/order/wreset.png'),
  126. videoimg:require('@/static/images/order/video.png'),
  127. videobg:require('@/static/images/order/videobg.png'),
  128. backgroundColor: "transparent",
  129. list:[
  130. //{entranceGuardName:'后门抓拍一体机1',controlsTime:'2024-08-22 11:21:44',type:'1',pictureUrl:"/profile/upload/2024/08/22/cardr_20240822145636A001.png,/profile/upload/2024/08/22/a_20240822151219A002.png"},
  131. ],
  132. pageSize: 15,
  133. pageNum: 1,
  134. reachflag: false,
  135. wtdt:'',
  136. parameter:{
  137. kgmlist:[],
  138. },
  139. adridx:0,
  140. address:'',
  141. adrlist:[{name:"后门抓拍一体…",indexCode:"1"},{name:"IPCamera34",indexCode:"2"},{name:"ZXY-工地走廊",indexCode:"3"},],//
  142. indexCode:'',
  143. fixedflag:false,
  144. videourl:'',
  145. nvaHeight:44,
  146. marTop:0,//距离顶部的距离
  147. stubarHeight:0,//
  148. tabtop:0,//表格距离顶部的距离
  149. daytime:'',//时间
  150. tabflag:false,
  151. tabscheight:0,//减去的部分
  152. autoplay:true,
  153. controls:true,
  154. enableProgressGesture: false,
  155. showPlayBtn: false,
  156. showCenterPlayBtn: false,
  157. showFullscreenBtn: false,
  158. windowWidth: '',
  159. windowHeight: '',
  160. flvPlayer: null,
  161. player: null,
  162. isloading:false,
  163. }
  164. },
  165. onPageScroll(e) {
  166. var scrollTop = Number(e.scrollTop);
  167. if (scrollTop > 0) {
  168. this.backgroundColor = '#0491FD'
  169. } else {
  170. this.backgroundColor = 'transparent'
  171. }
  172. if(scrollTop<this.tabtop){
  173. this.tabflag=false;
  174. }else{
  175. this.tabflag=true;
  176. }
  177. },
  178. onLoad: function() {
  179. // uni.$on('refreshdatalist',(e) => {
  180. // this.reachflag=false;
  181. // this.pageNum=1;
  182. // this.list=[];
  183. // this.getDataFn();
  184. // })
  185. this.time()
  186. if(checkPermi(['system:camera:list'])){
  187. this.getCameraList()
  188. }
  189. this.init()
  190. // this.getDataFn()
  191. uni.getSystemInfo({
  192. success: (e) => {
  193. this.stubarHeight=Number(e.statusBarHeight);
  194. this.nvaHeight = Number(e.statusBarHeight)+44;
  195. this.tabscheight=Number(this.nvaHeight)*2+100;
  196. }
  197. })
  198. },
  199. onUnload() {
  200. uni.$off('refreshdatalist')
  201. // #ifdef H5
  202. this.flv_destroy();
  203. // #endif
  204. },
  205. onShow() {
  206. },
  207. // 上拉触底加载更多触发事件
  208. onReachBottom() {
  209. if (this.reachflag) {
  210. this.pageNum++
  211. this.getDataFn()
  212. }
  213. },
  214. methods:{
  215. checkPermi, checkRole,
  216. getOpenFn(){
  217. var that=this
  218. if(this.isloading){
  219. return
  220. }
  221. this.isloading=true;
  222. var params={
  223. equipmentName:this.address
  224. }
  225. getVideoOpenDz(params).then(res=>{
  226. this.isloading=false
  227. if(res.code==200){
  228. this.$toast('已开门')
  229. }
  230. }).catch(error=>{
  231. this.isloading=false
  232. })
  233. },
  234. getCloseFn(){
  235. var that=this
  236. if(this.isloading){
  237. return
  238. }
  239. this.isloading=true;
  240. var params={
  241. equipmentName:this.address
  242. }
  243. getVideoCloseDz(params).then(res=>{
  244. this.isloading=false
  245. if(res.code==200){
  246. this.$toast('已关门')
  247. }
  248. }).catch(error=>{
  249. this.isloading=false
  250. })
  251. },
  252. time() {
  253. var date = new Date();
  254. var y = date.getFullYear();
  255. var m = date.getMonth() + 1;
  256. var d = date.getDate();
  257. // var h = date.getHours();
  258. // var min = date.getMinutes();
  259. // var s = date.getSeconds();
  260. // var week = date.getDay(); //获取当前星期X(0-6,0代表星期天)
  261. // var weeks = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
  262. this.daytime = y + '-' + (m < 10 ? ('0' + m) : m) + '-' + (d < 10 ? ('0' + d) : d)
  263. // var timeStr = (h < 10 ? ('0' + h) : h) + ':' + (min < 10 ? ('0' + min) : min) + ':' + (s < 10 ? (
  264. // '0' + s) : s);
  265. if(checkPermi(['system:door:list'])){
  266. this.getDataFn()
  267. }
  268. },
  269. getLivePlayer() {
  270. uni.showLoading({
  271. mask: true,
  272. title: 'loading...'
  273. });
  274. // 生成需要的video 组件
  275. // var player = document.getElementById('videoElement');
  276. var player = document.createElement('video');
  277. player.id = 'video';
  278. player.style = 'width: 100%;height: 211px';
  279. player.enableProgressGesture = this.enableProgressGesture;
  280. player.controls = this.controls;
  281. player.muted = true;
  282. player.showCenterPlayBtn = this.showCenterPlayBtn;
  283. player.showPlayBtn = this.showPlayBtn;
  284. player.showFullscreenBtn = this.showFullscreenBtn;
  285. player.x5VideoPlayerType = 'h5-page';
  286. player.x5VideoPlayerFullscreen = 'false';
  287. player.autoplay = this.autoplay; // 以上均为 video标签的属性配置
  288. var myPlayer= document.getElementById('myPlayer')
  289. // console.log(myPlayer.childNodes,1)
  290. myPlayer.innerHTML=''
  291. myPlayer.appendChild(player);
  292. if (flvjs.isSupported()) {
  293. this.flvPlayer = flvjs.createPlayer({
  294. type: 'flv',
  295. isLive: true, //<====直播的话,加个这个
  296. url: this.videourl//直播流地址
  297. });
  298. this.flvPlayer.attachMediaElement(player);
  299. this.flvPlayer.load(); //加载
  300. // setTimeout(() => {
  301. // var player2 = document.createElement('video');
  302. // player2.play();
  303. // }, 2000);
  304. this.player = player;
  305. this.flvPlayer.on(flvjs.Events.ERROR, (errorType, errorDetail, errorInfo) => {
  306. console.log('播放错误');
  307. this.flv_destroy();
  308. });
  309. uni.hideLoading();
  310. }
  311. },
  312. flv_start() {
  313. //开始
  314. console.log(this.player);
  315. this.player.play();
  316. },
  317. flv_pause() {
  318. //暂停
  319. this.player.pause();
  320. },
  321. flv_destroy() {
  322. // console.log(23)
  323. //停止
  324. if(this.flvPlayer){
  325. this.flvPlayer.pause();
  326. this.flvPlayer.unload();
  327. this.flvPlayer.detachMediaElement();
  328. this.flvPlayer.destroy();
  329. this.flvPlayer = null;
  330. this.player=null;
  331. }
  332. },
  333. flv_seekto() {
  334. // 复制其他人的 我还没用这个
  335. this.player.currentTime = parseFloat(document.getElementsByName('seekpoint')[0].value);
  336. },
  337. bindDateChangea(e){
  338. var val=e.detail.value;
  339. this.adridx=val
  340. this.address=this.adrlist[val].name;
  341. this.indexCode=this.adrlist[val].indexCode;
  342. // 获取直播视频
  343. this.getCameraVideo()
  344. },
  345. getCodeFn(ite){
  346. this.address=ite.name;
  347. this.indexCode=ite.indexCode;
  348. // 获取直播视频
  349. this.getCameraVideo()
  350. },
  351. getCameraVideo(){
  352. // 设备
  353. getCameraVideo(this.indexCode).then(res=>{
  354. if(res.code==200){
  355. var data=res.data.data;
  356. if(data){
  357. this.videourl=data.url;
  358. // #ifdef H5
  359. this.getLivePlayer()
  360. // #endif
  361. }
  362. }else{
  363. this.$toast(res.msg)
  364. }
  365. })
  366. },
  367. getResetFn(){
  368. // 重置
  369. this.daytime='';
  370. this.getrefreshData()
  371. },
  372. bindDateChangeb(e){
  373. this.daytime=e.detail.value;
  374. this.getrefreshData()
  375. },
  376. getrefreshData(){
  377. this.pageNum=1;
  378. this.list=[];
  379. this.reachflag=true;
  380. this.getDataFn()
  381. },
  382. getCameraList(){
  383. // 设备
  384. var params={
  385. pageSize:1000,
  386. pageNo: 1,
  387. }
  388. getCameraList(params).then(res=>{
  389. if(res.code==200){
  390. var data=res.data.data;
  391. if(data&&data.list&&data.list.length>0){
  392. this.adrlist =data.list;
  393. this.address=data.list[0].name;
  394. this.indexCode=data.list[0].indexCode;
  395. if(checkPermi(['system:camera:video'])){
  396. this.getCameraVideo()
  397. }
  398. }
  399. }else{
  400. this.$toast(res.msg)
  401. }
  402. })
  403. },
  404. init(){
  405. // 开关门类型
  406. getDictionaryFn('is_open').then(res=>{
  407. if(res.code==200){
  408. this.parameter.kgmlist = res.data.map(v => {
  409. return {
  410. label: v.dictLabel,
  411. value: v.dictValue
  412. }
  413. })
  414. }
  415. })
  416. },
  417. getDataFn(){
  418. var params={
  419. pageSize:this.pageSize,
  420. pageNum: this.pageNum,
  421. }
  422. if(this.daytime){
  423. params.controlsTime=this.daytime
  424. }
  425. getDoorList(params).then(res=>{
  426. if(res.code==200){
  427. if (res.rows.length < this.pageSize) {
  428. this.reachflag = false
  429. this.wtdt = '到底了~';
  430. } else {
  431. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
  432. if (num < res.total) {
  433. this.reachflag = true
  434. this.wtdt = '上拉加载更多'
  435. } else {
  436. this.reachflag = false
  437. this.wtdt = '到底了~';
  438. }
  439. }
  440. if (this.pageNum == 1) {
  441. this.list = res.rows;
  442. } else {
  443. this.list = this.list.concat(res.rows)
  444. }
  445. }else{
  446. this.$toast(res.msg)
  447. }
  448. })
  449. },
  450. },
  451. }
  452. </script>
  453. <style>
  454. page{background: #ffffff;}
  455. </style>
  456. <style lang="scss" scoped>
  457. .navbox /deep/ .uni-navbar__header-container {align-items: center;padding-left: 0;}
  458. .navbox /deep/ uni-picker{flex: 1;}
  459. .navbox{position: fixed;left: 0;right: 0;top: 0;z-index: 4;
  460. }
  461. .chekt{font-weight: bold;font-size: 30rpx;color: #FFFFFF;display: flex;align-items: center;width: 200rpx;
  462. view{flex: 0 1 auto;min-width: 100rpx;}
  463. image{width: 16rpx;height: 10rpx;margin-left: 10rpx;flex: 0 0 auto;}
  464. }
  465. .reset{width:56rpx; height: 88rpx;display: flex;align-items: center;justify-content: center;
  466. image{width: 26rpx;height: 30rpx;}
  467. }
  468. .navbg{width: 100%;height: 692rpx;z-index: 0;}
  469. .vidbox{overflow: hidden;
  470. border-radius: 14rpx;box-sizing: border-box;width:100%;position: relative;display: flex;align-items: center;overflow: auto;flex-wrap: nowrap;
  471. video{width: 100%;height: 450rpx;flex: 1;}
  472. .vidfot{padding: 0 20rpx 0 30rpx;
  473. height: 76rpx;background: rgba(0, 0, 0, 0.5);position: absolute;left: 0;right: 0;bottom: 0;
  474. .vtit{font-weight: 500;font-size: 22rpx;color: #FFFFFF;}
  475. .vimgs{width: 50rpx;height: 50rpx;display: flex;align-items: center;justify-content: center;margin-left: 28rpx;
  476. .imga{width: 30rpx;height: 22rpx;}
  477. .imgb{width: 30rpx;height: 30rpx;}
  478. }
  479. }
  480. .control{width: 210rpx;flex: 0 0 auto;background: #FFFFFF;border-radius: 14rpx;height: 450rpx;padding: 18rpx 0 4rpx;box-sizing: border-box;display: flex;flex-direction: column;margin-left: 16rpx;
  481. .contop{font-weight: bold;font-size:26rpx;color: #161616;margin-bottom: 10rpx;flex: 0 0 auto;
  482. image{width: 26rpx;height: 20rpx;margin-right: 12rpx;}
  483. }
  484. .conbox{
  485. mask:linear-gradient(#fff,#fff,#fff,transparent);
  486. -webkit-mask: linear-gradient(#fff,#fff,#fff,transparent);
  487. }
  488. .contit{font-size: 22rpx;height: 48rpx;line-height: 48rpx;text-align: center;
  489. color: #161616;position: relative;
  490. &.act{font-weight: bold;color: #FFFFFF;}
  491. }
  492. .videobg{position: absolute;left: 0;right: 0;top: 0;bottom: 0;width: 100%;height: 48rpx;z-index: -1;}
  493. }
  494. }
  495. .openbox{margin-bottom: 36rpx;
  496. .btns{width: 320rpx;height: 98rpx;border-radius: 14rpx;display: flex;align-items: center;justify-content: center;
  497. font-weight: bold;font-size: 28rpx;color: #FFFFFF;
  498. image{width: 24rpx;height: 20rpx;margin-right: 14rpx;}
  499. &.bga{background: #0391FD;}
  500. &.bgb{background: #58CA5C;}
  501. }
  502. }
  503. .vlisttop{font-weight: bold;font-size: 30rpx;color: #161616;padding: 16rpx 0;margin-bottom: 20rpx;
  504. .vlleft{flex: 1;
  505. image{width: 26rpx;height: 26rpx;margin-right: 12rpx;}
  506. }
  507. .rlleft{
  508. view{font-weight: bold;font-size: 26rpx;color: #0391FD;min-width: 152rpx;}
  509. image{width: 18rpx;height: 10rpx;margin-left: 12rpx;}
  510. }
  511. }
  512. .table{
  513. // height: calc();
  514. overflow: auto;
  515. }
  516. .zxmain{position: relative;padding: 0 32rpx;
  517. }
  518. </style>