添加报警功能
This commit is contained in:
43
App.vue
43
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特有相关 */
|
||||||
@ -85,7 +85,7 @@
|
|||||||
"appkey_ios" : "065c43f02c7b627a74ad7dd23b16bb4f",
|
"appkey_ios" : "065c43f02c7b627a74ad7dd23b16bb4f",
|
||||||
"appkey_android" : "d7d852dbda2b95f6f796fb9a711a9fee"
|
"appkey_android" : "d7d852dbda2b95f6f796fb9a711a9fee"
|
||||||
},
|
},
|
||||||
"customStyle": true
|
"customStyle" : true
|
||||||
},
|
},
|
||||||
"oauth" : {},
|
"oauth" : {},
|
||||||
"push" : {}
|
"push" : {}
|
||||||
|
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" : "历史记录"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
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