water_xcx/packageD/pages/device/device.js

101 lines
2.1 KiB
JavaScript

var myRequest = require("../../../utils/api.js");
Page({
/**
* 页面的初始数据
*/
data: {
deviceData: [],
deviceName: ''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getDeviceData();
},
changeHandle(e) {
const { value } = e.detail;
this.setData({
deviceName: value,
});
this.getDeviceData();
},
getDeviceData() {
var that = this;
myRequest.myRequest('system/devicesLocation', {
projectId: wx.getStorageSync('projectId'),
name: that.data.deviceName
},'get').then(function(res){
that.setData({
deviceData: res.data.data,
})
}).catch(function(res){
console.log(res);
})
},
toVideo(e) {
myRequest.myRequest('monitor/getTokenAndSerial', {
deviceCode: e.currentTarget.dataset.code,
},'get').then(function(res){
var data = res.data.data;
var tokenValue = data.accessToken;
var deviceValue = data.deviceSerial;
var channelNoValue = 1;
var modelTypeValue = 'full';
var backModelTypeValue = 'full';
wx.openEmbeddedMiniProgram({ appId: 'wxf2b3a0262975d8c2', path: '/pages/live/live?accessToken=' + tokenValue +'&deviceSerial='+ deviceValue + '&channelNo=' + channelNoValue+'&modelType=' + modelTypeValue+'&backModelType=' + backModelTypeValue, envVersion: 'release'})
}).catch(function(res){
console.log(res);
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})