tanghaolin
2022-11-04 7408718077dce5375650999e44654444b7b8cae8
增加告警记录按日期查询
已修改2个文件
349 ■■■■■ 文件已修改
video/single/index.js 327 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
video/single/index.wxml 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
video/single/index.js
@@ -1,6 +1,6 @@
var Constant = require('../../utils/constant.js');
var app = getApp();
import Request  from "../../utils/api"
import Request from "../../utils/api"
let Utils = require('../../utils/util');
/**
 * ifRotate:是否可旋转
@@ -29,23 +29,32 @@
Page({
  data: {
    list: {
      Code:"",
      Name:"",
      SeriesNO:"",
      IsRotateAble:true,
      IsZoomble:false,
      TokenInfo:{
        LiveUrl:"",
        ViewToken:"at.cbyr6wyr12q4av8b35ha4zrs8e8xzzuk-26knzphnzo-10wmjk6-kyxbisivp",
      }
      Code: "",
      Name: "",
      SeriesNO: "",
      IsRotateAble: true,
      IsZoomble: false,
      TokenInfo: {
        LiveUrl: "",
        ViewToken: "at.cbyr6wyr12q4av8b35ha4zrs8e8xzzuk-26knzphnzo-10wmjk6-kyxbisivp",
      },
    },
    Name:"",
    Name: "",
    moreVideo: [],
    fullScreen: false, // 操作是否显示
    btnCmd:"",//当前操作的cmd按钮
    videoTabBarIndex:1, //当前的tabbar索引
    isLoadingDeviceAlarmList:false,//是否加载了设备告警记录
    deviceAlarmList:[],//设备告警列表
    btnCmd: "", //当前操作的cmd按钮
    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')
@@ -60,7 +69,7 @@
        title: videoInfo.Name,
      })
      that.setData({
        Name:videoInfo.Name
        Name: videoInfo.Name
      })
    }
    if (options.more == 'CA') {
@@ -70,9 +79,9 @@
      return;
    }
    that.setData({
      list:videoInfo
      list: videoInfo
    })
    console.log(videoInfo,"videoInfo")
    // console.log(videoInfo,"videoInfo")
    that.getVideoAddressSrc(videoInfo);
  },
@@ -105,123 +114,184 @@
    }
  },
//获取所有的视频列表的播放路径
getVideoAddressSrc(videoInfo){
  let that = this
  // console.log(token,deviceNo + ":" + channelNo,132)
  wx.request({
    url: Constant.YING_SHI_URL + "api/lapp/live/address/get",
    header: {
      'content-type': 'application/x-www-form-urlencoded'
    },
    method: 'POST',
    data: {
      accessToken : videoInfo.ViewToken,
      source:videoInfo.SeriesNO + ":" + videoInfo.ChannelNo
    },
    success: function (res) {
        console.log(res, '摄像头播放地址')
      let m_allVideoAddressInfo = res.data.data;
      var m_caremaList = that.data.list;
      m_caremaList.LiveUrl = m_allVideoAddressInfo[0].hlsHd
      // console.log(m_caremaList,140)
  //获取所有的视频列表的播放路径
  getVideoAddressSrc(videoInfo) {
    let that = this
    // console.log(token,deviceNo + ":" + channelNo,132)
    wx.request({
      url: Constant.YING_SHI_URL + "api/lapp/live/address/get",
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      method: 'POST',
      data: {
        accessToken: videoInfo.ViewToken,
        source: videoInfo.SeriesNO + ":" + videoInfo.ChannelNo
      },
      success: function (res) {
        // console.log(res, '摄像头播放地址')
        let m_allVideoAddressInfo = res.data.data;
        var m_caremaList = that.data.list;
        m_caremaList.LiveUrl = m_allVideoAddressInfo[0].hlsHd
        // console.log(m_caremaList,140)
      m_caremaList.Code = m_allVideoAddressInfo[0].deviceName
      m_caremaList.Name= that.data.Name
      m_caremaList.SeriesNO = m_allVideoAddressInfo[0].deviceSerial
      m_caremaList.IsRotateAble= true
      m_caremaList.IsZoomble= false
        m_caremaList.Code = m_allVideoAddressInfo[0].deviceName
        m_caremaList.Name = that.data.Name
        m_caremaList.SeriesNO = m_allVideoAddressInfo[0].deviceSerial
        m_caremaList.IsRotateAble = true
        m_caremaList.IsZoomble = false
      that.setData({
        list: m_caremaList
      })
      // that.getVideoPalyBackSrc()
      //  console.log(that.data.list,"list")
    },
    fail: function (res) {
      console.log('失败')
    },
  })
},
//获取视频回放路径
getVideoPalyBackSrc(){
  let that = this
  let m_caremaInfo = that.data.list
  console.log(m_caremaInfo,181181)
  // console.log(token,deviceNo + ":" + channelNo,132)
  wx.request({
    url: Constant.YING_SHI_URL + "api/lapp/v2/live/address/get",
    header: {
      'content-type': 'application/x-www-form-urlencoded'
    },
    method: 'POST',
    data: {
      accessToken : m_caremaInfo.TokenInfo.ViewToken,
      deviceSerial:m_caremaInfo.SeriesNO,
      protocol:1,
      startTime:"2022-10-13 00:00:00",
      stopTime:"2022-10-18 00:00:00",
      type:2
    },
    success: function (res) {
        console.log(res, '摄像头回放地址')
    },
    fail: function (res) {
      console.log('失败')
    },
  })
},
//获取设备告警信息列表
getAlarmByDeviceList(){
  let _this = this
  // console.log(_this.data.list,175)
wx.request({
  url: Constant.YING_SHI_URL +'api/lapp/alarm/device/list',
  header: {
    'content-type': 'application/x-www-form-urlencoded'
        that.setData({
          list: m_caremaList
        })
        // that.getVideoPalyBackSrc()
        //  console.log(that.data.list,"list")
      },
      fail: function (res) {
        console.log('失败')
      },
    })
  },
  method: 'POST',
  data:{
    accessToken:_this.data.list.ViewToken,
    deviceSerial:_this.data.list.SeriesNO,
  //获取视频回放路径
  getVideoPalyBackSrc() {
    let that = this
    let m_caremaInfo = that.data.list
    // console.log(m_caremaInfo,181181)
    // console.log(token,deviceNo + ":" + channelNo,132)
    wx.request({
      url: Constant.YING_SHI_URL + "api/lapp/v2/live/address/get",
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      method: 'POST',
      data: {
        accessToken: m_caremaInfo.TokenInfo.ViewToken,
        deviceSerial: m_caremaInfo.SeriesNO,
        protocol: 1,
        startTime: "2022-10-13 00:00:00",
        stopTime: "2022-10-18 00:00:00",
        type: 2
      },
      success: function (res) {
        // console.log(res, '摄像头回放地址')
      },
      fail: function (res) {
        console.log('失败')
      },
    })
  },
  success:res=>{
     console.log(res,188)
    if(res.data.code==200){
      let arr= []
      res.data.data.forEach(item=>{
        item.alarmTime = Utils.formatDay(new Date(item.alarmTime))
        arr.push(item)
      })
      _this.setData({
        deviceAlarmList:arr,
        isLoadingDeviceAlarmList:true
      })
  //当报警列表加载到底部的时候刷新数据
  toLowerLoadAlarmList(){
    this.getAlarmByDeviceList()
  },
  //获取设备告警信息列表
  getAlarmByDeviceList() {
    let _this = this
    wx.request({
      url: Constant.YING_SHI_URL + 'api/lapp/alarm/device/list',
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      method: 'POST',
      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.formatTime(new Date(item.alarmTime))
              item.alarmType = _this.getAlarmTypeEnum(item.alarmType)
              arr.push(item)
            })
            _this.setData({
              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 = "移动侦测告警"
    }
  },
  fail:err=>{
    console.log(err,191)
  }
})
},
//监控功能tabBar切换
videoTabBarChange(e){
  // console.log(e,173)
  if(e.currentTarget.dataset.id == 2 && !this.data.isLoadingDeviceAlarmList){
  //监控功能tabBar切换
  videoTabBarChange(e) {
    // console.log(e,173)
    if (e.currentTarget.dataset.id == 2 && !this.data.isLoadingDeviceAlarmList) {
      this.getAlarmByDeviceList()
  }
  this.setData({
    videoTabBarIndex:e.currentTarget.dataset.id
  })
},
    }
    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;
    var m_caremaList = that.data.list;
    var i = 1;
    var cmd = e.currentTarget.dataset.cmd;
    that.setData({
      btnCmd:e.currentTarget.dataset.direction
      btnCmd: e.currentTarget.dataset.direction
    })
    wx.request({
      url: Constant.YING_SHI_URL + "api/lapp/device/ptz/start",
@@ -251,7 +321,7 @@
    var i = 1;
    var cmd = e.currentTarget.dataset.cmd;
    that.setData({
      btnCmd:""
      btnCmd: ""
    })
    wx.request({
      url: Constant.YING_SHI_URL + "api/lapp/device/ptz/stop",
@@ -267,7 +337,7 @@
        speed: 1,
      },
      success: function (res) {
          // console.log(res, i, cmd,'成功fullScreenEnd')
        // console.log(res, i, cmd,'成功fullScreenEnd')
      },
      fail: function (res) {
        console.log('失败')
@@ -289,16 +359,15 @@
    var videoTime = e.detail
    this.setData({
      videoTime: {
        currentTime: videoTime.currentTime?videoTime.currentTime:0,
        duration: videoTime.duration?videoTime.duration:0
        currentTime: videoTime.currentTime ? videoTime.currentTime : 0,
        duration: videoTime.duration ? videoTime.duration : 0
      }
    })
  },
  toPlayBack(){
    console.log(this.data.moreVideo,305)
  toPlayBack() {
    // 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>