完成008A功能开发
@ -2,6 +2,7 @@
|
||||
"version" : "1.0",
|
||||
"configurations" : [
|
||||
{
|
||||
"customPlaygroundType" : "local",
|
||||
"playground" : "standard",
|
||||
"type" : "uni-app:app-ios"
|
||||
},
|
||||
|
||||
146
App.vue
@ -15,25 +15,25 @@
|
||||
console.log("appid=", appid);
|
||||
|
||||
if (appid === 'HBuilder') {
|
||||
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" || val == 'phone') {
|
||||
console.log("忽略登陆信息");
|
||||
} else {
|
||||
uni.removeStorageSync(val);
|
||||
}
|
||||
});
|
||||
// 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" || val == 'phone') {
|
||||
// console.log("忽略登陆信息");
|
||||
// } else {
|
||||
// uni.removeStorageSync(val);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
|
||||
@ -46,6 +46,7 @@
|
||||
|
||||
uni.getPushClientId({
|
||||
success(res) {
|
||||
|
||||
console.log("推送信息:", res);
|
||||
uni.setStorageSync('push_cid', res.cid);
|
||||
},
|
||||
@ -65,29 +66,31 @@
|
||||
//将App角标设置为0,清空app在消息中心的所有消息
|
||||
uni.setAppBadgeNumber(0);
|
||||
plus && plus.push.clear();
|
||||
uni.navigateTo({
|
||||
url:'/pages/common/Msgs/deviceMsg',
|
||||
success(r) {
|
||||
console.log("11111");
|
||||
r.eventChannel.emit("pushMsg",res);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
uni.createPushMessage({
|
||||
title: res.data.title,
|
||||
content: res.data.content,
|
||||
payload: res.data.payload
|
||||
});
|
||||
if(res.data.payload && res.data.payload.force==true){
|
||||
console.log("此消息是强制消息")
|
||||
//设备在线,丢弃消息,只显示强制的消息
|
||||
uni.createPushMessage({
|
||||
title: res.data.title,
|
||||
content: res.data.content,
|
||||
payload: res.data.payload
|
||||
});
|
||||
return;
|
||||
}
|
||||
console.error("设备在线,不是强制消息,丢弃此消息");
|
||||
|
||||
|
||||
});
|
||||
|
||||
//监听网络变化
|
||||
uni.onNetworkStatusChange((res)=>{
|
||||
let title='网络连接已断开';
|
||||
|
||||
if(res.isConnected){
|
||||
title='网络连接已恢复';
|
||||
|
||||
}
|
||||
uni.showToast({
|
||||
title:title
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (system.osName == 'android') {
|
||||
@ -105,14 +108,16 @@
|
||||
},
|
||||
onShow: function() {
|
||||
console.log('App Show');
|
||||
// 取消延迟断开:用户可能只是选文件/录音后返回,不断开蓝牙
|
||||
|
||||
|
||||
//将检查更新换到onshow,因为苹果用户喜欢一直挂着
|
||||
// #ifdef APP|APP-PLUS
|
||||
|
||||
if (_bleDisconnectTimer) {
|
||||
clearTimeout(_bleDisconnectTimer);
|
||||
_bleDisconnectTimer = null;
|
||||
}
|
||||
//将检查更新换到onshow,因为苹果用户喜欢一直挂着
|
||||
// #ifdef APP|APP-PLUS
|
||||
|
||||
|
||||
let appid = plus.runtime.appid;
|
||||
console.log("appid=", appid);
|
||||
|
||||
@ -123,14 +128,28 @@
|
||||
uni.setKeepScreenOn({
|
||||
keepScreenOn: true
|
||||
}).then(res => {
|
||||
console.log("已设置屏幕常亮");
|
||||
console.log("已打开屏幕常亮");
|
||||
}).catch(ex => {
|
||||
console.error("设置屏幕常亮失败,ex=", ex)
|
||||
})
|
||||
});
|
||||
|
||||
//监听网络变化
|
||||
uni.onNetworkStatusChange((res)=>{
|
||||
let title='网络连接已断开';
|
||||
|
||||
if(res.isConnected){
|
||||
title='网络连接已恢复';
|
||||
|
||||
}
|
||||
uni.showToast({
|
||||
title:title
|
||||
|
||||
});
|
||||
});
|
||||
// #endif
|
||||
|
||||
|
||||
},
|
||||
},
|
||||
onHide: function() {
|
||||
console.log('App Hide');
|
||||
// #ifdef APP|APP-PLUS
|
||||
@ -157,11 +176,11 @@
|
||||
if (_bleDisconnectTimer) clearTimeout(_bleDisconnectTimer);
|
||||
_bleDisconnectTimer = setTimeout(() => {
|
||||
_bleDisconnectTimer = null;
|
||||
let ble2 = bleTool.getBleTool();
|
||||
if (ble2) {
|
||||
|
||||
if (ble) {
|
||||
console.log("App隐藏了,断开所有蓝牙设备,停止搜索");
|
||||
ble2.StopSearch().catch(ex => {});
|
||||
ble2.disconnectDevice().catch(ex => {});
|
||||
ble.StopSearch().catch(ex => {});
|
||||
ble.disconnectDevice().catch(ex => {});
|
||||
console.log("断开所有蓝牙设备");
|
||||
|
||||
|
||||
@ -285,13 +304,22 @@
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.colCenter{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-wrap: wrap;
|
||||
align-content: center;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.navbarRight .img {
|
||||
width: 35rpx;
|
||||
height: 35rpx;
|
||||
margin-right: 30rpx;
|
||||
}
|
||||
|
||||
.navbarRight .img:last-child{
|
||||
margin-right: 10rpx !important;
|
||||
}
|
||||
.uni-navbar--fixed {
|
||||
top: 0rpx;
|
||||
}
|
||||
@ -303,17 +331,19 @@
|
||||
::v-deep .uni-navbar__placeholder {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
::v-deep .mescroll-upwarp{
|
||||
text-align: center;
|
||||
}
|
||||
/* #endif */
|
||||
|
||||
|
||||
// @font-face {
|
||||
// font-family: "PingFang SC";
|
||||
// src: url("~@/static/fonts/PingFangSC.ttf") format("opentype");
|
||||
// }
|
||||
@font-face {
|
||||
font-family: "PingFang SC";
|
||||
src: url("~@/static/fonts/PingFangSC.ttf") format("opentype");
|
||||
}
|
||||
|
||||
// @font-face {
|
||||
// font-family: "PingFangBold";
|
||||
// src: url("~@/static/fonts/PingFangBold.ttf") format("opentype");
|
||||
// }
|
||||
@font-face {
|
||||
font-family: "PingFangBold";
|
||||
src: url("~@/static/fonts/PingFangSC.ttf") format("opentype");
|
||||
}
|
||||
</style>
|
||||
@ -133,8 +133,10 @@
|
||||
return json;
|
||||
},
|
||||
//弹出预定好的四种弹窗
|
||||
showMsg(msg, btnTxt, type, okCallback) {
|
||||
|
||||
showMsg(msg, btnTxt, type, okCallback,showCancel) {
|
||||
if(!showCancel){
|
||||
showCancel=false;
|
||||
}
|
||||
let cfg = {
|
||||
error: {
|
||||
icoUrl: '/static/images/common/uploadErr.png',
|
||||
@ -142,7 +144,7 @@
|
||||
buttonBgColor: "#E03434",
|
||||
bgColor:'#383934cc',
|
||||
buttonTextColor:'#FFFFFFde',
|
||||
showCancel:true,
|
||||
showCancel:showCancel,
|
||||
buttonCancelText:'取消'
|
||||
},
|
||||
succ: {
|
||||
@ -151,35 +153,34 @@
|
||||
buttonBgColor: "#BBE600",
|
||||
buttonTextColor:'#232323de',
|
||||
bgColor:'#383934cc',
|
||||
showCancel:true,
|
||||
showCancel:showCancel,
|
||||
buttonCancelText:'取消'
|
||||
},
|
||||
warn: {
|
||||
icoUrl: '/static/images/common/warning.png',
|
||||
borderColor: "#FFC84E4d",
|
||||
buttonBgColor: "#FFC84E",
|
||||
buttonTextColor:'#FFFFFFde',
|
||||
buttonTextColor:'#1a1A1A',
|
||||
bgColor:'#383934cc',
|
||||
showCancel:true,
|
||||
showCancel:showCancel,
|
||||
buttonCancelText:'取消'
|
||||
},
|
||||
info:{
|
||||
borderColor: "#BBE6004d",
|
||||
buttonBgColor: "#BBE600",
|
||||
bgColor:'#383934cc',
|
||||
icoUrl: '/static/images/common/ver.png',
|
||||
borderColor: "#FFFFFF4d",
|
||||
buttonBgColor: "#FFFFFFde",
|
||||
buttonTextColor:'#232323de',
|
||||
showCancel:true,
|
||||
bgColor:'#383934cc',
|
||||
showCancel:showCancel,
|
||||
buttonCancelText:'取消'
|
||||
},
|
||||
prompt:{
|
||||
|
||||
|
||||
prompt:{
|
||||
borderColor: "#aed6004d",
|
||||
buttonBgColor: "#aed600",
|
||||
bgColor:'#38393466',
|
||||
bgColor:'#383934cc',
|
||||
buttonTextColor:'#232323de',
|
||||
showSlot:true,
|
||||
showCancel:true,
|
||||
showCancel:showCancel,
|
||||
buttonCancelText:'取消'
|
||||
}
|
||||
}
|
||||
|
||||
158
components/SubStep/SubStep.vue
Normal file
@ -0,0 +1,158 @@
|
||||
<template>
|
||||
<view class="stepPanel" :class="size" :style="{'height':height}">
|
||||
<!-- 步骤控件,实现效果1-2-3-4-N -->
|
||||
<view v-for="item,index in steps" class="item" :class="{'lastItem':index==steps.length-1}">
|
||||
|
||||
<view class="step " @click="stepClick(item,index)" :class="{'active':index<=curr}">
|
||||
<view class="circle center ">{{index+1}}</view>
|
||||
<view class="txt">{{item.text}}</view>
|
||||
</view>
|
||||
<view class="line" v-if="index<steps.length-1" :class="{'active':index<=curr-1}">
|
||||
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "SubStep",
|
||||
data() {
|
||||
return {}
|
||||
},
|
||||
computed: {
|
||||
|
||||
},
|
||||
props: {
|
||||
steps: {
|
||||
type: Array,
|
||||
default: []
|
||||
},
|
||||
curr: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
size: {
|
||||
type: String,
|
||||
default: 'nomal'
|
||||
},
|
||||
height: {
|
||||
type: String,
|
||||
default: "140rpx"
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
stepClick(item, index) {
|
||||
this.$emit('stepClick', item, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.stepPanel {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
align-content: center;
|
||||
align-items: center;
|
||||
justify-content: space-evenly;
|
||||
}
|
||||
|
||||
.item {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.item {
|
||||
width: calc((100% - 100rpx) / 3);
|
||||
}
|
||||
|
||||
.item:last-of-type,
|
||||
.item.lastItem{
|
||||
width: 100rpx !important;
|
||||
}
|
||||
|
||||
.item .step {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-wrap: wrap;
|
||||
align-content: center;
|
||||
align-items: center;
|
||||
justify-content: space-around;
|
||||
float: left;
|
||||
width: 100rpx;
|
||||
}
|
||||
|
||||
.item .line {
|
||||
|
||||
height: 0rpx;
|
||||
border: 2rpx solid rgba(42, 42, 42, 1);
|
||||
margin-top: 39rpx;
|
||||
float: left;
|
||||
width: calc(100% - 120rpx);
|
||||
margin-left: 10rpx;
|
||||
}
|
||||
|
||||
.item .circle {
|
||||
width: 35rpx;
|
||||
height: 35rpx;
|
||||
border-radius: 50%;
|
||||
background: rgba(58, 58, 58, 1);
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
font-family: "PingFang SC";
|
||||
font-style: Regular;
|
||||
font-size: 22rpx;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.nomal .item .circle {
|
||||
width: 45rpx;
|
||||
height: 45rpx;
|
||||
}
|
||||
|
||||
.small .item .circle {
|
||||
width: 35rpx;
|
||||
height: 35rpx;
|
||||
}
|
||||
|
||||
.large .item .circle {
|
||||
width: 50rpx;
|
||||
height: 50rpx;
|
||||
}
|
||||
|
||||
.item .txt {
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
font-family: "PingFang SC";
|
||||
font-style: Regular;
|
||||
font-size: 24rpx;
|
||||
font-weight: 400;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.nomal .item .txt {
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.small .item .txt {
|
||||
font-size: 20rpx;
|
||||
}
|
||||
|
||||
.large .item .txt {
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.item .step.active .circle {
|
||||
background: #AED600 !important;
|
||||
color: rgba(255, 255, 255, 1) !important;
|
||||
box-shadow: 0px 0px 0px 12rpx #aed6004a;
|
||||
}
|
||||
|
||||
.item .line.active {
|
||||
border: 1px solid #AED600 !important;
|
||||
}
|
||||
</style>
|
||||
@ -2,7 +2,7 @@
|
||||
"name" : "星汉物联",
|
||||
"appid" : "__UNI__A21EF43",
|
||||
"description" : "设备管控",
|
||||
"versionName" : "1.0.27",
|
||||
"versionName" : "1.0.30",
|
||||
"versionCode" : 101,
|
||||
"transformPx" : false,
|
||||
/* 5+App特有相关 */
|
||||
|
||||
41
pages.json
@ -168,8 +168,8 @@
|
||||
{
|
||||
"path": "pages/common/map/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "地图"
|
||||
|
||||
"navigationBarTitleText": "地图",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -473,15 +473,15 @@
|
||||
{
|
||||
"path": "pages/common/sosSet/TxtMsgSetting",
|
||||
"style": {
|
||||
"navigationBarTitleText": "短信设置",
|
||||
"navigationStyle": "custom"
|
||||
"navigationBarTitleText": "短信设置"
|
||||
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/sosSet/LinkManSetting",
|
||||
"style": {
|
||||
"navigationBarTitleText": "紧急联系人",
|
||||
"navigationStyle": "custom"
|
||||
"navigationBarTitleText": "紧急联系人"
|
||||
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -495,6 +495,35 @@
|
||||
"style": {
|
||||
"navigationBarTitleText": "报警记录"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/linkDefence/defence",
|
||||
"style": {
|
||||
"navigationBarTitleText": "预警布防",
|
||||
"navigationStyle": "custom",
|
||||
"app-plus":{
|
||||
"bounce":"none"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/linkDefence/addDefence",
|
||||
"style": {
|
||||
"navigationBarTitleText": "编辑预警编组"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/linkDefence/checkDevice",
|
||||
"style": {
|
||||
"navigationBarTitleText": "",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/Msgs/deviceMsg",
|
||||
"style": {
|
||||
"navigationBarTitleText": "设备消息"
|
||||
}
|
||||
}
|
||||
|
||||
],
|
||||
|
||||
@ -53,23 +53,100 @@
|
||||
<text class="lbl">蓝牙名称</text>
|
||||
<text class="value valueFont">{{device.bluetoothName}}</text>
|
||||
</view>
|
||||
|
||||
<view class="item">
|
||||
<text class="lbl">设备状态</text>
|
||||
<text class="value valueFont">{{formData.sta_system}}</text>
|
||||
</view>
|
||||
<view class="item" @click.top="bleStatuToggle">
|
||||
<text class="lbl">蓝牙状态</text>
|
||||
<text class="value" :class="formData.bleStatu?'green':'red'">{{getbleStatu}}</text>
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="lbl">设备状态</text>
|
||||
<text class="value valueFont">{{formData.sta_system}}</text>
|
||||
<text class="lbl">信道:{{formData.sta_Channel}}</text>
|
||||
<text class="value green" @click.stop="ShowChannelEdit()">修改</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
<view class="lampMode">
|
||||
<view class="mode type " :class="{'active':formData.sta_Ms=='M'}" @click.stop="MsSetting('M')">
|
||||
<view class="txt center">M</view>
|
||||
</view>
|
||||
<view class="mode type" :class="{'active':formData.sta_Ms=='S'}" @click.stop="MsSetting('S')">
|
||||
<view class="txt center">S</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="optTitle">
|
||||
开关模式
|
||||
</view>
|
||||
<view class="btn-container">
|
||||
<view class="btn" @click.stop="btnSetting(0,'warnSwitch')" :class="{'active':Status.warnSwitch==0}">总开关
|
||||
</view>
|
||||
<view class="btn" @click.stop="btnSetting(-1,'warnSwitch')" :class="{'active':Status.warnSwitch==-1}">左侧
|
||||
</view>
|
||||
<view class="btn" @click.stop="btnSetting(1,'warnSwitch')" :class="{'active':Status.warnSwitch==1}">右侧
|
||||
</view>
|
||||
</view>
|
||||
<view class="lampMode">
|
||||
|
||||
<view class="mode " :class="getSwitchActive(item,index,'warn')" v-for="item,index in dic.warLight"
|
||||
v-on:click.stop="lightsetting(item,index,'warn')">
|
||||
<view class="leftImg">
|
||||
|
||||
<image class="img image" :src="item.img" mode="aspectFit"></image>
|
||||
<image class="img imageA" :src="item.imgA" mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
<text class="bigTxt">{{item.text}}</text>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
</view>
|
||||
|
||||
|
||||
<view class="optTitle">
|
||||
泛光灯
|
||||
</view>
|
||||
<view class="btn-container">
|
||||
<view class="btn" @click.stop="btnSetting(0,'fanSwitch')" :class="{'active':Status.fanSwitch==0}">前置</view>
|
||||
<view class="btn" @click.stop="btnSetting(-1,'fanSwitch')" :class="{'active':Status.fanSwitch==-1}">左侧
|
||||
</view>
|
||||
<view class="btn" @click.stop="btnSetting(1,'fanSwitch')" :class="{'active':Status.fanSwitch==1}">右侧</view>
|
||||
</view>
|
||||
|
||||
<view class="fanMode">
|
||||
<view class="fanItem" :class="getSwitchActive(item,index,'fan')" v-for="item,index in dic.fanLight"
|
||||
v-on:click.stop="lightsetting(item,index,'fan')">
|
||||
<view class="topImg">
|
||||
|
||||
<image class="img image" :src="item.img" mode="aspectFit"></image>
|
||||
<image class="img imageA" :src="item.imgA" mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="bottomTxt">
|
||||
<text class="bigTxt">{{item.text}}</text>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
<ProParams :id="device.id"></ProParams>
|
||||
|
||||
<MsgBox ref="msgPop" />
|
||||
|
||||
<global-loading ref="loading" />
|
||||
|
||||
<MsgBox ref="msgEditChannel">
|
||||
<view class="popup-prompt">
|
||||
<text class="popup-prompt-title">修改信道</text>
|
||||
<input class="popup-prompt-input" type="number" placeholder="大于0的整数"
|
||||
placeholder-class="popup-prompt-input-placeHolder" v-model="formData.tmp_Channel" />
|
||||
|
||||
</view>
|
||||
</MsgBox>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@ -112,11 +189,11 @@
|
||||
apiType: "listA",
|
||||
navbar: {
|
||||
icons: [{
|
||||
type:'msg',
|
||||
type: 'msg',
|
||||
src: '/static/images/common/msg.png'
|
||||
},
|
||||
{
|
||||
type:'share',
|
||||
type: 'share',
|
||||
src: '/static/images/common/shape.png'
|
||||
}
|
||||
],
|
||||
@ -125,31 +202,25 @@
|
||||
height: 90
|
||||
},
|
||||
usrToggle: true,
|
||||
bleLinkCnt: 0
|
||||
bleLinkCnt: 0,
|
||||
warnSwitch: 0,
|
||||
fanSwitch: 0
|
||||
},
|
||||
formData: {
|
||||
img: '/static/images/common/BJQ6075.png',
|
||||
battary: "", //电量
|
||||
xuhang: "", //续航
|
||||
imei: "", //imei
|
||||
Lon: "", //经度
|
||||
Lat: "", //纬度
|
||||
address: "", //地址
|
||||
modeCurr: "", //档位
|
||||
SOS: "", //sos
|
||||
lightCurr: "qiang", //照明模式
|
||||
company: "湖北消防总队", //单位
|
||||
usrname: "胡红军", //姓名
|
||||
job: "中队长", //职位
|
||||
usrid: "", //id
|
||||
msgTxt: "", //消息1
|
||||
qzwarn: false, //是否强制报警
|
||||
warnLevel: "", //报警级别
|
||||
staticWarn: false, //静止报警
|
||||
fourGStrenth: 0, //4G信号强度
|
||||
img: '/static/images/common/HBY008A.png',
|
||||
deviceId: "",
|
||||
sta_system: "", //设备状态,0关机,1仅充电,2开机未充电,3,开机且充电
|
||||
bleStatu: false
|
||||
sta_leftLight: null,
|
||||
sta_rightLight: null,
|
||||
sta_frontFan: null,
|
||||
sta_leftFan: null,
|
||||
sta_rightFan: null,
|
||||
sta_channel: null,
|
||||
sta_Ms: null,
|
||||
sta_PowerPercent: null,
|
||||
sta_PowerTime: null,
|
||||
sta_system: null,
|
||||
bleStatu: null,
|
||||
tmp_Channel: null
|
||||
},
|
||||
device: {
|
||||
id: "",
|
||||
@ -170,7 +241,58 @@
|
||||
detailPageUrl: "/pages/670/HBY670",
|
||||
showConfirm: false
|
||||
},
|
||||
|
||||
dic: {
|
||||
fanLight: [{
|
||||
text: '强光',
|
||||
value: 1,
|
||||
img: '/static/images/lightImg/qiang.png',
|
||||
imgA: '/static/images/lightImg/qiangActive.png',
|
||||
},
|
||||
{
|
||||
text: '工作光',
|
||||
value: 2,
|
||||
img: '/static/images/lightImg/work.png',
|
||||
imgA: '/static/images/lightImg/workActive.png',
|
||||
},
|
||||
{
|
||||
text: '爆闪',
|
||||
value: 4,
|
||||
img: '/static/images/lightImg/light.png',
|
||||
imgA: '/static/images/lightImg/lightActive.png',
|
||||
}
|
||||
],
|
||||
warLight: [{
|
||||
text: '红色长亮',
|
||||
value: 1,
|
||||
img: '/static/images/lightImg/liting.png',
|
||||
imgA: '/static/images/lightImg/litingActive.png',
|
||||
},
|
||||
{
|
||||
text: '红色爆闪',
|
||||
value: 2,
|
||||
img: '/static/images/lightImg/light.png',
|
||||
imgA: '/static/images/lightImg/lightActive.png',
|
||||
},
|
||||
{
|
||||
text: '红蓝双闪',
|
||||
value: 3,
|
||||
img: '/static/images/lightImg/rb.png',
|
||||
imgA: '/static/images/lightImg/rbActive.png',
|
||||
},
|
||||
{
|
||||
text: '黄色长亮',
|
||||
value: 4,
|
||||
img: '/static/images/lightImg/liting.png',
|
||||
imgA: '/static/images/lightImg/litingActive.png',
|
||||
},
|
||||
{
|
||||
text: '黄色爆闪',
|
||||
value: 5,
|
||||
img: '/static/images/lightImg/light.png',
|
||||
imgA: '/static/images/lightImg/lightActive.png',
|
||||
}
|
||||
]
|
||||
},
|
||||
permissions: []
|
||||
|
||||
}
|
||||
@ -250,9 +372,7 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
if (these.device.deviceImei) {
|
||||
these.initMQ();
|
||||
}
|
||||
|
||||
let f = ble.data.LinkedList.find((v) => {
|
||||
if (v.macAddress == device.deviceMac) {
|
||||
console.log("找到设备了", v);
|
||||
@ -263,7 +383,7 @@
|
||||
});
|
||||
if (!f) {
|
||||
these.showBleUnConnect();
|
||||
these.getDetail();
|
||||
|
||||
return;
|
||||
}
|
||||
let form = f.formData;
|
||||
@ -275,12 +395,8 @@
|
||||
these.formData[key] = form[key];
|
||||
}
|
||||
}
|
||||
if (these.formData['imei'] && !these.device.deviceImei) {
|
||||
these.initMQ();
|
||||
} else if (these.device.deviceImei) {
|
||||
these.formData['imei'] = these.device.deviceImei;
|
||||
}
|
||||
these.getDetail();
|
||||
|
||||
|
||||
|
||||
these.formData.bleStatu = 'connecting';
|
||||
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
|
||||
@ -294,6 +410,171 @@
|
||||
|
||||
},
|
||||
methods: {
|
||||
btnSetting(val, type) {
|
||||
if (this.Status[type] == val) {
|
||||
return;
|
||||
}
|
||||
this.Status[type] = val;
|
||||
},
|
||||
MsSetting(type) {
|
||||
let f = this.getDevice();
|
||||
|
||||
if (!f) {
|
||||
this.showBleUnConnect();
|
||||
return;
|
||||
}
|
||||
|
||||
let json = {
|
||||
ins_Ms: type
|
||||
};
|
||||
ble.sendString(f.deviceId, json).then(res => {
|
||||
MsgSuccess("发送设置指令成功,等待设备响应", '', this, null, false);
|
||||
}).catch(ex => {
|
||||
MsgError(ex.msg, '', this, null, false);
|
||||
});
|
||||
},
|
||||
ShowChannelEdit() {
|
||||
if (!this.permissions.includes('55') && this.Status.apiType !== 'listA') {
|
||||
MsgError("无操作权限", '', this, null, false);
|
||||
return;
|
||||
}
|
||||
|
||||
let f = this.getDevice();
|
||||
|
||||
if (!f) {
|
||||
this.showBleUnConnect();
|
||||
return;
|
||||
}
|
||||
|
||||
MsgPrompt(this, 'msgEditChannel', () => {
|
||||
let json = {
|
||||
ins_channel: this.formData.tmp_Channel
|
||||
};
|
||||
ble.sendString(f.deviceId, json).then(res => {
|
||||
MsgSuccess("发送设置指令成功,等待设备响应", '', this, null, false);
|
||||
}).catch(ex => {
|
||||
MsgError(ex.msg, '', this, null, false);
|
||||
});
|
||||
}, true, true);
|
||||
|
||||
},
|
||||
lightsetting(item, index, type) {
|
||||
debugger;
|
||||
if (!this.permissions.includes('1') && this.Status.apiType !== 'listA') {
|
||||
MsgError("无操作权限", '', this, null, false);
|
||||
return;
|
||||
}
|
||||
let f = this.getDevice();
|
||||
if (!f) {
|
||||
this.showBleUnConnect();
|
||||
return;
|
||||
}
|
||||
|
||||
let key = type == 'warn' ? 'warnSwitch' : 'fanSwitch'
|
||||
let json = {};
|
||||
switch (this.Status[key]) {
|
||||
case -1: //左
|
||||
if (type == 'warn') {
|
||||
if (this.formData.sta_leftLight == item.value) {
|
||||
json.ins_leftLight = 0;
|
||||
} else {
|
||||
json.ins_leftLight = item.value;
|
||||
}
|
||||
} else {
|
||||
if (this.formData.sta_leftFan == item.value) {
|
||||
json.ins_leftFan = 0;
|
||||
} else {
|
||||
json.ins_leftFan = item.value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
|
||||
case 0: //总开关
|
||||
if (type == 'warn') {
|
||||
if (this.formData.sta_leftLight == item.value && this.formData.sta_rightLight == item.value) {
|
||||
json.ins_leftLight = 0;
|
||||
json.ins_rightLight = 0;
|
||||
} else {
|
||||
json.ins_leftLight = item.value;
|
||||
json.ins_rightLight = item.value;
|
||||
}
|
||||
} else {
|
||||
if (this.formData.sta_leftFan == item.value && this.formData.sta_rightFan == item.value) {
|
||||
json.ins_frontFan = 0;
|
||||
|
||||
} else {
|
||||
json.ins_frontFan = item.value;
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 1: //右
|
||||
if (type == 'warn') {
|
||||
if (this.formData.sta_rightLight == item.value) {
|
||||
json.ins_rightLight = 0;
|
||||
} else {
|
||||
json.ins_rightLight = item.value;
|
||||
}
|
||||
} else {
|
||||
if (this.formData.sta_rightFan == item.value) {
|
||||
json.ins_rightFan = 0;
|
||||
} else {
|
||||
json.ins_rightFan = item.value;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
ble.sendString(f.deviceId, json).then(res => {
|
||||
let keys = Object.keys(json);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
let val = json[keys[i]];
|
||||
let key = keys[i].replace('ins_', 'sta_');
|
||||
this.formData[key] = val;
|
||||
}
|
||||
}).catch(ex => {
|
||||
MsgError(ex.msg, '', this, null, false);
|
||||
});
|
||||
|
||||
},
|
||||
getSwitchActive(item, index, type) {
|
||||
|
||||
let flag = false;
|
||||
let key = type == 'warn' ? 'warnSwitch' : 'fanSwitch'
|
||||
|
||||
switch (this.Status[key]) {
|
||||
case -1: //左
|
||||
|
||||
if (key == 'warnSwitch') {
|
||||
flag = this.formData.sta_leftLight == item.value;
|
||||
} else {
|
||||
flag = this.formData.sta_leftFan == item.value;
|
||||
}
|
||||
break;
|
||||
case 0: //总开关
|
||||
if (key == 'warnSwitch') {
|
||||
flag = this.formData.sta_leftLight == item.value && this.formData.sta_rightLight == item.value;
|
||||
} else {
|
||||
flag = this.formData.sta_frontFan == item.value;
|
||||
}
|
||||
break;
|
||||
case 1: //右
|
||||
if (key == 'warnSwitch') {
|
||||
flag = this.formData.sta_rightLight == item.value;
|
||||
} else {
|
||||
flag = this.formData.sta_rightFan == item.value;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (flag) {
|
||||
return 'active';
|
||||
}
|
||||
return '';
|
||||
},
|
||||
|
||||
bleStatuToggle() {
|
||||
let f = this.getDevice();
|
||||
if (!f) {
|
||||
@ -325,7 +606,11 @@
|
||||
let f = ble.data.LinkedList.find((v) => {
|
||||
return v.macAddress == these.device.deviceMac;
|
||||
});
|
||||
|
||||
// #ifdef WEB
|
||||
f = {
|
||||
deviceId: '123'
|
||||
}
|
||||
// #endif
|
||||
return f;
|
||||
},
|
||||
showBleUnConnect() {
|
||||
@ -352,32 +637,7 @@
|
||||
})
|
||||
|
||||
},
|
||||
initMQ() {
|
||||
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
if (mq) {
|
||||
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
console.log("正在初始化MQtt")
|
||||
mq = new MqttClient();
|
||||
mq.connect(() => {
|
||||
console.log("连接成功,开始订阅消息")
|
||||
// 订阅来自设备的状态更新
|
||||
const statusTopic =
|
||||
`A/${this.formData.imei?this.formData.imei:this.device.deviceImei}`;
|
||||
mq.subscribe(statusTopic, (payload, receive) => {
|
||||
console.log("mq收到消息", payload)
|
||||
let json = JSON.parse(payload);
|
||||
this.receivData(json);
|
||||
});
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
},
|
||||
bleValueNotify: function(receive, device, path, recArr) { //订阅消息
|
||||
if (receive.deviceId !== this.formData.deviceId) {
|
||||
return;
|
||||
@ -413,13 +673,7 @@
|
||||
}
|
||||
if (res.deviceId == these.formData.deviceId) {
|
||||
this.formData.bleStatu = true;
|
||||
setTimeout(() => {
|
||||
hideLoading(these, 1000);
|
||||
});
|
||||
uni.showToast({
|
||||
icon: 'success',
|
||||
title: '蓝牙连接成功'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
@ -694,10 +948,16 @@
|
||||
}
|
||||
|
||||
.lampMode {
|
||||
padding: 30rpx 0rpx;
|
||||
padding: 0rpx 0rpx;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
|
||||
display: flex;
|
||||
align-content: space-around;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
justify-items: stretch;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.lampMode .mode {
|
||||
@ -713,11 +973,52 @@
|
||||
justify-content: flex-start;
|
||||
padding: 30rpx;
|
||||
box-sizing: border-box;
|
||||
border: 0.5px solid #00000000;
|
||||
height: 140rpx;
|
||||
}
|
||||
|
||||
.lampMode .mode.active {
|
||||
|
||||
border: 1px solid rgba(174, 214, 0, 1);
|
||||
border: 1rpx solid rgba(174, 214, 0, 1);
|
||||
}
|
||||
|
||||
.lampMode .mode.active .bigTxt {
|
||||
|
||||
color: rgba(174, 214, 0, 1) !important;
|
||||
}
|
||||
|
||||
.lampMode .type {
|
||||
border-radius: 75rpx !important;
|
||||
box-sizing: border-box;
|
||||
border-style: solid;
|
||||
border-width: 5rpx;
|
||||
border-color: #00000000;
|
||||
padding: 5rpx;
|
||||
}
|
||||
|
||||
.lampMode .type .txt {
|
||||
color: rgba(255, 255, 255, 0.2);
|
||||
background-color: #00000000;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 50rpx;
|
||||
font-weight: 400;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 70rpx;
|
||||
}
|
||||
|
||||
.lampMode .type.active {
|
||||
border-color: #AED600 !important;
|
||||
}
|
||||
|
||||
.lampMode .type.active .txt {
|
||||
background-color: #AED600 !important;
|
||||
color: rgba(26, 26, 26, 1) !important;
|
||||
}
|
||||
|
||||
.lampMode .mode.active:not(.type) {
|
||||
|
||||
border: 1rpx solid rgba(174, 214, 0, 1) !important;
|
||||
}
|
||||
|
||||
.lampMode .mode.active .bigTxt {
|
||||
@ -729,9 +1030,34 @@
|
||||
margin-left: 34rpx !important;
|
||||
}
|
||||
|
||||
.mode .leftImg .img {
|
||||
.mode .leftImg {
|
||||
width: 70rpx;
|
||||
height: 70rpx;
|
||||
border-radius: 4px;
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
align-content: center;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.mode .leftImg .img {
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
}
|
||||
|
||||
.mode .imageA {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.mode.active .image {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.mode.active .imageA {
|
||||
display: block !important;
|
||||
}
|
||||
|
||||
.mode .rightTxt {
|
||||
@ -1070,7 +1396,7 @@
|
||||
text-align: left;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
padding: 30rpx 0rpx 10rpx 30rpx;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.sosContent {
|
||||
@ -1246,4 +1572,153 @@
|
||||
/deep/ .uni-navbar__placeholder {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.btn-container {
|
||||
width: 100%;
|
||||
height: 60rpx;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
align-content: center;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin: 20rpx 0rpx;
|
||||
}
|
||||
|
||||
.btn-container .btn {
|
||||
width: 140rpx;
|
||||
height: 100%;
|
||||
border-radius: 8px;
|
||||
background-color: #2A2A2A;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
|
||||
font-family: "PingFang SC";
|
||||
font-style: Medium;
|
||||
font-size: 24rpx;
|
||||
font-weight: 400;
|
||||
line-height: 60rpx;
|
||||
letter-spacing: 0.14rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.btn-container .btn.active {
|
||||
background-color: rgba(174, 214, 0, 1) !important;
|
||||
color: rgba(26, 26, 26, 1) !important;
|
||||
}
|
||||
|
||||
.popup-prompt {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
padding: 30rpx 15%;
|
||||
}
|
||||
|
||||
|
||||
.popup-prompt-title {
|
||||
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
float: left;
|
||||
box-sizing: border-box;
|
||||
white-space: nowrap;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
font-family: PingFang SC;
|
||||
font-size: 28rpx;
|
||||
font-weight: 400;
|
||||
line-height: 40rpx;
|
||||
letter-spacing: 0.14rpx;
|
||||
|
||||
|
||||
}
|
||||
|
||||
.popup-prompt-input {
|
||||
|
||||
width: 100%;
|
||||
height: 60rpx;
|
||||
line-height: 60rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
box-sizing: border-box;
|
||||
border-bottom: 2rpx solid rgba(255, 255, 255, 0.4);
|
||||
font-size: 28rpx;
|
||||
font-weight: 400;
|
||||
letter-spacing: 0.14px;
|
||||
}
|
||||
|
||||
.popup-prompt-input-placeHolder {
|
||||
color: rgba(255, 255, 255, 0.4);
|
||||
|
||||
font-family: PingFang SC;
|
||||
font-size: 28rpx;
|
||||
font-weight: 400;
|
||||
|
||||
letter-spacing: 0.14px;
|
||||
text-align: center;
|
||||
|
||||
}
|
||||
|
||||
|
||||
.fanMode {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
align-content: center;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-top: 25rpx;
|
||||
}
|
||||
|
||||
.fanMode .fanItem {
|
||||
width: 25%;
|
||||
height: auto;
|
||||
min-height: 180rpx;
|
||||
padding: 24rpx 30rpx 18rpx 30rpx;
|
||||
background-color: rgba(26, 26, 26, 1);
|
||||
border-radius: 16rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-wrap: nowrap;
|
||||
align-content: center;
|
||||
align-items: center;
|
||||
justify-content: space-around;
|
||||
white-space: nowrap;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
border: 1rpx solid #00000000;
|
||||
font-family: "PingFang SC";
|
||||
font-style: Regular;
|
||||
font-size: 28rpx;
|
||||
font-weight: 400;
|
||||
|
||||
letter-spacing: 0.14rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.fanMode .fanItem.active {
|
||||
color: rgba(174, 214, 0, 1) !important;
|
||||
border: 1rpx solid rgba(174, 214, 0, 1);
|
||||
}
|
||||
|
||||
.fanMode .fanItem .imageA {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.fanMode .fanItem.active .imageA {
|
||||
display: inline !important;
|
||||
}
|
||||
|
||||
.fanMode .fanItem.active .image {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.fanItem .topImg {
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
}
|
||||
|
||||
.fanItem .topImg .img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.fanItem .bottomTxt {}
|
||||
</style>
|
||||
@ -84,12 +84,24 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="warnnig" v-show="formData.sta_ShakeBit==1 && formData.sta_ShakeBit==2"
|
||||
@click="showAction('map')">
|
||||
<view class="warnnig" v-show="formData.sta_ShakeBit==1 && formData.sta_ShakeBit==2" @click="showAction('map')">
|
||||
<view>{{ShakeBit}}</view>
|
||||
</view>
|
||||
|
||||
|
||||
<view class="lamp">
|
||||
<view class="title">
|
||||
<text>灯光亮度</text>
|
||||
<text>{{formData.sta_brightness}}%</text>
|
||||
</view>
|
||||
|
||||
<view class="slider-container">
|
||||
<slider min="50" max="100" step="1" :disabled="false" :value="formData.sta_brightness"
|
||||
activeColor="#bbe600" backgroundColor="#00000000" block-size="20" block-color="#ffffffde"
|
||||
@change="sliderChange" @changing="sliderChanging" class="custom-slider" />
|
||||
|
||||
</view>
|
||||
</view>
|
||||
<view class="lampMode">
|
||||
<view class="sosContent">
|
||||
<view class="btnSos openSos center"
|
||||
@ -147,6 +159,17 @@
|
||||
|
||||
</view>
|
||||
</view>
|
||||
<view class="mode fleft " @click.stop="WarnToggle()" :class="{active:formData.warnStatu}">
|
||||
<view class="leftImg">
|
||||
<image class="img" src="/static/images/common/linkMan.png" mode="aspectFit">
|
||||
</image>
|
||||
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
<text class="bigTxt">关闭静止报警</text>
|
||||
<text class="smallTxt" v-show="formData.warnStatu">已关闭</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
|
||||
@ -182,10 +205,10 @@
|
||||
showPop,
|
||||
MsgInfo,
|
||||
MsgClear
|
||||
} from '@/utils/MsgPops.js'
|
||||
} from '@/utils/MsgPops.js';
|
||||
import request, {
|
||||
baseURL
|
||||
} from '@/utils/request.js'
|
||||
} from '@/utils/request.js';
|
||||
import lnglatConvert from '@/utils/wgs84_to_gcj02.js';
|
||||
|
||||
import Common from '@/utils/Common.js';
|
||||
@ -199,7 +222,7 @@
|
||||
var mq = null;
|
||||
var instrusionTime = null;
|
||||
var reGeoTime = null;
|
||||
|
||||
var brightnessTimer=null;
|
||||
|
||||
export default {
|
||||
data() {
|
||||
@ -233,7 +256,8 @@
|
||||
sta_ShakeBit: 0, //报警状态
|
||||
sta_system: '', //0关机 1关机充电 2开机未充电 3开机充电
|
||||
bleStatu: '',
|
||||
|
||||
warnStatu:false,
|
||||
sta_brightness:50
|
||||
},
|
||||
dic: {
|
||||
sta_Side_Light: [
|
||||
@ -297,9 +321,9 @@
|
||||
permissions: []
|
||||
}
|
||||
},
|
||||
created() {
|
||||
created() {
|
||||
this.Status.navbar.height = uni.getSystemInfoSync().statusBarHeight + 44;
|
||||
console.log("this.Status.navbar.height=",this.Status.navbar.height);
|
||||
console.log("this.Status.navbar.height=", this.Status.navbar.height);
|
||||
},
|
||||
onUnload() {
|
||||
console.log("页面卸载,释放资源");
|
||||
@ -352,13 +376,15 @@ created() {
|
||||
let key = keys[i];
|
||||
these.formData[key] = form[key];
|
||||
}
|
||||
these.device.longitude = form.sta_longitude;
|
||||
these.device.latitude = form.sta_latitude;
|
||||
}
|
||||
|
||||
these.device.longitude = form.sta_longitude;
|
||||
these.device.latitude = form.sta_latitude;
|
||||
|
||||
|
||||
these.formData.blename = f.name ? f.name : "Unname";
|
||||
these.formData.deviceName = device.deviceName;
|
||||
|
||||
|
||||
these.formData.bleStatu = false;
|
||||
these.formData.deviceId = f.deviceId;
|
||||
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
|
||||
@ -366,13 +392,13 @@ created() {
|
||||
}).catch(ex => {
|
||||
these.formData.bleStatu = 'err';
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
});;
|
||||
});
|
||||
these.formData.sta_IntrusTime = 0;
|
||||
these.formData.sta_sosadd = "";
|
||||
these.setBleFormData();
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
@ -415,7 +441,7 @@ created() {
|
||||
let dic = {
|
||||
"1": "设备SOS求救中",
|
||||
"2": "设备静止报警中",
|
||||
"6":"设备遇水报警中"
|
||||
"6": "设备遇水报警中"
|
||||
};
|
||||
let keys = Object.keys(dic);
|
||||
let f = keys.find(key => {
|
||||
@ -432,6 +458,61 @@ created() {
|
||||
|
||||
},
|
||||
methods: {
|
||||
sliderChanging(e) {
|
||||
this.formData.sta_brightness = e.detail.value;
|
||||
},
|
||||
sliderChange(e) {
|
||||
this.formData.sta_brightness = e.detail.value;
|
||||
|
||||
// 清除之前的定时器
|
||||
if (brightnessTimer) {
|
||||
clearTimeout(brightnessTimer);
|
||||
}
|
||||
|
||||
// 设置新的定时器,控制发送频率
|
||||
brightnessTimer = setTimeout(() => {
|
||||
|
||||
let json = {
|
||||
ins_brightness: e.detail.value
|
||||
}
|
||||
let f = this.getDevice();
|
||||
if(f){
|
||||
ble.sendString(f.deviceId, json).then(() => {
|
||||
|
||||
}).catch(() => {
|
||||
|
||||
this.mqSend(json).catch(ex=>{
|
||||
MsgError(ex.msg,'',this,null,false);
|
||||
});
|
||||
});
|
||||
}else{
|
||||
this.mqSend(json).catch(ex=>{
|
||||
MsgError(ex.msg,'',this,null,false);
|
||||
});
|
||||
}
|
||||
}, 200);
|
||||
},
|
||||
|
||||
WarnToggle(){
|
||||
let json={ins_stop:1};
|
||||
let f = this.getDevice();
|
||||
|
||||
if(f){
|
||||
ble.sendString(f.deviceId, json).then(() => {
|
||||
this.formData.warnStatu=true;
|
||||
}).catch(() => {
|
||||
// MsgError(ex.msg,'',this,null,false);
|
||||
this.mqSend(json).catch(ex=>{
|
||||
MsgError(ex.msg,'',this,null,false);
|
||||
});
|
||||
});
|
||||
}else{
|
||||
this.mqSend(json).catch(ex=>{
|
||||
MsgError(ex.msg,'',this,null,false);
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
prevPage() {
|
||||
uni.navigateBack({
|
||||
|
||||
@ -745,7 +826,7 @@ created() {
|
||||
console.log("this.formData[key] =", this.formData[key]);
|
||||
}
|
||||
},
|
||||
bleSend(json, validWarn = true,bleLink) {
|
||||
bleSend(json, validWarn = true, bleLink) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.formData.sta_ShakeBit != '' && this.formData.sta_ShakeBit != '0' && validWarn) {
|
||||
reject({
|
||||
@ -759,10 +840,10 @@ created() {
|
||||
reject({
|
||||
code: -1
|
||||
});
|
||||
if(bleLink){
|
||||
this.showBleUnConnect();
|
||||
if (bleLink) {
|
||||
this.showBleUnConnect();
|
||||
}
|
||||
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
@ -849,6 +930,10 @@ created() {
|
||||
|
||||
},
|
||||
gotoMap() {
|
||||
if (!this.formData) {
|
||||
MsgError("获取设备位置异常", '', these);
|
||||
return;
|
||||
}
|
||||
if (!this.formData.sta_longitude || !this.formData.sta_latitude) {
|
||||
MsgError("获取设备位置异常", '', these);
|
||||
return;
|
||||
@ -893,8 +978,8 @@ created() {
|
||||
let json = {
|
||||
ins_Side_Light: val
|
||||
}
|
||||
this.bleSend(json, true,false).then(() => {}).catch(ex => {
|
||||
|
||||
this.bleSend(json, true, false).then(() => {}).catch(ex => {
|
||||
|
||||
console.log("蓝牙发送失败,尝试用mq发送");
|
||||
this.mqSend(json, true).catch(err => {
|
||||
if (err.code == -1) {
|
||||
@ -922,7 +1007,20 @@ created() {
|
||||
return;
|
||||
}
|
||||
let msg = type == 1 ? "确定开启强制报警" : '确定解除强制报警';
|
||||
|
||||
|
||||
let json = {
|
||||
ins_ShakeBit: type
|
||||
};
|
||||
|
||||
let recordSOS=()=>{
|
||||
request({
|
||||
url: `/app/hby018a/device/ShakeBitSettings`,
|
||||
method: 'post',
|
||||
data: { 'deviceId': this.device.id, 'deviceImei': this.device.deviceImei, 'instructValue': json.ins_ShakeBit }
|
||||
}).then((res) => {
|
||||
console.log("记录强制报警",res);
|
||||
});
|
||||
}
|
||||
showPop({
|
||||
|
||||
message: msg,
|
||||
@ -938,19 +1036,21 @@ created() {
|
||||
MsgClear(these);
|
||||
},
|
||||
okCallback: () => {
|
||||
let json = {
|
||||
ins_ShakeBit: type
|
||||
};
|
||||
|
||||
this.bleSend(json, false,false).catch(ex => {
|
||||
|
||||
|
||||
this.bleSend(json, false, false).then(res=>{
|
||||
recordSOS();
|
||||
}).catch(ex => {
|
||||
this.mqSend(json, false).catch(err => {
|
||||
if (err.code == -1) {
|
||||
return;
|
||||
}
|
||||
MsgError(err.msg, '', these);
|
||||
})
|
||||
|
||||
recordSOS();
|
||||
}).then(()=>{
|
||||
recordSOS();
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
@ -974,17 +1074,10 @@ created() {
|
||||
these.setBleFormData();
|
||||
},
|
||||
deviceRecovry(res) {
|
||||
console.log("蓝牙连接成功", these.formData);
|
||||
console.log("蓝牙连接成功", res);
|
||||
|
||||
if (res.deviceId == these.formData.deviceId) {
|
||||
this.formData.bleStatu = true;
|
||||
setTimeout(() => {
|
||||
hideLoading(these, 1000);
|
||||
});
|
||||
uni.showToast({
|
||||
icon: 'success',
|
||||
title: '蓝牙连接成功'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
@ -1064,12 +1157,6 @@ created() {
|
||||
|
||||
let json = recei.ReceiveData(receive, device, pagePath, recArr);
|
||||
this.receivData(json);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
},
|
||||
getDevice: function() {
|
||||
|
||||
@ -1102,10 +1189,9 @@ created() {
|
||||
uni.navigateTo({
|
||||
url: "/pages/common/addBLE/addEquip",
|
||||
events: {
|
||||
// BindOver: function(data) {
|
||||
// console.log(data)
|
||||
// these.formData.bleStatu = true;
|
||||
// }
|
||||
BindOver(data) {
|
||||
these.formData.bleStatu = true;
|
||||
}
|
||||
},
|
||||
success: function(res) {
|
||||
// 通过eventChannel向被打开页面传送数据
|
||||
|
||||
@ -164,9 +164,9 @@
|
||||
}" v-on:click.stop="lightTypeSet(item,index)">
|
||||
<view class="leftImg">
|
||||
<image class="img" :class="{'displayNone':formData.sta_LightType===item.key}"
|
||||
src="/static/images/100/light.png" mode="aspectFit"></image>
|
||||
src="/static/images/lightImg/light.png" mode="aspectFit"></image>
|
||||
<image class="img" :class="{'displayNone':formData.sta_LightType!==item.key}"
|
||||
src="/static/images/100/lightActive.png" mode="aspectFit"></image>
|
||||
src="/static/images/lightImg/lightActive.png" mode="aspectFit"></image>
|
||||
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
@ -1167,13 +1167,7 @@ onFreqChanging(e){
|
||||
}
|
||||
if (res.deviceId == these.formData.deviceId) {
|
||||
this.formData.bleStatu = true;
|
||||
setTimeout(() => {
|
||||
hideLoading(these, 1000);
|
||||
});
|
||||
uni.showToast({
|
||||
icon: 'success',
|
||||
title: '蓝牙连接成功'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
@ -152,9 +152,9 @@
|
||||
}" v-on:click.stop="lightTypeSet(item, index)">
|
||||
<view class="leftImg">
|
||||
<image class="img" :class="{ 'displayNone': formData.sta_LightType === item.key }"
|
||||
src="/static/images/100/light.png" mode="aspectFit"></image>
|
||||
src="/static/images/lightImg/light.png" mode="aspectFit"></image>
|
||||
<image class="img" :class="{ 'displayNone': formData.sta_LightType !== item.key }"
|
||||
src="/static/images/100/lightActive.png" mode="aspectFit"></image>
|
||||
src="/static/images/lightImg/lightActive.png" mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
<text class="bigTxt">{{ item.name }}</text>
|
||||
|
||||
@ -377,13 +377,7 @@
|
||||
}
|
||||
if (res.deviceId == these.formData.deviceId) {
|
||||
this.formData.bleStatu = true;
|
||||
setTimeout(() => {
|
||||
hideLoading(these, 1000);
|
||||
});
|
||||
uni.showToast({
|
||||
icon: 'success',
|
||||
title: '蓝牙连接成功'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
@ -331,8 +331,8 @@
|
||||
key: 'led_flash',
|
||||
name: '红色爆闪',
|
||||
show: true,
|
||||
img: '/static/images/100/light.png',
|
||||
activeImg: '/static/images/100/lightActive.png',
|
||||
img: '/static/images/lightImg/light.png',
|
||||
activeImg: '/static/images/lightImg/lightActive.png',
|
||||
group: 'sta_LedType',
|
||||
permission: '1'
|
||||
},
|
||||
@ -349,8 +349,8 @@
|
||||
key: 'led_steady',
|
||||
name: '红色常亮',
|
||||
show: true,
|
||||
img: '/static/images/102/liting.png',
|
||||
activeImg: '/static/images/102/litingActive.png',
|
||||
img: '/static/images/lightImg/liting.png',
|
||||
activeImg: '/static/images/lightImg/litingActive.png',
|
||||
group: 'sta_LedType',
|
||||
permission: '1'
|
||||
},
|
||||
@ -1043,13 +1043,7 @@ created() {
|
||||
}
|
||||
if (res.deviceId == these.formData.deviceId) {
|
||||
this.formData.bleStatu = true;
|
||||
setTimeout(() => {
|
||||
hideLoading(these, 1000);
|
||||
});
|
||||
uni.showToast({
|
||||
icon: 'success',
|
||||
title: '蓝牙连接成功'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
@ -93,6 +93,13 @@
|
||||
|
||||
|
||||
<view class="lampMode">
|
||||
<view class="mode type " :class="{'active':formData.sta_Ms=='M'}" @click.stop="modeToggle('M')">
|
||||
<view class="txt center">M</view>
|
||||
</view>
|
||||
<view class="mode type" :class="{'active':formData.sta_Ms=='S'}" @click.stop="modeToggle('S')">
|
||||
<view class="txt center">S</view>
|
||||
</view>
|
||||
|
||||
<view class="mode " :class="{active:formData.sta_SOSGrade==2}" v-on:click.stop="sosSetting(2)">
|
||||
<view class="leftImg">
|
||||
<image v-show="formData.sta_SOSGrade!=2" class="img" src="/static/images/670/rb.png"
|
||||
@ -170,23 +177,23 @@
|
||||
|
||||
<view class="item">
|
||||
<text class="lbl">单位:</text>
|
||||
<input class="value" v-model.trim="formData.company" placeholder="请输入单位" maxlength="6"
|
||||
<input class="value" v-model.trim="formData.company" placeholder="请输入单位" maxlength="8"
|
||||
placeholder-class="usrplace" />
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="lbl">姓名:</text>
|
||||
<input class="value" v-model.trim="formData.usrname" placeholder="请输入职位" maxlength="6"
|
||||
<input class="value" v-model.trim="formData.name" placeholder="请输入职位" maxlength="8"
|
||||
placeholder-class="usrplace" />
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="lbl">部门:</text>
|
||||
<input class="value" v-model.trim="formData.job" placeholder="请输入姓名" maxlength="6"
|
||||
<input class="value" v-model.trim="formData.job" placeholder="请输入姓名" maxlength="8"
|
||||
placeholder-class="usrplace" />
|
||||
</view>
|
||||
|
||||
<view class="item">
|
||||
<text class="lbl">ID:</text>
|
||||
<input class="value" v-model.trim="formData.usrid" placeholder="ID" maxlength="6"
|
||||
<input class="value" v-model.trim="formData.id" placeholder="ID" maxlength="16"
|
||||
placeholder-class="usrplace" />
|
||||
</view>
|
||||
</view>
|
||||
@ -369,9 +376,9 @@
|
||||
address: "", //地址
|
||||
|
||||
company: "", //单位
|
||||
usrname: "", //姓名
|
||||
name: "", //姓名
|
||||
job: "", //职位
|
||||
usrid: "", //id
|
||||
id: "", //id
|
||||
sendMsg: '',
|
||||
|
||||
deviceId: "",
|
||||
@ -388,7 +395,8 @@
|
||||
sta_ShakeBit: 0, //报警状态
|
||||
sta_InfraRed: 0,
|
||||
textLines: ['湖北星汉文化', '有限', '公司', '12345678'],
|
||||
sta_BreakNews:''
|
||||
sta_BreakNews: '',
|
||||
sta_Ms: ''
|
||||
},
|
||||
device: {
|
||||
id: "",
|
||||
@ -541,7 +549,7 @@
|
||||
these.device = device;
|
||||
|
||||
|
||||
these.formData.usrid = device.deviceImei;
|
||||
these.formData.id = device.deviceImei;
|
||||
if (data.apiType !== 'listA') {
|
||||
Common.getdeviceShareId(data.data.id).then(res => {
|
||||
if (res.code == 200) {
|
||||
@ -600,16 +608,16 @@
|
||||
|
||||
},
|
||||
methods: {
|
||||
initWatch(){
|
||||
this.$watch('formData.sta_BreakNews',(newVal,oldVal)=>{
|
||||
if(newVal && newVal=='I get it'){
|
||||
initWatch() {
|
||||
this.$watch('formData.sta_BreakNews', (newVal, oldVal) => {
|
||||
if (newVal && newVal == 'I get it') {
|
||||
MsgSuccess("用户已确认收到紧急通知", "确定", these);
|
||||
setTimeout(() => {
|
||||
these.formData.sta_BreakNews = "";
|
||||
}, 10);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
this.$watch("formData.sta_PowerPercent", (newVal, oldVal) => {
|
||||
console.log("电量发生变化");
|
||||
if (newVal <= 20 && (this.formData.sta_system === 2 || this.formData.sta_system === 0)) {
|
||||
@ -1251,12 +1259,15 @@
|
||||
this.Status.PictureMenu.show = false;
|
||||
},
|
||||
sendUsr() {
|
||||
debugger;
|
||||
console.log("1111111");
|
||||
if (!this.permissions.includes('4') && this.Status.apiType !== 'listA') {
|
||||
|
||||
|
||||
MsgError('无操作权限', '', these);
|
||||
return;
|
||||
}
|
||||
console.log("1111111");
|
||||
let f = this.getDevice();
|
||||
if (!f) {
|
||||
these.showBleUnConnect()
|
||||
@ -1266,7 +1277,10 @@
|
||||
if (!batchTool) {
|
||||
batchTool = new SendBatchData(these, f, ble);
|
||||
}
|
||||
batchTool.SendUsr(4);
|
||||
console.log("batch",batchTool);
|
||||
// batchTool.SendUsr(4);
|
||||
let txts=[these.formData.company, these.formData.name, these.formData.job,this.formData.id]
|
||||
batchTool.sendUsrByGBK(txts);
|
||||
return;
|
||||
|
||||
|
||||
@ -1333,7 +1347,7 @@
|
||||
let json = {
|
||||
ins_ShakeBit: 0
|
||||
};
|
||||
|
||||
|
||||
if (ble && f) {
|
||||
ble.sendString(f.deviceId, json).then(res => {
|
||||
this.formData.sta_ShakeBit = 0;
|
||||
@ -1352,6 +1366,41 @@
|
||||
|
||||
MsgError('确定解除报警?', '', these, bleSend);
|
||||
},
|
||||
modeToggle(val) {
|
||||
console.log("old=", this.formData.sta_Ms);
|
||||
let f = these.getDevice();
|
||||
let newVal = null;
|
||||
if (val == these.formData.sta_Ms) {
|
||||
newVal = "0";
|
||||
} else {
|
||||
newVal = val;
|
||||
}
|
||||
console.log("old1=", this.formData.sta_Ms);
|
||||
|
||||
let bleSend = () => {
|
||||
console.log("old2=", this.formData.sta_Ms);
|
||||
let json = {
|
||||
ins_Ms: newVal
|
||||
};
|
||||
|
||||
|
||||
|
||||
console.log("new=", this.formData.sta_Ms);
|
||||
these.setBleFormData();
|
||||
console.log("these.formData.sta_Ms=" + these.formData.sta_Ms);
|
||||
|
||||
if (ble && f) {
|
||||
ble.sendString(f.deviceId, json).then(res=>{
|
||||
these.formData.sta_Ms = newVal;
|
||||
}).catch(ex => {
|
||||
these.mqSend(json);
|
||||
});
|
||||
} else {
|
||||
these.mqSend(json);
|
||||
}
|
||||
};
|
||||
bleSend();
|
||||
},
|
||||
sosSetting(val) {
|
||||
console.log("old=", this.formData.sta_SOSGrade);
|
||||
let f = these.getDevice();
|
||||
@ -1374,9 +1423,9 @@
|
||||
let json = {
|
||||
ins_SOSGrade: newVal
|
||||
};
|
||||
console.log("json="+JSON.stringify(json));
|
||||
console.log("json=" + JSON.stringify(json));
|
||||
these.formData.sta_SOSGrade = newVal;
|
||||
|
||||
|
||||
console.log("new=", this.formData.sta_SOSGrade);
|
||||
these.setBleFormData();
|
||||
console.log("these.formData.sta_SOSGrade=" + these.formData.sta_SOSGrade);
|
||||
@ -1407,9 +1456,9 @@
|
||||
let personnelInfo = res.personnelInfo;
|
||||
if (personnelInfo) {
|
||||
that.formData.company = personnelInfo.unitName;
|
||||
that.formData.usrname = personnelInfo.name;
|
||||
that.formData.name = personnelInfo.name;
|
||||
that.formData.job = personnelInfo.position;
|
||||
that.formData.usrid = personnelInfo.code
|
||||
that.formData.id = personnelInfo.code
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1418,7 +1467,10 @@
|
||||
});
|
||||
},
|
||||
getDevice: function() {
|
||||
let f = ble.data.LinkedList.find((v) => {
|
||||
|
||||
let f ={deviceId:'123'};
|
||||
// #ifdef APP
|
||||
f= ble.data.LinkedList.find((v) => {
|
||||
if (v.macAddress == these.device.deviceMac) {
|
||||
if (!this.formData.deviceId) {
|
||||
this.formData.deviceId = v.deviceId
|
||||
@ -1426,6 +1478,8 @@
|
||||
return true;
|
||||
}
|
||||
});
|
||||
// #endif
|
||||
|
||||
|
||||
return f;
|
||||
},
|
||||
@ -1463,41 +1517,34 @@
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
let f = this.getDevice();
|
||||
|
||||
this.formData.sendMsg.padStart(16, ' ');
|
||||
|
||||
this.formData.textLines = [this.formData.sendMsg.slice(0, 8), this.formData.sendMsg.slice(8, 16)];
|
||||
|
||||
|
||||
|
||||
if (!batchTool) {
|
||||
batchTool = new SendBatchData(these, f, ble);
|
||||
}
|
||||
|
||||
batchTool.SendMsgByGBK(this.formData.textLines,mq);
|
||||
return;
|
||||
|
||||
|
||||
showLoading(this, {
|
||||
text: "发送中"
|
||||
});
|
||||
//握手
|
||||
let holdHand = (hexs, time) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
|
||||
setTimeout(() => {
|
||||
resolve(true)
|
||||
}, time);
|
||||
});
|
||||
}
|
||||
//画图
|
||||
let drawText = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.$refs.textToHex.drawAndGetPixels().then(allPixels => {
|
||||
if (!allPixels) {
|
||||
reject("文本初始化失败");
|
||||
return;
|
||||
}
|
||||
console.log("画图成功");
|
||||
resolve(allPixels);
|
||||
}).catch(compEx => {
|
||||
reject(compEx);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
//发送3个分包的数据
|
||||
let task = (allPixels) => {
|
||||
try {
|
||||
@ -1584,7 +1631,7 @@
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
Promise.allSettled([holdHand('word transmit start', 2200), drawText()]).then(
|
||||
Promise.allSettled([holdHand('word transmit start', 2200)]).then(
|
||||
results => {
|
||||
console.log("PromiseAll=", results);
|
||||
if (results[0].status == 'rejected') {
|
||||
@ -1594,10 +1641,7 @@
|
||||
}, 500);
|
||||
return;
|
||||
}
|
||||
if (results[1].status == 'rejected') {
|
||||
console.log("任务1失败了", results[1].reason);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("开始发送数据包");
|
||||
task(results[1].value);
|
||||
})
|
||||
@ -1607,10 +1651,11 @@
|
||||
mqSend(json) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (mq) {
|
||||
|
||||
mq.publish("B/" + this.device.deviceImei, typeof(json)=='string'?json:JSON.stringify(json)).then(res => {
|
||||
json=typeof(json)=='string'?JSON.parse(json):json
|
||||
let keys = Object.keys(json);
|
||||
|
||||
mq.publish("B/" + this.device.deviceImei, typeof(json) == 'string' ? json : JSON.stringify(
|
||||
json)).then(res => {
|
||||
json = typeof(json) == 'string' ? JSON.parse(json) : json
|
||||
let keys = Object.keys(json);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
let key = keys[i];
|
||||
let state = key.replace('ins_', 'sta_');
|
||||
@ -1711,13 +1756,7 @@
|
||||
}
|
||||
if (res.deviceId == these.formData.deviceId) {
|
||||
this.formData.bleStatu = true;
|
||||
setTimeout(() => {
|
||||
hideLoading(these, 1000);
|
||||
});
|
||||
uni.showToast({
|
||||
icon: 'success',
|
||||
title: '蓝牙连接成功'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
@ -2018,9 +2057,39 @@
|
||||
padding: 30rpx;
|
||||
box-sizing: border-box;
|
||||
border: 1rpx solid #00000000;
|
||||
height: 140rpx;
|
||||
}
|
||||
|
||||
.lampMode .mode.active {
|
||||
.lampMode .type {
|
||||
border-radius: 75rpx !important;
|
||||
box-sizing: border-box;
|
||||
border-style: solid;
|
||||
border-width: 5rpx;
|
||||
border-color: #00000000;
|
||||
padding: 5rpx;
|
||||
}
|
||||
|
||||
.lampMode .type .txt {
|
||||
color: rgba(255, 255, 255, 0.2);
|
||||
background-color: #00000000;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 50rpx;
|
||||
font-weight: 400;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 70rpx;
|
||||
}
|
||||
|
||||
.lampMode .type.active {
|
||||
border-color: #AED600 !important;
|
||||
}
|
||||
|
||||
.lampMode .type.active .txt {
|
||||
background-color: #AED600 !important;
|
||||
color: rgba(26, 26, 26, 1) !important;
|
||||
}
|
||||
|
||||
.lampMode .mode.active:not(.type) {
|
||||
|
||||
border: 1rpx solid rgba(174, 214, 0, 1) !important;
|
||||
}
|
||||
|
||||
@ -1122,13 +1122,7 @@
|
||||
}
|
||||
if (res.deviceId == these.formData.deviceId) {
|
||||
this.formData.bleStatu = true;
|
||||
setTimeout(() => {
|
||||
hideLoading(these, 1000);
|
||||
});
|
||||
uni.showToast({
|
||||
icon: 'success',
|
||||
title: '蓝牙连接成功'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
@ -572,13 +572,7 @@ import request, { baseURL } from '@/utils/request.js';
|
||||
}
|
||||
if (res.deviceId == these.formData.deviceId) {
|
||||
this.formData.bleStatu = true;
|
||||
setTimeout(() => {
|
||||
hideLoading(these, 1000);
|
||||
});
|
||||
uni.showToast({
|
||||
icon: 'success',
|
||||
title: '蓝牙连接成功'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
@ -502,7 +502,7 @@
|
||||
these = this;
|
||||
this.initActionData();
|
||||
|
||||
this.initWatch();
|
||||
|
||||
|
||||
|
||||
|
||||
@ -545,6 +545,7 @@
|
||||
if (!f) {
|
||||
these.showBleUnConnect();
|
||||
these.getDetail();
|
||||
these.initWatch();
|
||||
return;
|
||||
}
|
||||
let form = f.formData;
|
||||
@ -564,6 +565,7 @@
|
||||
});
|
||||
|
||||
these.getDetail();
|
||||
these.initWatch();
|
||||
});
|
||||
|
||||
|
||||
@ -1280,8 +1282,8 @@
|
||||
},
|
||||
getDevice: function() {
|
||||
|
||||
// console.log("LinkedList=", ble.data.LinkedList);
|
||||
// console.log("this.device=", this.device);
|
||||
console.log("LinkedList=", ble.data.LinkedList);
|
||||
console.log("this.device=", this.device);
|
||||
let f = ble.data.LinkedList.find((v) => {
|
||||
if (v.macAddress == these.device.deviceMac) {
|
||||
if (!this.formData.deviceId) {
|
||||
@ -1428,13 +1430,7 @@
|
||||
this.formData.bleStatu = true;
|
||||
|
||||
batchTool = new SendBatchData(this, res, ble);
|
||||
setTimeout(() => {
|
||||
hideLoading(these, 1000);
|
||||
});
|
||||
uni.showToast({
|
||||
icon: 'success',
|
||||
title: '蓝牙连接成功'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
@ -680,13 +680,7 @@
|
||||
}
|
||||
if (res.deviceId == these.formData.deviceId) {
|
||||
this.formData.bleStatu = true;
|
||||
setTimeout(() => {
|
||||
hideLoading(these, 1000);
|
||||
});
|
||||
uni.showToast({
|
||||
icon: 'success',
|
||||
title: '蓝牙连接成功'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
@ -37,7 +37,7 @@
|
||||
<view class="row">
|
||||
<image class="img" src="/static/images/common/time.png" mode="aspectFit"></image>
|
||||
<view class="txt">
|
||||
<view class="bigTxt">{{formData.xuhang}}</view>
|
||||
<view class="bigTxt" v-show="getMode('main')!='关闭'||getMode('fu')!='关闭'">{{formData.xuhang}}</view>
|
||||
<view class="smallTxt">续航时间</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -112,7 +112,7 @@
|
||||
<image class="img" src="/static/images/common/video.png" mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
<text class="bigTxt">开机视频</text>
|
||||
<text class="bigTxt">开机动画</text>
|
||||
<text class="smallTxt">上传</text>
|
||||
</view>
|
||||
</view>
|
||||
@ -591,13 +591,7 @@
|
||||
}
|
||||
if (res.deviceId == these.formData.deviceId) {
|
||||
this.formData.bleStatu = true;
|
||||
setTimeout(() => {
|
||||
hideLoading(these, 1000);
|
||||
});
|
||||
uni.showToast({
|
||||
icon: 'success',
|
||||
title: '蓝牙连接成功'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
@ -558,13 +558,7 @@
|
||||
}
|
||||
if (res.deviceId == these.formData.deviceId) {
|
||||
this.formData.bleStatu = true;
|
||||
setTimeout(() => {
|
||||
hideLoading(these, 1000);
|
||||
});
|
||||
uni.showToast({
|
||||
icon: 'success',
|
||||
title: '蓝牙连接成功'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
@ -608,13 +608,7 @@ import request, { baseURL } from '@/utils/request.js';
|
||||
}
|
||||
if (res.deviceId == these.formData.deviceId) {
|
||||
this.formData.bleStatu = true;
|
||||
setTimeout(() => {
|
||||
hideLoading(these, 1000);
|
||||
});
|
||||
uni.showToast({
|
||||
icon: 'success',
|
||||
title: '蓝牙连接成功'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
@ -477,13 +477,7 @@ created() {
|
||||
}
|
||||
if (res.deviceId == these.formData.deviceId) {
|
||||
this.formData.bleStatu = true;
|
||||
setTimeout(() => {
|
||||
hideLoading(these, 1000);
|
||||
});
|
||||
uni.showToast({
|
||||
icon: 'success',
|
||||
title: '蓝牙连接成功'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
@ -1373,7 +1367,7 @@ created() {
|
||||
|
||||
sendUsr: function(ReSendNo) {
|
||||
|
||||
if (!this.permissions.includes('4') && this.Status.apiType !== 'listA') {
|
||||
if (!this.permissions.includes('4') && this.Status.apiType !== 'listA') {
|
||||
|
||||
showPop({
|
||||
message: '无操作权限',
|
||||
|
||||
@ -627,13 +627,7 @@
|
||||
}
|
||||
if (res.deviceId == these.formData.deviceId) {
|
||||
this.formData.bleStatu = true;
|
||||
setTimeout(() => {
|
||||
hideLoading(these, 1000);
|
||||
});
|
||||
uni.showToast({
|
||||
icon: 'success',
|
||||
title: '蓝牙连接成功'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
@ -490,13 +490,7 @@
|
||||
if (res.deviceId == these.formData.deviceId) {
|
||||
this.formData.bleStatu = true;
|
||||
// 重新连接后状态以设备上报为准
|
||||
setTimeout(() => {
|
||||
hideLoading(these, 1000);
|
||||
});
|
||||
uni.showToast({
|
||||
icon: 'success',
|
||||
title: '蓝牙连接成功'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
75
pages/common/Msgs/deviceMsg.vue
Normal file
@ -0,0 +1,75 @@
|
||||
<template>
|
||||
<view class="maincontent contentBg">
|
||||
<view>通知标题:{{payload.title}}</view>
|
||||
<view>设备信息:{{device.deviceName}}</view>
|
||||
<view>Mac地址:{{device.deviceMac}}</view>
|
||||
<view>设备IMEI:{{device.deviceImei}}</view>
|
||||
<view>通知详情:{{payload.content}}</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {deviceInfo} from '@/api/common/index.js';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
payload: {
|
||||
device_mac: '',
|
||||
device_imei: '',
|
||||
content: '',
|
||||
title: ''
|
||||
},
|
||||
device: {
|
||||
"id": "",
|
||||
"deviceName": "",
|
||||
"deviceImei": "",
|
||||
"deviceMac": "",
|
||||
"communicationMode": null,
|
||||
"devicePic": "",
|
||||
"typeName": "",
|
||||
"bluetoothName": "",
|
||||
"deviceStatus": null,
|
||||
"bindingTime": "",
|
||||
"onlineStatus": null,
|
||||
"battery": "",
|
||||
"latitude": "",
|
||||
"longitude": "",
|
||||
"alarmStatus": null,
|
||||
"detailPageUrl": ""
|
||||
}
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
var eventChannel = this.getOpenerEventChannel();
|
||||
|
||||
eventChannel.on('pushMsg', (res) => {
|
||||
this.payload.content = res.data.content;
|
||||
this.payload.title = res.data.payload.title;
|
||||
this.payload.device_mac = res.data.payload.device_mac;
|
||||
this.payload.device_imei = res.data.payload.device_imei;
|
||||
|
||||
this.getDevice();
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
getDevice() {
|
||||
deviceInfo({
|
||||
pageNum: 1,
|
||||
pageSize: 1,
|
||||
deviceMac: this.payload.device_mac
|
||||
}).then(res => {
|
||||
if (res.code == 200) {
|
||||
if (res.rows && res.rows.length) {
|
||||
let device=res.rows[0];
|
||||
this.device=device;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
@ -2,7 +2,7 @@
|
||||
<view class="content">
|
||||
<view class="deviceDetail">
|
||||
<view class="imgContent">
|
||||
<image src="/static/images/BLEAdd/addBleDevice.png" class="titleIco" mode="aspectFit">
|
||||
<image src="/static/images/common/svg.png" class="titleIco" mode="aspectFit">
|
||||
</image>
|
||||
</view>
|
||||
<view class="deviceName">
|
||||
@ -46,7 +46,7 @@
|
||||
var these = null;
|
||||
var eventChannel = null;
|
||||
var ble = null;
|
||||
var inteval=null;
|
||||
var inteval = null;
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@ -54,8 +54,8 @@
|
||||
bound: null,
|
||||
timeInteval: null,
|
||||
isSearch: false,
|
||||
pageHide:false,
|
||||
isBind:false
|
||||
pageHide: false,
|
||||
isBind: false
|
||||
},
|
||||
device: {
|
||||
"deviceId": "",
|
||||
@ -72,9 +72,9 @@
|
||||
"imei": ""
|
||||
},
|
||||
serverDevice: null,
|
||||
groupid:null,
|
||||
typeList:[],
|
||||
uploadStatu:null
|
||||
groupid: null,
|
||||
typeList: [],
|
||||
uploadStatu: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -110,54 +110,54 @@
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
return "找到有效设备"
|
||||
|
||||
|
||||
|
||||
return "找到有效设备"
|
||||
|
||||
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
this.Statu.pageHide=false;
|
||||
this.Statu.pageHide = false;
|
||||
},
|
||||
onHide() {
|
||||
this.Statu.pageHide=true;
|
||||
this.Statu.pageHide = true;
|
||||
},
|
||||
onUnload() {
|
||||
console.log("返回取消订阅");
|
||||
clearInterval(inteval);
|
||||
ble.removeAllCallback(pagePath);
|
||||
clearTimeout(this.Statu.timeInteval);
|
||||
this.uploadStatu=null;
|
||||
if(!this.Statu.isBind && these.device.deviceId){
|
||||
ble.disconnectDevice(these.device.deviceId).catch(ex=>{
|
||||
this.uploadStatu = null;
|
||||
if (!this.Statu.isBind && these.device.deviceId) {
|
||||
ble.disconnectDevice(these.device.deviceId).catch(ex => {
|
||||
console.error("无法断开蓝牙连接");
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
onLoad(option) {
|
||||
these = this;
|
||||
this.groupid=new Date().getTime()+"";
|
||||
|
||||
this.groupid = new Date().getTime() + "";
|
||||
|
||||
ble = bleTool.getBleTool();
|
||||
|
||||
ble.addStateBreakCallback(res => {
|
||||
if(this.Statu.pageHide){
|
||||
if (this.Statu.pageHide) {
|
||||
return;
|
||||
}
|
||||
these.device.linkStatu = false;
|
||||
hideLoading(these);
|
||||
uni.showToast({
|
||||
icon:'fail',
|
||||
title:'蓝牙已不可用'
|
||||
icon: 'fail',
|
||||
title: '蓝牙已不可用'
|
||||
})
|
||||
},pagePath);
|
||||
|
||||
}, pagePath);
|
||||
|
||||
ble.addStateRecoveryCallback(res => {
|
||||
if(this.Statu.pageHide){
|
||||
if (this.Statu.pageHide) {
|
||||
return;
|
||||
}
|
||||
if (these.device.deviceId) {
|
||||
@ -167,9 +167,9 @@
|
||||
|
||||
these.reLinkdevice();
|
||||
}
|
||||
},pagePath);
|
||||
}, pagePath);
|
||||
ble.addDisposeCallback(res => {
|
||||
if(this.Statu.pageHide){
|
||||
if (this.Statu.pageHide) {
|
||||
return;
|
||||
}
|
||||
console.log("处理蓝牙断开连接");
|
||||
@ -181,59 +181,56 @@
|
||||
});
|
||||
these.reLinkdevice();
|
||||
}
|
||||
},pagePath);
|
||||
}, pagePath);
|
||||
|
||||
ble.addReceiveCallback((receive, f, path) => {
|
||||
if(this.Statu.pageHide){
|
||||
if (this.Statu.pageHide) {
|
||||
return;
|
||||
}
|
||||
console.log("收到设备消息,", receive);
|
||||
if (these.device.deviceId == receive.deviceId) {
|
||||
console.log("11111:", receive);
|
||||
these.device.imei = f.imei;
|
||||
let flag=false;
|
||||
if (receive.bytes && receive.bytes.length && receive.bytes[0] == 0xFC) {//6155 7305
|
||||
let flag = false;
|
||||
if (receive.bytes && receive.bytes.length && receive.bytes[0] == 0xFC) { //6155 7305
|
||||
if (f && f.macAddress) {
|
||||
flag=true;
|
||||
}
|
||||
}
|
||||
else if(receive.str.indexOf('mac address:') == 0){//650 670
|
||||
flag = true;
|
||||
}
|
||||
} else if (receive.str.indexOf('mac address:') == 0) { //650 670
|
||||
if (f && f.macAddress) {
|
||||
flag=true;
|
||||
}
|
||||
}
|
||||
else{
|
||||
try{
|
||||
console.log("str=",receive.str)
|
||||
let json=JSON.parse(receive.str);
|
||||
let key = "sta_address";
|
||||
if (key in json) {//100
|
||||
flag = true;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
console.log("str=", receive.str)
|
||||
let json = JSON.parse(receive.str);
|
||||
let key = "sta_address";
|
||||
if (key in json) { //100
|
||||
if (f && f.macAddress) {
|
||||
flag=true;
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
}catch(err){
|
||||
console.log("出现异常,",err);
|
||||
} catch (err) {
|
||||
console.log("出现异常,", err);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(flag){
|
||||
|
||||
|
||||
if (flag) {
|
||||
these.device.macAddress = f.macAddress;
|
||||
console.log("222222");
|
||||
these.Statu.isSearch = false;
|
||||
these.initDevice();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}, pagePath);
|
||||
eventChannel = this.getOpenerEventChannel();
|
||||
|
||||
if(option.mac){
|
||||
this.device.macAddress=option.mac;
|
||||
|
||||
if (option.mac) {
|
||||
this.device.macAddress = option.mac;
|
||||
these.initDevice();
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
eventChannel.on('LinkItem', function(data) {
|
||||
console.log("data=", data);
|
||||
let f = ble.data.LinkedList.find((v) => {
|
||||
@ -244,126 +241,140 @@
|
||||
keys.forEach((v, index) => {
|
||||
these.device[v] = f[v];
|
||||
})
|
||||
these.device.name = data.name;
|
||||
// console.log("LinkedList=", ble.data.LinkedList)
|
||||
// console.log("f=", f);
|
||||
// console.log("获取到设备", these.device);
|
||||
console.log("获取到设备", these.device);
|
||||
if (f.macAddress) {
|
||||
these.device.macAddress = f.macAddress;
|
||||
|
||||
|
||||
these.initDevice();
|
||||
}
|
||||
} else {
|
||||
console.log("未获取到设备");
|
||||
}
|
||||
})
|
||||
|
||||
inteval = setInterval(this.initDevice, 10000);
|
||||
|
||||
inteval = setInterval(this.initDevice, 10000);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
},
|
||||
methods: {
|
||||
getDevList() {
|
||||
return new Promise((resolve,reject)=>{
|
||||
return new Promise((resolve, reject) => {
|
||||
let arr = [
|
||||
|
||||
];
|
||||
request({
|
||||
url: '/app/xinghan/device/typeAll',
|
||||
method: 'get'
|
||||
}).then(res => {
|
||||
if (res && res.code == 200) {
|
||||
console.log("获取到类型", res.data);
|
||||
arr = res.data;
|
||||
this.typeList = arr;
|
||||
resolve(arr);
|
||||
return;
|
||||
}
|
||||
reject();
|
||||
|
||||
}).catch(ex => {
|
||||
console.error("获取设备类型列表失败",ex);
|
||||
reject();
|
||||
})
|
||||
});
|
||||
|
||||
},
|
||||
uploadItem() {
|
||||
if(this.uploadStatu!==null){
|
||||
console.error("执行过上传,不再执行");
|
||||
return;
|
||||
}
|
||||
|
||||
this.uploadStatu="start";
|
||||
console.log("开始上传设备");
|
||||
|
||||
let type=this.device.name.toLowerCase();
|
||||
if(type.indexOf("bjq6155-")>-1){//6155特别处理
|
||||
type="xh6155"
|
||||
}
|
||||
if(type.indexOf("bjq6155-")>-1){//6155特别处理
|
||||
type="xh6155"
|
||||
}
|
||||
if(type.indexOf("bjq6075-")>-1){//6075j特别处理
|
||||
bype='bjq6075j';
|
||||
}
|
||||
type=type.replace(/-/g,'');
|
||||
let upload=()=>{
|
||||
let f=this.typeList.find((v,i)=>{
|
||||
if(type.indexOf(v.typeName.replace(/-/g,'').toLowerCase())>-1){
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
if(!f){
|
||||
this.uploadStatu="type is valid";
|
||||
console.error("找不到此类型名称",type);
|
||||
console.error("tpelist=",this.typeList);
|
||||
return;
|
||||
}
|
||||
let json = {
|
||||
"deviceType": f.id,
|
||||
"deviceName": this.device.name,
|
||||
"deviceMac": this.device.macAddress,
|
||||
"bluetoothName": this.device.name,
|
||||
"deviceImei":this.device.imei?this.device.imei:'',
|
||||
"remark": "com.chxhyc.cn auto upload"
|
||||
}
|
||||
|
||||
];
|
||||
request({
|
||||
url: '/app/xinghan/device/add',
|
||||
method: 'post',
|
||||
data: json
|
||||
url: '/app/xinghan/device/typeAll',
|
||||
method: 'get'
|
||||
}).then(res => {
|
||||
if (res && res.code == 200) {
|
||||
this.uploadStatu="success";
|
||||
console.log("上传成功",res);
|
||||
} else {
|
||||
this.uploadStatu="upload error";
|
||||
console.error("上传失败,",res);
|
||||
console.log("获取到类型", res.data);
|
||||
arr = res.data;
|
||||
this.typeList = arr;
|
||||
resolve(arr);
|
||||
return;
|
||||
}
|
||||
reject();
|
||||
|
||||
}).catch(ex => {
|
||||
this.uploadStatu="upload error";
|
||||
console.error("上传失败,",ex);
|
||||
});
|
||||
}
|
||||
|
||||
let exec = () => {
|
||||
|
||||
if(this.typeList.length==0){
|
||||
this.getDevList().then(results=>{
|
||||
upload();
|
||||
}).catch(ex=>{
|
||||
this.uploadStatu="get types error";
|
||||
console.error("获取类型失败,",ex);
|
||||
});
|
||||
}else{
|
||||
upload();
|
||||
console.error("获取设备类型列表失败", ex);
|
||||
reject();
|
||||
})
|
||||
});
|
||||
|
||||
},
|
||||
uploadItem() {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.uploadStatu !== null) {
|
||||
let err = "执行过上传,不再执行";
|
||||
console.error(err);
|
||||
reject(err);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
setTimeout(exec, 10)
|
||||
|
||||
this.uploadStatu = "start";
|
||||
console.log("开始上传设备");
|
||||
|
||||
let type = this.device.name.toLowerCase();
|
||||
|
||||
if (type.indexOf("bjq6155-") > -1) { //6155特别处理
|
||||
type = "xh6155"
|
||||
}
|
||||
if (type.indexOf("bjq6075-") > -1) { //6075j特别处理
|
||||
type = 'bjq6075j';
|
||||
}
|
||||
type = type.replace(/-/g, '');
|
||||
let upload = () => {
|
||||
let f = this.typeList.find((v, i) => {
|
||||
if (type.indexOf(v.typeName.replace(/-/g, '').toLowerCase()) > -1) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
if (!f) {
|
||||
this.uploadStatu = "type is valid";
|
||||
console.error("找不到此类型名称", type);
|
||||
console.error("tpelist=", this.typeList);
|
||||
reject(this.uploadStatu);
|
||||
return;
|
||||
}
|
||||
let json = {
|
||||
"deviceType": f.id,
|
||||
"deviceName": this.device.name,
|
||||
"deviceMac": this.device.macAddress,
|
||||
"bluetoothName": this.device.name,
|
||||
"remark": "com.chxhyc.cn auto upload"
|
||||
}
|
||||
|
||||
if (this.device.imei) {
|
||||
json.deviceImei = this.device.imei;
|
||||
}
|
||||
request({
|
||||
url: '/app/xinghan/device/add',
|
||||
method: 'post',
|
||||
data: json
|
||||
}).then(res => {
|
||||
if (res && res.code == 200) {
|
||||
this.uploadStatu = "success";
|
||||
console.log("上传成功", res);
|
||||
resolve();
|
||||
} else {
|
||||
this.uploadStatu = "upload error";
|
||||
console.error("上传失败,", res);
|
||||
console.error("上传失败,", json);
|
||||
reject(this.uploadStatu);
|
||||
}
|
||||
}).catch(ex => {
|
||||
this.uploadStatu = "upload error";
|
||||
console.error("上传失败,", ex);
|
||||
reject(this.uploadStatu);
|
||||
});
|
||||
}
|
||||
|
||||
let exec = () => {
|
||||
|
||||
if (this.typeList.length == 0) {
|
||||
this.getDevList().then(results => {
|
||||
upload();
|
||||
}).catch(ex => {
|
||||
this.uploadStatu = "get types error";
|
||||
console.error("获取类型失败,", ex);
|
||||
reject(this.uploadStatu);
|
||||
});
|
||||
} else {
|
||||
upload();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
setTimeout(exec, 10)
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
reLinkdevice() {
|
||||
ble.LinkBlue(these.device.deviceId).then(res => {
|
||||
@ -388,10 +399,10 @@
|
||||
return;
|
||||
}
|
||||
//无效的设备回调
|
||||
let deviceInvalid = () => {
|
||||
these.$set(these.device, "deviceName", "");
|
||||
|
||||
|
||||
let deviceInvalid = () => {
|
||||
these.$set(these.device, "deviceName", "");
|
||||
|
||||
|
||||
}
|
||||
clearTimeout(this.Statu.timeInteval);
|
||||
|
||||
@ -427,10 +438,16 @@
|
||||
clearInterval(inteval);
|
||||
} else {
|
||||
deviceInvalid();
|
||||
this.uploadItem();
|
||||
if (this.uploadStatu==null) {
|
||||
this.uploadItem().then(res => {
|
||||
this.initDevice();
|
||||
}).catch(err => {
|
||||
console.error("上传失败", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.serverDevice =null;
|
||||
this.serverDevice = null;
|
||||
deviceInvalid();
|
||||
}
|
||||
|
||||
@ -447,15 +464,67 @@
|
||||
},
|
||||
Bind() {
|
||||
// 调用绑定设备接口
|
||||
|
||||
// let f = ble.data.LinkedList.find((v) => {
|
||||
// return v.deviceId == these.device.deviceId;
|
||||
// });
|
||||
// if (!f) {
|
||||
// these.Statu.bound = false;
|
||||
// these.Statu.boundRemark = "蓝牙连接不成功";
|
||||
// return;
|
||||
// }
|
||||
|
||||
let task = () => {
|
||||
these.Statu.bound = null;
|
||||
these.Statu.boundRemark = "";
|
||||
showLoading(these, {
|
||||
|
||||
text: "绑定中..."
|
||||
})
|
||||
let promise = request({
|
||||
url: '/app/device/bind',
|
||||
method: 'POST',
|
||||
data: {
|
||||
deviceImei: '',
|
||||
deviceMac: these.device.macAddress,
|
||||
communicationMode: 1, //0是4g,1是蓝牙,2蓝牙&4G
|
||||
}
|
||||
});
|
||||
promise.then((res) => {
|
||||
console.log("1111" + JSON.stringify(res));
|
||||
if (res.code == 200) {
|
||||
these.Statu.bound = true;
|
||||
these.Statu.boundRemark = "设备绑定成功!";
|
||||
let data = these.serverDevice;
|
||||
let keys = Object.keys(data);
|
||||
ble.data.LinkedList.find((v) => {
|
||||
if (v.deviceId == these.device.deviceId) {
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
let key = keys[i];
|
||||
if (!v.device) {
|
||||
v.device = {};
|
||||
}
|
||||
v.device[key] = data[key];
|
||||
}
|
||||
|
||||
ble.updateCache();
|
||||
}
|
||||
});
|
||||
|
||||
ble.removeReceiveCallback(pagePath);
|
||||
clearTimeout(this.Statu.timeInteval);
|
||||
this.device.macAddress = null;
|
||||
this.Statu.timeInteval = null;
|
||||
this.Statu.isBind = true;
|
||||
uni.$emit("refreshDeviceList");
|
||||
setTimeout(() => {
|
||||
uni.switchTab({
|
||||
url: "/pages/common/index/index"
|
||||
});
|
||||
}, 500);
|
||||
} else {
|
||||
these.Statu.bound = false;
|
||||
these.Statu.boundRemark = res.msg;
|
||||
}
|
||||
}).catch((ex) => {
|
||||
these.Statu.bound = false;
|
||||
these.Statu.boundRemark = '出现了未知的异常,操作失败';
|
||||
console.log("ex=", ex);
|
||||
}).finally(() => {
|
||||
hideLoading(this);
|
||||
});
|
||||
}
|
||||
if (!this.device.macAddress) {
|
||||
these.Statu.bound = false;
|
||||
these.Statu.boundRemark = "获取设备Mac地址异常";
|
||||
@ -466,64 +535,9 @@
|
||||
these.Statu.boundRemark = "设备未入库";
|
||||
return;
|
||||
}
|
||||
these.Statu.bound = null;
|
||||
these.Statu.boundRemark = "";
|
||||
showLoading(these, {
|
||||
|
||||
text: "绑定中..."
|
||||
})
|
||||
let promise = request({
|
||||
url: '/app/device/bind',
|
||||
method: 'POST',
|
||||
data: {
|
||||
deviceImei: '',
|
||||
deviceMac: these.device.macAddress,
|
||||
communicationMode: 1, //0是4g,1是蓝牙,2蓝牙&4G
|
||||
}
|
||||
});
|
||||
promise.then((res) => {
|
||||
console.log("1111" + JSON.stringify(res));
|
||||
if (res.code == 200) {
|
||||
these.Statu.bound = true;
|
||||
these.Statu.boundRemark = "设备绑定成功!";
|
||||
let data = these.serverDevice;
|
||||
let keys = Object.keys(data);
|
||||
ble.data.LinkedList.find((v) => {
|
||||
if (v.deviceId == these.device.deviceId) {
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
let key = keys[i];
|
||||
if (!v.device) {
|
||||
v.device = {};
|
||||
}
|
||||
v.device[key] = data[key];
|
||||
}
|
||||
task();
|
||||
|
||||
ble.updateCache();
|
||||
}
|
||||
});
|
||||
|
||||
ble.removeReceiveCallback(pagePath);
|
||||
clearTimeout(this.Statu.timeInteval);
|
||||
this.device.macAddress = null;
|
||||
this.Statu.timeInteval = null;
|
||||
this.Statu.isBind=true;
|
||||
uni.$emit("refreshDeviceList");
|
||||
setTimeout(() => {
|
||||
uni.switchTab({
|
||||
url: "/pages/common/index/index"
|
||||
});
|
||||
}, 500);
|
||||
} else {
|
||||
these.Statu.bound = false;
|
||||
these.Statu.boundRemark = res.msg;
|
||||
}
|
||||
}).catch((ex) => {
|
||||
these.Statu.bound = false;
|
||||
these.Statu.boundRemark = '出现了未知的异常,操作失败';
|
||||
console.log("ex=", ex);
|
||||
}).finally(() => {
|
||||
hideLoading(this);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -991,17 +991,17 @@
|
||||
});
|
||||
}
|
||||
|
||||
for (let i = 0; i < this.EquipMents.length; i++) {
|
||||
let element = this.EquipMents[i];
|
||||
if (!element.isValid) {
|
||||
task(element).catch(ex => {
|
||||
if (ex === null && element.advertisData) {
|
||||
console.log("广播自动入库");
|
||||
this.uploadItem(element);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
// for (let i = 0; i < this.EquipMents.length; i++) {
|
||||
// let element = this.EquipMents[i];
|
||||
// if (!element.isValid) {
|
||||
// task(element).catch(ex => {
|
||||
// if (ex === null && element.advertisData) {
|
||||
// console.log("广播自动入库");
|
||||
// this.uploadItem(element);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
},
|
||||
scan() {
|
||||
@ -1111,9 +1111,7 @@
|
||||
this.EquipMents = [];
|
||||
this.PairEquip = [];
|
||||
setTimeout(() => {
|
||||
ble.StartSearch().then(result => {
|
||||
|
||||
}).catch(err => {
|
||||
ble.StartSearch().then(result => {}).catch(err => {
|
||||
console.error("err=", err);
|
||||
MsgError("出现错误:" + err.msg, '', these);
|
||||
}).finally(() => {
|
||||
@ -1228,8 +1226,16 @@
|
||||
|
||||
these.PairEquip.push(item);
|
||||
}
|
||||
console.log("连接成功", these.device);
|
||||
console.log("连接成功,开始发送识别指令", these.device);
|
||||
hideLoading(these);
|
||||
|
||||
let json = {
|
||||
ins_disc: 1
|
||||
}
|
||||
ble.sendString(item.deviceId, json, item.writeServiceId, item.wirteCharactId, 30).then(res => {
|
||||
}).catch(ex => {
|
||||
console.error("蓝牙识别指令发送失败", ex);
|
||||
});
|
||||
}
|
||||
let execLink = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
@ -58,7 +58,11 @@
|
||||
<view>电量:{{item.battery || '0'}}%</view>
|
||||
</view>
|
||||
|
||||
<!-- <view @click.stop="Disc()">识别</view> -->
|
||||
<view @click.stop="Disc(item,index)" class="disc center" :class="{active:item.isDisc}">
|
||||
<image src="/static/images/common/disc.png"
|
||||
class="discImg" mode="aspectFit"></image>
|
||||
<text>识别</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -158,26 +162,28 @@
|
||||
deviceInfo,
|
||||
deviceUnbind, //删除设备
|
||||
deviceReName
|
||||
} from '@/api/common/index.js'
|
||||
} from '@/api/common/index.js'
|
||||
import MescrollUni from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-uni.vue';
|
||||
import bleTool from '@/utils/BleHelper.js';
|
||||
import MescrollUni from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-uni.vue'
|
||||
import BleReceive from '@/utils/BleReceive';
|
||||
import {
|
||||
MsgError
|
||||
MsgError, MsgSuccess
|
||||
} from '@/utils/MsgPops';
|
||||
import MqttClient from '@/utils/mqtt.js';
|
||||
|
||||
var pagePath = 'pages/common/index';
|
||||
var ble = null;
|
||||
|
||||
var mq=null;
|
||||
var timeout = null;
|
||||
var ble = null;
|
||||
var recei = null;
|
||||
var these=null;
|
||||
export default {
|
||||
components: {
|
||||
MescrollUni
|
||||
},
|
||||
computed: {
|
||||
showSendFlex() {
|
||||
// return this.activeTab && this.activeTab.id !== ''&& (this.activeTabInfo.communicationMode==0 || this.activeTabInfo.communicationMode==2);
|
||||
showSendFlex() {
|
||||
if (this.showMap || this.ShowSendmessage || this.showWarn) {
|
||||
return true;
|
||||
}
|
||||
@ -243,6 +249,11 @@
|
||||
text: '所有分享',
|
||||
icon: '/static/images/common/share.png',
|
||||
action: 'share'
|
||||
},
|
||||
{
|
||||
text: '预警布防',
|
||||
icon: '/static/images/common/defence.png',
|
||||
action: 'defence'
|
||||
}
|
||||
],
|
||||
downOption: {
|
||||
@ -299,21 +310,14 @@
|
||||
},
|
||||
// 下拉刷新
|
||||
downCallback() {
|
||||
|
||||
|
||||
if (this.mescroll) {
|
||||
this.mescroll.resetUpScroll(false);
|
||||
this.mescroll.scrollTo(0, 0);
|
||||
}
|
||||
this.getData();
|
||||
|
||||
|
||||
},
|
||||
// 上拉加载
|
||||
upCallback() {
|
||||
|
||||
|
||||
|
||||
this.getData();
|
||||
},
|
||||
bleStateBreak() {
|
||||
@ -325,22 +329,18 @@
|
||||
console.log("蓝牙适配器恢复可用,重连断开的设备");
|
||||
ble.linkAllDevices();
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
bleBreak(res) {
|
||||
console.error("蓝牙断开连接", res);
|
||||
if (res.deviceId) {
|
||||
this.updateBleStatu(res.deviceId);
|
||||
}
|
||||
|
||||
},
|
||||
bleRecovery(res) {
|
||||
// console.log("蓝牙连接成功", res);
|
||||
if (res.deviceId) {
|
||||
this.updateBleStatu(res.deviceId);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
updateBleStatu() { //更新列表的蓝牙连接状态,电池 电量
|
||||
@ -390,6 +390,7 @@
|
||||
},
|
||||
// 所有分享,所有类型
|
||||
handleshareClick(item) {
|
||||
debugger;
|
||||
this.showshare = false; // 关闭弹窗
|
||||
var that = this;
|
||||
switch (item.action) {
|
||||
@ -414,8 +415,12 @@
|
||||
case 'share':
|
||||
uni.navigateTo({
|
||||
url: "/pages/common/allShare/index",
|
||||
|
||||
})
|
||||
});
|
||||
break;
|
||||
case 'defence':
|
||||
uni.navigateTo({
|
||||
url: "/pages/common/linkDefence/defence"
|
||||
});
|
||||
break;
|
||||
}
|
||||
},
|
||||
@ -720,6 +725,8 @@
|
||||
this.$set(this.deviceList[index], 'showOption', 'none');
|
||||
},
|
||||
Disc(item, index) { //发送识别指令
|
||||
|
||||
this.$set(this.deviceList[index], 'isDisc', true);
|
||||
let json = {
|
||||
ins_disc: 1
|
||||
};
|
||||
@ -729,51 +736,100 @@
|
||||
return v.macAddress == item.deviceMac;
|
||||
});
|
||||
if (f) {
|
||||
console.log("f=",f);
|
||||
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
|
||||
index++;
|
||||
setTimeout(sendNextPacket, 300);
|
||||
MsgSuccess("发送识别指令成功",'',these);
|
||||
this.$set(this.deviceList[index], 'isDisc', false);
|
||||
}).catch(err => {
|
||||
console.error('err=',err);
|
||||
if (item.communicationMode == 1) {
|
||||
MsgError(err.msg, '', this);
|
||||
this.$set(this.deviceList[index], 'isDisc', false);
|
||||
return;
|
||||
}
|
||||
mqSend();
|
||||
mqSend(true);
|
||||
});
|
||||
}else{
|
||||
if (item.communicationMode == 1) {
|
||||
MsgError("请连接蓝牙后再试", '去连接', this,()=>{
|
||||
uni.navigateTo({
|
||||
url: "/pages/common/addBLE/addEquip",
|
||||
events: {
|
||||
BindOver(data) {
|
||||
console.log("蓝牙配对成功了");
|
||||
}
|
||||
},
|
||||
success: function(res) {
|
||||
res.eventChannel.emit('detailData', {
|
||||
data: item
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
this.$set(this.deviceList[index], 'isDisc', false);
|
||||
return;
|
||||
}
|
||||
mqSend(true);
|
||||
}
|
||||
}
|
||||
|
||||
let mqSend = () => {
|
||||
let mqSend = (isBle) => {
|
||||
|
||||
if(!item.deviceImei){
|
||||
if(ble){
|
||||
MsgError("发送识别指令,蓝牙发送失败、IMEI缺失4G发送也失败",'',these);
|
||||
}else{
|
||||
MsgError("发送识别指令失败,设备IMEI缺失",'',these);
|
||||
}
|
||||
this.$set(this.deviceList[index], 'isDisc', false);
|
||||
return;
|
||||
}
|
||||
|
||||
let Send = () => {
|
||||
|
||||
let flag = mq.publish("B/" + item.deviceImei, JSON.stringify(json));
|
||||
if (!flag) {
|
||||
MsgError("识别设备失败,请检查手机网络连接", '', this);
|
||||
MsgError("发送识别指令失败,请检查手机网络连接", '', this);
|
||||
this.$set(this.deviceList[index], 'isDisc', false);
|
||||
return;
|
||||
}
|
||||
this.$set(this.deviceList[index], 'isDisc', false);
|
||||
}
|
||||
|
||||
if (!mq) {
|
||||
|
||||
mq = new MqttClient();
|
||||
mq.connect(() => {
|
||||
console.log("MQTT连接成功")
|
||||
Send();
|
||||
},()=>{
|
||||
MsgError("发送识别指令时,无法连接消息服务器");
|
||||
mq.disconnect();
|
||||
mq=null;
|
||||
}).catch(ex=>{
|
||||
console.error("ex=",ex);
|
||||
this.$set(this.deviceList[index], 'isDisc', false);
|
||||
});
|
||||
|
||||
return ;
|
||||
}else{
|
||||
console.log("mq=",mq);
|
||||
Send();
|
||||
}
|
||||
Send();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (item.communicationMode == 1 || item.communicationMode == 2) {
|
||||
bleSend.catch(ex => {
|
||||
mqSend();
|
||||
});
|
||||
setTimeout(()=>{
|
||||
if (item.communicationMode == 1 || item.communicationMode == 2) {
|
||||
bleSend();
|
||||
return;
|
||||
}
|
||||
if (item.communicationMode == 0) {
|
||||
mqSend();
|
||||
return;
|
||||
}
|
||||
},250);
|
||||
|
||||
},
|
||||
// 列表跳转
|
||||
handleFile(item, index) {
|
||||
@ -781,6 +837,7 @@
|
||||
this.$set(this.deviceList[index], 'showOption', 'none');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
this.$set(this.deviceList[index], 'active', true);
|
||||
setTimeout(() => {
|
||||
@ -846,6 +903,7 @@
|
||||
},
|
||||
onLoad() {
|
||||
// console.error("首页加载");
|
||||
these=this;
|
||||
this.getTab()
|
||||
this.downCallback();
|
||||
|
||||
@ -914,6 +972,9 @@
|
||||
console.log("onUnload...");
|
||||
uni.$off('deviceStatusUpdate');
|
||||
ble && ble.removeAllCallback(pagePath);
|
||||
if(mq){
|
||||
mq.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1387,15 +1448,26 @@
|
||||
}
|
||||
|
||||
.splitLine {
|
||||
background: linear-gradient(90.00deg, rgba(0, 0, 0, 0), rgba(255, 255, 255, 1) 44.525%, rgba(255, 254.75, 254.75, 0) 92%);
|
||||
background: linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(255, 255, 255, 1) 44.525%, rgba(255, 254.75, 254.75, 0) 92%);
|
||||
opacity: 0.2;
|
||||
width: 25rpx;
|
||||
height: 4rpx;
|
||||
margin: 0rpx 10rpx;
|
||||
transform: rotate(90.00deg);
|
||||
width: 4rpx;
|
||||
height: 25rpx;
|
||||
margin: 0rpx 20rpx;
|
||||
}
|
||||
|
||||
.p10 {
|
||||
padding-left: 20rpx;
|
||||
}
|
||||
.disc{
|
||||
padding: 5rpx 10rpx;
|
||||
margin-right: -30rpx;
|
||||
}
|
||||
.disc.active{
|
||||
background-color: #2a2a2a !important;;
|
||||
}
|
||||
.discImg{
|
||||
width:24rpx;
|
||||
height: 24rpx;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
</style>
|
||||
447
pages/common/linkDefence/addDefence.vue
Normal file
@ -0,0 +1,447 @@
|
||||
<template>
|
||||
<view class="content contentBg">
|
||||
|
||||
<SubStep :steps="Status.steps.list" :height="'140rpx'" :curr="Status.steps.curr" @stepClick="stepClick">
|
||||
</SubStep>
|
||||
|
||||
|
||||
<view class="mainPanel" v-show="Status.steps.curr===0">
|
||||
<view class="main">
|
||||
<uni-easyinput maxlength="30" class="txteare" v-model="formData.name" :trim="true" placeholder="输入编组名称"
|
||||
type="textarea" autoHeight :inputBorder="false" :border="false"></uni-easyinput>
|
||||
</view>
|
||||
<button class="btnNext" :disabled="!formData.name" :class="{'active':formData.name}"
|
||||
@click="gotoStep(1)">下一步</button>
|
||||
</view>
|
||||
|
||||
<view class="mainPanel" v-show="Status.steps.curr===1">
|
||||
<view class="btnAdd" @click="goCheckDevice('main')">
|
||||
<image class="img" mode="aspectFit" src="/static/images/common/add.png"></image>
|
||||
<text>添加预警主机</text>
|
||||
</view>
|
||||
|
||||
<scroll-view scroll-y="true" scroll-with-animation class="checkedList" v-show="formData.main.length>0">
|
||||
<view class="item " v-for="item,index in formData.main">
|
||||
<view class="panel imgContent center" @click.stop="imgView(item,index)">
|
||||
<image class="img" :src="item.devicePic" mode="aspectFit"></image>
|
||||
</view>
|
||||
|
||||
<view class="panel centerCol lbl">
|
||||
<view class="LargeTxt">{{item.deviceName}}</view>
|
||||
<view class="smallTxt">ID:{{item.deviceImei?item.deviceImei:item.deviceMac}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<button class="btnNext" :class="{'active':formData.main.length>0}" :disabled="formData.main.length==0"
|
||||
@click="gotoStep(1)">下一步</button>
|
||||
</view>
|
||||
|
||||
<view class="mainPanel" v-show="Status.steps.curr===2">
|
||||
<view class="btnAdd" @click="goCheckDevice('sub')">
|
||||
<image class="img" mode="aspectFit" src="/static/images/common/add.png"></image>
|
||||
<text>添加布防联机</text>
|
||||
</view>
|
||||
<scroll-view scroll-y="true" scroll-with-animation class="checkedList" v-show="formData.sub.length>0">
|
||||
<view class="item center" v-for="item,index in formData.sub">
|
||||
<view class="panel imgContent center" @click.stop="imgView(item,index)">
|
||||
<image class="img" :src="item.devicePic" mode="aspectFit"></image>
|
||||
</view>
|
||||
|
||||
<view class="panel centerCol lbl">
|
||||
<view class="LargeTxt">{{item.deviceName}}</view>
|
||||
<view class="smallTxt">ID:{{item.deviceImei?item.deviceImei:item.deviceMac}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<button class="btnNext" :class="{'active':formData.sub.length>0}" :disabled="formData.sub.length==0"
|
||||
@click="gotoStep(1)">下一步</button>
|
||||
</view>
|
||||
|
||||
<view class="mainPanel" v-show="Status.steps.curr===3">
|
||||
<view class="btnAdd" @click="goCheckDevice('notify')">
|
||||
<image class="img" mode="aspectFit" src="/static/images/common/add.png"></image>
|
||||
<text>添加接收设备</text>
|
||||
</view>
|
||||
<scroll-view scroll-y="true" scroll-with-animation class="checkedList" v-show="formData.notify.length>0">
|
||||
<view class="item" v-for="item,index in formData.notify">
|
||||
<view class="panel imgContent center" @click.stop="imgView(item,index)">
|
||||
<image class="img" :src="item.devicePic" mode="aspectFit"></image>
|
||||
</view>
|
||||
|
||||
<view class="panel centerCol lbl">
|
||||
<view class="LargeTxt">{{item.deviceName}}</view>
|
||||
<view class="smallTxt">ID:{{item.deviceImei?item.deviceImei:item.deviceMac}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<button class="btnNext" :class="{'active':formData.notify.length>0}" :disabled="formData.notify.length==0"
|
||||
@click="Send">发送</button>
|
||||
</view>
|
||||
|
||||
|
||||
<MsgBox ref="msgPop" />
|
||||
<global-loading ref="loading" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import request from '@/utils/request.js';
|
||||
import {
|
||||
showLoading,
|
||||
hideLoading,
|
||||
updateLoading
|
||||
} from '@/utils/loading.js';
|
||||
|
||||
import {
|
||||
MsgSuccess,
|
||||
MsgError,
|
||||
MsgClose,
|
||||
MsgWarning,
|
||||
showPop,
|
||||
MsgInfo
|
||||
} from '@/utils/MsgPops.js'
|
||||
import Common from '@/utils/Common.js';
|
||||
|
||||
var these = null;
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
|
||||
Status: {
|
||||
steps: {
|
||||
list: [{
|
||||
text: '设置名称'
|
||||
},
|
||||
{
|
||||
text: '设置主机'
|
||||
},
|
||||
{
|
||||
text: '设置联机'
|
||||
},
|
||||
{
|
||||
text: '发送编组'
|
||||
}
|
||||
],
|
||||
curr: 0
|
||||
}
|
||||
},
|
||||
formData: {
|
||||
id: '',
|
||||
name: '',
|
||||
main: [], //通知设备
|
||||
sub: [], //预警设备
|
||||
notify: [] //发送设备
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
||||
},
|
||||
created() {
|
||||
|
||||
},
|
||||
onUnload() {
|
||||
|
||||
|
||||
},
|
||||
onBackPress() {
|
||||
if (this.Status.steps.curr > 0) {
|
||||
this.gotoStep(-1);
|
||||
return true;
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
|
||||
},
|
||||
onHide: function() {
|
||||
|
||||
},
|
||||
|
||||
onLoad(opt) {
|
||||
these = this;
|
||||
let eventChannel = this.getOpenerEventChannel();
|
||||
|
||||
eventChannel.on('detailData', (res) => {
|
||||
let data = res.data;
|
||||
if (data) {
|
||||
this.formData.id = data.id;
|
||||
this.formData.name = data.name;
|
||||
this.formData.main = [];
|
||||
this.formData.sub = [];
|
||||
this.formData.notify = [];
|
||||
setTimeout(this.initData, 0);
|
||||
}
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
imgView(item,index){
|
||||
if(!item.devicePic){
|
||||
return;
|
||||
}
|
||||
|
||||
uni.previewImage({
|
||||
urls: [item.devicePic]
|
||||
});
|
||||
},
|
||||
goCheckDevice(type) {
|
||||
let json = {
|
||||
type: type,
|
||||
formData:this.formData
|
||||
};
|
||||
Object.assign(json, this.formData);
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/linkDefence/checkDevice',
|
||||
success(res) {
|
||||
res.eventChannel.emit("detailData", {
|
||||
data: json
|
||||
});
|
||||
},
|
||||
events: {
|
||||
checkOver(res) {
|
||||
these.$set(these.formData, res.type, res.arr)
|
||||
}
|
||||
},
|
||||
fail(ex) {
|
||||
console.error("出现异常", ex);
|
||||
}
|
||||
});
|
||||
},
|
||||
initData() {
|
||||
|
||||
if (!this.formData.id) {
|
||||
return;
|
||||
}
|
||||
let url = '';
|
||||
if (!url) {
|
||||
MsgWarning('后端未开发此接口,敬请期待', '', this);
|
||||
return;
|
||||
}
|
||||
request({
|
||||
url: url,
|
||||
data: {
|
||||
id: this.formData.id
|
||||
},
|
||||
method: 'POST'
|
||||
}).then(res => {
|
||||
if (res && res.code == 200) {
|
||||
console.log("请求数据成功", res);
|
||||
this.formData.main = res.data.filter(v => {
|
||||
return v.type == 'notify';
|
||||
});
|
||||
this.formData.sub = res.data.filter(v => {
|
||||
return v.type == 'warn';
|
||||
});
|
||||
} else {
|
||||
MsgError(res.msg, '', this);
|
||||
}
|
||||
}).catch(ex => {
|
||||
console.log("ex=", ex);
|
||||
MsgError(ex.errMsg, '', this);
|
||||
});
|
||||
|
||||
},
|
||||
stepClick(item, index) {
|
||||
console.log("步骤被点击:", item);
|
||||
},
|
||||
Send() {
|
||||
showLoading(these, {
|
||||
text: '发送中'
|
||||
});
|
||||
let task = () => {
|
||||
hideLoading(these);
|
||||
MsgSuccess("敬请期待", '', these);
|
||||
}
|
||||
|
||||
setTimeout(task, 800);
|
||||
},
|
||||
gotoStep(intval) {
|
||||
if (this.Status.steps.curr + intval > this.Status.steps.list.length - 1) {
|
||||
return;
|
||||
} else if (this.Status.steps.curr + intval < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.Status.steps.curr += intval;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.content {
|
||||
padding: 30rpx;
|
||||
box-sizing: border-box;
|
||||
|
||||
width: 100%;
|
||||
|
||||
}
|
||||
|
||||
/* #ifdef APP */
|
||||
.content {
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
/* #endif */
|
||||
/* #ifdef WEB|H5 */
|
||||
.content {
|
||||
height: calc(100vh - 44px);
|
||||
}
|
||||
|
||||
/* #endif */
|
||||
|
||||
.mainPanel {
|
||||
width: 100%;
|
||||
height: calc(100% - 140rpx);
|
||||
position: relative;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #FFFFFF00;
|
||||
}
|
||||
|
||||
.mainPanel .btnNext {
|
||||
width: 90%;
|
||||
transform: translateX(5%);
|
||||
position: absolute;
|
||||
bottom: 0rpx;
|
||||
border-radius: 45rpx;
|
||||
background: #1A1A1A;
|
||||
color: rgba(255, 255, 255, 0.4);
|
||||
font-family: "PingFang SC";
|
||||
height: 80rpx;
|
||||
font-size: 28rpx;
|
||||
line-height: 80rpx;
|
||||
letter-spacing: 0px;
|
||||
text-align: center;
|
||||
|
||||
|
||||
}
|
||||
|
||||
.mainPanel .btnNext.active {
|
||||
background: #BBE600;
|
||||
color: #232323;
|
||||
}
|
||||
|
||||
/deep/ .uni-easyinput__content,
|
||||
.uni-easyinput__content {
|
||||
background-color: #1A1A1A !important;
|
||||
border-radius: 16rpx;
|
||||
color: #FFFFFF;
|
||||
text-indent: 10rpx;
|
||||
box-sizing: border-box;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
/deep/ .uni-textarea-placeholder,
|
||||
.uni-textarea-placeholder {
|
||||
color: rgba(255, 255, 255, 0.5);
|
||||
|
||||
font-family: "PingFang SC";
|
||||
font-style: Regular;
|
||||
font-size: 24rpx;
|
||||
font-weight: 400;
|
||||
letter-spacing: 0.14rpx;
|
||||
}
|
||||
|
||||
.mainPanel .main {
|
||||
transform: translateY(30rpx);
|
||||
}
|
||||
|
||||
.mainPanel .btnAdd {
|
||||
|
||||
width: 100%;
|
||||
height: 150rpx;
|
||||
border-radius: 16rpx;
|
||||
background: rgba(26, 26, 26, 1);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-evenly;
|
||||
align-items: center;
|
||||
flex-wrap: nowrap;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
font-family: "PingFang SC";
|
||||
font-style: Regular;
|
||||
font-size: 24rpx;
|
||||
font-weight: 400;
|
||||
letter-spacing: 0.14rpx;
|
||||
margin-top: 30rpx;
|
||||
}
|
||||
|
||||
.mainPanel .btnAdd .img {
|
||||
width: 50rpx;
|
||||
height: 50rpx;
|
||||
}
|
||||
|
||||
.mainPanel .checkedList {
|
||||
width: 100%;
|
||||
height: calc(100% - 300rpx);
|
||||
transform: translateY(20rpx);
|
||||
border-radius: 16rpx;
|
||||
background-color: #1A1A1A;
|
||||
box-sizing: border-box;
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.mainPanel .checkedList .item {
|
||||
width: 100%;
|
||||
height: 100rpx;
|
||||
overflow: hidden;
|
||||
margin-bottom: 20rpx;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
align-content: center;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
|
||||
}
|
||||
.mainPanel .checkedList .item .panel{
|
||||
height: 100%;
|
||||
|
||||
}
|
||||
.mainPanel .checkedList .item .lbl{
|
||||
width: calc(100% - 120rpx);
|
||||
height: 100%;
|
||||
transform: translateX(24rpx);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-wrap: wrap;
|
||||
align-content: flex-start;
|
||||
align-items: flex-start;
|
||||
justify-content: space-evenly;
|
||||
}
|
||||
.mainPanel .checkedList .item .imgContent {
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
background-color: #2A2A2A;
|
||||
border-radius: 16rpx;
|
||||
}
|
||||
|
||||
.mainPanel .checkedList .item .img {
|
||||
width: 80%;
|
||||
height: 80%;
|
||||
}
|
||||
|
||||
.checkedList .LargeTxt{
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
|
||||
font-family: "PingFang SC";
|
||||
font-style: Regular;
|
||||
font-size: 32rpx;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.checkedList .smallTxt{
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
|
||||
font-family: "PingFang SC";
|
||||
font-style: Regular;
|
||||
font-size: 24rpx;
|
||||
font-weight: 400;
|
||||
|
||||
letter-spacing: 0.14rpx;
|
||||
|
||||
}
|
||||
</style>
|
||||
882
pages/common/linkDefence/checkDevice.vue
Normal file
@ -0,0 +1,882 @@
|
||||
<template>
|
||||
<view class="maincontent contentBg">
|
||||
<uni-nav-bar :border="false" @clickLeft="prevPage" fixed="true" statusBar="true" background-color="#121212"
|
||||
color="#FFFFFF" :title="Status.navbar.title">
|
||||
<template v-slot:left>
|
||||
<view>
|
||||
<uni-icons type="left" size="24" color="#FFFFFF"></uni-icons>
|
||||
</view>
|
||||
</template>
|
||||
<block slot="right">
|
||||
<view class="navbarRight center">
|
||||
<image @click.stop="handleRightClick(index,item)" v-for="item,index in Status.navbar.icons"
|
||||
class="img" :src="item.src" mode="aspectFit"></image>
|
||||
</view>
|
||||
|
||||
</block>
|
||||
</uni-nav-bar>
|
||||
<view class="tab-bar-wrap" v-show="!Status.Search">
|
||||
<scroll-view class="tab-bar" scroll-x="true" scroll-with-animation>
|
||||
<view class="tab-container">
|
||||
<view v-for="(tab, index) in tabs" :key="index"
|
||||
:class="['tab-item', activeTab === index ? 'active' : '']" @click="switchTab(tab,index)">
|
||||
{{tab.typeName}}
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<view class="tab-more" @click="Status.Search=!Status.Search">
|
||||
<image src="/static/images/common/search.png" mode="aspectFit" class="more"></image>
|
||||
</view>
|
||||
</view>
|
||||
<view class="searchRow" v-show="Status.Search">
|
||||
<view class="ipt">
|
||||
<uni-easyinput class="txteare" maxlength="30" v-model="filter.txt" :trim="true" placeholder="搜索设备"
|
||||
type="text" :inputBorder="false" :border="false"></uni-easyinput>
|
||||
</view>
|
||||
|
||||
<view class="btn" @click.stop="Status.Search=false">取消</view>
|
||||
<view class="clear"></view>
|
||||
</view>
|
||||
<view class="listContent">
|
||||
<mescroll-uni class="device-list" @init="mescrollInit" @down="downCallback" @up="upCallback" :up="upOption"
|
||||
:down="downOption" :fixed="false">
|
||||
<view class="listItem center" v-for="item,index in deviceList">
|
||||
<view class="opt center">
|
||||
<view class="checkbox center" @click.stop="checkToggle(item,index)"
|
||||
:class="{active:checks.find((v,i)=>{return v.id===item.id})}">
|
||||
<uni-icons class="icon" type="checkmarkempty" size="17" color="#000000"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
<view class="main">
|
||||
<view class="device-header">
|
||||
<view class="deviceIMG" @click.stop="imgView(item,index)">
|
||||
<image :src="item.devicePic" class="IMG" mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="device-name">
|
||||
<view>设备:{{item.deviceName}}</view>
|
||||
|
||||
<view class="ID">
|
||||
ID:{{item.deviceImei?item.deviceImei:item.deviceMac}}
|
||||
</view>
|
||||
|
||||
|
||||
<view class="ID">
|
||||
|
||||
<view class="center ">
|
||||
<view :class="{'onlines':item.onlineStatus==1,'offlines':item.onlineStatus==0}">
|
||||
{{item.onlineStatus==1?'在线':'离线'}}
|
||||
</view>
|
||||
<view class="splitLine"></view>
|
||||
|
||||
<view>电量:{{item.battery || '0'}}%</view>
|
||||
</view>
|
||||
|
||||
<view @click.stop="Disc(item,index)" class="disc center"
|
||||
:class="{active:item.isDisc}">
|
||||
<image src="/static/images/common/disc.png" class="discImg" mode="aspectFit">
|
||||
</image>
|
||||
<text>识别</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="device-callpolice"
|
||||
v-if="item.communicationMode==0 && item.onlineStatus==1 && item.alarmStatus==1">
|
||||
报警中</view>
|
||||
<view v-if="item.communicationMode==1 || item.communicationMode==2">
|
||||
<view class="device-status" :class="item.bleStatu?'online':'unline'">
|
||||
{{item.bleStatu?'已连接':'未连接'}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</mescroll-uni>
|
||||
</view>
|
||||
|
||||
<view :class="{active:checks.length>0}" class="btnOK" @click.stop="OkCheck()">确定</view>
|
||||
<global-loading ref="loading" />
|
||||
|
||||
<MsgBox ref="msgPop" />
|
||||
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var timeout = null;
|
||||
var these = null;
|
||||
var eventChannel = null;
|
||||
var ble = null;
|
||||
var recei = null;
|
||||
var pagePath = "pages/common/linkDefence/checkDevice";
|
||||
import request, {
|
||||
baseURL
|
||||
} from '@/utils/request.js';
|
||||
import {
|
||||
showLoading,
|
||||
hideLoading,
|
||||
updateLoading
|
||||
} from '@/utils/loading.js';
|
||||
import {
|
||||
MsgSuccess,
|
||||
MsgError,
|
||||
MsgClose,
|
||||
MsgWarning,
|
||||
showPop,
|
||||
MsgInfo,
|
||||
MsgClear,
|
||||
MsgPrompt
|
||||
} from '@/utils/MsgPops.js';
|
||||
import {
|
||||
deviceInfo,
|
||||
deviceTypeList
|
||||
} from '@/api/common/index.js'
|
||||
import Common from '@/utils/Common.js';
|
||||
import bleTool from '@/utils/BleHelper.js';
|
||||
import BleReceive from '@/utils/BleReceive';
|
||||
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
filter: {
|
||||
txt: ''
|
||||
},
|
||||
Status: {
|
||||
navbar: {
|
||||
icons: [{
|
||||
src: '/static/images/common/add.png',
|
||||
type: 'add'
|
||||
}],
|
||||
title: '选择设备',
|
||||
showBack: true,
|
||||
height: 90,
|
||||
|
||||
},
|
||||
type: null,
|
||||
Search: false
|
||||
|
||||
},
|
||||
|
||||
mescroll: null,
|
||||
downOption: {
|
||||
auto: false,
|
||||
autoShowLoading: false,
|
||||
},
|
||||
upOption: {
|
||||
auto: false,
|
||||
noMoreSize: 0,
|
||||
offset: 10,
|
||||
isLock: false,
|
||||
empty: {
|
||||
tip: '暂无数据',
|
||||
hideScroll: false,
|
||||
icon: '/static/images/common/empty.png'
|
||||
},
|
||||
textNoMore: '没有更多数据了'
|
||||
},
|
||||
deviceList: [],
|
||||
checks: [],
|
||||
tabs: [],
|
||||
activeTabInfo: '',
|
||||
activeTab: 0,
|
||||
formData: {
|
||||
id: '',
|
||||
name: '',
|
||||
main: [], //通知设备
|
||||
sub: [], //预警设备
|
||||
notify: [] //发送设备
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.Status.navbar.height = uni.getSystemInfoSync().statusBarHeight + 44;
|
||||
},
|
||||
onLoad() {
|
||||
this.getTab();
|
||||
these = this;
|
||||
this.$watch("filter.txt",(newVal,oldVal)=>{
|
||||
if(this.mescroll){
|
||||
this.mescroll.triggerDownScroll();
|
||||
}
|
||||
});
|
||||
eventChannel = this.getOpenerEventChannel();
|
||||
eventChannel.on('detailData', (res) => {
|
||||
let data = res.data;
|
||||
console.log("收到上级页面传参", data);
|
||||
this.Status.type = data.type;
|
||||
let keys = Object.keys(data.formData);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
let key = keys[i];
|
||||
this.formData[key] = data.formData[key];
|
||||
}
|
||||
if (data.type == 'main') {
|
||||
this.checks = data.main;
|
||||
this.Status.navbar.title = "选择预警主机";
|
||||
} else if (data.type == 'sub') {
|
||||
this.checks = data.sub;
|
||||
this.Status.navbar.title = "选择布防联机";
|
||||
} else if (data.type == 'notify') {
|
||||
this.checks = data.notify;
|
||||
this.Status.navbar.title = "选择接收设备";
|
||||
|
||||
}
|
||||
setTimeout(() => {
|
||||
if (this.mescroll) {
|
||||
this.mescroll.triggerDownScroll();
|
||||
}
|
||||
}, 0);
|
||||
|
||||
});
|
||||
|
||||
|
||||
ble = bleTool.getBleTool();
|
||||
|
||||
recei = BleReceive.getBleReceive();
|
||||
//蓝牙连接成功的回调
|
||||
ble.addRecoveryCallback((res) => {
|
||||
// console.log("蓝牙连接成功的回调");
|
||||
this.bleRecovery(res);
|
||||
}, pagePath);
|
||||
|
||||
//蓝牙断开连接的回调
|
||||
ble.addDisposeCallback((res) => {
|
||||
console.log("蓝牙断开连接的回调");
|
||||
this.bleBreak(res);
|
||||
}, pagePath);
|
||||
|
||||
//蓝牙适配器恢复可用的回调,一般是重连设备
|
||||
ble.addStateRecoveryCallback(res => {
|
||||
// console.log("蓝牙适配器恢复可用的回调");
|
||||
this.bleStateRecovery();
|
||||
}, pagePath);
|
||||
|
||||
//蓝牙适配器不可用的回调
|
||||
ble.addStateBreakCallback(res => {
|
||||
// console.error("蓝牙适配器不可用的回调");
|
||||
this.bleStateBreak();
|
||||
}, pagePath);
|
||||
|
||||
//接收到消息的回调
|
||||
ble.addReceiveCallback((receive, device, path, recArr) => {
|
||||
// console.error("首页收到消息了");
|
||||
let json = recei.ReceiveData(receive, device, path, recArr);
|
||||
// console.error("消息内容",json);
|
||||
this.updateBleStatu();
|
||||
}, pagePath);
|
||||
// eventChannel.emit('checkOver', {type:'',arr:[]});//
|
||||
},
|
||||
methods: {
|
||||
imgView(item, index) {
|
||||
if (!item.devicePic) {
|
||||
return;
|
||||
}
|
||||
|
||||
uni.previewImage({
|
||||
urls: [item.devicePic]
|
||||
});
|
||||
},
|
||||
checkToggle(item, index) {
|
||||
|
||||
let f = this.checks.find((v, i) => {
|
||||
if (v.id === item.id) {
|
||||
this.checks.splice(i, 1);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
if (!f) {
|
||||
this.checks.push({
|
||||
id: item.id,
|
||||
deviceName: item.deviceName,
|
||||
deviceImei: item.deviceImei,
|
||||
deviceMac: item.deviceMac,
|
||||
devicePic: item.devicePic
|
||||
});
|
||||
}
|
||||
|
||||
console.log("checks=", this.checks);
|
||||
},
|
||||
bleStateBreak() {
|
||||
console.error("蓝牙适配器不可用");
|
||||
this.updateBleStatu();
|
||||
},
|
||||
bleStateRecovery() {
|
||||
if (this.isPageShow) {
|
||||
console.log("蓝牙适配器恢复可用,重连断开的设备");
|
||||
ble.linkAllDevices();
|
||||
}
|
||||
},
|
||||
bleBreak(res) {
|
||||
console.error("蓝牙断开连接", res);
|
||||
if (res.deviceId) {
|
||||
this.updateBleStatu(res.deviceId);
|
||||
}
|
||||
},
|
||||
bleRecovery(res) {
|
||||
// console.log("蓝牙连接成功", res);
|
||||
if (res.deviceId) {
|
||||
this.updateBleStatu(res.deviceId);
|
||||
}
|
||||
},
|
||||
|
||||
updateBleStatu() { //更新列表的蓝牙连接状态,电池 电量
|
||||
if (ble) {
|
||||
|
||||
for (var i = 0; i < this.deviceList.length; i++) {
|
||||
|
||||
|
||||
let f = null;
|
||||
if (ble.data && ble.data.LinkedList) {
|
||||
f = ble.data.LinkedList.find(v => {
|
||||
|
||||
if (v.macAddress && v.device && v.device.id) {
|
||||
return v.device.id == this.deviceList[i].id;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
if (f) {
|
||||
|
||||
this.$set(this.deviceList[i], 'bleStatu', f.Linked);
|
||||
if (f.formData) {
|
||||
let battary = 0;
|
||||
if ('battary' in f.formData) {
|
||||
battary = f.formData.battary;
|
||||
} else if ('sta_PowerPercent' in f.formData) {
|
||||
battary = f.formData.sta_PowerPercent;
|
||||
} else if ('sta_battery' in f.formData) {
|
||||
battary = f.formData.sta_battery;
|
||||
}
|
||||
this.$set(this.deviceList[i], 'battery', battary);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
console.error("ble is null")
|
||||
},
|
||||
getTab() {
|
||||
deviceTypeList({}).then((res) => {
|
||||
if (res.code == 200) {
|
||||
//console.log("deviceTypeList=" + JSON.stringify(res.data));
|
||||
this.tabs = [{
|
||||
id: '',
|
||||
name: '全部设备',
|
||||
typeName: '全部设备'
|
||||
},
|
||||
...res.data.map(item => ({
|
||||
id: item.id,
|
||||
name: item.typeName,
|
||||
typeName: item.typeName,
|
||||
communicationMode: item.communicationMode
|
||||
}))
|
||||
];
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
isChecked(item, index) {
|
||||
let f = this.checks.find((v, i) => {
|
||||
return v.id == item.id;
|
||||
});
|
||||
if (f) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
OkCheck() {
|
||||
if (this.checks.length == 0) {
|
||||
return;
|
||||
}
|
||||
eventChannel.emit('checkOver', {
|
||||
type: this.Status.type,
|
||||
arr: this.checks
|
||||
});
|
||||
uni.navigateBack();
|
||||
},
|
||||
onClick(btn, i, item, index) {
|
||||
if (btn.type == 'rename') {
|
||||
console.log("执行重命名");
|
||||
MsgPrompt(this, btn.type, () => {
|
||||
console.log("确定被点击");
|
||||
}, false, true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (btn.type == 'drop') {
|
||||
console.log("执行删除");
|
||||
MsgError('删除后不可恢复,您确认删除"' + item + '"吗?', '确定', this, () => {
|
||||
this.deviceList.splice(index, 1);
|
||||
}, true);
|
||||
return;
|
||||
}
|
||||
},
|
||||
change(event) {
|
||||
console.log('改变事件', event);
|
||||
},
|
||||
swipeChange(e, index) {
|
||||
console.log('当前状态:' + e + ',下标:' + index)
|
||||
},
|
||||
gotoDetail(item, index) {
|
||||
console.log("item=", item);
|
||||
},
|
||||
mescrollInit(mescroll) {
|
||||
this.mescroll = mescroll;
|
||||
},
|
||||
// 下拉刷新
|
||||
downCallback() {
|
||||
if (this.mescroll) {
|
||||
this.mescroll.resetUpScroll(false);
|
||||
this.mescroll.scrollTo(0, 0);
|
||||
}
|
||||
this.getData();
|
||||
},
|
||||
// 上拉加载
|
||||
upCallback() {
|
||||
this.getData();
|
||||
},
|
||||
getData() {
|
||||
var task = () => {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!this.Status.type) {
|
||||
this.mescroll.endSuccess(0, false);
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
let data = {
|
||||
pageNum: this.mescroll.num,
|
||||
pageSize: 10,
|
||||
deviceType: this.activeTabInfo ? this.activeTabInfo.id : '', // 使用传入的设备类型
|
||||
isAsc: 'desc',
|
||||
orderByColumn: 'bindingTime',
|
||||
deviceName:this.filter.txt
|
||||
}
|
||||
if (!data.pageNum) {
|
||||
this.mescroll.endSuccess(0, false);
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
let method = deviceInfo;
|
||||
if (this.Status.type == 'notify') {
|
||||
method = () => {
|
||||
let rows=this.formData.main;
|
||||
rows=rows.concat(this.formData.sub);
|
||||
rows=rows.filter(v=>{
|
||||
return v.deviceName.toLowerCase().indexOf(this.filter.txt.toLowerCase())>-1;
|
||||
})
|
||||
let json = {
|
||||
code: 200,
|
||||
rows: rows
|
||||
};
|
||||
|
||||
return Promise.resolve(json);
|
||||
}
|
||||
}
|
||||
method(data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
|
||||
const newDevices = res.rows.map(device => ({
|
||||
...device,
|
||||
showConfirm: false
|
||||
}));
|
||||
|
||||
// 如果是第一页或切换分类,替换数据
|
||||
if (data.pageNum === 1) {
|
||||
this.deviceList = newDevices
|
||||
} else {
|
||||
//防止后端返回的数据包含已有数据
|
||||
for (var i = 0; i < newDevices.length; i++) {
|
||||
let device = newDevices[i];
|
||||
let f = this.deviceList.find(v => {
|
||||
return v.id === device.id;
|
||||
});
|
||||
if (!f) {
|
||||
this.deviceList.push(device);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.updateBleStatu();
|
||||
|
||||
|
||||
// 判断是否加载完成
|
||||
let hasNext = true;
|
||||
if (res.rows.length < data.pageSize || this.deviceList.length >= this
|
||||
.total) {
|
||||
hasNext = false;
|
||||
} else {
|
||||
hasNext = true;
|
||||
}
|
||||
this.mescroll.endSuccess(res.rows.length, hasNext);
|
||||
} else {
|
||||
this.mescroll.endSuccess(0, false);
|
||||
}
|
||||
}).finally(() => {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
clearTimeout(timeout);
|
||||
//防止下拉刷新的同时会调用一次上拉加载的问题
|
||||
timeout = setTimeout(task, 50);
|
||||
|
||||
},
|
||||
prevPage() {
|
||||
uni.navigateBack({
|
||||
|
||||
});
|
||||
},
|
||||
handleRightClick(s, e) {
|
||||
|
||||
if (s === 0) {
|
||||
|
||||
} else if (s === 1) {
|
||||
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.maincontent {
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.listContent {
|
||||
height: calc(100% - 270rpx);
|
||||
transform: translateY(20rpx);
|
||||
}
|
||||
|
||||
.listItem {
|
||||
width: 100%;
|
||||
min-height: 140rpx;
|
||||
box-sizing: border-box;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.swipBtn {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-wrap: wrap;
|
||||
align-content: center;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.uni-swipe .icon,
|
||||
/deep/ .uni-swipe .icon {
|
||||
width: 35rpx;
|
||||
height: 35rpx;
|
||||
}
|
||||
|
||||
.uni-swipe .txt,
|
||||
/deep/ .uni-swipe .txt {
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
|
||||
font-family: "PingFang SC";
|
||||
font-style: Regular;
|
||||
font-size: 24rpx;
|
||||
font-weight: 400;
|
||||
|
||||
letter-spacing: 0.14rpx;
|
||||
|
||||
}
|
||||
|
||||
.uni-swipe,
|
||||
/deep/ .uni-swipe {
|
||||
margin-bottom: 20rpx;
|
||||
border-radius: 16rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.tab-bar-wrap {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
margin-top: 90rpx;
|
||||
height: 66rpx;
|
||||
}
|
||||
|
||||
.tab-bar {
|
||||
width: 100%;
|
||||
color: rgb(255, 255, 255);
|
||||
white-space: nowrap;
|
||||
/* 禁止换行 */
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
|
||||
}
|
||||
|
||||
.tab-container {
|
||||
display: flex;
|
||||
cursor: pointer;
|
||||
align-items: center;
|
||||
padding-right: 80rpx;
|
||||
/* 预留更多按钮空间 */
|
||||
}
|
||||
|
||||
.tab-item {
|
||||
font-size: 28rpx;
|
||||
padding: 0 30rpx;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.tab-item.active {
|
||||
color: #bbe600;
|
||||
|
||||
height: 66rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.tab-item.active::before {
|
||||
content: "";
|
||||
background-color: #bbe600;
|
||||
position: absolute;
|
||||
top: 90%;
|
||||
left: 35%;
|
||||
width: 30%;
|
||||
height: 6rpx;
|
||||
border-radius: 6rpx;
|
||||
}
|
||||
|
||||
.tab-more {
|
||||
margin-left: 10rpx;
|
||||
/* 与Tab的间距 */
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: linear-gradient(-88.60deg, rgba(18, 18, 18, 1), rgba(18, 18, 18, 0) 100%);
|
||||
height: 66rpx;
|
||||
}
|
||||
|
||||
.more {
|
||||
width: 30rpx;
|
||||
height: 30rpx;
|
||||
margin-top: 5rpx;
|
||||
}
|
||||
|
||||
.listItem .opt {
|
||||
width: 70rpx;
|
||||
height: 210rpx;
|
||||
|
||||
}
|
||||
|
||||
.listItem .opt .checkbox {
|
||||
width: 35rpx;
|
||||
height: 35rpx;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid rgba(255, 255, 255, 0.4);
|
||||
border-radius: 8rpx;
|
||||
background-color: #00000000;
|
||||
}
|
||||
|
||||
.listItem .opt .checkbox .icon {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.listItem .opt .checkbox.active {
|
||||
background-color: #AED600 !important;
|
||||
}
|
||||
|
||||
.listItem .opt .checkbox.active .icon {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.listItem .main {
|
||||
width: calc(100% - 70rpx);
|
||||
height: 210rpx;
|
||||
}
|
||||
|
||||
.device-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 15rpx;
|
||||
padding: 30rpx 0 10rpx 30rpx;
|
||||
background: rgba(26, 26, 26, 1);
|
||||
}
|
||||
|
||||
.device-name {
|
||||
font-size: 32rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
margin-left: 24rpx;
|
||||
line-height: 50rpx;
|
||||
width: 75%;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.ID {
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
font-size: 26rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
position: relative;
|
||||
|
||||
}
|
||||
|
||||
.deviceIMG {
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
border-radius: 16rpx;
|
||||
position: relative;
|
||||
background-color: rgba(42, 42, 42, 0.6);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.p10 {
|
||||
padding-left: 20rpx;
|
||||
}
|
||||
|
||||
.splitLine {
|
||||
background: linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(255, 255, 255, 1) 44.525%, rgba(255, 254.75, 254.75, 0) 92%);
|
||||
opacity: 0.2;
|
||||
width: 4rpx;
|
||||
height: 25rpx;
|
||||
margin: 0rpx 20rpx;
|
||||
}
|
||||
|
||||
.disc {
|
||||
padding: 5rpx 10rpx;
|
||||
margin-right: -30rpx;
|
||||
}
|
||||
|
||||
.disc.active {
|
||||
background-color: #2a2a2a !important;
|
||||
;
|
||||
}
|
||||
|
||||
.discImg {
|
||||
width: 24rpx;
|
||||
height: 24rpx;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
|
||||
.IMG {
|
||||
width: 68rpx;
|
||||
height: 50rpx;
|
||||
margin-left: 17%;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.device-callpolice {
|
||||
width: 122rpx;
|
||||
height: 52rpx;
|
||||
font-size: 24rpx;
|
||||
border-radius: 0px 8px 0px 8px;
|
||||
background-color: rgba(224, 52, 52, 1);
|
||||
position: absolute;
|
||||
top: 0rpx;
|
||||
right: -4rpx;
|
||||
text-align: center;
|
||||
line-height: 52rpx;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.device-status {
|
||||
width: 122rpx;
|
||||
height: 52rpx;
|
||||
font-size: 26rpx;
|
||||
border-radius: 0px 8px 0px 8px;
|
||||
background-color: rgb(42, 42, 42);
|
||||
position: absolute;
|
||||
top: 0rpx;
|
||||
right: 0rpx;
|
||||
text-align: center;
|
||||
line-height: 52rpx;
|
||||
}
|
||||
|
||||
.online {
|
||||
color: rgb(187, 230, 0);
|
||||
}
|
||||
|
||||
.unline {
|
||||
color: rgba(255, 255, 255, 0.4);
|
||||
}
|
||||
|
||||
.btnOK.active {
|
||||
background: rgba(187, 230, 0, 1) !important;
|
||||
color: rgba(35, 35, 35, 1) !important;
|
||||
}
|
||||
|
||||
.btnOK {
|
||||
/* 矩形 7 */
|
||||
width: 80%;
|
||||
height: 90rpx;
|
||||
line-height: 90rpx;
|
||||
border-radius: 90rpx;
|
||||
text-align: center;
|
||||
color: rgba(255, 255, 255, 0.4);
|
||||
background: rgba(26, 26, 26, 1);
|
||||
font-family: "PingFang SC";
|
||||
font-style: Bold;
|
||||
font-size: 28rpx;
|
||||
font-weight: 400;
|
||||
box-shadow: 0px 0px 2px 0px rgb(255 255 255 / 30%);
|
||||
position: fixed;
|
||||
z-index: 1;
|
||||
bottom: 50rpx;
|
||||
left: 10%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.searchRow {
|
||||
width: 100%;
|
||||
height: 70rpx;
|
||||
margin-top: 90rpx;
|
||||
|
||||
}
|
||||
|
||||
|
||||
.searchRow .ipt {
|
||||
width: calc(100% - 80rpx);
|
||||
height: 100%;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.searchRow .btn {
|
||||
width: 80rpx;
|
||||
height: 100%;
|
||||
line-height: 70rpx;
|
||||
text-align: right;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
font-family: "PingFang SC";
|
||||
font-style: Regular;
|
||||
font-size: 28rpx;
|
||||
font-weight: 400;
|
||||
letter-spacing: 0.14rpx;
|
||||
float: left;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/deep/ .uni-easyinput__content,
|
||||
.uni-easyinput__content {
|
||||
background-color: #1A1A1A !important;
|
||||
border-radius: 70rpx;
|
||||
color: #FFFFFF;
|
||||
text-indent: 10rpx;
|
||||
box-sizing: border-box;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
/deep/ .uni-textarea-placeholder,
|
||||
.uni-textarea-placeholder {
|
||||
color: rgba(255, 255, 255, 0.5);
|
||||
|
||||
font-family: "PingFang SC";
|
||||
font-style: Regular;
|
||||
font-size: 24rpx;
|
||||
font-weight: 400;
|
||||
letter-spacing: 0.14rpx;
|
||||
}
|
||||
</style>
|
||||
509
pages/common/linkDefence/defence.vue
Normal file
@ -0,0 +1,509 @@
|
||||
<template>
|
||||
<view class="maincontent contentBg">
|
||||
<uni-nav-bar :border="false" @clickLeft="prevPage" fixed="true" statusBar="true" background-color="#121212"
|
||||
color="#FFFFFF" :title="Status.navbar.title">
|
||||
<template v-slot:left>
|
||||
<view>
|
||||
<uni-icons type="left" size="24" color="#FFFFFF"></uni-icons>
|
||||
</view>
|
||||
</template>
|
||||
<block slot="right">
|
||||
<view class="navbarRight center">
|
||||
<image @click.stop="handleRightClick(index,item)" v-for="item,index in Status.navbar.icons"
|
||||
class="img" :src="item.src" mode="aspectFit"></image>
|
||||
</view>
|
||||
|
||||
</block>
|
||||
</uni-nav-bar>
|
||||
|
||||
|
||||
<view class="listContent">
|
||||
<mescroll-uni class="device-list" @init="mescrollInit" @down="downCallback" @up="upCallback" :up="upOption"
|
||||
:down="downOption" :fixed="false">
|
||||
|
||||
<uni-swipe-action>
|
||||
<uni-swipe-action-item v-for="item,index in deviceList" @click="onClick"
|
||||
@change="swipeChange($event, 0)" :autoClose="false">
|
||||
<view class="listItem" @click.stop="gotoDetail(item,index)">
|
||||
<view class="itemMain">
|
||||
|
||||
|
||||
<view class="title">{{item.name?item.name:'预警设防'+index}}</view>
|
||||
<view class="splitLine"></view>
|
||||
<view class="row">
|
||||
<view class="lbl">布防联机:{{item.total}}</view>
|
||||
<view class="lbl">接收设备:{{item.notify}}</view>
|
||||
</view>
|
||||
<view class="row">
|
||||
<view class="lbl">布防联机:{{item.sub}}</view>
|
||||
<view class="lbl">预警主机:{{item.warn}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<template v-slot:right>
|
||||
<view class="swipBtn" @click.stop="onClick(btn,i,item,index)"
|
||||
v-for="btn,i in Status.SwipOptions"
|
||||
:style="{'backgroundColor':btn.style.backgroundColor,'width':btn.style.width}">
|
||||
|
||||
<image :src="btn.style.icon" mode="aspectFit" class="icon"
|
||||
:style="{'filter':btn.style.filter}"></image>
|
||||
<text class="txt">{{btn.text}}</text>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
</uni-swipe-action-item>
|
||||
|
||||
</uni-swipe-action>
|
||||
|
||||
|
||||
</mescroll-uni>
|
||||
</view>
|
||||
|
||||
<global-loading ref="loading" />
|
||||
|
||||
<MsgBox ref="msgPop" />
|
||||
|
||||
<MsgBox ref="rename">
|
||||
<view class="renamePop center">
|
||||
<view class="lbl">设备名称</view>
|
||||
<input class="txt" v-model="cEdit.name" type="text" placeholder="输入名称" maxlength="20"
|
||||
placeholder-class="txtplace" />
|
||||
</view>
|
||||
</MsgBox>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import request, {
|
||||
baseURL
|
||||
} from '@/utils/request.js';
|
||||
import {
|
||||
showLoading,
|
||||
hideLoading,
|
||||
updateLoading
|
||||
} from '@/utils/loading.js';
|
||||
import {
|
||||
MsgSuccess,
|
||||
MsgError,
|
||||
MsgClose,
|
||||
MsgWarning,
|
||||
showPop,
|
||||
MsgInfo,
|
||||
MsgClear,
|
||||
MsgPrompt
|
||||
} from '@/utils/MsgPops.js';
|
||||
import Common from '@/utils/Common.js';
|
||||
|
||||
var timeout = null;
|
||||
var these = null;
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
Status: {
|
||||
navbar: {
|
||||
icons: [{
|
||||
src: '/static/images/common/add.png',
|
||||
type: 'add'
|
||||
}],
|
||||
title: '预警布防',
|
||||
showBack: true,
|
||||
height: 90
|
||||
},
|
||||
SwipOptions: [{
|
||||
type: "rename",
|
||||
text: '重命名',
|
||||
style: {
|
||||
backgroundColor: '#E09319',
|
||||
icon: '/static/images/common/rename.png',
|
||||
width: '120rpx', // 初始宽度
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'drop',
|
||||
text: '删除',
|
||||
style: {
|
||||
backgroundColor: 'rgb(240, 60, 60)',
|
||||
icon: '/static/images/common/dell.png',
|
||||
width: '120rpx', // 初始宽度
|
||||
filter: 'brightness(0) invert(0.87)'
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
mescroll: null,
|
||||
downOption: {
|
||||
auto: true,
|
||||
autoShowLoading: false,
|
||||
},
|
||||
upOption: {
|
||||
auto: false,
|
||||
noMoreSize: 0,
|
||||
offset: 10,
|
||||
isLock: false,
|
||||
empty: {
|
||||
tip: '暂无数据',
|
||||
hideScroll: false,
|
||||
icon: '/static/images/common/empty.png'
|
||||
},
|
||||
textNoMore: '没有更多数据了'
|
||||
},
|
||||
deviceList: [],
|
||||
cEdit: {
|
||||
id: null,
|
||||
name: null,
|
||||
total: null,
|
||||
notify: null,
|
||||
sub: null,
|
||||
warn: null
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.Status.navbar.height = uni.getSystemInfoSync().statusBarHeight + 44;
|
||||
},
|
||||
onLoad() {
|
||||
these = this;
|
||||
},
|
||||
methods: {
|
||||
ReName() {
|
||||
if (!this.cEdit.name) {
|
||||
MsgError('请输入名称', '', these, null, false);
|
||||
return;
|
||||
}
|
||||
let ok = () => {
|
||||
this.deviceList.find((v, i) => {
|
||||
if (v.id == this.cEdit.id) {
|
||||
this.$set(this.deviceList[i], "name", this.cEdit.name)
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
let url = '';
|
||||
if (url) {
|
||||
request({
|
||||
url: url,
|
||||
data: this.cEdit,
|
||||
method: 'update'
|
||||
}).then(res => {
|
||||
if (res && res.code == 200) {
|
||||
ok();
|
||||
}
|
||||
}).catch(ex => {
|
||||
MsgError(ex.msg, '', these);
|
||||
});
|
||||
} else {
|
||||
ok();
|
||||
}
|
||||
},
|
||||
onClick(btn, i, item, index) {
|
||||
if (btn.type == 'rename') {
|
||||
these.cEdit = Object.assign(these.cEdit, item);
|
||||
console.log("执行重命名");
|
||||
MsgPrompt(this, btn.type, this.ReName, false, true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (btn.type == 'drop') {
|
||||
console.log("执行删除");
|
||||
MsgError('删除后不可恢复,您确认删除"' + item.name + '"吗?', '确定', this, () => {
|
||||
this.deviceList.splice(index, 1);
|
||||
}, true);
|
||||
return;
|
||||
}
|
||||
},
|
||||
change(event) {
|
||||
console.log('改变事件', event);
|
||||
},
|
||||
swipeChange(e, index) {
|
||||
console.log('当前状态:' + e + ',下标:' + index)
|
||||
},
|
||||
gotoDetail(item, index) {
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/linkDefence/addDefence',
|
||||
success(res) {
|
||||
res.eventChannel.emit('detailData',{data:item})
|
||||
}
|
||||
});
|
||||
},
|
||||
mescrollInit(mescroll) {
|
||||
this.mescroll = mescroll;
|
||||
},
|
||||
// 下拉刷新
|
||||
downCallback() {
|
||||
|
||||
|
||||
if (this.mescroll) {
|
||||
this.mescroll.resetUpScroll(false);
|
||||
this.mescroll.scrollTo(0, 0);
|
||||
}
|
||||
this.getData();
|
||||
|
||||
|
||||
},
|
||||
// 上拉加载
|
||||
upCallback() {
|
||||
this.getData();
|
||||
},
|
||||
getData() {
|
||||
let task = () => {
|
||||
|
||||
let data = {
|
||||
pageNum: this.mescroll.num,
|
||||
pageSize: 10,
|
||||
}
|
||||
|
||||
if (!data.pageNum) {
|
||||
this.mescroll.endSuccess(0, false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
let result = (res) => {
|
||||
|
||||
// 分页处理
|
||||
if (data.pageNum === 1) {
|
||||
this.deviceList = res.rows;
|
||||
} else {
|
||||
this.deviceList = this.deviceList.concat(res.rows);
|
||||
}
|
||||
|
||||
let hasNext = true;
|
||||
|
||||
if (res.rows.length < data.pageSize || this.deviceList.length >= res.total) {
|
||||
|
||||
hasNext = false;
|
||||
} else {
|
||||
|
||||
hasNext = true;
|
||||
}
|
||||
this.mescroll.endSuccess(res.rows.length, hasNext);
|
||||
}
|
||||
let url = ''; //请求地址
|
||||
if (url) {
|
||||
request({
|
||||
url: url,
|
||||
data: data,
|
||||
method: 'GET'
|
||||
}).then((res) => {
|
||||
if (res.code == 200) {
|
||||
result(res);
|
||||
} else {
|
||||
this.mescroll.endSuccess(0, false);
|
||||
}
|
||||
}).catch(ex => {
|
||||
MsgError(ex.errMsg, '', this);
|
||||
this.mescroll.endSuccess(0, false);
|
||||
});
|
||||
} else {
|
||||
if (data.pageNum === 1) {
|
||||
//开发时做假数据模拟成功
|
||||
MsgWarning("这是测试数据,非真实场景,真实功能敬请期待", '', this, true, null, false);
|
||||
}
|
||||
let res = {
|
||||
code: 200,
|
||||
total: 108,
|
||||
rows: []
|
||||
};
|
||||
let currLen = this.deviceList.length;
|
||||
|
||||
for (let i = 0; i < data.pageSize; i++) {
|
||||
if (currLen + i + 1 >= res.total) {
|
||||
break;
|
||||
}
|
||||
let json = {
|
||||
id: Common.guid(),
|
||||
name: '预警设防 ' + (i + (data.pageNum - 1) * data.pageSize + 1),
|
||||
total: (Math.random() * 100).toFixed(0),
|
||||
notify: (Math.random() * 100).toFixed(0),
|
||||
sub: (Math.random() * 100).toFixed(0),
|
||||
warn: (Math.random() * 100).toFixed(0)
|
||||
};
|
||||
res.rows.push(json);
|
||||
}
|
||||
result(res);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(task, 50);
|
||||
|
||||
},
|
||||
prevPage() {
|
||||
uni.navigateBack({
|
||||
|
||||
});
|
||||
},
|
||||
handleRightClick(s, e) {
|
||||
|
||||
if (s === 0) {
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/linkDefence/addDefence'
|
||||
})
|
||||
} else if (s === 1) {
|
||||
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.maincontent {
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.listContent {
|
||||
height: calc(100% - 90rpx);
|
||||
margin-top: 90rpx;
|
||||
}
|
||||
|
||||
.listItem {
|
||||
|
||||
|
||||
background: rgba(26, 26, 26, 1);
|
||||
width: 100%;
|
||||
min-height: 140rpx;
|
||||
height: auto;
|
||||
|
||||
box-sizing: border-box;
|
||||
padding: 20rpx 30rpx;
|
||||
}
|
||||
|
||||
.listItem .itemMain {
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.listItem .title {
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
|
||||
font-family: "PingFang SC";
|
||||
|
||||
font-size: 32rpx;
|
||||
font-weight: 400;
|
||||
|
||||
letter-spacing: 0.14rpx;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.listItem .splitLine {
|
||||
border-bottom: 1rpx solid rgba(255, 255, 255, 1);
|
||||
width: 10000px;
|
||||
height: 0rpx;
|
||||
margin-top: 15rpx;
|
||||
margin-bottom: 15rpx;
|
||||
transform: scale(0.1);
|
||||
margin-left: -5000px;
|
||||
}
|
||||
|
||||
.listItem .row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
align-content: center;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 15rpx;
|
||||
|
||||
color: rgba(255, 255, 255, 1);
|
||||
|
||||
font-family: "PingFang SC";
|
||||
font-style: Regular;
|
||||
font-size: 24rpx;
|
||||
font-weight: 200;
|
||||
|
||||
letter-spacing: 0.07px;
|
||||
|
||||
}
|
||||
|
||||
/* .listItem .row .lbl{
|
||||
padding: 0rpx 30rpx 0rpx 0rpx;
|
||||
text-align: left;
|
||||
} */
|
||||
.listItem .row:last-of-type {
|
||||
margin-bottom: 0rpx;
|
||||
}
|
||||
|
||||
.swipBtn {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-wrap: wrap;
|
||||
align-content: center;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.uni-swipe .icon,
|
||||
/deep/ .uni-swipe .icon {
|
||||
width: 35rpx;
|
||||
height: 35rpx;
|
||||
}
|
||||
|
||||
.uni-swipe .txt,
|
||||
/deep/ .uni-swipe .txt {
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
|
||||
font-family: "PingFang SC";
|
||||
font-style: Regular;
|
||||
font-size: 24rpx;
|
||||
font-weight: 400;
|
||||
|
||||
letter-spacing: 0.14rpx;
|
||||
|
||||
}
|
||||
|
||||
.uni-swipe,
|
||||
/deep/ .uni-swipe {
|
||||
margin-bottom: 20rpx;
|
||||
border-radius: 16rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.renamePop {
|
||||
width: 100%;
|
||||
height: 80rpx;
|
||||
padding: 60rpx 0rpx 30rpx 0rpx;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.renamePop .lbl {
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
font-family: "PingFang SC";
|
||||
font-style: Regular;
|
||||
font-size: 26rpx;
|
||||
letter-spacing: 0.14rpx;
|
||||
width: auto;
|
||||
padding: 0rpx 10rpx 0rpx 0rpx;
|
||||
}
|
||||
|
||||
.renamePop .txt {
|
||||
flex: 1;
|
||||
height: 60rpx;
|
||||
box-sizing: border-box;
|
||||
border: 1rpx solid rgba(255, 255, 255, 0.4);
|
||||
border-radius: 8rpx;
|
||||
text-align: left;
|
||||
text-indent: 10rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
|
||||
font-family: "PingFang SC";
|
||||
|
||||
font-size: 28rpx;
|
||||
|
||||
letter-spacing: 0.14rpx;
|
||||
|
||||
}
|
||||
|
||||
.txtplace {
|
||||
color: rgba(255, 255, 255, 0.43);
|
||||
|
||||
font-family: "PingFang SC";
|
||||
|
||||
font-size: 26rpx;
|
||||
}
|
||||
</style>
|
||||
@ -68,6 +68,8 @@
|
||||
login,
|
||||
resourceSmsCode
|
||||
} from '@/api/common/login.js';
|
||||
import mqplus from '@/utils/MqPlus.js';
|
||||
var mqcommon=null;
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@ -85,6 +87,7 @@
|
||||
},
|
||||
onLoad() {
|
||||
this.phone= uni.getStorageSync('phone');
|
||||
mqcommon=mqplus.getMqPlus();
|
||||
if (uni.getStorageSync("token") && uni.getStorageSync("clientID")) { //免登陆
|
||||
let time = uni.getStorageSync("tokenTime");
|
||||
if (!time) {
|
||||
@ -258,10 +261,14 @@
|
||||
uni.showToast({
|
||||
title: '登录成功',
|
||||
icon: 'success'
|
||||
})
|
||||
});
|
||||
|
||||
uni.switchTab({
|
||||
url: '/pages/common/index/index'
|
||||
})
|
||||
});
|
||||
if(mqcommon){
|
||||
mqcommon.sendUsrLogin();
|
||||
}
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg || '服务器异常,请稍后重试',
|
||||
@ -294,8 +301,9 @@
|
||||
},
|
||||
// 同意
|
||||
handleAgree() {
|
||||
this.isChecked = !this.isChecked
|
||||
this.showAgreement = false
|
||||
this.isChecked = !this.isChecked;
|
||||
this.showAgreement = false;
|
||||
this.handleLogin();
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@ -1,6 +1,22 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<map class="map" :latitude="latitude" :longitude="longitude" :markers="covers" @markertap="onMarkerTap"
|
||||
<uni-nav-bar :border="false" @clickLeft="prevPage" fixed="true" statusBar="true" background-color="#121212"
|
||||
color="#FFFFFF" :title="Status.navbar.title">
|
||||
<template v-slot:left>
|
||||
<view>
|
||||
<uni-icons type="left" size="24" color="#FFFFFF"></uni-icons>
|
||||
</view>
|
||||
</template>
|
||||
<block slot="right">
|
||||
<view class="navbarRight center">
|
||||
<image @click.stop="handleRightClick(index,item)" v-for="item,index in Status.navbar.icons"
|
||||
class="img" :src="item.src" mode="aspectFit"></image>
|
||||
</view>
|
||||
|
||||
</block>
|
||||
</uni-nav-bar>
|
||||
|
||||
<map id="map" ref="map" class="map" :latitude="latitude" :longitude="longitude" :markers="covers" @markertap="onMarkerTap"
|
||||
:scale="16"></map>
|
||||
|
||||
<!-- 加载提示 -->
|
||||
@ -13,6 +29,7 @@
|
||||
|
||||
<script>
|
||||
import Common from "@/utils/Common.js";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@ -79,6 +96,17 @@
|
||||
showMask: true,
|
||||
maskBgColor: '#00000066',
|
||||
showClose: false
|
||||
},
|
||||
navbar: {
|
||||
icons: [
|
||||
// {
|
||||
// type:'msg',
|
||||
// src: '/static/images/common/guiji.png'
|
||||
// }
|
||||
],
|
||||
title: '查看位置',
|
||||
showBack: true,
|
||||
height: 90
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,9 +141,20 @@
|
||||
this.loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
prevPage() {
|
||||
uni.navigateBack({
|
||||
|
||||
});
|
||||
},
|
||||
handleRightClick: function(s, e) {
|
||||
|
||||
console.log("敬请期待");
|
||||
},
|
||||
showAction() {
|
||||
|
||||
let gd=plus.runtime.isApplicationExist({
|
||||
@ -277,4 +316,22 @@
|
||||
background-color: rgba(0, 0, 0, 0.7);
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.img {
|
||||
width: 35rpx;
|
||||
height: 35rpx;
|
||||
margin-right: 30rpx;
|
||||
}
|
||||
|
||||
.uni-navbar--fixed {
|
||||
top: 0rpx;
|
||||
}
|
||||
|
||||
.uni-navbar--fixed {
|
||||
top: 0px;
|
||||
}
|
||||
|
||||
.uni-navbar__placeholder {
|
||||
display: none !important;
|
||||
}
|
||||
</style>
|
||||
@ -53,8 +53,11 @@
|
||||
MsgPrompt
|
||||
} from '@/utils/MsgPops.js'
|
||||
import Common from '@/utils/Common.js';
|
||||
import api from '@/api/670/HBY670.js';
|
||||
|
||||
var these = null;
|
||||
var eventChannel = null;
|
||||
import {deviceInfo} from '@/api/common/index.js'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@ -86,7 +89,9 @@
|
||||
longitude: null,
|
||||
alarmStatus: null,
|
||||
detailPageUrl: "/pages/650/HBY650",
|
||||
showConfirm: false
|
||||
showConfirm: false,
|
||||
contact1Phone:null,
|
||||
contact2Phone:null
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -125,14 +130,41 @@
|
||||
console.log("收到父页面的参数:" + JSON.stringify(data));
|
||||
these.device = data;
|
||||
|
||||
this.list[0] = data.contact1Phone;
|
||||
this.list[1] = data.contact2Phone;
|
||||
|
||||
|
||||
this.init();
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
methods: {
|
||||
init(){
|
||||
api.getDetail(this.device.id).then(res => {
|
||||
|
||||
if (res && res.code == 200) {
|
||||
let data = res.data;
|
||||
if(data.length){
|
||||
data=data[0];
|
||||
}
|
||||
let keys = Object.keys(data);
|
||||
let dKeys = Object.keys(this.device);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
let key = keys[i];
|
||||
|
||||
let dk = dKeys.find(k => {
|
||||
return key.toLowerCase() == k.toLowerCase();
|
||||
});
|
||||
if (dk) {
|
||||
this.$set(this.device, dk, data[key]);
|
||||
} else {
|
||||
this.$set(this.device, key, data[key]);
|
||||
}
|
||||
}
|
||||
|
||||
this.list[0] = data.contact1Phone;
|
||||
this.list[1] = data.contact2Phone;
|
||||
}
|
||||
});
|
||||
},
|
||||
notifyPrevPage(){//通知上一个页面
|
||||
if (eventChannel) {
|
||||
eventChannel.emit('linkManOver', this.list);
|
||||
@ -231,9 +263,7 @@
|
||||
|
||||
let requestCall = () => {
|
||||
|
||||
this.$set(this.list, this.cEdit.index, this.cEdit.txt)
|
||||
|
||||
|
||||
this.$set(this.list, this.cEdit.index, this.cEdit.txt)
|
||||
this.cEdit.txt = "";
|
||||
this.cEdit.index = -1;
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
MsgInfo
|
||||
} from '@/utils/MsgPops.js'
|
||||
import Common from '@/utils/Common.js';
|
||||
|
||||
import api from '@/api/670/HBY670.js';
|
||||
|
||||
var these = null;
|
||||
var eventChannel = null;
|
||||
@ -67,7 +67,8 @@
|
||||
longitude: null,
|
||||
alarmStatus: null,
|
||||
detailPageUrl: "",
|
||||
showConfirm: false
|
||||
showConfirm: false,
|
||||
sosSmsMsg:null
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -101,11 +102,24 @@
|
||||
if(data.sosSmsMsg){
|
||||
this.txt=data.sosSmsMsg;
|
||||
}
|
||||
this.init();
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
methods: {
|
||||
init(){
|
||||
api.getDetail(this.device.id).then(res => {
|
||||
|
||||
if (res && res.code == 200) {
|
||||
let data = res.data;
|
||||
if(data.length){
|
||||
data=data[0];
|
||||
}
|
||||
this.txt=data.sosSmsMsg;
|
||||
}
|
||||
});
|
||||
},
|
||||
copyTo(item, index) {
|
||||
this.txt = item;
|
||||
},
|
||||
|
||||
@ -27,6 +27,12 @@
|
||||
<text class="title">版本更新 ({{appVersion}})</text>
|
||||
<uni-icons type="right" size="25" color="rgba(255, 255, 255, 0.4)" class="uniIcon"></uni-icons>
|
||||
</view>
|
||||
<view class="menu-item" @click="clearCatch">
|
||||
<image src="/static/images/common/clear.png" class="icon"></image>
|
||||
<text class="title">清理缓存</text>
|
||||
<uni-icons type="right" size="25" color="rgba(255, 255, 255, 0.4)" class="uniIcon"></uni-icons>
|
||||
</view>
|
||||
|
||||
<view class="menu-item" @click="sendCounsel">
|
||||
<image src="/static/images/common/yijianfankui.png" class="icon"></image>
|
||||
<text class="title">举报反馈</text>
|
||||
@ -37,16 +43,11 @@
|
||||
<text class="title">关于我们</text>
|
||||
<uni-icons type="right" size="25" color="rgba(255, 255, 255, 0.4)" class="uniIcon"></uni-icons>
|
||||
</view>
|
||||
<!-- <view class="menu-item" @click="logOff">
|
||||
<image src="/static/images/common/zhuxiao.png" class="icon"></image>
|
||||
<text class="title">注销账号</text>
|
||||
<uni-icons type="right" size="25" color="rgba(255, 255, 255, 0.4)" class="uniIcon"></uni-icons>
|
||||
</view> -->
|
||||
<view class="menu-item" @click="account">
|
||||
<image src="/static/images/common/wm.png" class="icon"></image>
|
||||
<text class="title">账号</text>
|
||||
<uni-icons type="right" size="25" color="rgba(255, 255, 255, 0.4)" class="uniIcon"></uni-icons>
|
||||
</view>
|
||||
<view class="menu-item" @click="account">
|
||||
<image src="/static/images/common/wm.png" class="icon"></image>
|
||||
<text class="title">账号</text>
|
||||
<uni-icons type="right" size="25" color="rgba(255, 255, 255, 0.4)" class="uniIcon"></uni-icons>
|
||||
</view>
|
||||
<view class="btn_footer">
|
||||
<button class="logout" @click="logout">退出登录</button>
|
||||
</view>
|
||||
@ -69,6 +70,8 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<MsgBox ref="msgPop" />
|
||||
</view>
|
||||
|
||||
</template>
|
||||
@ -78,6 +81,15 @@
|
||||
Logout
|
||||
} from '@/api/common/login.js'
|
||||
import bleTool from '@/utils/BleHelper.js';
|
||||
import {
|
||||
MsgSuccess,
|
||||
MsgError,
|
||||
MsgClose,
|
||||
MsgWarning,
|
||||
showPop,
|
||||
MsgInfo,
|
||||
MsgClear
|
||||
} from '@/utils/MsgPops.js'
|
||||
var ble=null;
|
||||
export default {
|
||||
data() {
|
||||
@ -106,6 +118,32 @@
|
||||
|
||||
},
|
||||
methods: {
|
||||
clearCatch(){
|
||||
MsgWarning("将清除以下缓存数据:设备配对、网络缓存、音频、视频,清除后下次使用将重新加载,您确认清除?",'确定',this,true,()=>{
|
||||
let store = uni.getStorageInfoSync();
|
||||
store.keys.forEach((val, index, array) => {
|
||||
if (val == "linkedDevices") {
|
||||
//设备配对只保留已连接的数据
|
||||
if(ble){
|
||||
let linked=ble.data.LinkedList.filter((v,i)=>{
|
||||
return v.Linked;
|
||||
});
|
||||
|
||||
ble.data.LinkedList=linked;
|
||||
ble.updateCache();
|
||||
}
|
||||
|
||||
} else if (val == "tokenTime" || val == "token" || val == "clientID" || val == 'phone') {
|
||||
console.log("忽略登陆信息");
|
||||
} else {
|
||||
uni.removeStorageSync(val);
|
||||
}
|
||||
});
|
||||
|
||||
MsgSuccess("清理成功",'',this);
|
||||
},true);
|
||||
|
||||
},
|
||||
//版本更新
|
||||
gotoAppStore(){
|
||||
let os=uni.getSystemInfoSync().platform;
|
||||
@ -196,6 +234,7 @@
|
||||
url: '/pages/common/account/index'
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
Before Width: | Height: | Size: 867 B |
BIN
static/images/common/clear.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
static/images/common/defence.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
static/images/common/disc.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
static/images/common/guiji.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
static/images/common/rename.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
static/images/common/search.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 471 B After Width: | Height: | Size: 867 B |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 612 B After Width: | Height: | Size: 1.9 KiB |
BIN
static/images/lightImg/qiangActive.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
static/images/lightImg/rb.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
static/images/lightImg/rbActive.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 813 B After Width: | Height: | Size: 1.5 KiB |
BIN
static/images/lightImg/workActive.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
1
uniCloud-aliyun/database/JqUsrClient.schema.json
Normal file
@ -0,0 +1 @@
|
||||
{"bsonType":"object","required":[],"permission":{"read":false,"create":false,"update":false,"delete":false},"properties":{"_id":{"description":"ID,系统自动生成"},"phone":{"bsonType":"string","description":"手机号"},"cid":{"bsonType":"string","description":"推送号"}}}
|
||||
@ -73,15 +73,15 @@ class BleHelper {
|
||||
},
|
||||
{
|
||||
key: '10001',
|
||||
remark: '当前蓝牙适配器不可用'
|
||||
remark: '当前蓝牙适配器不可用,请打开手机蓝牙'
|
||||
},
|
||||
{
|
||||
key: '10002',
|
||||
remark: '没有找到指定设备'
|
||||
remark: '没有找到指定设备,设备不在信号范围或被他人连接'
|
||||
},
|
||||
{
|
||||
key: '10003',
|
||||
remark: '蓝牙设备连接失败'
|
||||
remark: '蓝牙设备连接失败,请重试'
|
||||
},
|
||||
{
|
||||
key: '10004',
|
||||
@ -101,7 +101,7 @@ class BleHelper {
|
||||
},
|
||||
{
|
||||
key: '10008',
|
||||
remark: '其余所有系统上报的异常'
|
||||
remark: '系统错误,请重试'
|
||||
},
|
||||
{
|
||||
key: '10009',
|
||||
@ -122,7 +122,7 @@ class BleHelper {
|
||||
{
|
||||
key: '10013',
|
||||
remark: '连接 deviceId 为空或者是格式不正确'
|
||||
},
|
||||
},
|
||||
{
|
||||
key: '10016',
|
||||
remark: '定位服务已关闭'
|
||||
@ -1667,7 +1667,7 @@ class BleHelper {
|
||||
console.log("当前已连接,释放连接锁");
|
||||
delete this.data.connectingDevices[deviceId];
|
||||
resolve(false);
|
||||
LinkedCallback();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1689,7 +1689,7 @@ class BleHelper {
|
||||
|
||||
delete this.data.connectingDevices[deviceId];
|
||||
console.error("新连接成功释放连接锁", deviceId);
|
||||
LinkedCallback();
|
||||
|
||||
// 处理 MTU 设置
|
||||
if (plus.os.name === 'Android') {
|
||||
this.setMtu(deviceId).catch(ex => {
|
||||
@ -1703,6 +1703,7 @@ class BleHelper {
|
||||
if (c.deviceId == deviceId) {
|
||||
c.Linked = true;
|
||||
c.linkId = linkId
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -1710,8 +1711,9 @@ class BleHelper {
|
||||
|
||||
if (fIndex > -1) {
|
||||
this.data.LinkedList[fIndex].Linked = true;
|
||||
this.data.LinkedList[fIndex].linkId =
|
||||
linkId;
|
||||
this.data.LinkedList[fIndex].linkId =linkId;
|
||||
this.data.LinkedList[fIndex].name =cr.name;
|
||||
this.data.LinkedList[fIndex].advertisData =cr.advertisData;
|
||||
} else {
|
||||
this.data.LinkedList.push(cr);
|
||||
}
|
||||
@ -1725,12 +1727,7 @@ class BleHelper {
|
||||
return true;
|
||||
}
|
||||
})
|
||||
// console.log("LinkedList=", this.data
|
||||
// .LinkedList);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
resolve(true);
|
||||
|
||||
}).catch((ex) => {
|
||||
@ -1738,6 +1735,12 @@ class BleHelper {
|
||||
});
|
||||
},
|
||||
fail: (ex) => {
|
||||
if(ex.code===10010){
|
||||
console.log("设备已连接,无需重复连接");
|
||||
delete this.data.connectingDevices[deviceId];
|
||||
resolve(true);
|
||||
return;
|
||||
}
|
||||
ex = this.getError(ex);
|
||||
console.error("蓝牙" + deviceId + "连接失败" + JSON.stringify(
|
||||
ex));
|
||||
@ -1772,7 +1775,7 @@ class BleHelper {
|
||||
console.log("2222222");
|
||||
return linkDevice(deviceId);
|
||||
}).then((res) => {
|
||||
|
||||
LinkedCallback();
|
||||
if (res) { //新连接(含 createBLEConnection 刚成功)
|
||||
// console.log("11111111");
|
||||
if (fIndex == -1) {
|
||||
@ -1780,11 +1783,19 @@ class BleHelper {
|
||||
return this.getService(deviceId, targetServiceId, writeCharId,
|
||||
notifyCharId); //获取服务
|
||||
} else {
|
||||
// 设备已在 LinkedList(例如缓存/重连):不能仅用缓存的 write/notify UUID 直接订阅。
|
||||
// 重连后须先 getBLEDeviceServices,否则部分机型 notifyBLECharacteristicValueChange 报 no service(10004),notify 收不到任何数据。
|
||||
console.log("已缓存设备重新连接,重新发现服务并订阅", deviceId);
|
||||
return this.getService(deviceId, targetServiceId, writeCharId,
|
||||
notifyCharId);
|
||||
if (f.wirteCharactId && f.notifyCharactId) {
|
||||
if (!f.notifyState) {
|
||||
// console.log("开始订阅特征");
|
||||
this.subScribe(deviceId, true);
|
||||
} else {
|
||||
console.log("不订阅消息");
|
||||
}
|
||||
return Promise.resolve(true);
|
||||
} else {
|
||||
console.log("开始获取服务", targetServiceId)
|
||||
return this.getService(deviceId, targetServiceId, writeCharId,
|
||||
notifyCharId);
|
||||
}
|
||||
}
|
||||
} else { //已连接过,直接订阅消息
|
||||
// console.log("11111111");
|
||||
|
||||
@ -11,12 +11,15 @@ import {
|
||||
MsgClear,
|
||||
MsgInfo
|
||||
} from '@/utils/MsgPops.js';
|
||||
import MqPlus from '@/utils/MqPlus.js';
|
||||
|
||||
var mqcommon = null;
|
||||
const homePath = 'pages/common/index'
|
||||
class BleReceive {
|
||||
constructor(_ref) {
|
||||
if(_ref && !this.ref){
|
||||
this.ref = _ref;
|
||||
}
|
||||
if (_ref && !this.ref) {
|
||||
this.ref = _ref;
|
||||
}
|
||||
this.StorageKey = "linkedDevices";
|
||||
this.HandlerMap = {
|
||||
'/pages/6155/deviceDetail': this.Receive_6155.bind(this),
|
||||
@ -30,10 +33,10 @@ class BleReceive {
|
||||
'/pages/6170/deviceControl/index': this.Receive_6170.bind(this),
|
||||
'/pages/100J/HBY100-J': this.Receive_100J.bind(this),
|
||||
'/pages/6075J/BJQ6075J': this.Receive_6075.bind(this),
|
||||
'/pages/210/HBY210':this.Receive_210.bind(this),
|
||||
'/pages/018A/HBY018A':this.Receive_018A.bind(this)
|
||||
'/pages/210/HBY210': this.Receive_210.bind(this),
|
||||
'/pages/018A/HBY018A': this.Receive_018A.bind(this)
|
||||
};
|
||||
|
||||
mqcommon = MqPlus.getMqPlus();
|
||||
}
|
||||
|
||||
|
||||
@ -213,7 +216,7 @@ class BleReceive {
|
||||
msg.push("设备'" + f.device.deviceName + "'环境存在漏电电源");
|
||||
}
|
||||
|
||||
if (this.ref && msg.length>0) {
|
||||
if (this.ref && msg.length > 0) {
|
||||
if (msg.length > 0) {
|
||||
msg = msg.join(',');
|
||||
MsgError("'" + f.device.deviceName + "'环境存在漏电电源", '', this.ref, () => {
|
||||
@ -222,8 +225,6 @@ class BleReceive {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return formData;
|
||||
} catch (error) {
|
||||
@ -289,6 +290,13 @@ class BleReceive {
|
||||
|
||||
let data = parseData(receive.bytes);
|
||||
console.log("data=", data);
|
||||
if (f && f.device && mqcommon && path == homePath) {
|
||||
if (data.battary) {
|
||||
mqcommon.sendCharge(f.device.id, 1, data.battary);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
}
|
||||
@ -373,7 +381,7 @@ class BleReceive {
|
||||
msgs.push("静止报警中");
|
||||
}
|
||||
if (receiveData.battary <= 20) {
|
||||
msg.push("设备'" + f.device.deviceName + "'电量低");
|
||||
msgs.push("设备'" + f.device.deviceName + "'电量低");
|
||||
}
|
||||
if (msgs.length > 0) {
|
||||
msgs = msgs.join(";");
|
||||
@ -461,7 +469,9 @@ class BleReceive {
|
||||
|
||||
|
||||
let data = todo(receive.bytes);
|
||||
|
||||
if (f && f.device && mqcommon && path == homePath) {
|
||||
mqcommon.sendCharge(f.device.id, 1);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
@ -503,11 +513,18 @@ class BleReceive {
|
||||
|
||||
|
||||
//充电状态
|
||||
let chargeType = 1;
|
||||
let warn = bytes[5];
|
||||
if (warn == 0x00) {
|
||||
warn = '未充电';
|
||||
chargeType = 1;
|
||||
} else if (warn == 0x01) {
|
||||
warn = '充电中';
|
||||
chargeType = 0;
|
||||
}
|
||||
|
||||
if (f && f.device && mqcommon && path == homePath) {
|
||||
mqcommon.sendCharge(f.device.id, chargeType);
|
||||
}
|
||||
|
||||
// 解析剩余照明时间(第三和第四字节,小端序)
|
||||
@ -604,13 +621,17 @@ class BleReceive {
|
||||
|
||||
|
||||
//充电状态
|
||||
let chargeType = 1;
|
||||
let warn = bytes[5];
|
||||
if (warn == 0x00) {
|
||||
warn = '未充电';
|
||||
} else if (warn == 0x01) {
|
||||
warn = '充电中';
|
||||
chargeType = 0;
|
||||
}
|
||||
if (f && f.device && mqcommon && path == homePath) {
|
||||
mqcommon.sendCharge(f.device.id, chargeType);
|
||||
}
|
||||
|
||||
// 解析剩余照明时间(第三和第四字节,小端序)
|
||||
let lightingTime = "";
|
||||
let HH = Math.max(0, Math.min(100, bytes[6]));
|
||||
@ -633,7 +654,7 @@ class BleReceive {
|
||||
|
||||
|
||||
});
|
||||
console.log("formData=",formData)
|
||||
console.log("formData=", formData)
|
||||
if (!recCnt) {
|
||||
console.log("11111");
|
||||
if (formData.battary <= 20 && bytes[5] == 0x00) {
|
||||
@ -682,6 +703,10 @@ class BleReceive {
|
||||
} catch (error) {
|
||||
receiveData = {};
|
||||
console.log("文本解析失败", error)
|
||||
} finally {
|
||||
if (f && f.device && mqcommon && receiveData.sta_PowerPercent && path == homePath) {
|
||||
mqcommon.sendCharge(f.device.id, 1, receiveData.sta_PowerPercent);
|
||||
}
|
||||
}
|
||||
return receiveData;
|
||||
|
||||
@ -699,6 +724,14 @@ class BleReceive {
|
||||
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
|
||||
.replace(/\//g, "").toLowerCase();
|
||||
});
|
||||
let chargeType = 1;
|
||||
if (receiveData.sta_system == '1' || receiveData.sta_system == '3') {
|
||||
chargeType = 0;
|
||||
}
|
||||
if (f && f.device && mqcommon && path == homePath) {
|
||||
mqcommon.sendCharge(f.device.id, chargeType);
|
||||
}
|
||||
|
||||
if (!recCnt) {
|
||||
if (receiveData.sta_battery <= 20 && (receiveData.sta_system != '1' || receiveData.sta_system !=
|
||||
'3')) {
|
||||
@ -748,14 +781,16 @@ class BleReceive {
|
||||
// console.log("设备收到消息:", f);
|
||||
// console.log("消息内容:", receive);
|
||||
receiveData = JSON.parse(receive.str);
|
||||
let deviceState = receiveData.state;
|
||||
|
||||
let recCnt = recArr.find(v => {
|
||||
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
|
||||
.replace(/\//g, "").toLowerCase();
|
||||
});
|
||||
if (!recCnt) {
|
||||
let deviceState = receiveData.state;
|
||||
if (deviceState && deviceState instanceof Array) {
|
||||
|
||||
|
||||
if (deviceState && deviceState instanceof Array) {
|
||||
let recCnt = recArr.find(v => {
|
||||
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
|
||||
.replace(/\//g, "").toLowerCase();
|
||||
});
|
||||
if (!recCnt) {
|
||||
if (deviceState[0] == 12 && deviceState[3] <= 20 && deviceState[4] == 0) {
|
||||
if (this.ref) {
|
||||
MsgError("设备'" + f.device.deviceName + "'电量低", '', this.ref, () => {
|
||||
@ -764,14 +799,34 @@ class BleReceive {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (f && f.device && mqcommon && path == homePath) {
|
||||
if (deviceState[0] == 12) {
|
||||
let chargeType = 1;
|
||||
if (deviceState[4] == 0) {
|
||||
chargeType = 1;
|
||||
} else {
|
||||
chargeType = 0;
|
||||
}
|
||||
|
||||
mqcommon.sendCharge(f.device.id, chargeType);
|
||||
|
||||
} else {
|
||||
mqcommon.sendCharge(f.device.id, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} catch (error) {
|
||||
receiveData = {};
|
||||
console.error("文本解析失败", error)
|
||||
console.error("错误数据:",receive);
|
||||
console.error("错误数据:", receive);
|
||||
}
|
||||
return receiveData;
|
||||
|
||||
@ -790,6 +845,19 @@ class BleReceive {
|
||||
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
|
||||
.replace(/\//g, "").toLowerCase();
|
||||
});
|
||||
|
||||
|
||||
if (f && f.device && mqcommon && path == homePath) {
|
||||
let chargeType = 1;
|
||||
if (receiveData.sta_charge == 0) {
|
||||
chargeType = 1;
|
||||
} else {
|
||||
chargeType = 0;
|
||||
}
|
||||
mqcommon.sendCharge(f.device.id, chargeType);
|
||||
}
|
||||
|
||||
|
||||
if (!recCnt) {
|
||||
|
||||
let msgs = [];
|
||||
@ -800,9 +868,9 @@ class BleReceive {
|
||||
if (receiveData.sta_Intrusion === 1) {
|
||||
msgs.push("设备'" + f.device.deviceName + "'闯入报警中");
|
||||
}
|
||||
|
||||
|
||||
if (this.ref && msg.length>0) {
|
||||
|
||||
if (this.ref && msgs.length > 0) {
|
||||
msgs = msgs.join(",");
|
||||
MsgError(msgs, '', this.ref, () => {
|
||||
MsgClear(this.ref);
|
||||
@ -814,7 +882,6 @@ class BleReceive {
|
||||
|
||||
|
||||
if (f.device && path === "pages/common/index") { //仅在首页订阅此操作
|
||||
console.error("1111111111");
|
||||
let linkKey = "102_" + f.device.id + "_linked";
|
||||
let warnKey = "102_" + f.device.id + "_warning";
|
||||
let time = new Date(); //Common.DateFormat(new Date(),'yyyy-MM-dd HH:mmss');
|
||||
@ -954,17 +1021,29 @@ class BleReceive {
|
||||
|
||||
receiveData = JSON.parse(receive.str);
|
||||
|
||||
if (f && f.device && mqcommon && path == homePath) {
|
||||
|
||||
let chargeType = 1;
|
||||
if (receiveData.sta_system != 3 || receiveData.sta_system != 1) {
|
||||
chargeType = 1;
|
||||
} else {
|
||||
chargeType = 0;
|
||||
}
|
||||
mqcommon.sendCharge(f.device.id, chargeType);
|
||||
}
|
||||
|
||||
let recCnt = recArr.find(v => {
|
||||
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
|
||||
.replace(/\//g, "").toLowerCase();
|
||||
});
|
||||
if (!recCnt && this.ref) {
|
||||
if (receiveData.sta_PowerPercent <= 20 && (receiveData.sta_system != 3 || receiveData.sta_system !=1)) {
|
||||
|
||||
MsgError("设备'" + f.device.deviceName + "'电量低", '', this.ref, () => {
|
||||
MsgClear(this.ref);
|
||||
});
|
||||
|
||||
if (receiveData.sta_PowerPercent <= 20 && (receiveData.sta_system != 3 || receiveData.sta_system !=
|
||||
1)) {
|
||||
|
||||
MsgError("设备'" + f.device.deviceName + "'电量低", '', this.ref, () => {
|
||||
MsgClear(this.ref);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -977,33 +1056,47 @@ class BleReceive {
|
||||
}
|
||||
Receive_018A(receive, f, path, recArr) {
|
||||
let receiveData = {};
|
||||
|
||||
|
||||
try {
|
||||
|
||||
|
||||
receiveData = JSON.parse(receive.str);
|
||||
|
||||
|
||||
if (f && f.device && mqcommon && path == homePath) {
|
||||
|
||||
let chargeType = 1;
|
||||
if (receiveData.sta_system != 3 || receiveData.sta_system != 1) {
|
||||
chargeType = 1;
|
||||
} else {
|
||||
chargeType = 0;
|
||||
}
|
||||
mqcommon.sendCharge(f.device.id, chargeType);
|
||||
|
||||
|
||||
}
|
||||
|
||||
let recCnt = recArr.find(v => {
|
||||
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
|
||||
.replace(/\//g, "").toLowerCase();
|
||||
});
|
||||
if (!recCnt && this.ref) {
|
||||
if (receiveData.sta_PowerPercent <= 20 && (receiveData.sta_system != 3 || receiveData.sta_system !=1)) {
|
||||
|
||||
MsgError("设备'" + f.device.deviceName + "'电量低", '', this.ref, () => {
|
||||
MsgClear(this.ref);
|
||||
});
|
||||
|
||||
if (receiveData.sta_PowerPercent <= 20 && (receiveData.sta_system != 3 || receiveData.sta_system !=
|
||||
1)) {
|
||||
|
||||
MsgError("设备'" + f.device.deviceName + "'电量低", '', this.ref, () => {
|
||||
MsgClear(this.ref);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} catch (error) {
|
||||
receiveData = {};
|
||||
console.log("文本解析失败", error)
|
||||
}
|
||||
return receiveData;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Receive_210(receive, f, path, recArr) {
|
||||
let receiveData = {};
|
||||
|
||||
@ -1011,17 +1104,27 @@ class BleReceive {
|
||||
|
||||
receiveData = JSON.parse(receive.str);
|
||||
|
||||
if (f && f.device && mqcommon && path == homePath) {
|
||||
let chargeType = 1;
|
||||
if (receiveData.sta_system != 3 || receiveData.sta_system != 1) {
|
||||
chargeType = 1;
|
||||
} else {
|
||||
chargeType = 0;
|
||||
}
|
||||
mqcommon.sendCharge(f.device.id, chargeType);
|
||||
}
|
||||
let recCnt = recArr.find(v => {
|
||||
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
|
||||
.replace(/\//g, "").toLowerCase();
|
||||
});
|
||||
if (!recCnt && this.ref) {
|
||||
if (receiveData.sta_PowerPercent <= 20 && (receiveData.sta_system != 3 || receiveData.sta_system !=1)) {
|
||||
|
||||
MsgError("设备'" + f.device.deviceName + "'电量低", '', this.ref, () => {
|
||||
MsgClear(this.ref);
|
||||
});
|
||||
|
||||
if (receiveData.sta_PowerPercent <= 20 && (receiveData.sta_system != 3 || receiveData.sta_system !=
|
||||
1)) {
|
||||
|
||||
MsgError("设备'" + f.device.deviceName + "'电量低", '', this.ref, () => {
|
||||
MsgClear(this.ref);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -218,7 +218,7 @@ export default {
|
||||
value: "1",
|
||||
label: "灯光模式",
|
||||
checked: false,
|
||||
type: ['6170', '670', '102', '6155', '650', '7305', '6075']
|
||||
type: ['6170', '670', '102', '6155', '650', '7305', '6075','008A','018A']
|
||||
},
|
||||
{
|
||||
value: "2",
|
||||
@ -340,7 +340,7 @@ export default {
|
||||
value: "55",
|
||||
label: "修改信道",
|
||||
checked: false,
|
||||
type: ['4877', '102']
|
||||
type: ['4877', '102','008A']
|
||||
},
|
||||
{
|
||||
value: "56",
|
||||
|
||||
91
utils/MqPlus.js
Normal file
@ -0,0 +1,91 @@
|
||||
import MqttClient from '@/utils/mqtt.js';
|
||||
|
||||
class MqPlus {
|
||||
|
||||
constructor() {
|
||||
this.mq = null;
|
||||
this.init();
|
||||
|
||||
}
|
||||
|
||||
init(callback) {
|
||||
this.mq = new MqttClient();
|
||||
this.mq.connect(() => {
|
||||
console.log("连接成功");
|
||||
if(callback){
|
||||
callback();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
//通用发送消息
|
||||
sendData(topic, payload) {
|
||||
let task=()=>{
|
||||
if (payload === undefined || payload === null) {
|
||||
console.error("消息内容为空")
|
||||
return false;
|
||||
}
|
||||
|
||||
if (typeof payload === 'object') {
|
||||
payload = JSON.stringify(payload);
|
||||
}
|
||||
|
||||
this.mq.publish(topic, payload);
|
||||
}
|
||||
if(!this.mq){
|
||||
this.init(task)
|
||||
}else{
|
||||
task();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//发送手机号登陆与推送数据
|
||||
sendUsrLogin() {
|
||||
if(!this.mq){
|
||||
return
|
||||
}
|
||||
let pushid=uni.getStorageSync("push_cid");
|
||||
let phone=uni.getStorageSync("phone");
|
||||
this.sendData("app/login",{phone:phone,pushid:pushid});
|
||||
}
|
||||
//发送充放电数据,chargeType1放电,0充电
|
||||
sendCharge(deviceid,chargeType,battary){
|
||||
if(!this.mq){
|
||||
return;
|
||||
}
|
||||
|
||||
let json={
|
||||
deviceid:deviceid,
|
||||
sta_system:chargeType,
|
||||
}
|
||||
if(battary!==undefined){
|
||||
json.battary=battary;
|
||||
}
|
||||
this.sendData("app/charge",json);
|
||||
}
|
||||
//发送报警
|
||||
sendWarning(deviceid,warn){
|
||||
if(!this.mq){
|
||||
return;
|
||||
}
|
||||
|
||||
let json={
|
||||
deviceid:deviceid,
|
||||
sta_ShakeBit:warn,
|
||||
}
|
||||
|
||||
this.sendData("app/warn",json);
|
||||
}
|
||||
|
||||
}
|
||||
let mqplusInstance = null;
|
||||
export default {
|
||||
getMqPlus: function() {
|
||||
|
||||
if (!mqplusInstance) {
|
||||
mqplusInstance = new MqPlus();
|
||||
}
|
||||
return mqplusInstance;
|
||||
}
|
||||
}
|
||||
@ -7,7 +7,7 @@ var MsgType = {
|
||||
}
|
||||
var time = null;
|
||||
// 显示成功
|
||||
export const MsgSuccess = (msg, btnTxt, ev,tapCallback) => {
|
||||
export const MsgSuccess = (msg, btnTxt, ev,tapCallback,showCancel) => {
|
||||
|
||||
if (!ev) {
|
||||
|
||||
@ -17,13 +17,13 @@ export const MsgSuccess = (msg, btnTxt, ev,tapCallback) => {
|
||||
|
||||
return null;
|
||||
}
|
||||
let option = ev.$refs.msgPop.showMsg(msg, btnTxt, MsgType.succ,tapCallback);
|
||||
let option = ev.$refs.msgPop.showMsg(msg, btnTxt, MsgType.succ,tapCallback,showCancel);
|
||||
|
||||
createClear(ev);
|
||||
return option;
|
||||
}
|
||||
//显示失败
|
||||
export const MsgError = (msg, btnTxt, ev,tapCallback) => {
|
||||
export const MsgError = (msg, btnTxt, ev,tapCallback,showCancel) => {
|
||||
|
||||
if (!ev) {
|
||||
|
||||
@ -34,12 +34,12 @@ export const MsgError = (msg, btnTxt, ev,tapCallback) => {
|
||||
return null;
|
||||
}
|
||||
|
||||
let option = ev.$refs.msgPop.showMsg(msg, btnTxt, MsgType.error,tapCallback);
|
||||
let option = ev.$refs.msgPop.showMsg(msg, btnTxt, MsgType.error,tapCallback,showCancel);
|
||||
createClear(ev);
|
||||
return option;
|
||||
}
|
||||
//显示警告
|
||||
export const MsgWarning = (msg, btnTxt, ev, isClear,tapCallback) => {
|
||||
export const MsgWarning = (msg, btnTxt, ev, isClear,tapCallback,showCancel) => {
|
||||
if (!ev) {
|
||||
|
||||
return null;
|
||||
@ -48,7 +48,7 @@ export const MsgWarning = (msg, btnTxt, ev, isClear,tapCallback) => {
|
||||
|
||||
return null;
|
||||
}
|
||||
let option = ev.$refs.msgPop.showMsg(msg, btnTxt, MsgType.warn,tapCallback);
|
||||
let option = ev.$refs.msgPop.showMsg(msg, btnTxt, MsgType.warn,tapCallback,showCancel);
|
||||
if (isClear === undefined || isClear) {
|
||||
createClear(ev);
|
||||
}
|
||||
@ -58,7 +58,7 @@ export const MsgWarning = (msg, btnTxt, ev, isClear,tapCallback) => {
|
||||
|
||||
}
|
||||
//显示警告
|
||||
export const MsgInfo = (msg, btnTxt, ev, isClear,btnCallback) => {
|
||||
export const MsgInfo = (msg, btnTxt, ev, isClear,btnCallback,showCancel) => {
|
||||
if (!ev) {
|
||||
|
||||
return null;
|
||||
@ -67,7 +67,7 @@ export const MsgInfo = (msg, btnTxt, ev, isClear,btnCallback) => {
|
||||
|
||||
return null;
|
||||
}
|
||||
let option = ev.$refs.msgPop.showMsg(msg, btnTxt, MsgType.info,btnCallback);
|
||||
let option = ev.$refs.msgPop.showMsg(msg, btnTxt, MsgType.info,btnCallback,showCancel);
|
||||
if (isClear === undefined || isClear) {
|
||||
createClear(ev);
|
||||
}
|
||||
@ -78,7 +78,7 @@ export const MsgInfo = (msg, btnTxt, ev, isClear,btnCallback) => {
|
||||
}
|
||||
|
||||
//显示捕获窗口,用于自定义弹窗内容
|
||||
export const MsgPrompt = ( ev,refName, btnCallback,isClear) => {
|
||||
export const MsgPrompt = ( ev,refName, btnCallback,isClear,showCancel) => {
|
||||
if (!ev) {
|
||||
|
||||
return null;
|
||||
@ -87,7 +87,7 @@ export const MsgPrompt = ( ev,refName, btnCallback,isClear) => {
|
||||
|
||||
return null;
|
||||
}
|
||||
let option = ev.$refs[refName].showMsg("", "", MsgType.prompt,btnCallback);
|
||||
let option = ev.$refs[refName].showMsg("", "", MsgType.prompt,btnCallback,showCancel);
|
||||
if (isClear === undefined || isClear) {
|
||||
createClear(ev);
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ import {
|
||||
} from '@/utils/MsgPops.js';
|
||||
import Common from '@/utils/Common.js';
|
||||
import api from '@/api/670/HBY670.js'
|
||||
|
||||
import gbk from '@/utils/gbk.js'
|
||||
|
||||
class SendBatchData {
|
||||
|
||||
@ -28,9 +28,13 @@ class SendBatchData {
|
||||
this.ble = _ble;
|
||||
}
|
||||
|
||||
//发送开机视频
|
||||
//发送开机视频,1536包
|
||||
SendVideo(bufferSize) {
|
||||
|
||||
const systemInfo = uni.getSystemInfoSync();
|
||||
const platform = systemInfo.platform;
|
||||
const isIOS = platform === 'ios';
|
||||
|
||||
let these = this.these;
|
||||
let f = this.f;
|
||||
let ble = this.ble;
|
||||
@ -49,7 +53,7 @@ class SendBatchData {
|
||||
console.log("开始发送分片数据");
|
||||
return new Promise((resolve, reject) => {
|
||||
if (f) {
|
||||
ble.data.voiceUploading=true;
|
||||
ble.data.voiceUploading = true;
|
||||
// 总数据包数
|
||||
var totalPackets = 1536; //36;
|
||||
|
||||
@ -64,7 +68,7 @@ class SendBatchData {
|
||||
const sendNextVideoPacket = () => {
|
||||
// console.log("准备发送一段数据");
|
||||
if (currentPacket > totalPackets) {
|
||||
ble.data.voiceUploading=false;
|
||||
ble.data.voiceUploading = false;
|
||||
if (!ReSendNo) {
|
||||
setTimeout(() => {
|
||||
|
||||
@ -76,7 +80,7 @@ class SendBatchData {
|
||||
}).catch((ex) => {
|
||||
console.log("出现异常", ex);
|
||||
});
|
||||
}, 500);
|
||||
}, 2000);
|
||||
|
||||
}
|
||||
|
||||
@ -128,10 +132,10 @@ class SendBatchData {
|
||||
|
||||
|
||||
for (let i = 0; i < packetData.length; i++) {
|
||||
dataView.setUint8(beginIndex + i, packetData[i]);
|
||||
dataView.setUint8(beginIndex + i, parseInt(packetData[i], 16));
|
||||
}
|
||||
|
||||
let inteval = 80;
|
||||
let inteval = isIOS ? 300 : 80;
|
||||
|
||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f
|
||||
.wirteCharactId, 10).then(() => {
|
||||
@ -152,7 +156,7 @@ class SendBatchData {
|
||||
currentPacket);
|
||||
setTimeout(sendNextVideoPacket, 800);
|
||||
} else {
|
||||
ble.data.voiceUploading=false;
|
||||
ble.data.voiceUploading = false;
|
||||
hideLoading(these);
|
||||
|
||||
showPop({
|
||||
@ -194,7 +198,7 @@ class SendBatchData {
|
||||
|
||||
ble.sendString(f.deviceId, "video transmit start", f
|
||||
.writeServiceId, f.wirteCharactId).then(res => {
|
||||
ble.data.voiceUploading=true;
|
||||
ble.data.voiceUploading = true;
|
||||
setTimeout(() => {
|
||||
console.log("握手成功了");
|
||||
resolve(true);
|
||||
@ -244,6 +248,8 @@ class SendBatchData {
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
Promise.all([p1, p2]).then((arr) => {
|
||||
@ -327,9 +333,7 @@ class SendBatchData {
|
||||
let duration = res.duration;
|
||||
|
||||
// 获取平台信息
|
||||
const systemInfo = uni.getSystemInfoSync();
|
||||
const platform = systemInfo.platform;
|
||||
const isIOS = platform === 'ios';
|
||||
|
||||
|
||||
console.log("平台:", platform, "uni.chooseVideo返回 - 宽度:", width, "高度:", height,
|
||||
"时长:", duration);
|
||||
@ -379,7 +383,7 @@ class SendBatchData {
|
||||
}
|
||||
|
||||
|
||||
//发送图片,
|
||||
//发送图片,52包
|
||||
SendImg() {
|
||||
let these = this.these;
|
||||
let f = this.f;
|
||||
@ -558,7 +562,7 @@ class SendBatchData {
|
||||
});
|
||||
}
|
||||
|
||||
//发送人员信息
|
||||
//发送人员信息(点阵)
|
||||
SendUsr(totalRows) {
|
||||
|
||||
let these = this.these;
|
||||
@ -594,14 +598,17 @@ class SendBatchData {
|
||||
//握手
|
||||
let holdHand = (hexs, time) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
console.log("11111");
|
||||
|
||||
|
||||
these.sendData(hexs, 'ble', "string").then(res => {
|
||||
ble.sendString(f.deviceId, hexs, null, null, 15).then(res => {
|
||||
console.log("22222")
|
||||
setTimeout(() => {
|
||||
resolve(res)
|
||||
}, time);
|
||||
|
||||
}).catch(ex => {
|
||||
console.log("33333", ex);
|
||||
console.error("握手失败")
|
||||
reject(ex)
|
||||
});
|
||||
@ -715,7 +722,7 @@ class SendBatchData {
|
||||
setTimeout(() => {
|
||||
Promise.allSettled([holdHand('word transmit start', 2200), drawText()]).then(results => {
|
||||
if (results[0].status == 'rejected') {
|
||||
MsgError("与蓝牙设备握手失败,请重试", '', these);
|
||||
MsgError("与蓝牙设备握手失败,请重试," + results[0].reason, '', these);
|
||||
setTimeout(() => {
|
||||
hideLoading(these)
|
||||
}, 500);
|
||||
@ -749,11 +756,267 @@ class SendBatchData {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
SendMsg(){
|
||||
|
||||
|
||||
|
||||
SendMsgByGBK(txts, _mq) {
|
||||
debugger;
|
||||
let these = this.these;
|
||||
let f = this.f;
|
||||
let ble = this.ble;
|
||||
let mq = _mq;
|
||||
if (!these.permissions.includes('5') && these.Status.apiType !== 'listA') {
|
||||
|
||||
showPop({
|
||||
message: '无操作权限',
|
||||
iconUrl: "/static/images/common/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
buttonTextColor: "#FFFFFFde",
|
||||
okCallback: null,
|
||||
buttonText: "确定"
|
||||
}, these)
|
||||
return;
|
||||
}
|
||||
|
||||
showLoading(these, {
|
||||
text: "请稍候..."
|
||||
});
|
||||
let send = (txt) => {
|
||||
|
||||
return mq.publish("B/" + these.device.deviceImei, txt);
|
||||
}
|
||||
|
||||
|
||||
let curr = 0;
|
||||
let sendNext = () => {
|
||||
if (curr >= txts.length) {
|
||||
hideLoading(these);
|
||||
MsgSuccess("发送成功", '', these);
|
||||
return;
|
||||
}
|
||||
let txt = txts[curr];
|
||||
let arr = gbk.encode(txt)
|
||||
console.log("正在发送:", txt);
|
||||
|
||||
let json = {
|
||||
ins_msg: [curr + 1]
|
||||
}
|
||||
|
||||
let gbkData = gbk.arr2hex(arr);
|
||||
for (let i = 0; i < gbkData.length; i += 2) {
|
||||
let value = parseInt(gbkData[i] + "" + gbkData[i + 1], 16);
|
||||
json.ins_msg.push(value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
txt = JSON.stringify(json);
|
||||
updateLoading(these, {
|
||||
text: '正在发送' + (curr + 1) + '/' + txts.length
|
||||
});
|
||||
if (send(txt)) {
|
||||
curr++;
|
||||
setTimeout(sendNext, 200);
|
||||
} else {
|
||||
MsgError("发送失败了,请检查网络连接后重试", '', these);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
setTimeout(sendNext, 2200);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
HoldYouHand(cmd, timeout) {
|
||||
let these = this.these;
|
||||
let f = this.f;
|
||||
let ble = this.ble;
|
||||
return new Promise((resolve, reject) => {
|
||||
ble.sendString(f.deviceId, cmd, f
|
||||
.writeServiceId, f.wirteCharactId).then(res => {
|
||||
|
||||
if (timeout) {
|
||||
setTimeout(() => {
|
||||
console.log("握手成功了");
|
||||
resolve(true);
|
||||
}, timeout);
|
||||
return;
|
||||
}
|
||||
|
||||
resolve(true);
|
||||
|
||||
}).catch(ex => {
|
||||
reject(ex);
|
||||
console.error("发送文本‘" + cmd + "’失败");
|
||||
console.error("ex=", ex);
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
sendUsrByGBK(textLines, ReSendNo) {
|
||||
let these = this.these;
|
||||
let f = this.f;
|
||||
let ble = this.ble;
|
||||
if (!these.permissions.includes('4') && these.Status.apiType !== 'listA') {
|
||||
|
||||
showPop({
|
||||
message: '无操作权限',
|
||||
iconUrl: "/static/images/common/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
okCallback: null,
|
||||
buttonText: "确定"
|
||||
}, these)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
showLoading(these, {
|
||||
text: "请稍候..."
|
||||
});
|
||||
var sendText = () => {
|
||||
// 总数据包数
|
||||
let totalPackets = textLines.length;
|
||||
let currentPacket = 1;
|
||||
// console.log("currentPacket=",currentPacket);
|
||||
// console.log("ReSendNo=",ReSendNo);
|
||||
if (ReSendNo) {
|
||||
totalPackets = ReSendNo;
|
||||
currentPacket = ReSendNo;
|
||||
}
|
||||
// console.log("currentPacket=",currentPacket);
|
||||
// 发送单个数据包
|
||||
const sendNextPacket = () => {
|
||||
|
||||
if (currentPacket > totalPackets) {
|
||||
if (!ReSendNo) {
|
||||
setTimeout(() => {
|
||||
this.HoldYouHand("transmit complete");
|
||||
}, 500);
|
||||
|
||||
}
|
||||
|
||||
showPop({
|
||||
showPop: true, //是否显示弹窗
|
||||
popType: 'custom',
|
||||
bgColor: '#383934bd',
|
||||
borderColor: '#BBE600',
|
||||
textColor: '#ffffffde',
|
||||
buttonBgColor: '#BBE600',
|
||||
buttonTextColor: '#232323DE',
|
||||
iconUrl: '/static/images/6155/DeviceDetail/sendSucc.png',
|
||||
message: '人员信息发送成功',
|
||||
buttonText: '确定',
|
||||
clickEvt: 'SendUsr',
|
||||
visiblePrompt: false,
|
||||
promptTitle: '',
|
||||
modelValue: '',
|
||||
visibleClose: true
|
||||
}, these);
|
||||
these.setBleFormData();
|
||||
|
||||
|
||||
let json = {
|
||||
deviceId: these.device.id,
|
||||
name: these.formData.name,
|
||||
position: these.formData.job,
|
||||
unitName: these.formData.company,
|
||||
code: these.formData.id
|
||||
};
|
||||
api.sendUsr(json)
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取当前行文字
|
||||
const text = textLines[currentPacket - 1] || '';
|
||||
let arr = gbk.encode(text)
|
||||
let gbkData = gbk.arr2hex(arr);
|
||||
|
||||
console.log("正在发送:" + text);
|
||||
console.log("正在发送:" + arr);
|
||||
// 构建数据包
|
||||
const bufferSize = 5 + gbkData.length / 2; // 头部4字节 + 数据部分
|
||||
const buffer = new ArrayBuffer(bufferSize);
|
||||
const dataView = new DataView(buffer);
|
||||
|
||||
// 填充头部
|
||||
dataView.setUint8(0, 0x55); // 帧头
|
||||
dataView.setUint8(1, 0x03); // 帧类型:文字
|
||||
dataView.setUint8(2, currentPacket.toString(16)); // 包序号
|
||||
dataView.setUint16(3, text.length, false); // 数据长度
|
||||
|
||||
|
||||
// 填充数据
|
||||
let index = 0;
|
||||
for (var i = 0; i < gbkData.length; i += 2) {
|
||||
let value = parseInt(gbkData[i] + "" + gbkData[i + 1], 16);
|
||||
console.log("value=", value)
|
||||
dataView.setUint8(5 + index, value);
|
||||
index++;
|
||||
}
|
||||
|
||||
|
||||
// 发送数据包
|
||||
|
||||
|
||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 10).then(() => {
|
||||
// 更新进度
|
||||
console.log(
|
||||
`发送文字数据包 ${currentPacket}/${totalPackets}: ${text}`
|
||||
);
|
||||
|
||||
// 发送下一个包
|
||||
currentPacket++;
|
||||
setTimeout(sendNextPacket, 80);
|
||||
}).catch(err => {
|
||||
|
||||
showPop({
|
||||
message: "文字发送失败," + err.msg,
|
||||
iconUrl: "/static/images/common/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
}, these);
|
||||
}).finally(() => {
|
||||
hideLoading(these);
|
||||
});
|
||||
};
|
||||
|
||||
// 开始发送第一个包
|
||||
sendNextPacket();
|
||||
}
|
||||
|
||||
|
||||
if (ReSendNo) {
|
||||
sendText(ReSendNo);
|
||||
return;
|
||||
}
|
||||
setTimeout(() => {
|
||||
this.HoldYouHand("word transmit start", 120).then(
|
||||
() => {
|
||||
|
||||
setTimeout(sendText, 200);
|
||||
}).catch((ex) => {
|
||||
console.log("握手没有成功", ex);
|
||||
hideLoading(these);
|
||||
showPop({
|
||||
message: ex.msg,
|
||||
iconUrl: "/static/images/common/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
}, these);
|
||||
});
|
||||
}, 0);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default SendBatchData;
|
||||
@ -148,6 +148,7 @@ class MqttClient {
|
||||
this.options.clientId
|
||||
);
|
||||
this.setCallbacks();
|
||||
|
||||
}
|
||||
|
||||
setCallbacks() {
|
||||
|
||||