index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. <template>
  2. <view>
  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" :style="'margin-top:-'+marTop+'rpx;'">
  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. // 3c8cadac11af4f1298a2882addc8788d
  199. },
  200. onUnload() {
  201. uni.$off('refreshdatalist')
  202. // #ifdef H5
  203. this.flv_destroy();
  204. // #endif
  205. },
  206. onShow() {
  207. },
  208. mounted() {
  209. this.getHeightFn()
  210. },
  211. // 上拉触底加载更多触发事件
  212. onReachBottom() {
  213. if (this.reachflag) {
  214. this.pageNum++
  215. this.getDataFn()
  216. }
  217. },
  218. methods:{
  219. checkPermi, checkRole,
  220. getOpenFn(){
  221. var that=this
  222. if(this.isloading){
  223. return
  224. }
  225. this.isloading=true;
  226. var params={
  227. equipmentName:this.address
  228. }
  229. getVideoOpenDz(params).then(res=>{
  230. this.isloading=false
  231. if(res.code==200){
  232. this.$toast('已开门')
  233. }
  234. }).catch(error=>{
  235. this.isloading=false
  236. })
  237. },
  238. getCloseFn(){
  239. var that=this
  240. if(this.isloading){
  241. return
  242. }
  243. this.isloading=true;
  244. var params={
  245. equipmentName:this.address
  246. }
  247. getVideoCloseDz(params).then(res=>{
  248. this.isloading=false
  249. if(res.code==200){
  250. this.$toast('已关门')
  251. }
  252. }).catch(error=>{
  253. this.isloading=false
  254. })
  255. },
  256. time() {
  257. var date = new Date();
  258. var y = date.getFullYear();
  259. var m = date.getMonth() + 1;
  260. var d = date.getDate();
  261. // var h = date.getHours();
  262. // var min = date.getMinutes();
  263. // var s = date.getSeconds();
  264. // var week = date.getDay(); //获取当前星期X(0-6,0代表星期天)
  265. // var weeks = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
  266. this.daytime = y + '-' + (m < 10 ? ('0' + m) : m) + '-' + (d < 10 ? ('0' + d) : d)
  267. // var timeStr = (h < 10 ? ('0' + h) : h) + ':' + (min < 10 ? ('0' + min) : min) + ':' + (s < 10 ? (
  268. // '0' + s) : s);
  269. if(checkPermi(['system:door:list'])){
  270. this.getDataFn()
  271. }
  272. },
  273. getLivePlayer() {
  274. uni.showLoading({
  275. mask: true,
  276. title: 'loading...'
  277. });
  278. // 生成需要的video 组件
  279. // var player = document.getElementById('videoElement');
  280. var player = document.createElement('video');
  281. player.id = 'video';
  282. player.style = 'width: 100%;height: 211px';
  283. player.enableProgressGesture = this.enableProgressGesture;
  284. player.controls = this.controls;
  285. player.muted = true;
  286. player.showCenterPlayBtn = this.showCenterPlayBtn;
  287. player.showPlayBtn = this.showPlayBtn;
  288. player.showFullscreenBtn = this.showFullscreenBtn;
  289. player.x5VideoPlayerType = 'h5-page';
  290. player.x5VideoPlayerFullscreen = 'false';
  291. player.autoplay = this.autoplay; // 以上均为 video标签的属性配置
  292. var myPlayer= document.getElementById('myPlayer')
  293. // console.log(myPlayer.childNodes,1)
  294. myPlayer.innerHTML=''
  295. myPlayer.appendChild(player);
  296. if (flvjs.isSupported()) {
  297. this.flvPlayer = flvjs.createPlayer({
  298. type: 'flv',
  299. isLive: true, //<====直播的话,加个这个
  300. url: this.videourl//直播流地址
  301. });
  302. this.flvPlayer.attachMediaElement(player);
  303. this.flvPlayer.load(); //加载
  304. // setTimeout(() => {
  305. // var player2 = document.createElement('video');
  306. // player2.play();
  307. // }, 2000);
  308. this.player = player;
  309. this.flvPlayer.on(flvjs.Events.ERROR, (errorType, errorDetail, errorInfo) => {
  310. console.log('播放错误');
  311. this.flv_destroy();
  312. });
  313. uni.hideLoading();
  314. }
  315. },
  316. flv_start() {
  317. //开始
  318. console.log(this.player);
  319. this.player.play();
  320. },
  321. flv_pause() {
  322. //暂停
  323. this.player.pause();
  324. },
  325. flv_destroy() {
  326. // console.log(23)
  327. //停止
  328. if(this.flvPlayer){
  329. this.flvPlayer.pause();
  330. this.flvPlayer.unload();
  331. this.flvPlayer.detachMediaElement();
  332. this.flvPlayer.destroy();
  333. this.flvPlayer = null;
  334. this.player=null;
  335. }
  336. },
  337. flv_seekto() {
  338. // 复制其他人的 我还没用这个
  339. this.player.currentTime = parseFloat(document.getElementsByName('seekpoint')[0].value);
  340. },
  341. bindDateChangea(e){
  342. var val=e.detail.value;
  343. this.adridx=val
  344. this.address=this.adrlist[val].name;
  345. this.indexCode=this.adrlist[val].indexCode;
  346. // 获取直播视频
  347. this.getCameraVideo()
  348. },
  349. getCodeFn(ite){
  350. this.address=ite.name;
  351. this.indexCode=ite.indexCode;
  352. // 获取直播视频
  353. this.getCameraVideo()
  354. },
  355. getCameraVideo(){
  356. // 设备
  357. getCameraVideo(this.indexCode).then(res=>{
  358. if(res.code==200){
  359. var data=res.data.data;
  360. if(data){
  361. this.videourl=data.url;
  362. // #ifdef H5
  363. this.getLivePlayer()
  364. // #endif
  365. }
  366. }else{
  367. this.$toast(res.msg)
  368. }
  369. })
  370. },
  371. getResetFn(){
  372. // 重置
  373. this.daytime='';
  374. this.getrefreshData()
  375. },
  376. bindDateChangeb(e){
  377. this.daytime=e.detail.value;
  378. this.getrefreshData()
  379. },
  380. getrefreshData(){
  381. this.pageNum=1;
  382. this.list=[];
  383. this.reachflag=true;
  384. this.getDataFn()
  385. },
  386. getHeightFn(){
  387. let query = uni.createSelectorQuery().in(this);
  388. //需要给黄色区域设置一个id标识,在这里是demo
  389. query.select('.navbox').boundingClientRect(data => {
  390. var top=data.top<0 ? -data.top : data.top;
  391. var stubarHeight=Number(this.stubarHeight);
  392. this.marTop =stubarHeight > 0?692 - Number(data.height)*2 : 692 - Number(data.height)*2 + 40 //赋值,待会要用
  393. if (top <=this.nvaHeight) {
  394. const opacity = top / 100 // 计算透明度值
  395. const color = `rgba(4, 145, 253, ${opacity})`
  396. this.backgroundColor = color // 更新盒子背景颜色
  397. } else {
  398. this.backgroundColor = '#00A9F0'
  399. }
  400. }).exec();
  401. query.select(".table").boundingClientRect(data => {
  402. var top=data.top<0 ? -data.top : data.top;
  403. this.tabtop=Number(top)-Number(this.nvaHeight)
  404. }).exec();
  405. },
  406. getCameraList(){
  407. // 设备
  408. var params={
  409. pageSize:1000,
  410. pageNo: 1,
  411. }
  412. getCameraList(params).then(res=>{
  413. if(res.code==200){
  414. var data=res.data.data;
  415. if(data&&data.list&&data.list.length>0){
  416. this.adrlist =data.list;
  417. this.address=data.list[0].name;
  418. this.indexCode=data.list[0].indexCode;
  419. if(checkPermi(['system:camera:video'])){
  420. this.getCameraVideo()
  421. }
  422. }
  423. }else{
  424. this.$toast(res.msg)
  425. }
  426. })
  427. },
  428. init(){
  429. // 开关门类型
  430. getDictionaryFn('is_open').then(res=>{
  431. if(res.code==200){
  432. this.parameter.kgmlist = res.data.map(v => {
  433. return {
  434. label: v.dictLabel,
  435. value: v.dictValue
  436. }
  437. })
  438. }
  439. })
  440. },
  441. getDataFn(){
  442. var params={
  443. pageSize:this.pageSize,
  444. pageNum: this.pageNum,
  445. }
  446. if(this.daytime){
  447. params.controlsTime=this.daytime
  448. }
  449. getDoorList(params).then(res=>{
  450. if(res.code==200){
  451. if (res.rows.length < this.pageSize) {
  452. this.reachflag = false
  453. this.wtdt = '到底了~';
  454. } else {
  455. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
  456. if (num < res.total) {
  457. this.reachflag = true
  458. this.wtdt = '上拉加载更多'
  459. } else {
  460. this.reachflag = false
  461. this.wtdt = '到底了~';
  462. }
  463. }
  464. if (this.pageNum == 1) {
  465. this.list = res.rows;
  466. } else {
  467. this.list = this.list.concat(res.rows)
  468. }
  469. }else{
  470. this.$toast(res.msg)
  471. }
  472. })
  473. },
  474. },
  475. }
  476. </script>
  477. <style>
  478. page{background: #ffffff;}
  479. </style>
  480. <style lang="scss" scoped>
  481. .navbox /deep/ .uni-navbar__header-container {align-items: center;padding-left: 0;}
  482. .navbox /deep/ uni-picker{flex: 1;}
  483. .navbox{position: fixed;left: 0;right: 0;top: 0;z-index: 4;
  484. }
  485. .chekt{font-weight: bold;font-size: 30rpx;color: #FFFFFF;display: flex;align-items: center;width: 200rpx;
  486. view{flex: 0 1 auto;min-width: 100rpx;}
  487. image{width: 16rpx;height: 10rpx;margin-left: 10rpx;flex: 0 0 auto;}
  488. }
  489. .reset{width:56rpx; height: 88rpx;display: flex;align-items: center;justify-content: center;
  490. image{width: 26rpx;height: 30rpx;}
  491. }
  492. .navbg{width: 100%;height: 692rpx;}
  493. .vidbox{overflow: hidden;
  494. border-radius: 14rpx;box-sizing: border-box;width:100%;position: relative;display: flex;align-items: center;overflow: auto;flex-wrap: nowrap;
  495. video{width: 100%;height: 450rpx;flex: 1;}
  496. .vidfot{padding: 0 20rpx 0 30rpx;
  497. height: 76rpx;background: rgba(0, 0, 0, 0.5);position: absolute;left: 0;right: 0;bottom: 0;
  498. .vtit{font-weight: 500;font-size: 22rpx;color: #FFFFFF;}
  499. .vimgs{width: 50rpx;height: 50rpx;display: flex;align-items: center;justify-content: center;margin-left: 28rpx;
  500. .imga{width: 30rpx;height: 22rpx;}
  501. .imgb{width: 30rpx;height: 30rpx;}
  502. }
  503. }
  504. .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;
  505. .contop{font-weight: bold;font-size:26rpx;color: #161616;margin-bottom: 10rpx;flex: 0 0 auto;
  506. image{width: 26rpx;height: 20rpx;margin-right: 12rpx;}
  507. }
  508. .conbox{
  509. mask:linear-gradient(#fff,#fff,#fff,transparent);
  510. -webkit-mask: linear-gradient(#fff,#fff,#fff,transparent);
  511. }
  512. .contit{font-size: 22rpx;height: 48rpx;line-height: 48rpx;text-align: center;
  513. color: #161616;position: relative;
  514. &.act{font-weight: bold;color: #FFFFFF;}
  515. }
  516. .videobg{position: absolute;left: 0;right: 0;top: 0;bottom: 0;width: 100%;height: 48rpx;z-index: -1;}
  517. }
  518. }
  519. .openbox{margin-bottom: 36rpx;
  520. .btns{width: 320rpx;height: 98rpx;border-radius: 14rpx;display: flex;align-items: center;justify-content: center;
  521. font-weight: bold;font-size: 28rpx;color: #FFFFFF;
  522. image{width: 24rpx;height: 20rpx;margin-right: 14rpx;}
  523. &.bga{background: #0391FD;}
  524. &.bgb{background: #58CA5C;}
  525. }
  526. }
  527. .vlisttop{font-weight: bold;font-size: 30rpx;color: #161616;padding: 16rpx 0;margin-bottom: 20rpx;
  528. .vlleft{flex: 1;
  529. image{width: 26rpx;height: 26rpx;margin-right: 12rpx;}
  530. }
  531. .rlleft{
  532. view{font-weight: bold;font-size: 26rpx;color: #0391FD;min-width: 152rpx;}
  533. image{width: 18rpx;height: 10rpx;margin-left: 12rpx;}
  534. }
  535. }
  536. .table{
  537. // height: calc();
  538. overflow: auto;
  539. }
  540. .zxmain{position: relative;padding: 0 32rpx;
  541. }
  542. </style>