var Constant = require('../../utils/constant.js');
|
var app = getApp();
|
import Request from "../../utils/api"
|
/**
|
* ifRotate:是否可旋转
|
* ifFocusing:是否可调焦
|
*/
|
const urls = [{
|
name: '1号监控',
|
src: 'http://hls01open.ys7.com/openlive/6d7b9734fad3402d9537ce5ae1ce3467.hd.m3u8',
|
IsRotateAble: false,
|
IsZoomble: false
|
},
|
{
|
name: '2号监控',
|
src: 'http://hls01open.ys7.com/openlive/61a4e139e958496692312c6f3fcf28b0.hd.m3u8',
|
IsRotateAble: false,
|
IsZoomble: false
|
},]
|
// {
|
// name: '3号监控',
|
// src: 'http://hls01open.ys7.com/openlive/61a4e139e958496692312c6f3fcf28b0.m3u8',
|
// IsRotateAble: true,
|
// IsZoomble: false
|
// },
|
// ]
|
|
|
Page({
|
data: {
|
list: {},
|
moreVideo: [],
|
urls:[],
|
stationID: '',
|
fullScreen: false, // 操作是否显示
|
StartX: '32', //圆点的初始中心点 x轴
|
StartY: '22', //圆点的初始中心点 y轴
|
leftLooks: '32',
|
topLooks: '22',
|
radius: '20',
|
},
|
onLoad(options) {
|
this.videoContext = wx.createVideoContext('myVideo')
|
var that = this;
|
that.setData({
|
stationID: options.stationID
|
})
|
// return;
|
that.onEquipment(options.stationID);
|
},
|
onShareAppMessage: function () {
|
return Constant.Share;
|
},
|
/**播放 */
|
bindPlay: function () {
|
this.videoContext.play()
|
},
|
/**暂停 */
|
bindPause: function () {
|
this.videoContext.pause()
|
},
|
/**播放错误 */
|
videoErrorCallback: function (e) {
|
this.showModal("提示", "视频错误信息")
|
console.log(e.detail.errMsg)
|
},
|
/**视频进入/退出全屏 */
|
fullScreen(e) {
|
if (e.detail.fullScreen) {
|
this.setData({
|
fullScreen: true
|
})
|
} else {
|
this.setData({
|
fullScreen: false
|
})
|
}
|
},
|
|
|
|
|
|
|
onEquipment(id) {
|
// console.log(id,90)
|
if (id == undefined) {
|
var id = 22;
|
}
|
var that = this;
|
Request({
|
url: Constant.BASE_SERVER_URL + "Assets/Camera/Logic/GetHikByBelongTypeAndBelongID@V1.0",
|
header: {
|
'content-type': 'application/json'
|
},
|
method: 'GET',
|
data: {
|
BelongType:'logic-site',
|
BelongID: id
|
},
|
success: function (res) {
|
id = id - 1; //减1获取下标
|
var m_caremaList = res.data.Data;
|
if(m_caremaList==null){
|
wx.showModal({
|
title: '暂无监控数据',
|
content: ''
|
})
|
return
|
}
|
that.setData({
|
list: m_caremaList
|
})
|
m_caremaList.forEach(item=>{
|
|
that.getallVideoAddressSrc(item.ViewToken)
|
})
|
// console.log(that.data.list,"list")
|
},
|
fail: function (res) {
|
console.log('失败')
|
},
|
})
|
},
|
//获取所有的视频列表的播放路径
|
getallVideoAddressSrc(token){
|
let that = this
|
// console.log(token,deviceNo + ":" + channelNo,132)
|
wx.request({
|
url: Constant.YING_SHI_URL + "api/lapp/live/video/list",
|
header: {
|
'content-type': 'application/x-www-form-urlencoded'
|
},
|
method: 'POST',
|
data: {
|
accessToken : token,
|
},
|
success: function (res) {
|
//console.log(res, '摄像头播放地址')
|
let m_allVideoAddressInfo = res.data.data;
|
var m_caremaList = that.data.list;
|
m_caremaList.forEach(item=>{
|
m_allVideoAddressInfo.forEach(allVideoItem=>{
|
if(item.SeriesNO==allVideoItem.deviceSerial&&item.ChannelNo==allVideoItem.channelNo){
|
item.LiveUrl = allVideoItem.hdAddress
|
}
|
})
|
})
|
// console.log(m_caremaList,153)
|
that.setData({
|
list: m_caremaList,
|
moreVideo:m_caremaList
|
})
|
},
|
fail: function (res) {
|
console.log('失败')
|
},
|
})
|
},
|
|
|
|
fullScreenStart(e) {
|
var that = this;
|
var m_caremaList = that.data.list;
|
var i = 1;
|
var cmd = e.currentTarget.dataset.cmd;
|
wx.request({
|
url: Constant.YING_SHI_URL + "api/lapp/device/ptz/start",
|
method: 'POST',
|
header: {
|
'Content-Type': 'application/x-www-form-urlencoded'
|
},
|
data: {
|
accessToken: m_caremaList.ViewToken,
|
deviceSerial: m_caremaList.SeriesNO,
|
channelNo: 1,
|
direction: cmd,
|
speed: 1,
|
},
|
success: function (res) {
|
// console.log(res, i, cmd, '成功fullScreenStart', m_caremaList.ViewToken, m_caremaList.SeriesNO)
|
},
|
fail: function (res) {
|
console.log('失败')
|
},
|
})
|
},
|
fullScreenEnd(e) {
|
var that = this;
|
var m_caremaList = that.data.list;
|
var i = 1;
|
var cmd = e.currentTarget.dataset.cmd;
|
wx.request({
|
url: Constant.YING_SHI_URL + "api/lapp/device/ptz/stop",
|
method: 'POST',
|
header: {
|
'Content-Type': 'application/x-www-form-urlencoded'
|
},
|
data: {
|
accessToken: m_caremaList.ViewToken,
|
deviceSerial: m_caremaList.SeriesNO,
|
channelNo: 1,
|
direction: cmd,
|
speed: 1,
|
},
|
success: function (res) {
|
// console.log(res, i, cmd,'成功fullScreenEnd')
|
},
|
fail: function (res) {
|
console.log('失败')
|
},
|
})
|
|
},
|
showModal(title, body) {
|
wx.showModal({
|
title: title,
|
content: body,
|
success: function (res) {},
|
fail: function (res) {}
|
})
|
},
|
|
onBindtimeupdate(e) {
|
var videoTime = e.detail
|
this.setData({
|
videoTime: {
|
currentTime: videoTime.currentTime,
|
duration: videoTime.duration
|
}
|
})
|
},
|
|
|
ImageTouch: function (e) {
|
// console.log("点击")
|
// console.log(e)
|
},
|
|
|
//拖动摇杆移动
|
ImageTouchMove: function (e) {
|
// console.log(e)
|
var self = this;
|
var touchX = e.touches[0].clientX - 267.5;
|
var touchY = e.touches[0].clientY - 74.75;
|
var movePos = self.GetPosition(touchX, touchY);
|
self.setData({
|
leftLooks: movePos.posX,
|
topLooks: movePos.posY
|
})
|
},
|
//获得触碰位置并且进行数据处理获得触碰位置与拖动范围的交点位置
|
GetPosition: function (touchX, touchY) {
|
var self = this;
|
var DValue_X;
|
var Dvalue_Y;
|
var Dvalue_Z;
|
var imageX;
|
var imageY;
|
var ratio;
|
DValue_X = touchX - self.data.StartX;
|
Dvalue_Y = touchY - self.data.StartY;
|
Dvalue_Z = Math.sqrt(DValue_X * DValue_X + Dvalue_Y * Dvalue_Y);
|
//触碰点在范围内
|
if (Dvalue_Z <= self.data.radius) {
|
imageX = touchX;
|
imageY = touchY;
|
imageX = Math.round(imageX);
|
imageY = Math.round(imageY);
|
return {
|
posX: imageX,
|
posY: imageY
|
};
|
}
|
|
//触碰点在范围外
|
else {
|
ratio = self.data.radius / Dvalue_Z;
|
imageX = DValue_X * ratio + 32;
|
imageY = Dvalue_Y * ratio + 22;
|
imageX = Math.round(imageX);
|
imageY = Math.round(imageY);
|
return {
|
posX: imageX,
|
posY: imageY
|
};
|
}
|
},
|
|
//松开摇杆复原
|
ImageReturn: function (e) {
|
// console.log("松开")
|
// console.log(e)
|
var self = this;
|
self.setData({
|
leftLooks: self.data.StartX,
|
topLooks: self.data.StartY,
|
})
|
},
|
})
|