018A初步完成
This commit is contained in:
@ -25,17 +25,11 @@
|
||||
<view class="row">
|
||||
<image class="img" src="/static/images/common/battry.png" mode="aspectFit"></image>
|
||||
<view class="txt">
|
||||
<view class="bigTxt">{{formData.battary}}%</view>
|
||||
<view class="bigTxt">{{formData.sta_PowerPercent}}%</view>
|
||||
<view class="smallTxt">电量</view>
|
||||
</view>
|
||||
</view>
|
||||
<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="smallTxt">续航时间</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
<view class="eqinfo">
|
||||
@ -69,15 +63,15 @@
|
||||
<view class="multiValue" @click.stop="gotoMap()">
|
||||
<view class="valueItem valueFont">
|
||||
{{formData.sta_longitude}}
|
||||
|
||||
|
||||
</view>
|
||||
<view class="valueItem valueFont">
|
||||
|
||||
|
||||
{{formData.sta_latitude}}
|
||||
|
||||
|
||||
</view>
|
||||
<view class="valueItem">
|
||||
|
||||
|
||||
<view style="width:80%;float: right;text-align: right;" class="valueFont">
|
||||
<uni-icons type="location" size="17" color="rgba(255, 255, 255, 0.8)"
|
||||
style="vertical-align: bottom;" />
|
||||
@ -86,46 +80,109 @@
|
||||
<view class="clear"></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
|
||||
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="warnnig" :class="ShakeBit?'':'displayNone'">
|
||||
<view>{{ShakeBit}}!</view>
|
||||
<view>{{AlarmTime}}</view>
|
||||
<uni-icons type="closeempty" size="16" color="#FFFFFF" @click="CloseWarn()"></uni-icons>
|
||||
</view>
|
||||
|
||||
|
||||
<view class="lampMode">
|
||||
<view class="mode " :class="{active:formData.sta_SOSGrade=='2'}" v-on:click.stop="sosSetting(2)">
|
||||
<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" mode="aspectFit"></image>
|
||||
<image v-show="formData.sta_SOSGrade=='2'" class="img" src="/static/images/670/rbActive.png" mode="aspectFit"></image>
|
||||
<image v-show="formData.sta_SOSGrade!='2'" class="img" src="/static/images/670/rb.png"
|
||||
mode="aspectFit"></image>
|
||||
<image v-show="formData.sta_SOSGrade=='2'" class="img" src="/static/images/670/rbActive.png"
|
||||
mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
<text class="bigTxt">红蓝警示</text>
|
||||
<text class="smallTxt">{{formData.sta_SOSGrade=='2'?'开启':'关闭'}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="mode " :class="{active:formData.sta_SOSGrade=='1'}" v-on:click.stop="sosSetting(1)">
|
||||
<view class="mode " :class="{active:formData.sta_SOSGrade=='1'}" v-on:click.stop="sosSetting(1)">
|
||||
<view class="leftImg">
|
||||
<image v-show="formData.sta_SOSGrade!='1'" class="img" src="/static/images/670/sg.png" mode="aspectFit"></image>
|
||||
<image v-show="formData.sta_SOSGrade=='1'" class="img" src="/static/images/670/sgActive.png" mode="aspectFit"></image>
|
||||
<image v-show="formData.sta_SOSGrade!='1'" class="img" src="/static/images/670/sg.png"
|
||||
mode="aspectFit"></image>
|
||||
<image v-show="formData.sta_SOSGrade=='1'" class="img" src="/static/images/670/sgActive.png"
|
||||
mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
<text class="bigTxt">声光报警</text>
|
||||
<text class="smallTxt">{{formData.sta_SOSGrade=='1'?'开启':'关闭'}}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="mode " :class="{active:formData.sta_RadarType=='1'}" v-on:click.stop="redarSetting(1)">
|
||||
|
||||
<view class="mode " :class="{active:formData.sta_RadarType=='1'}"
|
||||
v-on:click.stop="showAction">
|
||||
<view class="leftImg">
|
||||
<image v-show="formData.sta_RadarType=='1'" class="img" src="/static/images/102/redarActive.png" mode="aspectFit"></image>
|
||||
<image v-show="formData.sta_RadarType!='1'" class="img" src="/static/images/102/redar.png" mode="aspectFit"></image>
|
||||
<image v-show="formData.sta_RadarType=='1'" class="img" src="/static/images/102/redarActive.png"
|
||||
mode="aspectFit"></image>
|
||||
<image v-show="formData.sta_RadarType!='1'" class="img" src="/static/images/102/redar.png"
|
||||
mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
<text class="bigTxt">物体感应</text>
|
||||
<text class="smallTxt">{{formData.sta_RadarType=='1'?'开启':'关闭'}}</text>
|
||||
<text class="bigTxt">雷达感应</text>
|
||||
<text class="smallTxt">{{formData.sta_RadarType==0?'关闭':formData.sta_RadarType+'M'}}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
<view class="mode " :class="{active:formData.sta_InfraRed=='1'}"
|
||||
v-on:click.stop="toggleSetting(1,'InfraRed')">
|
||||
<view class="leftImg">
|
||||
<image v-show="formData.sta_InfraRed=='1'" class="img" src="/static/images/common/hongwaiActive.png"
|
||||
mode="aspectFit"></image>
|
||||
<image v-show="formData.sta_InfraRed!='1'" class="img" src="/static/images/common/hongwai.png"
|
||||
mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
<text class="bigTxt">红外感应</text>
|
||||
<text class="smallTxt">{{formData.sta_InfraRed=='1'?'开启':'关闭'}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
<view class="usrinfo">
|
||||
<view>
|
||||
<text class="usrtitle fleft">人员信息登记</text>
|
||||
<view class="btnSend fright" v-on:click.stop="sendUsr">发送</view>
|
||||
<view class="clear"></view>
|
||||
<TextToHexV1 class="TextToHex" ref="textToHex" :txts="formData.textLines" :bgColor="'#FFFFFF'"
|
||||
:color="'#000000'" :fontSize="16" />
|
||||
</view>
|
||||
|
||||
<view class="item">
|
||||
<text class="lbl">单位:</text>
|
||||
<input class="value" v-model.trim="formData.textLines[0]" placeholder="请输入单位" maxlength="8"
|
||||
placeholder-class="usrplace" />
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="lbl">部门:</text>
|
||||
<input class="value" v-model.trim="formData.textLines[1]" placeholder="请输入姓名" maxlength="8"
|
||||
placeholder-class="usrplace" />
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="lbl">姓名:</text>
|
||||
<input class="value" v-model.trim="formData.textLines[2]" placeholder="请输入职位" maxlength="8"
|
||||
placeholder-class="usrplace" />
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="lbl">ID:</text>
|
||||
<input class="value" v-model.trim="formData.textLines[3]" placeholder="ID" maxlength="16"
|
||||
placeholder-class="usrplace" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
|
||||
<BottomSlideMenuPlus :config="Status.BottomMenu" @btnClick="btnClick" @itemClick="itemClick" @close="closeActionSheet"></BottomSlideMenuPlus>
|
||||
<ProParams :id="device.id"></ProParams>
|
||||
<MsgBox ref="msgPop" />
|
||||
<global-loading ref="loading" />
|
||||
@ -133,6 +190,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import usrApi from '@/api/670/HBY670.js';
|
||||
import TextToHexV1 from '@/components/TextToHex/TextToHexV1.vue';
|
||||
import request from '@/utils/request.js';
|
||||
import {
|
||||
showLoading,
|
||||
@ -161,6 +220,9 @@
|
||||
var pagePath = "/pages/210/HBY210";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
TextToHexV1
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
Status: {
|
||||
@ -181,12 +243,61 @@
|
||||
height: 90
|
||||
},
|
||||
usrToggle: true,
|
||||
bleLinkCnt: 0
|
||||
bleLinkCnt: 0,
|
||||
BottomMenu: {
|
||||
show: false,
|
||||
showHeader: true,
|
||||
menuItems: [{
|
||||
text: '2M',
|
||||
value: 2,
|
||||
icon: ''
|
||||
},
|
||||
{
|
||||
text: '4M',
|
||||
value: 4,
|
||||
icon: ''
|
||||
},
|
||||
{
|
||||
text: '7M',
|
||||
value: 7,
|
||||
icon: ''
|
||||
},
|
||||
{
|
||||
text: '10M',
|
||||
value: 10,
|
||||
icon: ''
|
||||
},
|
||||
{
|
||||
text: '关闭',
|
||||
value: 0,
|
||||
icon: ''
|
||||
}
|
||||
],
|
||||
activeIndex: -1,
|
||||
bgColor: '#2a2a2a',
|
||||
itemBgColor: '#3a3a3a',
|
||||
textColor: '#ffffffde',
|
||||
textAlign: 'flex-start',
|
||||
title: '雷达设置',
|
||||
showDivider: false,
|
||||
dividerColor: '#00000000',
|
||||
dividerThickness: '0rpx',
|
||||
dividerMargin: '10rpx',
|
||||
itemHeight: '80rpx',
|
||||
type: '',
|
||||
showBtn: true,
|
||||
btnBgColor: "#bbe600",
|
||||
btnText: "确定",
|
||||
btnTextColor: "#232323de",
|
||||
showMask: true,
|
||||
maskBgColor: '#00000066',
|
||||
showClose: false
|
||||
}
|
||||
},
|
||||
formData: {
|
||||
img: '/static/images/common/BJQ6075.png',
|
||||
img: '/static/images/common/HBY210.png',
|
||||
|
||||
|
||||
|
||||
address: "", //地址
|
||||
|
||||
company: "湖北消防总队", //单位
|
||||
@ -197,14 +308,17 @@
|
||||
deviceId: "",
|
||||
|
||||
bleStatu: false,
|
||||
|
||||
sta_AlarmTime:0,
|
||||
sta_PowerPercent: "",
|
||||
sta_PowerTime: "",
|
||||
sta_SOSGrade: '',
|
||||
sta_SOSGrade:0,
|
||||
sta_longitude: "",
|
||||
sta_latitude: "",
|
||||
sta_system: "", //设备状态,0关机,1仅充电,2开机未充电,3,开机且充电
|
||||
sta_RadarType:""
|
||||
sta_RadarType: "",
|
||||
sta_ShakeBit: 0, //报警状态
|
||||
sta_InfraRed:0,
|
||||
textLines: ['湖北星汉文化', '有限', '公司','12345678']
|
||||
},
|
||||
device: {
|
||||
id: "",
|
||||
@ -231,6 +345,35 @@
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
AlarmTime(){
|
||||
if(this.formData.sta_AlarmTime){
|
||||
return Common.formatTime(this.formData.sta_AlarmTime,"second");
|
||||
}
|
||||
return "";
|
||||
},
|
||||
ShakeBit() {
|
||||
//"sta_ShakeBit":0-未报警,1-强制报警,2静止报警,3撞击报警,4雷达报警,5漏电报警,6触水报警,7红外报警
|
||||
let dic = {
|
||||
"0": "",
|
||||
"1": "设备强制报警中",
|
||||
"2": "设备静止报警中",
|
||||
"3": "设备疑似受到撞击",
|
||||
"4": "设备雷达报警中",
|
||||
"5": "设监测到漏电",
|
||||
"6": "设备触水报警中",
|
||||
"7": "红外闯入报警中"
|
||||
};
|
||||
let keys = Object.keys(dic);
|
||||
let f = keys.find(v => {
|
||||
return v == this.formData.sta_ShakeBit;
|
||||
});
|
||||
if (f) {
|
||||
let str= dic[f]
|
||||
|
||||
return str;
|
||||
}
|
||||
return "";
|
||||
},
|
||||
getbleStatu() {
|
||||
if (this.formData.bleStatu === true) {
|
||||
return '已连接';
|
||||
@ -246,18 +389,18 @@
|
||||
}
|
||||
return '未连接';
|
||||
},
|
||||
sta_system(){
|
||||
sta_system() {
|
||||
//0关机,1仅充电,2开机未充电,3,开机且充电
|
||||
if(this.formData.sta_system=='0'){
|
||||
if (this.formData.sta_system == '0') {
|
||||
return '已关机'
|
||||
}
|
||||
if(this.formData.sta_system=='1'){
|
||||
if (this.formData.sta_system == '1') {
|
||||
return '仅充电'
|
||||
}
|
||||
if(this.formData.sta_system=='2'){
|
||||
if (this.formData.sta_system == '2') {
|
||||
return '开机未充电'
|
||||
}
|
||||
if(this.formData.sta_system=='3'){
|
||||
if (this.formData.sta_system == '3') {
|
||||
return '开机充电中'
|
||||
}
|
||||
}
|
||||
@ -338,7 +481,7 @@
|
||||
});
|
||||
if (!f) {
|
||||
these.showBleUnConnect();
|
||||
these.getDetail();
|
||||
// these.getDetail();
|
||||
return;
|
||||
}
|
||||
let form = f.formData;
|
||||
@ -355,7 +498,7 @@
|
||||
} else if (these.device.deviceImei) {
|
||||
these.formData['imei'] = these.device.deviceImei;
|
||||
}
|
||||
these.getDetail();
|
||||
// these.getDetail();
|
||||
|
||||
these.formData.bleStatu = 'connecting';
|
||||
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
|
||||
@ -369,91 +512,373 @@
|
||||
|
||||
},
|
||||
methods: {
|
||||
redarSetting(val) {
|
||||
let f=this.getDevice();
|
||||
showAction(){
|
||||
this.Status.BottomMenu.show = true;
|
||||
|
||||
this.Status.BottomMenu.menuItems.find((v,i)=>{
|
||||
if(this.formData.sta_RadarType==v.value){
|
||||
this.Status.BottomMenu.activeIndex=i;
|
||||
return true;
|
||||
}
|
||||
})
|
||||
},
|
||||
btnClick(){
|
||||
this.Status.BottomMenu.show = false;
|
||||
|
||||
let d=this.Status.BottomMenu.menuItems[this.Status.BottomMenu.activeIndex];
|
||||
|
||||
|
||||
|
||||
let f = this.getDevice();
|
||||
|
||||
|
||||
if (!f) {
|
||||
this.showBleUnConnect();
|
||||
return;
|
||||
}
|
||||
|
||||
let newVal = null;
|
||||
if (val == this.formData.sta_RadarType) {
|
||||
newVal = 0;
|
||||
}else{
|
||||
newVal=val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
let bleSend=()=>{
|
||||
let json={ins_RadarType:newVal};
|
||||
json=JSON.stringify(json);
|
||||
if(ble){
|
||||
ble.sendString(f.deviceId, json).then(res=>{
|
||||
this.formData.sta_RadarType=newVal;
|
||||
}).catch(ex=>{
|
||||
let bleSend = () => {
|
||||
let json = {ins_RadarType:d.value};
|
||||
|
||||
json = JSON.stringify(json);
|
||||
if (ble) {
|
||||
ble.sendString(f.deviceId, json).then(res => {
|
||||
console.log("send success")
|
||||
this.formData.sta_RadarType = d.value;
|
||||
}).catch(ex => {
|
||||
this.mqSend(json);
|
||||
this.formData.sta_RadarType=newVal;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bleSend();
|
||||
bleSend();
|
||||
|
||||
|
||||
},
|
||||
sosSetting(val) {
|
||||
let f=this.getDevice();
|
||||
itemClick(item, index) {
|
||||
this.Status.BottomMenu.activeIndex=index;
|
||||
|
||||
|
||||
},
|
||||
closeActionSheet() {
|
||||
this.Status.BottomMenu.show = false;
|
||||
},
|
||||
sendUsr() {
|
||||
if (!this.permissions.includes('4') && this.Status.apiType !== 'listA') {
|
||||
|
||||
|
||||
MsgError('无操作权限', '', these);
|
||||
return;
|
||||
}
|
||||
let f = this.getDevice();
|
||||
if (!f) {
|
||||
these.showBleUnConnect()
|
||||
return;
|
||||
}
|
||||
|
||||
let toByteValue = (value) => {
|
||||
if (typeof value === 'number') {
|
||||
return value;
|
||||
}
|
||||
if (typeof value === 'string') {
|
||||
if (value.startsWith('0x') || value.startsWith('0X')) {
|
||||
return parseInt(value, 16);
|
||||
}
|
||||
return parseInt(`0x${value}`, 16);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
let err = false;
|
||||
this.formData.textLines.find((txt) => {
|
||||
if (txt.length === 0) {
|
||||
console.log("txt=", txt);
|
||||
err = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
})
|
||||
if (err) {
|
||||
MsgError('单位、部门、姓名、ID必须填写', '', these);
|
||||
return;
|
||||
}
|
||||
showLoading(these, {
|
||||
text: "请稍候..."
|
||||
});
|
||||
//握手
|
||||
let holdHand = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
updateLoading(these, {
|
||||
text: '设备准备中...'
|
||||
})
|
||||
let hexs = 'word transmit start';
|
||||
ble.sendString(f.deviceId, hexs, f.writeServiceId, f.wirteCharactId, 10).then(res => {
|
||||
setTimeout(() => {
|
||||
resolve(res)
|
||||
}, 2200);
|
||||
|
||||
}).catch(ex => {
|
||||
reject(ex)
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
//画图
|
||||
let drawText = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.$refs.textToHex.drawAndGetPixels().then(allPixels => {
|
||||
if (!allPixels) {
|
||||
reject("文本初始化失败");
|
||||
return;
|
||||
}
|
||||
resolve(allPixels);
|
||||
}).catch(compEx => {
|
||||
reject(compEx);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
//发送3个分包的数据
|
||||
let task = (allPixels) => {
|
||||
try {
|
||||
let combinedData = [];
|
||||
for (let i = 0; i < this.formData.textLines.length; i++) {
|
||||
let linePixels = (allPixels[i] || []).flat(Infinity).map(item =>
|
||||
typeof item === 'string' ? toByteValue(item) : item
|
||||
);
|
||||
for (var j = linePixels.length; j < 256; j++) {
|
||||
linePixels.push(0x00);
|
||||
|
||||
}
|
||||
combinedData.push([0xFA, 0x06, i + 1, 1].concat(linePixels.slice(0, 128)));
|
||||
combinedData.push([0xFA, 0x06, i + 1, 2].concat(linePixels.slice(128, 256)));
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
combinedData.push([0x74, 0x72, 0x61, 0x6E, 0x73, 0x6D, 0x69, 0x74, 0x20, 0x63, 0x6F, 0x6D,
|
||||
0x70, 0x6C, 0x65, 0x74, 0x65
|
||||
]);
|
||||
|
||||
|
||||
|
||||
let curr = 1;
|
||||
let len = combinedData.length;
|
||||
console.log(combinedData);
|
||||
showLoading(these, {
|
||||
text: '正在发送' + (curr - 1) + '/' + len
|
||||
});
|
||||
|
||||
//分包发送
|
||||
let sendPacket = () => {
|
||||
|
||||
if (combinedData.length === curr - 1) {
|
||||
|
||||
these.setBleFormData();
|
||||
|
||||
MsgSuccess("发送成功", '', these);
|
||||
let json = {
|
||||
deviceId: these.device.id,
|
||||
name: these.formData.textLines[1],
|
||||
position: these.formData.textLines[0],
|
||||
unitName: these.formData.textLines[2],
|
||||
code: ""
|
||||
};
|
||||
usrApi.sendUsr(json);
|
||||
|
||||
hideLoading(these);
|
||||
return;
|
||||
}
|
||||
|
||||
let array = combinedData[curr - 1];
|
||||
|
||||
|
||||
ble.sendHexs(f.deviceId, array, f.writeServiceId, f.wirteCharactId, 10).then(
|
||||
res => {
|
||||
|
||||
|
||||
updateLoading(these, {
|
||||
text: '正在发送' + curr + '/' + len
|
||||
});
|
||||
curr++;
|
||||
setTimeout(sendPacket, 300);
|
||||
}).catch(err => {
|
||||
if (err.code == '10007') {
|
||||
|
||||
setTimeout(sendPacket, 300);
|
||||
} else {
|
||||
console.log("err:", err);
|
||||
hideLoading(these);
|
||||
MsgError("发送失败: " + (err.msg || err.message), '', these)
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
setTimeout(sendPacket, 0);
|
||||
// 5. 发送成功处理
|
||||
|
||||
|
||||
} catch (ex) {
|
||||
hideLoading(these);
|
||||
|
||||
MsgError("发送失败: " + (ex.msg || ex.message), '', these);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
Promise.allSettled([holdHand(), drawText()]).then(results => {
|
||||
console.log("results=", results)
|
||||
if (results[0].status == 'rejected') {
|
||||
updateLoading(these, {
|
||||
text: results[0].reason
|
||||
});
|
||||
setTimeout(() => {
|
||||
hideLoading(these)
|
||||
}, 500);
|
||||
return;
|
||||
}
|
||||
if (results[1].status == 'rejected') {
|
||||
updateLoading(these, {
|
||||
text: results[1].reason
|
||||
})
|
||||
setTimeout(() => {
|
||||
hideLoading(these)
|
||||
}, 500);
|
||||
return;
|
||||
}
|
||||
|
||||
task(results[1].value);
|
||||
})
|
||||
|
||||
}, 0);
|
||||
},
|
||||
toggleSetting(val, type) {
|
||||
let f = this.getDevice();
|
||||
|
||||
|
||||
if (!f) {
|
||||
this.showBleUnConnect();
|
||||
return;
|
||||
}
|
||||
let sta_type = "sta_" + type;
|
||||
let newVal = null;
|
||||
if (val == this.formData[sta_type]) {
|
||||
newVal = 0;
|
||||
} else {
|
||||
newVal = val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
let bleSend = () => {
|
||||
let json = {};
|
||||
json['ins_' + type] = newVal
|
||||
json = JSON.stringify(json);
|
||||
if (ble) {
|
||||
ble.sendString(f.deviceId, json).then(res => {
|
||||
console.log("send success")
|
||||
this.formData[sta_type] = newVal;
|
||||
}).catch(ex => {
|
||||
this.mqSend(json);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bleSend();
|
||||
|
||||
|
||||
},
|
||||
CloseWarn(){
|
||||
let f = this.getDevice();
|
||||
|
||||
// #ifdef APP
|
||||
if (!f) {
|
||||
this.showBleUnConnect();
|
||||
return;
|
||||
}
|
||||
// #endif
|
||||
|
||||
// #ifdef WEB
|
||||
f={deviceId:12345}
|
||||
// #endif
|
||||
|
||||
let bleSend = () => {
|
||||
let json = {
|
||||
ins_ShakeBit: 0
|
||||
};
|
||||
json = JSON.stringify(json);
|
||||
if (ble) {
|
||||
ble.sendString(f.deviceId, json).then(res => {
|
||||
this.formData.sta_ShakeBit = 0;
|
||||
this.formData.sta_InfraRed=0;
|
||||
}).catch(ex => {
|
||||
this.mqSend(json);
|
||||
this.formData.sta_ShakeBit = 0;
|
||||
this.formData.sta_InfraRed=0;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
MsgError('确定解除报警?', '', these, bleSend);
|
||||
},
|
||||
sosSetting(val) {
|
||||
let f = this.getDevice();
|
||||
|
||||
|
||||
if (!f) {
|
||||
this.showBleUnConnect();
|
||||
return;
|
||||
}
|
||||
|
||||
let newVal = null;
|
||||
if (val == this.formData.sta_SOSGrade) {
|
||||
newVal = 0;
|
||||
}else{
|
||||
newVal=val;
|
||||
} else {
|
||||
newVal = val;
|
||||
}
|
||||
|
||||
|
||||
let msg="";
|
||||
|
||||
|
||||
let msg = "";
|
||||
if (newVal == 0 && this.formData.sta_SOSGrade == 1) {
|
||||
msg="确定解除声光报警?";
|
||||
|
||||
msg = "确定解除声光报警?";
|
||||
|
||||
} else if (newVal == 1) {
|
||||
msg = "确定开启声光报警?";
|
||||
}
|
||||
else if (newVal == 1) {
|
||||
msg="确定开启声光报警?";
|
||||
}
|
||||
let bleSend=()=>{
|
||||
let json={ins_SOSGrade:newVal};
|
||||
json=JSON.stringify(json);
|
||||
if(ble){
|
||||
ble.sendString(f.deviceId, json).then(res=>{
|
||||
this.formData.sta_SOSGrade=newVal;
|
||||
}).catch(ex=>{
|
||||
let bleSend = () => {
|
||||
let json = {
|
||||
ins_SOSGrade: newVal
|
||||
};
|
||||
json = JSON.stringify(json);
|
||||
if (ble) {
|
||||
ble.sendString(f.deviceId, json).then(res => {
|
||||
this.formData.sta_SOSGrade = newVal;
|
||||
}).catch(ex => {
|
||||
this.mqSend(json);
|
||||
this.formData.sta_SOSGrade=newVal;
|
||||
this.formData.sta_SOSGrade = newVal;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if(msg){
|
||||
MsgError(msg,'',these,()=>{
|
||||
bleSend();
|
||||
|
||||
if (msg) {
|
||||
MsgError(msg, '', these, () => {
|
||||
bleSend();
|
||||
});
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
bleSend();
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
getDevice: function() {
|
||||
getDevice: function() {
|
||||
let f = ble.data.LinkedList.find((v) => {
|
||||
if (v.macAddress == these.device.deviceMac) {
|
||||
if (!this.formData.deviceId) {
|
||||
@ -462,7 +887,7 @@
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return f;
|
||||
},
|
||||
bleStatuToggle() {
|
||||
@ -492,20 +917,25 @@
|
||||
|
||||
|
||||
},
|
||||
mqSend(json){
|
||||
if(mq){
|
||||
mq.publish("B/" + this.device.deviceImei, json).then(res=>{
|
||||
|
||||
}).catch(ex=>{
|
||||
|
||||
mqSend(json) {
|
||||
if (mq) {
|
||||
mq.publish("B/" + this.device.deviceImei, json).then(res => {
|
||||
let keys = Object.keys(JSON.parse(json));
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
let key = keys[i];
|
||||
let state = key.replace('ins_', 'sta_');
|
||||
this.formData[state] = json[key];
|
||||
}
|
||||
}).catch(ex => {
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
showBleUnConnect() {
|
||||
MsgError("蓝牙未连接过该设备,请使用蓝牙重新添加该设备",'去连接',this,()=>{
|
||||
MsgError("蓝牙未连接过该设备,请使用蓝牙重新添加该设备", '去连接', this, () => {
|
||||
uni.navigateTo({
|
||||
url: "/pages/common/addBLE/addEquip",
|
||||
events: {
|
||||
@ -522,7 +952,7 @@
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
},
|
||||
initMQ() {
|
||||
|
||||
@ -869,7 +1299,7 @@
|
||||
padding: 30rpx 0rpx;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
display: flex;
|
||||
align-content: space-around;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
@ -891,11 +1321,12 @@ display: flex;
|
||||
justify-content: flex-start;
|
||||
padding: 30rpx;
|
||||
box-sizing: border-box;
|
||||
border: 1rpx solid #00000000;
|
||||
}
|
||||
|
||||
.lampMode .mode.active {
|
||||
|
||||
border: 1px solid rgba(174, 214, 0, 1);
|
||||
border: 1rpx solid rgba(174, 214, 0, 1) !important;
|
||||
}
|
||||
|
||||
.lampMode .mode.active .bigTxt {
|
||||
@ -939,7 +1370,7 @@ display: flex;
|
||||
font-weight: 400;
|
||||
|
||||
letter-spacing: 0.07px;
|
||||
|
||||
border: 1px solid #00000000;
|
||||
}
|
||||
|
||||
.usrinfo {
|
||||
@ -1424,4 +1855,11 @@ display: flex;
|
||||
/deep/ .uni-navbar__placeholder {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.TextToHex {
|
||||
position: fixed;
|
||||
top: -99999rpx;
|
||||
left: -99999rpx;
|
||||
visibility: hidden;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user