index.vue 13 KB

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