Merge branch 'liubiao-new-20250827'
This commit is contained in:
1095
pages/670/HBY670.vue
1095
pages/670/HBY670.vue
File diff suppressed because it is too large
Load Diff
446
pages/670/History.vue
Normal file
446
pages/670/History.vue
Normal file
@ -0,0 +1,446 @@
|
||||
<template>
|
||||
<view class="content contentBg">
|
||||
<view class="topTip">
|
||||
<view class="item" @click="tabChange(0)" :class="Status.tabIndex===0?'active':''">开机</view>
|
||||
<view class="item" @click="tabChange(1)" :class="Status.tabIndex===1?'active':''">报警</view>
|
||||
<view class="item" @click="tabChange(2)" :class="Status.tabIndex===2?'active':''">故障</view>
|
||||
</view>
|
||||
<view class="tabs">
|
||||
|
||||
<view class="tab" :class="Status.tabIndex===0?'active':''">
|
||||
<view class="li" v-for="item,index in SwithData">
|
||||
<view>
|
||||
<view class="label">开机时间</view>
|
||||
<view class="value">{{item['open']}}</view>
|
||||
</view>
|
||||
<view class="marginTop10">
|
||||
<view class="label">关机时间</view>
|
||||
<view class="value">{{item['close']}}</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
<view class="tab" :class="Status.tabIndex===1?'active':''">
|
||||
<view class="li warn" v-for="item,index in WarnData">
|
||||
<view class="row">
|
||||
<view class="label">报警事项:</view>
|
||||
<view class="value red">{{item['evtName']}}</view>
|
||||
</view>
|
||||
<view class="marginTop10 row">
|
||||
<view class="label">报警地点:</view>
|
||||
<view class="value">{{item['address']}}</view>
|
||||
</view>
|
||||
<view class="marginTop10 row">
|
||||
<view class="label">报警时间:</view>
|
||||
<view class="value">{{item['open']}}</view>
|
||||
</view>
|
||||
<view class="marginTop10 row">
|
||||
<view class="label">解除时间:</view>
|
||||
<view class="value">{{item['close']}}</view>
|
||||
</view>
|
||||
<view class="marginTop10 row">
|
||||
<view class="label">报警时长:</view>
|
||||
<view class="value">{{item['time']}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="tab" :class="Status.tabIndex===2?'active':''">
|
||||
|
||||
<view class="li warn" v-for="item,index in FaultData">
|
||||
<view class="row">
|
||||
<view class="label">故障部位:</view>
|
||||
<view class="value red">{{item['evtName']}}</view>
|
||||
</view>
|
||||
|
||||
<view class="marginTop10 row">
|
||||
<view class="label">故障时间:</view>
|
||||
<view class="value">{{item['open']}}</view>
|
||||
</view>
|
||||
<view class="marginTop10 row">
|
||||
<view class="label">处理时间:</view>
|
||||
<view class="value">{{item['close']}}</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<global-loading ref="loading"></global-loading>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Common from '@/utils/Common.js';
|
||||
import api from '@/api/670/History.js'
|
||||
import {
|
||||
showLoading,
|
||||
hideLoading,
|
||||
updateLoading
|
||||
} from '@/utils/loading.js'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
Status: {
|
||||
tabIndex: 1
|
||||
},
|
||||
device: {},
|
||||
SwithData: [], //开关机的数据
|
||||
FaultData: [], //故障数据
|
||||
WarnData: [], //报警数据
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
var these = this;
|
||||
let channel = this.getOpenerEventChannel();
|
||||
channel.on('detailData', function(opt) {
|
||||
console.log("我收到你的数据了,谢谢你。", opt.data);
|
||||
these.device = opt.data;
|
||||
these.tabChange(these.Status.tabIndex, true);
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
loadWarnData() { //加载报警数据
|
||||
var these = this;
|
||||
let promise1 = new Promise((resolve, reject) => {
|
||||
let arr = [];
|
||||
let endDate = new Date();
|
||||
|
||||
arr.push({
|
||||
evtName: '环境存在漏电电源',
|
||||
address: '湖北省武汉市洪山区关山街道国际企业中心聚星楼',
|
||||
open: Common.DateFormat(endDate),
|
||||
time: '00:00:59'
|
||||
});
|
||||
for (var i = 1; i < 10; i++) {
|
||||
arr.push({
|
||||
evtName: '环境存在漏电电源',
|
||||
address: '湖北省武汉市洪山区关山街道国际企业中心聚星楼',
|
||||
open: Common.DateFormat(endDate.setHours(i * -24)),
|
||||
time: '00:00:59'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
let item = new Date(arr[i].open);
|
||||
let close = Common.DateFormat(item.setHours(4));
|
||||
arr[i].close = close;
|
||||
|
||||
}
|
||||
resolve(arr);
|
||||
});
|
||||
let promise2 = new Promise((resolve, reject) => {
|
||||
api.getWarnData(this.device).then((res) => {
|
||||
resolve(res);
|
||||
}).catch((ex) => {
|
||||
console.log("获取数据异常", ex);
|
||||
reject(ex);
|
||||
});
|
||||
});
|
||||
|
||||
Promise.allSettled([promise1, promise2]).then(results => {
|
||||
if (results[1].status == 'fulfilled') {
|
||||
these.WarnData = results[1].value;
|
||||
} else {
|
||||
these.WarnData = results[0].value;
|
||||
}
|
||||
|
||||
});
|
||||
},
|
||||
loadSwithData() { //加载开关机数据
|
||||
var these = this;
|
||||
let promise1 = new Promise((resolve, reject) => {
|
||||
let arr = [];
|
||||
let endDate = new Date();
|
||||
|
||||
arr.push({
|
||||
open: Common.DateFormat(endDate)
|
||||
});
|
||||
for (var i = 1; i < 10; i++) {
|
||||
arr.push({
|
||||
open: Common.DateFormat(endDate.setHours(i * -24))
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
let item = new Date(arr[i].open);
|
||||
let close = Common.DateFormat(item.setHours(4));
|
||||
arr[i].close = close;
|
||||
|
||||
}
|
||||
resolve(arr);
|
||||
});
|
||||
|
||||
|
||||
let promise2 = new Promise((resolve, reject) => {
|
||||
api.getSwithData(this.device).then((res) => {
|
||||
resolve(res);
|
||||
}).catch((ex) => {
|
||||
console.log("获取数据异常", ex);
|
||||
reject(ex);
|
||||
});
|
||||
});
|
||||
|
||||
Promise.allSettled([promise1, promise2]).then(results => {
|
||||
if (results[1].status == 'fulfilled') {
|
||||
these.SwithData = results[1].value;
|
||||
} else {
|
||||
these.SwithData = results[0].value;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
loadFaultData() { //加载故障数据
|
||||
var these = this;
|
||||
let promise1 = new Promise((resolve, reject) => {
|
||||
let arr = [];
|
||||
let endDate = new Date();
|
||||
|
||||
let dic = ['报警灯', '蜂鸣器', '电池', '蓝牙模块', '定位器', '4G模块'];
|
||||
arr.push({
|
||||
evtName: '报警灯',
|
||||
|
||||
open: Common.DateFormat(endDate),
|
||||
|
||||
});
|
||||
for (var i = 1; i < 10; i++) {
|
||||
arr.push({
|
||||
evtName: dic[i % 6],
|
||||
|
||||
open: Common.DateFormat(endDate.setHours(i * -24)),
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
let item = new Date(arr[i].open);
|
||||
let close = Common.DateFormat(item.setHours(72), "yyyy-MM-dd");
|
||||
arr[i].close = close;
|
||||
|
||||
}
|
||||
resolve(arr);
|
||||
});
|
||||
|
||||
let promise2 = new Promise((resolve, reject) => {
|
||||
api.getFaulData(this.device).then((res) => {
|
||||
resolve(res);
|
||||
}).catch((ex) => {
|
||||
console.log("获取数据异常", ex);
|
||||
reject(ex);
|
||||
});
|
||||
});
|
||||
|
||||
Promise.allSettled([promise1, promise2]).then(results => {
|
||||
if (results[1].status == 'fulfilled') {
|
||||
these.FaultData = results[1].value;
|
||||
} else {
|
||||
these.FaultData = results[0].value;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
tabChange(index, ispostback) {
|
||||
if (this.Status.tabIndex === index && !ispostback) {
|
||||
return;
|
||||
}
|
||||
this.Status.tabIndex = index;
|
||||
showLoading(this);
|
||||
let promise = new Promise((resolve, reject) => {
|
||||
try {
|
||||
if (index === 0) {
|
||||
this.loadSwithData();
|
||||
} else if (index === 1) {
|
||||
this.loadWarnData();
|
||||
} else if (index === 2) {
|
||||
this.loadFaultData();
|
||||
}
|
||||
} catch (error) {
|
||||
//TODO handle the exception
|
||||
} finally {
|
||||
hideLoading(this);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.tab .warn .value {
|
||||
padding-left: 10rpx;
|
||||
}
|
||||
|
||||
.tab .warn .value.red {
|
||||
color: rgba(224, 52, 52, 1) !important;
|
||||
}
|
||||
|
||||
.tab .warn .row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
align-content: center;
|
||||
justify-content: flex-start;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.marginTop10 {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.tab .li .value {
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
width: calc(100% - 110rpx);
|
||||
height: auto;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.tab .li .label {
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
white-space: nowrap;
|
||||
width: 110rpx;
|
||||
|
||||
}
|
||||
|
||||
.tab .li {
|
||||
font-family: 'PingFang SC';
|
||||
font-size: 24rpx;
|
||||
font-weight: 400;
|
||||
line-height: 35rpx;
|
||||
letter-spacing: 0.14rpx;
|
||||
|
||||
width: 100%;
|
||||
border-radius: 16rpx;
|
||||
margin-top: 24rpx;
|
||||
background: rgba(26, 26, 26, 1);
|
||||
box-sizing: border-box;
|
||||
padding: 20rpx 30rpx;
|
||||
}
|
||||
|
||||
.tab.active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.tab {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.tabs {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.topTip .item.active {
|
||||
color: rgba(187, 230, 0, 1) !important;
|
||||
font-size: 36rpx !important;
|
||||
|
||||
}
|
||||
|
||||
.topTip .item.active::before {
|
||||
background: rgba(187, 230, 0, 1);
|
||||
}
|
||||
|
||||
.topTip .item::before {
|
||||
content: "";
|
||||
width: 50%;
|
||||
height: 4px;
|
||||
border-radius: 31px;
|
||||
position: absolute;
|
||||
background: #00000000;
|
||||
bottom: -10px;
|
||||
left: 25%;
|
||||
}
|
||||
|
||||
.topTip .item {
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
font-family: 'PingFang SC';
|
||||
font-size: 28rpx;
|
||||
font-weight: 400;
|
||||
letter-spacing: 0.14rpx;
|
||||
position: relative;
|
||||
|
||||
}
|
||||
|
||||
.topTip {
|
||||
padding: 30rpx 0rpx;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
align-content: center;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
position: sticky;
|
||||
background-color: #121212;
|
||||
height: 110rpx;
|
||||
z-index: 9999;
|
||||
margin-top: -30rpx;
|
||||
}
|
||||
|
||||
/* #ifdef H5 */
|
||||
/* 仅在 H5 平台生效的样式 */
|
||||
.topTip {
|
||||
top: 44px;
|
||||
|
||||
}
|
||||
|
||||
/* #endif */
|
||||
|
||||
/* #ifdef APP-PLUS */
|
||||
/* 仅在 App 平台生效的样式 */
|
||||
.topTip {
|
||||
top: 0rpx;
|
||||
}
|
||||
|
||||
/* #endif */
|
||||
|
||||
.content {
|
||||
padding: 30rpx;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
min-height: 100vh;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.contentBg {
|
||||
background-color: #121212;
|
||||
color: #ffffffde;
|
||||
}
|
||||
|
||||
.fleft {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.fright {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.clear {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.displayNone {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.p100 {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.center {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
align-content: center;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
@ -78,6 +78,7 @@
|
||||
ble.removeReceiveCallback(pagePath);
|
||||
},
|
||||
onUnload() {
|
||||
console.log("返回时断开蓝牙连接,取消订阅");
|
||||
ble.removeReceiveCallback(pagePath);
|
||||
},
|
||||
onLoad(option) {
|
||||
@ -86,12 +87,12 @@
|
||||
ble.addReceiveCallback((receive,f,path) => {
|
||||
console.log("收到设备消息,", receive);
|
||||
if (these.device.deviceId == receive.deviceId) {
|
||||
console.log("11111");
|
||||
// console.log("11111");
|
||||
|
||||
if (receive.bytes[0] == 0xFC || receive.str.indexOf('mac address:') == 0) {
|
||||
if (f && f.macAddress) {
|
||||
these.device.macAddress = f.macAddress;
|
||||
console.log("222222");
|
||||
// console.log("222222");
|
||||
these.initDevice();
|
||||
}
|
||||
}
|
||||
@ -99,13 +100,23 @@
|
||||
},pagePath);
|
||||
eventChannel = this.getOpenerEventChannel();
|
||||
eventChannel.on('LinkItem', function(data) {
|
||||
console.log("data=",data);
|
||||
let f = ble.data.LinkedList.find((v) => {
|
||||
return v.deviceId = data.deviceId;
|
||||
return v.deviceId == data.deviceId;
|
||||
});
|
||||
if (f) {
|
||||
these.device = Object.assign({}, these.device, f);
|
||||
console.log("获取到设备", f);
|
||||
|
||||
let keys=Object.keys(f);
|
||||
keys.forEach((v,index)=>{
|
||||
these.device[v]=f[v];
|
||||
})
|
||||
console.log("LinkedList=",ble.data.LinkedList)
|
||||
console.log("f=", f);
|
||||
console.log("获取到设备", these.device);
|
||||
if (f.macAddress) {
|
||||
these.device.macAddress = f.macAddress;
|
||||
|
||||
these.initDevice();
|
||||
}
|
||||
} else {
|
||||
console.log("未获取到设备");
|
||||
}
|
||||
@ -117,6 +128,7 @@
|
||||
showLoading(these, {
|
||||
text: '正在获取设备信息'
|
||||
});
|
||||
console.log("these.device=",these.device);
|
||||
request({
|
||||
url: '/app/device/getDeviceInfoByDeviceMac',
|
||||
method: 'GET',
|
||||
@ -130,12 +142,12 @@
|
||||
if (data) {
|
||||
let keys = Object.keys(data);
|
||||
ble.data.LinkedList.find((v) => {
|
||||
if(v.deviceId = these.device.deviceId){
|
||||
if(v.deviceId == these.device.deviceId){
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
let key = keys[i];
|
||||
v[key] = data[key];
|
||||
console.log("key="+key);
|
||||
console.log("value="+data[key]);
|
||||
// console.log("key="+key);
|
||||
// console.log("value="+data[key]);
|
||||
|
||||
|
||||
these.$set(these.device, key, data[key]);
|
||||
@ -163,7 +175,7 @@
|
||||
// 调用绑定设备接口
|
||||
|
||||
let f = ble.data.LinkedList.find((v) => {
|
||||
return v.deviceId = these.device.deviceId;
|
||||
return v.deviceId == these.device.deviceId;
|
||||
});
|
||||
if (!f) {
|
||||
these.Statu.bound = false;
|
||||
@ -195,7 +207,7 @@
|
||||
if (res.code == 200) {
|
||||
these.Statu.bound = true;
|
||||
these.Statu.boundRemark = "设备绑定成功!";
|
||||
|
||||
ble.removeReceiveCallback(pagePath);
|
||||
|
||||
uni.$emit("refreshDeviceList");
|
||||
setTimeout(() => {
|
||||
|
@ -136,7 +136,7 @@
|
||||
},
|
||||
onHide: function() {
|
||||
ble.StopSearch();
|
||||
ble.removeReceiveCallback(pagePath);
|
||||
|
||||
},
|
||||
onBackPress: (e) => {
|
||||
ble.StopSearch();
|
||||
@ -145,8 +145,7 @@
|
||||
},
|
||||
onUnload(){
|
||||
ble.StopSearch();
|
||||
ble.removeDeviceFound(pagePath);
|
||||
ble.removeReceiveCallback(pagePath);
|
||||
|
||||
},
|
||||
onLoad() {
|
||||
these = this;
|
||||
@ -172,7 +171,12 @@
|
||||
}
|
||||
}
|
||||
},pagePath);
|
||||
|
||||
// ble.addReceiveCallback((receivData) => {
|
||||
// console.log("收到数据了:", receivData);//数据格式:{bytes:[109,97],str:"",hexs:"FA 01"}
|
||||
|
||||
// // let data=uni.getStorageSync(ble.StorageKey);
|
||||
// console.log("LinkedList=",ble.data.LinkedList);
|
||||
// },pagePath);
|
||||
},
|
||||
|
||||
onShow: function() {
|
||||
@ -187,12 +191,7 @@
|
||||
});
|
||||
|
||||
|
||||
ble.addReceiveCallback((receivData) => {
|
||||
console.log("收到数据了:", receivData);//数据格式:{bytes:[109,97],str:"",hexs:"FA 01"}
|
||||
console.log("LinkedList=",ble.data.LinkedList);
|
||||
let data=uni.getStorageSync(ble.StorageKey);
|
||||
console.log("data=",data);
|
||||
},pagePath);
|
||||
|
||||
|
||||
|
||||
},
|
||||
@ -241,7 +240,7 @@
|
||||
|
||||
these.PairEquip.push(item);
|
||||
}
|
||||
ble.removeReceiveCallback(pagePath);
|
||||
console.log("连接成功");
|
||||
uni.navigateTo({
|
||||
url:"/pages/common/addBLE/LinkBle",
|
||||
events:{
|
||||
|
@ -486,6 +486,10 @@
|
||||
// 列表跳转
|
||||
handleFile(item) {
|
||||
let url = item.detailPageUrl;
|
||||
// console.log("url=",url);
|
||||
// if(!url){
|
||||
//url="/pages/670/HBY670"
|
||||
// }
|
||||
uni.navigateTo({
|
||||
url: url,
|
||||
events: {
|
||||
@ -498,6 +502,8 @@
|
||||
deviceType: this.tabs[this.activeTab].id || '',
|
||||
apiType: 'listA' //标识,根据这个参数,区分普通详情,分享跳转详情,查不一样的权限信息
|
||||
});
|
||||
},fail(ex) {
|
||||
console.log("ex=",ex);
|
||||
}
|
||||
})
|
||||
},
|
||||
|
Reference in New Issue
Block a user