1
0
forked from dyf/APP

完成008A功能开发

This commit is contained in:
liub
2026-05-19 17:38:56 +08:00
parent 6d9df4c945
commit 8f53a45280
63 changed files with 4162 additions and 766 deletions

View File

@ -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;
}