tanghaolin
2022-11-04 7408718077dce5375650999e44654444b7b8cae8
增加告警记录按日期查询
已修改2个文件
111 ■■■■ 文件已修改
video/single/index.js 89 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
video/single/index.wxml 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
video/single/index.js
@@ -37,7 +37,7 @@
      TokenInfo:{
        LiveUrl:"",
        ViewToken:"at.cbyr6wyr12q4av8b35ha4zrs8e8xzzuk-26knzphnzo-10wmjk6-kyxbisivp",
      }
      },
    },
    Name:"",
    moreVideo: [],
@@ -46,6 +46,15 @@
    videoTabBarIndex:1, //当前的tabbar索引
    isLoadingDeviceAlarmList:false,//是否加载了设备告警记录
    deviceAlarmList:[],//设备告警列表
    alarmPageIndex: 0,
    alarmPageSize: 10,
    isLoadingAllDeviceAlarmListData: false, //是否加载了全部的告警列表数据
    isLoad:false,//列表加载状态
    isShowLoadItem:true, //是否显示加载框
    alarmDate:Utils.getDay("",new Date()) ,
    currentDate:Utils.getDay("",new Date()),
    startTime:Date.parse(new Date(new Date(Utils.getDay("",new Date())).setHours(0, 0, 0, 0))),
    endTime: Date.parse(new Date())
  },
  onLoad(options) {
    this.videoContext = wx.createVideoContext('myVideo')
@@ -72,7 +81,7 @@
    that.setData({
      list:videoInfo
    })
    console.log(videoInfo,"videoInfo")
    // console.log(videoInfo,"videoInfo")
    that.getVideoAddressSrc(videoInfo);
  },
@@ -120,7 +129,7 @@
      source:videoInfo.SeriesNO + ":" + videoInfo.ChannelNo
    },
    success: function (res) {
        console.log(res, '摄像头播放地址')
        // console.log(res, '摄像头播放地址')
      let m_allVideoAddressInfo = res.data.data;
      var m_caremaList = that.data.list;
      m_caremaList.LiveUrl = m_allVideoAddressInfo[0].hlsHd
@@ -148,7 +157,7 @@
getVideoPalyBackSrc(){
  let that = this
  let m_caremaInfo = that.data.list
  console.log(m_caremaInfo,181181)
    // console.log(m_caremaInfo,181181)
  // console.log(token,deviceNo + ":" + channelNo,132)
  wx.request({
    url: Constant.YING_SHI_URL + "api/lapp/v2/live/address/get",
@@ -165,17 +174,20 @@
      type:2
    },
    success: function (res) {
        console.log(res, '摄像头回放地址')
        // console.log(res, '摄像头回放地址')
    },
    fail: function (res) {
      console.log('失败')
    },
  })
},
  //当报警列表加载到底部的时候刷新数据
  toLowerLoadAlarmList(){
    this.getAlarmByDeviceList()
  },
