viewMonitoring.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <view>
  3. <u-navbar :back-text-style="{color:'#fff'}" back-icon-color="#fff" title-color="#fff"
  4. :title="form.warehouseName" :background="{background: '#1569e6'}" :border-bottom="false"></u-navbar>
  5. <view style="display: flex;flex-wrap: wrap;padding-top: 20rpx;">
  6. <view v-for="(item,index) in url" :key="index" style="width: 100%;margin: 20rpx auto;" v-if="index < 3">
  7. <view style="width: 100%;height: 44rpx;font-weight:bold;font-size: 32rpx;text-align: center;">
  8. <u-divider color="#1569e6">{{item.deviceName}}</u-divider>
  9. </view>
  10. <video :src="item.url" autoplay vslide-gesture-in-fullscreen :muted="true"
  11. style="width: 100%;height: 440rpx;margin-bottom: -10rpx;"></video>
  12. </view>
  13. </view>
  14. <view style="display: flex;justify-content: space-around;" v-if="urlList.length > 3">
  15. <u-button type="primary" @click="previousPage" :disabled="total == 0">上一页</u-button>
  16. <u-button type="primary" @click="nextPage" :disabled="urlList.length <= (total+1)*3">下一页</u-button>
  17. </view>
  18. <u-toast ref="uToast"/>
  19. <u-top-tips ref="uTips" :navbar-height="statusBarHeight + navbarHeight"></u-top-tips>
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. data() {
  25. return {
  26. url: [],
  27. urlList:[],
  28. form: '',
  29. timer: null,
  30. total:0,
  31. // 状态栏高度,H5中,此值为0,因为H5不可操作状态栏
  32. statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
  33. // 导航栏内容区域高度,不包括状态栏高度在内
  34. navbarHeight: 44
  35. }
  36. },
  37. onLoad(option) {
  38. this.form = JSON.parse(option.form)
  39. this.url = []
  40. for (let item in this.form.webcam) {
  41. this.getAddress(this.form.webcam[item])
  42. }
  43. },
  44. onUnload() {
  45. // clearInterval(this.timer)
  46. },
  47. onReady() {
  48. this.timer = setInterval(() => {
  49. this.$refs.uTips.show({
  50. title: '直连摄像头查看监控,消耗流量较多,请及时退出',
  51. type: 'info',
  52. duration: '2000'
  53. })
  54. }, 180000)
  55. },
  56. methods: {
  57. //上一页
  58. previousPage(){
  59. this.total--
  60. this.switch()
  61. },
  62. //下一页
  63. nextPage(){
  64. this.total++
  65. this.switch()
  66. },
  67. switch(){
  68. this.url = []
  69. for(let i = 0;i<this.urlList.length;i++){
  70. if(this.total*3 < (i+1) && (i+1) <= (this.total*3)+3){
  71. this.url.push(this.urlList[i])
  72. }
  73. }
  74. },
  75. getAddress(item) {
  76. uni.request({
  77. url: 'https://open.hikyun.com/artemis/api/eits/v1/global/live/address/get/by/deviceSerial', //视频流获取
  78. method: 'POST',
  79. header: {
  80. "access_token": uni.getStorageSync('access_token'),
  81. },
  82. data: {
  83. "toolBar": 0,
  84. "deviceSerial": item.deviceSerial,
  85. "channelNo": 1,
  86. "videoLevel": 1,
  87. "audio": 1,
  88. "autoPlay": 1,
  89. "protocol": 3, //流播放协议,1-ezopen、2-hls、3-rtmp、4-flv,默认为1
  90. "projectId": item.projectId,
  91. "supportH265": 1 //是否要求视频为H265编码格式默认1
  92. },
  93. success: (res) => {
  94. console.log(res)
  95. if (res.data.code == 200) {
  96. this.url.push({
  97. url: res.data.data.url,
  98. deviceName: item.deviceName
  99. })
  100. this.urlList = this.url
  101. } else if(res.data.msg.indexOf("The device is offline") != -1){
  102. this.$refs.uToast.show({
  103. title: '设备离线'
  104. })
  105. } else {
  106. this.$refs.uToast.show({
  107. title: res.data.msg
  108. })
  109. }
  110. }
  111. });
  112. }
  113. },
  114. }
  115. </script>
  116. <style scoped lang="scss">
  117. </style>