添加报警功能
This commit is contained in:
41
App.vue
41
App.vue
@ -1,14 +1,46 @@
|
|||||||
<script>
|
<script>
|
||||||
|
import bleTool from '@/utils/BleHelper.js'
|
||||||
|
import upgrade from '@/utils/update.js'
|
||||||
export default {
|
export default {
|
||||||
|
|
||||||
onLaunch: function() {
|
onLaunch: function() {
|
||||||
|
//以下代码仅在开发时使用,否则会出现不可预知的问题。
|
||||||
|
//清除登陆之外的所有信息;
|
||||||
|
// let store=uni.getStorageInfoSync();
|
||||||
|
// store.keys.forEach((val,index,array)=>{
|
||||||
|
// if(val=="tokenTime"){
|
||||||
|
// let time=uni.getStorageSync(val);
|
||||||
|
// if(!time){
|
||||||
|
// time=0;
|
||||||
|
// }
|
||||||
|
// let currTime=new Date().getTime();
|
||||||
|
// if(currTime>=time){
|
||||||
|
// uni.removeStorageSync(val);
|
||||||
|
// uni.removeStorageSync("token");
|
||||||
|
// uni.removeStorageSync("clientID");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else if(val=="token" || val=="clientID"){
|
||||||
|
// console.log("忽略登陆信息");
|
||||||
|
// }else{
|
||||||
|
// uni.removeStorageSync(val);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
//以上代码仅在开发时使用,否则会出现不可预知的问题。
|
||||||
|
|
||||||
|
uni.getSystemInfo({success:function(res){
|
||||||
|
if(res.uniPlatform=='app'){
|
||||||
|
upgrade.checkAndUpdateWgt("http://114.55.111.217/app/CheckUpdate");
|
||||||
|
bleTool.getBleTool();
|
||||||
|
}
|
||||||
|
}});
|
||||||
},
|
},
|
||||||
onShow: function() {
|
onShow: function() {
|
||||||
console.log('App Show')
|
console.log('App Show');
|
||||||
|
|
||||||
},
|
},
|
||||||
onHide: function() {
|
onHide: function() {
|
||||||
console.log('App Hide')
|
console.log('App Hide');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@ -54,4 +86,9 @@
|
|||||||
.uni-picker-view-wrapper{
|
.uni-picker-view-wrapper{
|
||||||
background: rgba(42, 42, 42, 1);
|
background: rgba(42, 42, 42, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: "PingFang SC";
|
||||||
|
src: url("~@/static/fonts/PingFangSC.ttf") format("opentype");
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {request,baseURL} from '@/utils/request'
|
import request, { baseURL } from '@/utils/request'
|
||||||
|
|
||||||
function getdata(data,url,method){
|
function getdata(data,url,method){
|
||||||
return new Promise((resolve,reject)=>{
|
return new Promise((resolve,reject)=>{
|
||||||
@ -14,6 +14,7 @@ function getdata(data,url,method){
|
|||||||
method: method,
|
method: method,
|
||||||
data:data
|
data:data
|
||||||
}).then((res)=>{
|
}).then((res)=>{
|
||||||
|
console.log("res=",res);
|
||||||
resolve(res);
|
resolve(res);
|
||||||
}).catch(ex=>{
|
}).catch(ex=>{
|
||||||
reject(ex);
|
reject(ex);
|
||||||
|
55
api/670/History.js
Normal file
55
api/670/History.js
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
import request, { baseURL } from '@/utils/request'
|
||||||
|
|
||||||
|
function getdata(data,url,method){
|
||||||
|
return new Promise((resolve,reject)=>{
|
||||||
|
if(!url){
|
||||||
|
reject('url为空');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(!method){
|
||||||
|
method='POST';
|
||||||
|
}
|
||||||
|
request({
|
||||||
|
url: url,
|
||||||
|
method: method,
|
||||||
|
data:data
|
||||||
|
}).then((res)=>{
|
||||||
|
console.log("res=",res);
|
||||||
|
resolve(res);
|
||||||
|
}).catch(ex=>{
|
||||||
|
console.log("ex=",ex);
|
||||||
|
reject(ex);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//获取开关机数据
|
||||||
|
function getSwithData(data){
|
||||||
|
let url="";
|
||||||
|
return getdata(data,url,"POST");
|
||||||
|
}
|
||||||
|
|
||||||
|
//报警信息
|
||||||
|
function getWarnData(data){
|
||||||
|
let url=""
|
||||||
|
return getdata(data,url,"POST");
|
||||||
|
}
|
||||||
|
|
||||||
|
//故障信息
|
||||||
|
function getFaulData(data){
|
||||||
|
let url=""
|
||||||
|
return getdata(data,url,"POST");
|
||||||
|
}
|
||||||
|
|
||||||
|
export default{
|
||||||
|
getSwithData:getSwithData,
|
||||||
|
getWarnData:getWarnData,
|
||||||
|
getFaulData:getFaulData
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -177,17 +177,19 @@ export default {
|
|||||||
return styles[this.type][styleType]
|
return styles[this.type][styleType]
|
||||||
},
|
},
|
||||||
handleButtonClick() {
|
handleButtonClick() {
|
||||||
console.log('[MessagePopup] Button clicked with value:', this.inputValue)
|
|
||||||
this.$emit('buttonClick', this.inputValue)
|
this.$emit('buttonClick', this.inputValue)
|
||||||
},
|
},
|
||||||
handleMaskClick() {
|
handleMaskClick() {
|
||||||
console.log('[MessagePopup] Mask clicked')
|
|
||||||
this.$emit('maskClick')
|
this.$emit('maskClick')
|
||||||
},
|
},
|
||||||
closeClick(){
|
closeClick(){
|
||||||
|
|
||||||
this.$emit('closePop')
|
this.$emit('closePop')
|
||||||
},
|
},
|
||||||
handleCancelClick(){
|
handleCancelClick(){
|
||||||
|
|
||||||
this.$emit('cancelPop');
|
this.$emit('cancelPop');
|
||||||
},
|
},
|
||||||
handleInput(e) {
|
handleInput(e) {
|
||||||
|
6
main.js
6
main.js
@ -2,14 +2,14 @@ import App from './App'
|
|||||||
|
|
||||||
//// 引入 uView UI
|
//// 引入 uView UI
|
||||||
import uView from 'vk-uview-ui';
|
import uView from 'vk-uview-ui';
|
||||||
import bleTool from '@/store/BLETools.js';
|
|
||||||
|
|
||||||
// #ifndef VUE3
|
// #ifndef VUE3
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import store from './store/store';
|
import store from './store/store';
|
||||||
import './uni.promisify.adaptor'
|
import './uni.promisify.adaptor'
|
||||||
Vue.config.productionTip = false
|
Vue.config.productionTip = false
|
||||||
Vue.prototype.$bleTool = bleTool;
|
|
||||||
App.mpType = 'app'
|
App.mpType = 'app'
|
||||||
const app = new Vue({
|
const app = new Vue({
|
||||||
store,
|
store,
|
||||||
@ -25,7 +25,7 @@ import {
|
|||||||
} from 'vue'
|
} from 'vue'
|
||||||
export function createApp() {
|
export function createApp() {
|
||||||
const app = createSSRApp(App)
|
const app = createSSRApp(App)
|
||||||
app.config.globalProperties.$bleTool = bleTool;
|
|
||||||
// 使用 uView UI
|
// 使用 uView UI
|
||||||
app.use(uView)
|
app.use(uView)
|
||||||
return {
|
return {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"name" : "JingQuan",
|
"name" : "JingQuan",
|
||||||
"appid" : "__UNI__A21EF43",
|
"appid" : "__UNI__A21EF43",
|
||||||
"description" : "设备管控",
|
"description" : "设备管控",
|
||||||
"versionName" : "1.0.0",
|
"versionName" : "1.0.9",
|
||||||
"versionCode" : "100",
|
"versionCode" : "100",
|
||||||
"transformPx" : false,
|
"transformPx" : false,
|
||||||
/* 5+App特有相关 */
|
/* 5+App特有相关 */
|
||||||
|
10
pages.json
10
pages.json
@ -265,7 +265,8 @@
|
|||||||
{
|
{
|
||||||
"path": "pages/670/HBY670",
|
"path": "pages/670/HBY670",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "HBY670"
|
"navigationBarTitleText": "HBY670",
|
||||||
|
"navigationStyle": "custom"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -273,6 +274,13 @@
|
|||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "HBY650"
|
"navigationBarTitleText": "HBY650"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path" : "pages/670/History",
|
||||||
|
"style" :
|
||||||
|
{
|
||||||
|
"navigationBarTitleText" : "历史记录"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="content contentBg">
|
<view class="content contentBg">
|
||||||
<view class="eq">
|
<custom-navbar :title="Status.navbar.title" :showBack="Status.navbar.showBack" color="#FFFFFF"
|
||||||
|
:rightIcons="Status.navbar.icons" @icon-click="handleRightClick"></custom-navbar>
|
||||||
|
|
||||||
|
<view class="eq" :style="{marginTop:Status.navbar.height+'px'}">
|
||||||
<view class="leftImg">
|
<view class="leftImg">
|
||||||
<image class="img" :src="device['devicePic']" mode="aspectFit"></image>
|
<image class="img" :src="device['devicePic']" mode="aspectFit"></image>
|
||||||
</view>
|
</view>
|
||||||
@ -41,8 +44,14 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="warnnig" v-bind:class="formData.staticWarn?'':'displayNone'">
|
<view class="warnnig" v-bind:class="formData.staticWarn?'':'displayNone'">
|
||||||
<view>设备自动报警中!</view>
|
<view>警告!环境存在漏电电源!</view>
|
||||||
<view>{{Status.staticWarn.time}}s</view>
|
<view class="netContent">
|
||||||
|
<view v-bind:class="getWarnStyle(1)" class="net netone"></view>
|
||||||
|
<view v-bind:class="getWarnStyle(2)" class="net nettwo"></view>
|
||||||
|
<view v-bind:class="getWarnStyle(3)" class="net netsiri"></view>
|
||||||
|
<view v-bind:class="getWarnStyle(4)" class="net netfour"></view>
|
||||||
|
<view v-bind:class="getWarnStyle(5)" class="net netfive"></view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="optTitle">
|
<view class="optTitle">
|
||||||
@ -64,18 +73,22 @@
|
|||||||
|
|
||||||
</view>
|
</view>
|
||||||
<view class="optTitle">
|
<view class="optTitle">
|
||||||
SOS
|
报警
|
||||||
</view>
|
</view>
|
||||||
<view class="sosContent">
|
<view class="sosContent">
|
||||||
<view class="item" @click="sosSetting('sg')" :class="formData.SOS=='sg'?'active':''">
|
<view class="item" @click="sosSetting('sg')" :class="formData.SOS=='sg'?'active':''">
|
||||||
<view class="imgContent center">
|
<view class="imgContent center">
|
||||||
<image class="img" :src="formData.SOS=='sg'?'/static/images/670/sgActive.png':'/static/images/670/sg.png'" mode="aspectFit"></image>
|
<image class="img"
|
||||||
|
:src="formData.SOS=='sg'?'/static/images/670/sgActive.png':'/static/images/670/sg.png'"
|
||||||
|
mode="aspectFit"></image>
|
||||||
</view>
|
</view>
|
||||||
<view class="txt">声光报警</view>
|
<view class="txt">声光报警</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="item" @click="sosSetting('rb')" :class="formData.SOS=='rb'?'active':''">
|
<view class="item" @click="sosSetting('rb')" :class="formData.SOS=='rb'?'active':''">
|
||||||
<view class="imgContent center">
|
<view class="imgContent center">
|
||||||
<image class="img" :src="formData.SOS=='rb'?'/static/images/670/rbActive.png':'/static/images/670/rb.png'" mode="aspectFit"></image>
|
<image class="img"
|
||||||
|
:src="formData.SOS=='rb'?'/static/images/670/rbActive.png':'/static/images/670/rb.png'"
|
||||||
|
mode="aspectFit"></image>
|
||||||
</view>
|
</view>
|
||||||
<view class="txt">红蓝闪烁</view>
|
<view class="txt">红蓝闪烁</view>
|
||||||
</view>
|
</view>
|
||||||
@ -86,19 +99,25 @@
|
|||||||
<view class="lightMode">
|
<view class="lightMode">
|
||||||
<view class="item" @click="lightSetting('qiang')" :class="formData.lightCurr=='qiang'?'active':''">
|
<view class="item" @click="lightSetting('qiang')" :class="formData.lightCurr=='qiang'?'active':''">
|
||||||
<view class="imgContent center">
|
<view class="imgContent center">
|
||||||
<image class="img" :src="formData.lightCurr=='qiang'?'/static/images/670/qiangActive.png':'/static/images/670/qiang.png'" mode="aspectFit"></image>
|
<image class="img"
|
||||||
|
:src="formData.lightCurr=='qiang'?'/static/images/670/qiangActive.png':'/static/images/670/qiang.png'"
|
||||||
|
mode="aspectFit"></image>
|
||||||
</view>
|
</view>
|
||||||
<view class="txt">强光</view>
|
<view class="txt">强光</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="item" @click="lightSetting('ruo')" :class="formData.lightCurr=='ruo'?'active':''">
|
<view class="item" @click="lightSetting('ruo')" :class="formData.lightCurr=='ruo'?'active':''">
|
||||||
<view class="imgContent center">
|
<view class="imgContent center">
|
||||||
<image class="img" :src="formData.lightCurr=='ruo'?'/static/images/670/ruoActive.png':'/static/images/670/ruo.png'" mode="aspectFit"></image>
|
<image class="img"
|
||||||
|
:src="formData.lightCurr=='ruo'?'/static/images/670/ruoActive.png':'/static/images/670/ruo.png'"
|
||||||
|
mode="aspectFit"></image>
|
||||||
</view>
|
</view>
|
||||||
<view class="txt">弱光</view>
|
<view class="txt">弱光</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="item" @click="lightSetting('close')" :class="formData.lightCurr=='close'?'active':''">
|
<view class="item" @click="lightSetting('close')" :class="formData.lightCurr=='close'?'active':''">
|
||||||
<view class="imgContent center">
|
<view class="imgContent center">
|
||||||
<image class="img" :src="formData.lightCurr=='close'?'/static/images/670/jieNActive.png':'/static/images/670/jieN.png'" mode="aspectFit"></image>
|
<image class="img"
|
||||||
|
:src="formData.lightCurr=='close'?'/static/images/670/jieNActive.png':'/static/images/670/jieN.png'"
|
||||||
|
mode="aspectFit"></image>
|
||||||
</view>
|
</view>
|
||||||
<view class="txt">关闭</view>
|
<view class="txt">关闭</view>
|
||||||
</view>
|
</view>
|
||||||
@ -149,7 +168,8 @@
|
|||||||
<view>
|
<view>
|
||||||
|
|
||||||
<view class="item">
|
<view class="item">
|
||||||
<input class="value" style="text-indent: 20rpx;" v-model="formData.msgTxt" placeholder="请输入文字" placeholder-class="usrplace" />
|
<input class="value" style="text-indent: 20rpx;" v-model="formData.msgTxt" placeholder="请输入文字"
|
||||||
|
placeholder-class="usrplace" />
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
@ -191,8 +211,8 @@
|
|||||||
:borderColor="Status.Pop.borderColor" :textColor="Status.Pop.textColor"
|
:borderColor="Status.Pop.borderColor" :textColor="Status.Pop.textColor"
|
||||||
:buttonBgColor="Status.Pop.buttonBgColor" :buttonTextColor="Status.Pop.buttonTextColor"
|
:buttonBgColor="Status.Pop.buttonBgColor" :buttonTextColor="Status.Pop.buttonTextColor"
|
||||||
:iconUrl="Status.Pop.iconUrl" :message="Status.Pop.message" :buttonText="Status.Pop.buttonText"
|
:iconUrl="Status.Pop.iconUrl" :message="Status.Pop.message" :buttonText="Status.Pop.buttonText"
|
||||||
@buttonClick="HidePop" :visiblePrompt="Status.Pop.visiblePrompt" :promptTitle="Status.Pop.promptTitle"
|
@buttonClick="HidePop" @closePop="closePop" @cancelPop="closePop" :visiblePrompt="Status.Pop.visiblePrompt"
|
||||||
v-model="Status.Pop.modelValue" />
|
:promptTitle="Status.Pop.promptTitle" v-model="Status.Pop.modelValue" />
|
||||||
|
|
||||||
<!-- 下方菜单 -->
|
<!-- 下方菜单 -->
|
||||||
<BottomSlideMenuPlus :config="Status.BottomMenu" @close="closeMenu" @itemClick="handleItemClick"
|
<BottomSlideMenuPlus :config="Status.BottomMenu" @close="closeMenu" @itemClick="handleItemClick"
|
||||||
@ -230,6 +250,19 @@
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
Status: {
|
Status: {
|
||||||
|
apiType:"listA",
|
||||||
|
navbar: {
|
||||||
|
icons: [{
|
||||||
|
src: '/static/images/common/msg.png'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: '/static/images/common/shape.png'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
title: 'HBY670',
|
||||||
|
showBack: true,
|
||||||
|
height: 90
|
||||||
|
},
|
||||||
staticWarn: {
|
staticWarn: {
|
||||||
time: 0,
|
time: 0,
|
||||||
inteval: null
|
inteval: null
|
||||||
@ -302,7 +335,7 @@
|
|||||||
company: "", //单位
|
company: "", //单位
|
||||||
usrname: "", //姓名
|
usrname: "", //姓名
|
||||||
job: "", //职位
|
job: "", //职位
|
||||||
id: "", //id
|
usrid: "", //id
|
||||||
msgTxt: "", //消息1
|
msgTxt: "", //消息1
|
||||||
qzwarn: false, //是否强制报警
|
qzwarn: false, //是否强制报警
|
||||||
warnLevel: "", //报警级别
|
warnLevel: "", //报警级别
|
||||||
@ -334,13 +367,22 @@
|
|||||||
picPath: ""
|
picPath: ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
created() {
|
||||||
|
this.Status.navbar.height = uni.getSystemInfoSync().statusBarHeight + 20;
|
||||||
|
},
|
||||||
onUnload() {
|
onUnload() {
|
||||||
console.log("页面卸载,释放资源");
|
console.log("页面卸载,释放资源");
|
||||||
|
let statusTopic = `A/${this.formData.imei?this.formData.imei:this.device.deviceImei}`;
|
||||||
ble.removeReceiveCallback(pagePath);
|
ble.removeReceiveCallback(pagePath);
|
||||||
|
if (mqttClient) {
|
||||||
|
mqttClient.unsubscribe(statusTopic);
|
||||||
|
mqttClient.disconnect();
|
||||||
|
mqttClient = null;
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
onLoad: function() {
|
onLoad: function() {
|
||||||
console.log("670页面加载");
|
// console.log("670页面加载");
|
||||||
these = this;
|
these = this;
|
||||||
recei = BleReceive.getBleReceive();
|
recei = BleReceive.getBleReceive();
|
||||||
ble = BleTool.getBleTool();
|
ble = BleTool.getBleTool();
|
||||||
@ -351,6 +393,7 @@
|
|||||||
|
|
||||||
console.log("收到父页面的参数:" + JSON.stringify(data));
|
console.log("收到父页面的参数:" + JSON.stringify(data));
|
||||||
var device = data.data;
|
var device = data.data;
|
||||||
|
these.Status.apiType=data.apiType;
|
||||||
these.device = device;
|
these.device = device;
|
||||||
if (these.device.deviceImei) {
|
if (these.device.deviceImei) {
|
||||||
these.initMQ();
|
these.initMQ();
|
||||||
@ -358,7 +401,7 @@
|
|||||||
let f = ble.data.LinkedList.find((v) => {
|
let f = ble.data.LinkedList.find((v) => {
|
||||||
if (v.macAddress == device.deviceMac) {
|
if (v.macAddress == device.deviceMac) {
|
||||||
console.log("找到设备了", v);
|
console.log("找到设备了", v);
|
||||||
|
these.formData.deviceId = v.deviceId;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -376,8 +419,7 @@
|
|||||||
}
|
}
|
||||||
if (these.formData['imei'] && !these.device.deviceImei) {
|
if (these.formData['imei'] && !these.device.deviceImei) {
|
||||||
these.initMQ();
|
these.initMQ();
|
||||||
}
|
} else if (these.device.deviceImei) {
|
||||||
else if(these.device.deviceImei){
|
|
||||||
these.formData['imei'] = these.device.deviceImei;
|
these.formData['imei'] = these.device.deviceImei;
|
||||||
}
|
}
|
||||||
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId);
|
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId);
|
||||||
@ -391,45 +433,91 @@
|
|||||||
ble.removeReceiveCallback(pagePath);
|
ble.removeReceiveCallback(pagePath);
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
RSSIRemark: function() {
|
|
||||||
let remark = '极弱';
|
|
||||||
if (this.formData.RSSI <= 0 && this.formData.RSSI >= -30) {
|
|
||||||
remark = '强';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.formData.RSSI < -30 && this.formData.RSSI >= -60) {
|
|
||||||
remark = '一般';
|
|
||||||
}
|
|
||||||
if (this.formData.RSSI < -60 && this.formData.RSSI >= -85) {
|
|
||||||
remark = '弱';
|
|
||||||
}
|
|
||||||
if (this.formData.RSSI < -85 && this.formData.RSSI >= -100) {
|
|
||||||
remark = '微弱';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
getWarnStyle(index) {
|
||||||
|
let className = "";
|
||||||
|
|
||||||
|
switch (this.formData.warnLevel) {
|
||||||
|
case "none":
|
||||||
|
break;
|
||||||
|
case "ruo":
|
||||||
|
if (index <= 1) {
|
||||||
|
className = "active";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "center":
|
||||||
|
if (index <= 3) {
|
||||||
|
className = "active";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "hight":
|
||||||
|
if (index <= 4) {
|
||||||
|
className = "active";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "veryhight":
|
||||||
|
if (index <= 5) {
|
||||||
|
className = "active";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return className;
|
||||||
|
},
|
||||||
|
handleRightClick: function(s, e) {
|
||||||
|
|
||||||
|
if (s === 0) {
|
||||||
|
console.log("消息");
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/670/History',
|
||||||
|
success: (res) => {
|
||||||
|
res.eventChannel.emit('detailData', {
|
||||||
|
data: these.device,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return;
|
||||||
|
} else if (s === 1) {
|
||||||
|
console.log("分享");
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/6170/share/index',
|
||||||
|
events: {
|
||||||
|
ack: function(data) {}
|
||||||
|
},
|
||||||
|
success: (res) => {
|
||||||
|
res.eventChannel.emit('share', {
|
||||||
|
data: this.device,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
initMQ() {
|
initMQ() {
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
console.log("正在初始化MQtt")
|
|
||||||
if (mqttClient) {
|
if (mqttClient) {
|
||||||
console.log("无需再次初始化")
|
console.log("无需再次初始化")
|
||||||
resolve();
|
resolve();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
console.log("正在初始化MQtt")
|
||||||
mqttClient = new MqttClient();
|
mqttClient = new MqttClient();
|
||||||
mqttClient.connect(() => {
|
mqttClient.connect(() => {
|
||||||
console.log("连接成功,开始订阅消息")
|
console.log("连接成功,开始订阅消息")
|
||||||
// 订阅来自设备的状态更新
|
// 订阅来自设备的状态更新
|
||||||
const statusTopic = `A/${this.formData.imei?this.formData.imei:this.device.deviceImei}`;
|
const statusTopic =
|
||||||
|
`A/${this.formData.imei?this.formData.imei:this.device.deviceImei}`;
|
||||||
mqttClient.subscribe(statusTopic, (payload, receive) => {
|
mqttClient.subscribe(statusTopic, (payload, receive) => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
let json = JSON.parse(payload);
|
let json = JSON.parse(payload);
|
||||||
let keys = Object.keys(json);
|
let keys = Object.keys(json);
|
||||||
// console.log("keys=", keys);
|
// console.log("keys=", keys);sta_DetectGrade
|
||||||
if (keys.indexOf('sta_DetectGrade') > -1) { //上报的报文
|
if (keys.indexOf('sta_DetectGrade') > -1) { //上报的报文
|
||||||
console.log("收到设备上报的数据", payload);
|
console.log("收到设备上报的数据", payload);
|
||||||
this.parseDataMQ(json);
|
this.parseDataMQ(json);
|
||||||
@ -462,6 +550,7 @@
|
|||||||
|
|
||||||
sendMQ(message) {
|
sendMQ(message) {
|
||||||
message = JSON.stringify(message);
|
message = JSON.stringify(message);
|
||||||
|
console.log("imei=", this.formData.imei ? this.formData.imei : this.device.deviceImei);
|
||||||
const topic = `B/${this.formData.imei?this.formData.imei:this.device.deviceImei}`;
|
const topic = `B/${this.formData.imei?this.formData.imei:this.device.deviceImei}`;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (!mqttClient) {
|
if (!mqttClient) {
|
||||||
@ -481,7 +570,8 @@
|
|||||||
reject("MQTT未连接,无法发布消息");
|
reject("MQTT未连接,无法发布消息");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("出现了异常", error);
|
console.log("出现了异常", error);
|
||||||
mqttClient.unsubscribe(`A/${this.formData.imei?this.formData.imei:this.device.deviceImei}`);
|
mqttClient.unsubscribe(
|
||||||
|
`A/${this.formData.imei?this.formData.imei:this.device.deviceImei}`);
|
||||||
mqttClient.disconnect();
|
mqttClient.disconnect();
|
||||||
this.initMQ();
|
this.initMQ();
|
||||||
reject(error);
|
reject(error);
|
||||||
@ -489,6 +579,7 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
parseDataMQ(json) {
|
parseDataMQ(json) {
|
||||||
|
let receiveData = {};
|
||||||
let staticLevelText = "";
|
let staticLevelText = "";
|
||||||
let dic = {
|
let dic = {
|
||||||
"3": "hight",
|
"3": "hight",
|
||||||
@ -516,16 +607,22 @@
|
|||||||
warn = dic[json.sta_DetectResult];
|
warn = dic[json.sta_DetectResult];
|
||||||
|
|
||||||
|
|
||||||
let sosText = json.sta_SOSGrade === 2 ? 'rb' :
|
let sosText =null;
|
||||||
|
if(json.sta_SOSGrade!==undefined){
|
||||||
|
|
||||||
|
|
||||||
|
sosText=json.sta_SOSGrade === 2 ? 'rb' :
|
||||||
json.sta_SOSGrade === 1 ? "sg" : "close"
|
json.sta_SOSGrade === 1 ? "sg" : "close"
|
||||||
|
|
||||||
|
receiveData.SOS = sosText;
|
||||||
|
}
|
||||||
let staticWarn = json.sta_ShakeBit === 1;
|
let staticWarn = json.sta_ShakeBit === 1;
|
||||||
|
|
||||||
receiveData.modeCurr = staticLevelText;
|
receiveData.modeCurr = staticLevelText;
|
||||||
receiveData.lightCurr = lightingLevelText;
|
receiveData.lightCurr = lightingLevelText;
|
||||||
receiveData.xuhang = json.sta_PowerTime + "分钟";
|
receiveData.xuhang = json.sta_PowerTime + "分钟";
|
||||||
receiveData.battary = json.sta_PowerPercent + "%";
|
receiveData.battary = json.sta_PowerPercent + "%";
|
||||||
receiveData.SOS = sosText;
|
|
||||||
receiveData.warnLevel = warn;
|
receiveData.warnLevel = warn;
|
||||||
receiveData.staticWarn = staticWarn;
|
receiveData.staticWarn = staticWarn;
|
||||||
receiveData.fourGStrenth = json.sta_4gSinal;
|
receiveData.fourGStrenth = json.sta_4gSinal;
|
||||||
@ -533,7 +630,7 @@
|
|||||||
receiveData.Lon = json.sta_longitude;
|
receiveData.Lon = json.sta_longitude;
|
||||||
receiveData.Lat = json.sta_latitude;
|
receiveData.Lat = json.sta_latitude;
|
||||||
|
|
||||||
this.refreshFormData(receiveData);
|
this.refreshFormData(receiveData,'auto');
|
||||||
return receiveData;
|
return receiveData;
|
||||||
},
|
},
|
||||||
bleValueNotify: function(receive, device, path) { //订阅消息
|
bleValueNotify: function(receive, device, path) { //订阅消息
|
||||||
@ -562,11 +659,11 @@
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.refreshFormData(data);
|
this.refreshFormData(data,'auto');
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
refreshFormData(data){
|
refreshFormData(data,type) {
|
||||||
let keys = Object.keys(data);
|
let keys = Object.keys(data);
|
||||||
for (var i = 0; i < keys.length; i++) {
|
for (var i = 0; i < keys.length; i++) {
|
||||||
let key = keys[i];
|
let key = keys[i];
|
||||||
@ -579,22 +676,22 @@
|
|||||||
}
|
}
|
||||||
if (these.formData.staticWarn) { //有静止报警
|
if (these.formData.staticWarn) { //有静止报警
|
||||||
these.showPop({
|
these.showPop({
|
||||||
message: "自动报警",
|
message: "环境存在漏电电源",
|
||||||
iconUrl: "/static/images/6155/DeviceDetail/warnning.png",
|
iconUrl: "/static/images/6155/DeviceDetail/warnning.png",
|
||||||
borderColor: "#e034344d",
|
borderColor: "#e034344d",
|
||||||
buttonBgColor: "#E03434",
|
buttonBgColor: "#E03434",
|
||||||
buttonText:"解除报警",
|
buttonText: "确定",
|
||||||
clickEvt: "staticWarn"
|
clickEvt: "staticWarn"
|
||||||
});
|
});
|
||||||
this.Status.staticWarn.time=180;
|
// this.Status.staticWarn.time=5;
|
||||||
this.Status.staticWarn.inteval=setInterval(()=>{
|
// this.Status.staticWarn.inteval=setInterval(()=>{
|
||||||
if(this.Status.staticWarn.time===0){
|
// if(this.Status.staticWarn.time===0){
|
||||||
clearInterval(this.Status.staticWarn.inteval);
|
// clearInterval(this.Status.staticWarn.inteval);
|
||||||
this.formData.staticWarn=false;
|
// this.formData.staticWarn=false;
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
this.Status.staticWarn.time=this.Status.staticWarn.time-1;
|
// this.Status.staticWarn.time=this.Status.staticWarn.time-1;
|
||||||
},1000)
|
// },1000)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -650,13 +747,14 @@
|
|||||||
};
|
};
|
||||||
console.log("type=", type);
|
console.log("type=", type);
|
||||||
let json = {
|
let json = {
|
||||||
ins_SOSGrade: [dic.mqtt[type]]
|
ins_LightGrade: [dic.mqtt[type]]
|
||||||
};
|
};
|
||||||
|
|
||||||
let requestSend = () => {
|
let requestSend = () => {
|
||||||
this.sendMQ(json).then((res) => {
|
this.sendMQ(json).then((res) => {
|
||||||
console.log("4g发送成功");
|
console.log("4g发送成功");
|
||||||
}).catch((ex) => {
|
}).catch((ex) => {
|
||||||
|
console.log("ex=",ex);
|
||||||
these.showPop({
|
these.showPop({
|
||||||
message: "通信异常,请检查手机或设备网络",
|
message: "通信异常,请检查手机或设备网络",
|
||||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||||
@ -713,13 +811,13 @@
|
|||||||
this.formData.SOS = type;
|
this.formData.SOS = type;
|
||||||
let dic = {
|
let dic = {
|
||||||
ble: {
|
ble: {
|
||||||
sg: 0x68,
|
rb: 0x68,
|
||||||
rb: 0x69,
|
sg: 0x69,
|
||||||
close: 0x6A
|
close: 0x6A
|
||||||
},
|
},
|
||||||
mqtt: {
|
mqtt: {
|
||||||
sg: 2,
|
sg: 1,
|
||||||
rb: 1,
|
rb: 2,
|
||||||
close: 0
|
close: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -733,6 +831,7 @@
|
|||||||
this.sendMQ(json).then((res) => {
|
this.sendMQ(json).then((res) => {
|
||||||
console.log("4g发送成功");
|
console.log("4g发送成功");
|
||||||
}).catch((ex) => {
|
}).catch((ex) => {
|
||||||
|
console.log("ex=",ex);
|
||||||
these.showPop({
|
these.showPop({
|
||||||
message: "通信异常,请检查手机或设备网络",
|
message: "通信异常,请检查手机或设备网络",
|
||||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||||
@ -748,6 +847,7 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let SendCmd = () => {
|
||||||
let f = this.getDevice();
|
let f = this.getDevice();
|
||||||
let buffer = null;
|
let buffer = null;
|
||||||
if (f) {
|
if (f) {
|
||||||
@ -761,8 +861,25 @@
|
|||||||
dataView.setUint8(4, 0x01); // 数据长度
|
dataView.setUint8(4, 0x01); // 数据长度
|
||||||
dataView.setUint8(5, dic.ble[type]); // 数据
|
dataView.setUint8(5, dic.ble[type]); // 数据
|
||||||
|
|
||||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 10).then(() => {
|
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 10).then(
|
||||||
|
() => {
|
||||||
console.log("蓝牙发送成功了");
|
console.log("蓝牙发送成功了");
|
||||||
|
|
||||||
|
dic={
|
||||||
|
close: 0x71
|
||||||
|
}
|
||||||
|
if(type in dic){
|
||||||
|
dataView.setUint8(1, 0x06); // 帧类型
|
||||||
|
dataView.setUint8(5, 0x71); // 数据
|
||||||
|
|
||||||
|
}else{
|
||||||
|
dataView.setUint8(1, 0x06); // 帧类型
|
||||||
|
dataView.setUint8(5, 0x70); // 数据
|
||||||
|
}
|
||||||
|
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 10).then(()=>{
|
||||||
|
console.log("蓝牙发送报警成功",type);
|
||||||
|
})
|
||||||
|
|
||||||
hideLoading(these);
|
hideLoading(these);
|
||||||
these.setBleFormData();
|
these.setBleFormData();
|
||||||
}).catch((ex) => {
|
}).catch((ex) => {
|
||||||
@ -775,6 +892,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SendCmd();
|
||||||
|
}
|
||||||
|
|
||||||
setTimeout(task, 0);
|
setTimeout(task, 0);
|
||||||
},
|
},
|
||||||
GearSetting: function(type) { //档位设置
|
GearSetting: function(type) { //档位设置
|
||||||
@ -809,6 +929,7 @@
|
|||||||
this.sendMQ(json).then((res) => {
|
this.sendMQ(json).then((res) => {
|
||||||
console.log("4g发送成功");
|
console.log("4g发送成功");
|
||||||
}).catch((ex) => {
|
}).catch((ex) => {
|
||||||
|
console.log("ex=",ex)
|
||||||
these.showPop({
|
these.showPop({
|
||||||
message: "通信异常,请检查手机或设备网络",
|
message: "通信异常,请检查手机或设备网络",
|
||||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||||
@ -848,6 +969,7 @@
|
|||||||
requestSend();
|
requestSend();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
console.log("找不到蓝牙设备,使用4G发送")
|
||||||
requestSend();
|
requestSend();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1057,6 +1179,8 @@
|
|||||||
sendImgByRequest().then(resolve).catch(reject);
|
sendImgByRequest().then(resolve).catch(reject);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
sendImgByRequest().then(resolve).catch(reject);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1406,26 +1530,51 @@
|
|||||||
},
|
},
|
||||||
HidePop: function() {
|
HidePop: function() {
|
||||||
if (this.Status.Pop.clickEvt == 'staticWarn') {
|
if (this.Status.Pop.clickEvt == 'staticWarn') {
|
||||||
this.Status.staticWarnTime=0;
|
// this.Status.staticWarnTime=0;
|
||||||
|
// clearInterval(this.Status.staticWarn.inteval);
|
||||||
|
// this.formData.staticWarn=false;
|
||||||
}
|
}
|
||||||
|
if(this.Status.Pop.okCallback){
|
||||||
|
console.log("执行点击按钮回调");
|
||||||
|
this.Status.Pop.okCallback();
|
||||||
|
}
|
||||||
|
|
||||||
this.Status.Pop.showPop = false;
|
this.Status.Pop.showPop = false;
|
||||||
},
|
},
|
||||||
showPop: function(option) {
|
closePop: function() {
|
||||||
|
this.Status.Pop.showPop = false;
|
||||||
|
|
||||||
if (!option) {
|
if(this.Status.Pop.cancelCallback){
|
||||||
option = {
|
this.Status.Pop.cancelCallback();
|
||||||
a: 1
|
}
|
||||||
|
},
|
||||||
|
showPop: function(option) {
|
||||||
|
hideLoading(this);
|
||||||
|
let defaultCfg = {
|
||||||
|
showCancel: false,
|
||||||
|
borderColor: '#BBE600',
|
||||||
|
buttonBgColor:'#BBE600',
|
||||||
|
okCallback:null,
|
||||||
|
cancelCallback:null,
|
||||||
|
popType: 'custom'
|
||||||
};
|
};
|
||||||
|
if (!option) {
|
||||||
|
|
||||||
}
|
}
|
||||||
let keys = Object.keys(option);
|
let keys = Object.keys(option);
|
||||||
for (var i = 0; i < keys.length; i++) {
|
for (var i = 0; i < keys.length; i++) {
|
||||||
let key = keys[i];
|
let key = keys[i];
|
||||||
these.Status.Pop[key] = option[key];
|
these.Status.Pop[key] = option[key];
|
||||||
}
|
}
|
||||||
if (!option.borderColor) {
|
keys = Object.keys(defaultCfg);
|
||||||
option.borderColor = '#BBE600';
|
for (var i = 0; i < keys.length; i++) {
|
||||||
option.buttonBgColor = '#BBE600';
|
let key = keys[i];
|
||||||
|
if(key in option){
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
these.Status.Pop[key] = defaultCfg[key];
|
||||||
|
}
|
||||||
|
|
||||||
these.Status.Pop.showPop = true;
|
these.Status.Pop.showPop = true;
|
||||||
},
|
},
|
||||||
sendUsr: function(ReSendNo) {
|
sendUsr: function(ReSendNo) {
|
||||||
@ -1435,9 +1584,9 @@
|
|||||||
deviceId: this.device.id,
|
deviceId: this.device.id,
|
||||||
deviceImei: this.device.deviceImei ? this.device.deviceImei : this.formData.imei,
|
deviceImei: this.device.deviceImei ? this.device.deviceImei : this.formData.imei,
|
||||||
name: this.formData.company,
|
name: this.formData.company,
|
||||||
position: this.formData.name,
|
position: this.formData.usrname,
|
||||||
unitName: this.formData.job,
|
unitName: this.formData.job,
|
||||||
code: this.formData.id
|
code: this.formData.usrid
|
||||||
};
|
};
|
||||||
api.sendUsr(json).then((res) => {
|
api.sendUsr(json).then((res) => {
|
||||||
these.showPop({
|
these.showPop({
|
||||||
@ -1472,9 +1621,9 @@
|
|||||||
|
|
||||||
var textLines = [
|
var textLines = [
|
||||||
this.formData.company,
|
this.formData.company,
|
||||||
this.formData.name,
|
this.formData.usrname,
|
||||||
this.formData.job,
|
this.formData.job,
|
||||||
this.formData.id
|
this.formData.usrid
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
@ -1641,7 +1790,10 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
console.log("data=", data);
|
console.log("data=", data);
|
||||||
api.warnMsg(data).then((res)=>{
|
api.warnMsg(data).catch((ex) => {
|
||||||
|
console.log("ex=", ex);
|
||||||
|
}).then((res) => {
|
||||||
|
console.log("res=", res)
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
these.showPop({
|
these.showPop({
|
||||||
showPop: true, //是否显示弹窗
|
showPop: true, //是否显示弹窗
|
||||||
@ -1945,6 +2097,7 @@
|
|||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding: 24rpx 28rpx;
|
padding: 24rpx 28rpx;
|
||||||
background: rgba(26, 26, 26, 1);
|
background: rgba(26, 26, 26, 1);
|
||||||
|
margin-bottom: 20rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.usrtitle {
|
.usrtitle {
|
||||||
@ -2258,6 +2411,7 @@ padding:30rpx 0rpx 10rpx 30rpx;
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sosContent .item {
|
.sosContent .item {
|
||||||
width: calc(calc(100% - 80rpx) / 2);
|
width: calc(calc(100% - 80rpx) / 2);
|
||||||
height: 100%;
|
height: 100%;
|
||||||
@ -2289,6 +2443,7 @@ padding:30rpx 0rpx 10rpx 30rpx;
|
|||||||
border-radius: 4rpx;
|
border-radius: 4rpx;
|
||||||
margin-right: 30rpx;
|
margin-right: 30rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sosContent .imgContent .img {
|
.sosContent .imgContent .img {
|
||||||
width: 70%;
|
width: 70%;
|
||||||
height: 70%;
|
height: 70%;
|
||||||
@ -2342,19 +2497,62 @@ display: flex;
|
|||||||
width: 80rpx;
|
width: 80rpx;
|
||||||
height: 100rpx;
|
height: 100rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.lightMode .imgContent .img {
|
.lightMode .imgContent .img {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.picVideo .btnImg {
|
.picVideo .btnImg {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100rpx;
|
height: 100rpx;
|
||||||
border-radius: 16rpx;
|
border-radius: 16rpx;
|
||||||
background: rgba(42, 42, 42, 1);
|
background: rgba(42, 42, 42, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.picVideo .btnImg .img {
|
.picVideo .btnImg .img {
|
||||||
width: 40rpx;
|
width: 40rpx;
|
||||||
height: 40rpx;
|
height: 40rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.netContent {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
align-content: flex-end;
|
||||||
|
justify-content: space-around;
|
||||||
|
align-items: flex-end;
|
||||||
|
width: 50rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.net {
|
||||||
|
width: 7rpx;
|
||||||
|
background: rgba(255, 255, 255, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.net.netone {
|
||||||
|
height: 11rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.net.nettwo {
|
||||||
|
height: 17rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.net.netsiri {
|
||||||
|
height: 23rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.net.netfour {
|
||||||
|
height: 29rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.net.netfive {
|
||||||
|
height: 35rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.net.active {
|
||||||
|
background: #FFFFFF !important;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
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);
|
ble.removeReceiveCallback(pagePath);
|
||||||
},
|
},
|
||||||
onUnload() {
|
onUnload() {
|
||||||
|
console.log("返回时断开蓝牙连接,取消订阅");
|
||||||
ble.removeReceiveCallback(pagePath);
|
ble.removeReceiveCallback(pagePath);
|
||||||
},
|
},
|
||||||
onLoad(option) {
|
onLoad(option) {
|
||||||
@ -86,12 +87,12 @@
|
|||||||
ble.addReceiveCallback((receive,f,path) => {
|
ble.addReceiveCallback((receive,f,path) => {
|
||||||
console.log("收到设备消息,", receive);
|
console.log("收到设备消息,", receive);
|
||||||
if (these.device.deviceId == receive.deviceId) {
|
if (these.device.deviceId == receive.deviceId) {
|
||||||
console.log("11111");
|
// console.log("11111");
|
||||||
|
|
||||||
if (receive.bytes[0] == 0xFC || receive.str.indexOf('mac address:') == 0) {
|
if (receive.bytes[0] == 0xFC || receive.str.indexOf('mac address:') == 0) {
|
||||||
if (f && f.macAddress) {
|
if (f && f.macAddress) {
|
||||||
these.device.macAddress = f.macAddress;
|
these.device.macAddress = f.macAddress;
|
||||||
console.log("222222");
|
// console.log("222222");
|
||||||
these.initDevice();
|
these.initDevice();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,13 +100,23 @@
|
|||||||
},pagePath);
|
},pagePath);
|
||||||
eventChannel = this.getOpenerEventChannel();
|
eventChannel = this.getOpenerEventChannel();
|
||||||
eventChannel.on('LinkItem', function(data) {
|
eventChannel.on('LinkItem', function(data) {
|
||||||
|
console.log("data=",data);
|
||||||
let f = ble.data.LinkedList.find((v) => {
|
let f = ble.data.LinkedList.find((v) => {
|
||||||
return v.deviceId = data.deviceId;
|
return v.deviceId == data.deviceId;
|
||||||
});
|
});
|
||||||
if (f) {
|
if (f) {
|
||||||
these.device = Object.assign({}, these.device, f);
|
let keys=Object.keys(f);
|
||||||
console.log("获取到设备", 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 {
|
} else {
|
||||||
console.log("未获取到设备");
|
console.log("未获取到设备");
|
||||||
}
|
}
|
||||||
@ -117,6 +128,7 @@
|
|||||||
showLoading(these, {
|
showLoading(these, {
|
||||||
text: '正在获取设备信息'
|
text: '正在获取设备信息'
|
||||||
});
|
});
|
||||||
|
console.log("these.device=",these.device);
|
||||||
request({
|
request({
|
||||||
url: '/app/device/getDeviceInfoByDeviceMac',
|
url: '/app/device/getDeviceInfoByDeviceMac',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
@ -130,12 +142,12 @@
|
|||||||
if (data) {
|
if (data) {
|
||||||
let keys = Object.keys(data);
|
let keys = Object.keys(data);
|
||||||
ble.data.LinkedList.find((v) => {
|
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++) {
|
for (var i = 0; i < keys.length; i++) {
|
||||||
let key = keys[i];
|
let key = keys[i];
|
||||||
v[key] = data[key];
|
v[key] = data[key];
|
||||||
console.log("key="+key);
|
// console.log("key="+key);
|
||||||
console.log("value="+data[key]);
|
// console.log("value="+data[key]);
|
||||||
|
|
||||||
|
|
||||||
these.$set(these.device, key, data[key]);
|
these.$set(these.device, key, data[key]);
|
||||||
@ -163,7 +175,7 @@
|
|||||||
// 调用绑定设备接口
|
// 调用绑定设备接口
|
||||||
|
|
||||||
let f = ble.data.LinkedList.find((v) => {
|
let f = ble.data.LinkedList.find((v) => {
|
||||||
return v.deviceId = these.device.deviceId;
|
return v.deviceId == these.device.deviceId;
|
||||||
});
|
});
|
||||||
if (!f) {
|
if (!f) {
|
||||||
these.Statu.bound = false;
|
these.Statu.bound = false;
|
||||||
@ -195,7 +207,7 @@
|
|||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
these.Statu.bound = true;
|
these.Statu.bound = true;
|
||||||
these.Statu.boundRemark = "设备绑定成功!";
|
these.Statu.boundRemark = "设备绑定成功!";
|
||||||
|
ble.removeReceiveCallback(pagePath);
|
||||||
|
|
||||||
uni.$emit("refreshDeviceList");
|
uni.$emit("refreshDeviceList");
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
@ -136,7 +136,7 @@
|
|||||||
},
|
},
|
||||||
onHide: function() {
|
onHide: function() {
|
||||||
ble.StopSearch();
|
ble.StopSearch();
|
||||||
ble.removeReceiveCallback(pagePath);
|
|
||||||
},
|
},
|
||||||
onBackPress: (e) => {
|
onBackPress: (e) => {
|
||||||
ble.StopSearch();
|
ble.StopSearch();
|
||||||
@ -145,8 +145,7 @@
|
|||||||
},
|
},
|
||||||
onUnload(){
|
onUnload(){
|
||||||
ble.StopSearch();
|
ble.StopSearch();
|
||||||
ble.removeDeviceFound(pagePath);
|
|
||||||
ble.removeReceiveCallback(pagePath);
|
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
these = this;
|
these = this;
|
||||||
@ -172,7 +171,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},pagePath);
|
},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() {
|
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);
|
these.PairEquip.push(item);
|
||||||
}
|
}
|
||||||
ble.removeReceiveCallback(pagePath);
|
console.log("连接成功");
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url:"/pages/common/addBLE/LinkBle",
|
url:"/pages/common/addBLE/LinkBle",
|
||||||
events:{
|
events:{
|
||||||
|
@ -486,6 +486,10 @@
|
|||||||
// 列表跳转
|
// 列表跳转
|
||||||
handleFile(item) {
|
handleFile(item) {
|
||||||
let url = item.detailPageUrl;
|
let url = item.detailPageUrl;
|
||||||
|
// console.log("url=",url);
|
||||||
|
// if(!url){
|
||||||
|
//url="/pages/670/HBY670"
|
||||||
|
// }
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: url,
|
url: url,
|
||||||
events: {
|
events: {
|
||||||
@ -498,6 +502,8 @@
|
|||||||
deviceType: this.tabs[this.activeTab].id || '',
|
deviceType: this.tabs[this.activeTab].id || '',
|
||||||
apiType: 'listA' //标识,根据这个参数,区分普通详情,分享跳转详情,查不一样的权限信息
|
apiType: 'listA' //标识,根据这个参数,区分普通详情,分享跳转详情,查不一样的权限信息
|
||||||
});
|
});
|
||||||
|
},fail(ex) {
|
||||||
|
console.log("ex=",ex);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
BIN
static/images/common/msg.png
Normal file
BIN
static/images/common/msg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
@ -105,17 +105,17 @@ class BleHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
linkAllDevices() {
|
linkAllDevices() {
|
||||||
console.log("模块启动时,自动连接已连接过的设备", this.data.LinkedList);
|
// console.log("模块启动时,自动连接已连接过的设备", this.data.LinkedList);
|
||||||
|
|
||||||
if (this.data.LinkedList && this.data.LinkedList.length > 0) {
|
if (this.data.LinkedList && this.data.LinkedList.length > 0) {
|
||||||
for (var i = 0; i < this.data.LinkedList.length; i++) {
|
for (var i = 0; i < this.data.LinkedList.length; i++) {
|
||||||
let device = this.data.LinkedList[i];
|
let device = this.data.LinkedList[i];
|
||||||
console.log("自动连接:" + device.deviceId);
|
// console.log("自动连接:" + device.deviceId);
|
||||||
this.LinkBlue(device.deviceId, device.writeServiceId, device.wirteCharactId, device
|
this.LinkBlue(device.deviceId, device.writeServiceId, device.wirteCharactId, device
|
||||||
.notifyCharactId);
|
.notifyCharactId);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log("无设备连接");
|
// console.log("无设备连接");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ class BleHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const currentPage = pages[pages.length - 1];
|
const currentPage = pages[pages.length - 1];
|
||||||
console.log("currentPage=", currentPage.route);
|
// console.log("currentPage=", currentPage.route);
|
||||||
return currentPage.route;
|
return currentPage.route;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,7 +181,7 @@ class BleHelper {
|
|||||||
key = new Date().getTime();
|
key = new Date().getTime();
|
||||||
}
|
}
|
||||||
if (key) {
|
if (key) {
|
||||||
console.log("订阅消息回调,key=" + key);
|
// console.log("订阅消息回调,key=" + key);
|
||||||
let f = this.cfg.receivDataCallback.findIndex((v) => {
|
let f = this.cfg.receivDataCallback.findIndex((v) => {
|
||||||
return v.key == key;
|
return v.key == key;
|
||||||
});
|
});
|
||||||
@ -363,7 +363,7 @@ class BleHelper {
|
|||||||
|
|
||||||
uni.openBluetoothAdapter({
|
uni.openBluetoothAdapter({
|
||||||
success: (args) => {
|
success: (args) => {
|
||||||
console.log("蓝牙初始化成功:" + JSON.stringify(args));
|
// console.log("蓝牙初始化成功:" + JSON.stringify(args));
|
||||||
this.data.isOpenBlue = true;
|
this.data.isOpenBlue = true;
|
||||||
this.data.available=true;
|
this.data.available=true;
|
||||||
resolve(true);
|
resolve(true);
|
||||||
@ -371,7 +371,7 @@ class BleHelper {
|
|||||||
if (this.data.isSubscribe) { //整个App生命周期,只订阅一次
|
if (this.data.isSubscribe) { //整个App生命周期,只订阅一次
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log("开始订阅各类变化消息");
|
// console.log("开始订阅各类变化消息");
|
||||||
this.data.isSubscribe = true;
|
this.data.isSubscribe = true;
|
||||||
|
|
||||||
|
|
||||||
@ -417,7 +417,7 @@ class BleHelper {
|
|||||||
uni.setStorageSync(this.StorageKey, this.data
|
uni.setStorageSync(this.StorageKey, this.data
|
||||||
.LinkedList);
|
.LinkedList);
|
||||||
} else {
|
} else {
|
||||||
console.log("蓝牙连接已恢复,", res);
|
// console.log("蓝牙连接已恢复,", res);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -437,7 +437,7 @@ class BleHelper {
|
|||||||
|
|
||||||
uni.onBLECharacteristicValueChange((receive) => {
|
uni.onBLECharacteristicValueChange((receive) => {
|
||||||
//订阅消息
|
//订阅消息
|
||||||
console.log("收到订阅消息",receive);
|
// console.log("收到订阅消息",receive);
|
||||||
let f=this.data.LinkedList.find((v) => {
|
let f=this.data.LinkedList.find((v) => {
|
||||||
return v.deviceId == receive.deviceId;
|
return v.deviceId == receive.deviceId;
|
||||||
})
|
})
|
||||||
@ -500,7 +500,7 @@ class BleHelper {
|
|||||||
str: str,
|
str: str,
|
||||||
hexs: hexs
|
hexs: hexs
|
||||||
};
|
};
|
||||||
console.log("监听到特征值:" + JSON.stringify(recData));
|
// console.log("监听到特征值:" + JSON.stringify(recData));
|
||||||
if (this.cfg.receivDataCallback) {
|
if (this.cfg.receivDataCallback) {
|
||||||
|
|
||||||
if (this.cfg.receivDataCallback.length > 0) {
|
if (this.cfg.receivDataCallback.length > 0) {
|
||||||
@ -678,7 +678,7 @@ class BleHelper {
|
|||||||
state: state,
|
state: state,
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
if (state) {
|
if (state) {
|
||||||
console.log("订阅消息成功", res);
|
// console.log("订阅消息成功", res);
|
||||||
} else {
|
} else {
|
||||||
console.log("取消订阅成功", res);
|
console.log("取消订阅成功", res);
|
||||||
}
|
}
|
||||||
|
@ -48,22 +48,23 @@ class BleReceive {
|
|||||||
if(f && f.macAddress && f.id){
|
if(f && f.macAddress && f.id){
|
||||||
let data={};
|
let data={};
|
||||||
if(f.detailPageUrl=='/pages/6155/deviceDetail'){
|
if(f.detailPageUrl=='/pages/6155/deviceDetail'){
|
||||||
console.log("该设备是6155");
|
// console.log("该设备是6155");
|
||||||
data= this.Receive_6155(receive,f,path);
|
data= this.Receive_6155(receive,f,path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(f.detailPageUrl=='/pages/650/HBY650'){
|
if(f.detailPageUrl=='/pages/650/HBY650'){
|
||||||
console.log("该设备是650");
|
// console.log("该设备是650");
|
||||||
data= this.Receive_650(receive,f,path);
|
data= this.Receive_650(receive,f,path);
|
||||||
}
|
}
|
||||||
if(f.detailPageUrl=='/pages/670/HBY670'){
|
if(f.detailPageUrl=='/pages/670/HBY670'){
|
||||||
console.log("该设备是670");
|
// console.log("该设备是670");
|
||||||
data= this.Receive_670(receive,f,path);
|
data= this.Receive_670(receive,f,path);
|
||||||
}
|
}
|
||||||
console.log("收到数据并处理完毕,",data);
|
// console.log("收到数据并处理完毕,",data);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
console.log("已收到该消息,但无法处理",f);
|
// console.log("已收到该消息,但无法处理",receive);
|
||||||
|
return receive;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,11 +254,11 @@ class BleReceive {
|
|||||||
Receive_670(receive,f,path){
|
Receive_670(receive,f,path){
|
||||||
|
|
||||||
var todo = (bytes) =>{
|
var todo = (bytes) =>{
|
||||||
console.log("todo");
|
// console.log("todo",receive);
|
||||||
let receiveData = {};
|
let receiveData = {};
|
||||||
if (bytes[0] == 0x55) {
|
if (bytes[0] == 0x55) {
|
||||||
try {
|
try {
|
||||||
console.log("todo");
|
// console.log("todo");
|
||||||
// 跳过帧头(第一个字节),从第二个字节开始解析
|
// 跳过帧头(第一个字节),从第二个字节开始解析
|
||||||
let staticLevelByte = bytes[1];
|
let staticLevelByte = bytes[1];
|
||||||
let staticLevelText = '';
|
let staticLevelText = '';
|
||||||
@ -275,7 +276,7 @@ class BleReceive {
|
|||||||
staticLevelText = 'close';
|
staticLevelText = 'close';
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
console.log("todo");
|
// console.log("todo");
|
||||||
// 解析照明档位
|
// 解析照明档位
|
||||||
let lightingLevelByte = bytes[2];
|
let lightingLevelByte = bytes[2];
|
||||||
let lightingLevelText = lightingLevelByte === 0x6d ? 'hight': lightingLevelByte === 0x6e ? 'low': 'close';
|
let lightingLevelText = lightingLevelByte === 0x6d ? 'hight': lightingLevelByte === 0x6e ? 'low': 'close';
|
||||||
@ -287,7 +288,7 @@ class BleReceive {
|
|||||||
let batteryLevelByte = bytes[5];
|
let batteryLevelByte = bytes[5];
|
||||||
|
|
||||||
let batteryLevel = Math.max(0, Math.min(100, batteryLevelByte));
|
let batteryLevel = Math.max(0, Math.min(100, batteryLevelByte));
|
||||||
console.log("todo");
|
// console.log("todo");
|
||||||
let warn = bytes[6];
|
let warn = bytes[6];
|
||||||
if (warn == 0x00) {
|
if (warn == 0x00) {
|
||||||
warn = 'none';
|
warn = 'none';
|
||||||
@ -304,7 +305,7 @@ class BleReceive {
|
|||||||
let staticWarn = bytes[7] == 0x01;//静止报警
|
let staticWarn = bytes[7] == 0x01;//静止报警
|
||||||
let fourGStrenth = bytes[8]; //4g信号强度
|
let fourGStrenth = bytes[8]; //4g信号强度
|
||||||
let sosTxt = bytes[9] == 0x00 ? 'close' : bytes[9] == 0x01 ? 'sg' : 'rb';
|
let sosTxt = bytes[9] == 0x00 ? 'close' : bytes[9] == 0x01 ? 'sg' : 'rb';
|
||||||
console.log("todo");
|
// console.log("todo");
|
||||||
receiveData.modeCurr = staticLevelText;
|
receiveData.modeCurr = staticLevelText;
|
||||||
receiveData.lightCurr = lightingLevelText;
|
receiveData.lightCurr = lightingLevelText;
|
||||||
receiveData.xuhang = lightingTime ;
|
receiveData.xuhang = lightingTime ;
|
||||||
@ -316,7 +317,7 @@ class BleReceive {
|
|||||||
} catch(error) {
|
} catch(error) {
|
||||||
console.log('数据解析错误:', error);
|
console.log('数据解析错误:', error);
|
||||||
}
|
}
|
||||||
console.log("todo");
|
// console.log("todo");
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
let uint8Array = new Uint8Array(receive.value);
|
let uint8Array = new Uint8Array(receive.value);
|
||||||
@ -340,6 +341,7 @@ class BleReceive {
|
|||||||
console.log('收到纬度:', +this.receiveData.macAddress);
|
console.log('收到纬度:', +this.receiveData.macAddress);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
// console.log("str=",str);
|
||||||
let json=JSON.parse(str);
|
let json=JSON.parse(str);
|
||||||
if("staBlue_picture" in json){
|
if("staBlue_picture" in json){
|
||||||
//重发图片
|
//重发图片
|
||||||
@ -372,7 +374,7 @@ class BleReceive {
|
|||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
receiveData={};
|
receiveData={};
|
||||||
console.log("文本解析失败")
|
// console.log("文本解析失败",error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(ex) {
|
} catch(ex) {
|
||||||
@ -380,7 +382,7 @@ class BleReceive {
|
|||||||
console.log('将数据转文本失败', ex);
|
console.log('将数据转文本失败', ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log("todo",receiveData);
|
// console.log("todo",receiveData);
|
||||||
this.setBleFormData(receiveData,f);
|
this.setBleFormData(receiveData,f);
|
||||||
return receiveData;
|
return receiveData;
|
||||||
}
|
}
|
||||||
|
@ -5,19 +5,17 @@ export const showLoading = (ev,options) => {
|
|||||||
if(!ev){
|
if(!ev){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
let defaultTxt="请稍候...";
|
||||||
if(!options){
|
if(!options){
|
||||||
options={a:1};
|
options={text:defaultTxt};
|
||||||
}
|
}
|
||||||
if(!options.text && options.title){
|
if(!options.text && options.title){
|
||||||
options.text=options.title;
|
options.text=options.title;
|
||||||
}
|
}
|
||||||
if(!options.text){
|
if(!options.text){
|
||||||
options.text="请稍候...";
|
options.text=defaultTxt;
|
||||||
}
|
}
|
||||||
ev.$refs.loading.show(options);
|
ev.$refs.loading.show(options);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 隐藏loading
|
// 隐藏loading
|
||||||
|
@ -171,7 +171,7 @@ class MqttClient {
|
|||||||
potentialJsons.forEach(jsonString => {
|
potentialJsons.forEach(jsonString => {
|
||||||
if (jsonString.trim() === '') return;
|
if (jsonString.trim() === '') return;
|
||||||
if (this.messageCallbacks.has(topic)) {
|
if (this.messageCallbacks.has(topic)) {
|
||||||
this.messageCallbacks.get(topic)(jsonString);
|
this.messageCallbacks.get(topic)(jsonString,message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -285,8 +285,10 @@ class MqttClient {
|
|||||||
mqttMessage.qos = 1;
|
mqttMessage.qos = 1;
|
||||||
this.client.send(mqttMessage);
|
this.client.send(mqttMessage);
|
||||||
console.log(`成功发布消息到主题 ${topic}: ${message}`);
|
console.log(`成功发布消息到主题 ${topic}: ${message}`);
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
console.error('MQTT未连接,无法发布');
|
console.error('MQTT未连接,无法发布');
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,9 +22,11 @@ const request = (options) => {
|
|||||||
header: options.header || {},
|
header: options.header || {},
|
||||||
timeout: 30000,
|
timeout: 30000,
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
|
console.log("res=",res);
|
||||||
resolve(res.data);
|
resolve(res.data);
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
|
console.log("ex=",err);
|
||||||
reject(err);
|
reject(err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user