//获取设备告警信息列表
getAlarmByDeviceList(){
  let _this = this
  // console.log(_this.data.list,175)
wx.request({
  url: Constant.YING_SHI_URL +'api/lapp/alarm/device/list',
  header: {
@@ -185,25 +197,56 @@
  data:{
    accessToken:_this.data.list.ViewToken,
    deviceSerial:_this.data.list.SeriesNO,
        pageStart: _this.data.alarmPageIndex,
        pageSize: _this.data.alarmPageSize,
        startTime:_this.data.startTime,
        endTime: _this.data.endTime
  },
  success:res=>{
     console.log(res,188)
        _this.setData({
          isLoad:true,
          isShowLoadItem:false
        })
    if(res.data.code==200){
          if(res.data.data.length == 0){
            _this.setData({
              isShowLoadItem:true
            })
            return
          }
      let arr= []
          if (_this.data.deviceAlarmList.length < res.data.page.total) {
      res.data.data.forEach(item=>{
        item.alarmTime = Utils.formatDay(new Date(item.alarmTime))
              item.alarmTime = Utils.formatTime(new Date(item.alarmTime))
              item.alarmType = _this.getAlarmTypeEnum(item.alarmType)
        arr.push(item)
      })
      _this.setData({
        deviceAlarmList:arr,
              alarmPageIndex: ++ _this.data.alarmPageIndex,
              deviceAlarmList: _this.data.deviceAlarmList.concat(arr),
        isLoadingDeviceAlarmList:true
      })
          }
          if (_this.data.deviceAlarmList.length == res.data.page.total) {
            _this.setData({
              isLoadingAllDeviceAlarmListData: true,
              // isShowLoadItem:true
            })
            return
          }
    }
  },
  fail:err=>{
    console.log(err,191)
  }
})
  },
  // 获取警告类型枚举
  getAlarmTypeEnum(type){
    if(type == 10002){
      return type = "移动侦测告警"
    }
},
//监控功能tabBar切换 
videoTabBarChange(e){
@@ -214,6 +257,33 @@
  this.setData({
    videoTabBarIndex:e.currentTarget.dataset.id
  })
  },
  //告警查询日期选择
  alarmDateChange(e){
    // console.log(e,258)
    let startTime = ""
    let endTime = ""
    let selectDate = Date.parse(new Date(e.detail.value))
    let currentDate = Date.parse(new Date())
    //判断选择的日期与今天是不是同一天
    if(selectDate == currentDate){
      startTime = Date.parse(new Date(new Date(Utils.getDay("",new Date())).setHours(0, 0, 0, 0)))
      endTime = Date.parse(new Date())
    }else {
      startTime = Date.parse(new Date(new Date(e.detail.value).setHours(0, 0, 0, 0)))
      endTime = Date.parse(new Date(new Date(e.detail.value).setHours(23, 59, 0, 0)))
    }
    // console.log(selectDate,currentDate,266)
    this.setData({
      deviceAlarmList:[],
      alarmDate:e.detail.value,
      alarmPageIndex:0,
      alarmPageSize:10,
      startTime:startTime,
      endTime:endTime,
    })
    this.getAlarmByDeviceList()
},
  fullScreenStart(e) {
    var that = this;
@@ -295,10 +365,9 @@
    })
  },
  toPlayBack(){
    console.log(this.data.moreVideo,305)
    // console.log(this.data.moreVideo,305)
    wx.navigateTo({
      url: '../playBack/index',
    })
  },
})
video/single/index.wxml
@@ -7,7 +7,7 @@
  <button bindtap="bindPause" class="page-body-button" type="primary">暂停</button>
</view> -->
<video wx:if="{{list.LiveUrl && list}}" id="myVideo" src="{{list.LiveUrl}}" binderror="videoErrorCallback" bindfullscreenchange="fullScreen" title='{{list.Name}}号监控'  enable-play-gesture show-mute-btn autoplay="{{list.LiveUrl.length>0?true:false}}"
<video wx:if="{{list.LiveUrl && list}}" id="myVideo" src="{{list.LiveUrl}}" bindfullscreenchange="fullScreen" title='{{list.Name}}号监控'  enable-play-gesture show-mute-btn autoplay="{{list.LiveUrl.length>0?true:false}}"
show-progress="{{true}}" bindtimeupdate="onBindtimeupdate">
  <view class="v_operation" wx:if='{{list.IsRotateAble==true && fullScreen==true}}'>
    <icon class="iconfont icon-jiantou IsRotateAble   data-cmd='0'" bindtouchstart="fullScreenStart" bindtouchend="fullScreenEnd" ></icon>
@@ -91,15 +91,25 @@
      </view>
</view>
<!-- 告警列表 -->
<scroll-view style="height: calc(100vh - 271px);" scroll-y wx:if="{{videoTabBarIndex == 2}}">
<!-- 时间选择 -->
<view class="cu-form-group" wx:if="{{videoTabBarIndex == 2}}">
    <picker mode="date" value="{{alarmDate}}" start="1900-1-1" end="{{currentDate}}" bindchange="alarmDateChange">
      <view class="picker">
        {{alarmDate}}
      </view>
    </picker>
  </view>
<scroll-view style="height: calc(100vh - 323px);" lower-threshold="72" bindscrolltolower="toLowerLoadAlarmList" scroll-y wx:if="{{videoTabBarIndex == 2}}">
  <view class="cu-list menu menu-avatar" style="margin-top:5rpx">
  <view class="cu-item " wx:for="{{deviceAlarmList}}" wx:for-item="alarm_item" wx:for-index="index" wx:key="index">
    <view class="cu-avatar radius lg" style="background-image:url({{alarm_item.alarmPicUrl}});"></view>
    <view class='content' style="width: 100%;">
      <view>{{alarm_item.alarmName}}</view>
    <view class="cu-avatar radius lg"  style="width: 200rpx;height:110rpx;background-image:url({{alarm_item.alarmPicUrl}});"></view>
    <view class='content' style="width: 100%;left:270rpx">
      <view>告警类型:{{alarm_item.alarmType}}</view>
      <view class='text-gray text-sm'>
        {{alarm_item.alarmTime}}</view>
        告警时间:{{alarm_item.alarmTime}}
    </view>
  </view>
  </view>
  <view wx:if="{{isShowLoadItem}}" class="cu-load bg-grey {{!isLoad?'loading':'over'}}"></view>
  </view>
</scroll-view>