1
0
forked from dyf/APP

018A初步完成

This commit is contained in:
liub
2026-04-14 15:19:05 +08:00
parent d82ae6445e
commit 01ff9c7a05
43 changed files with 2626 additions and 892 deletions

View File

@ -43,7 +43,7 @@
<text class="lbl">设备名称</text>
<text class="value valueFont">{{device.deviceName}}</text>
</view>
<view class="item">
<text class="lbl">Mac地址</text>
@ -62,13 +62,13 @@
<text class="value valueFont">{{formData.sta_system}}</text>
</view>
</view>
<ProParams :id="device.id"></ProParams>
<MsgBox ref="msgPop" />
<global-loading ref="loading" />
</view>
</template>
@ -100,7 +100,7 @@
var ble = null;
var recei = null;
var mq = null;
var pagePath="pages/008A/HBY008A";
var pagePath = "pages/008A/HBY008A";
export default {
data() {
@ -112,9 +112,11 @@
apiType: "listA",
navbar: {
icons: [{
type:'msg',
src: '/static/images/common/msg.png'
},
{
type:'share',
src: '/static/images/common/shape.png'
}
],
@ -196,11 +198,11 @@
onUnload() {
console.log("页面卸载,释放资源");
let statusTopic = `A/${this.formData.imei?this.formData.imei:this.device.deviceImei}`;
if(ble){
ble.removeAllCallback(pagePath);
ble.removeReceiveCallback(pagePath);
if (ble) {
ble.removeAllCallback(pagePath);
ble.removeReceiveCallback(pagePath);
}
if (mq) {
mq.unsubscribe(statusTopic);
mq.disconnect();
@ -216,7 +218,7 @@
},
onLoad() {
these = this;
recei = BleReceive.getBleReceive();
ble = BleTool.getBleTool();
@ -230,8 +232,8 @@
eventChannel = this.getOpenerEventChannel();
eventChannel.on('detailData', (data)=> {
eventChannel.on('detailData', (data) => {
console.log("收到父页面的参数:" + JSON.stringify(data));
var device = data.data;
these.Status.apiType = data.apiType;
@ -285,7 +287,7 @@
these.formData.bleStatu = true;
}).catch(ex => {
these.formData.bleStatu = 'err';
MsgError("连接错误:" + ex.msg, "确定", these);
MsgError("连接错误:" + ex.msg, "确定", these);
});
});
@ -312,12 +314,43 @@
these.formData.bleStatu = true;
}).catch(ex => {
these.formData.bleStatu = 'err';
MsgError("连接错误:" + ex.msg, "确定", these);
MsgError("连接错误:" + ex.msg, "确定", these);
});
return;
}
},
getDevice: function() {
let f = ble.data.LinkedList.find((v) => {
return v.macAddress == these.device.deviceMac;
});
return f;
},
showBleUnConnect() {
MsgError("蓝牙未连接过该设备,请使用蓝牙重新添加该设备", "去连接", these, () => {
uni.navigateTo({
url: "/pages/common/addBLE/addEquip",
events: {
BindOver: function(data) {
console.log(data)
these.formData.bleStatu = true;
}
},
success: function(res) {
// 通过eventChannel向被打开页面传送数据
res.eventChannel.emit('detailData', {
data: these.device
})
},
fail(ex) {
console.log("跳转失败", ex);
}
})
})
},
initMQ() {
@ -442,8 +475,8 @@
updateLoading(these, {
text: ex.msg
})
these.formData.bleStatu = 'err';
MsgError("连接错误:" + ex.msg, "确定", these);
these.formData.bleStatu = 'err';
MsgError("连接错误:" + ex.msg, "确定", these);
}).finally(() => {
setTimeout(() => {
hideLoading(these);
@ -451,7 +484,7 @@
});
},
prevPage() {
uni.navigateBack({

File diff suppressed because it is too large Load Diff

View File

@ -339,36 +339,37 @@
},
dic: {
sta_VoiceType: {
"1": {
key: "1",
name: '消防',
show: true
},
"2": {
key: "2",
name: '公安',
show: true
},
"1": {
key: "1",
name: '消防',
show: true
},
"3": {
key: "3",
name: '交警',
show: true
},
"5": {
key: "5",
name: '应急',
show: true
},
"6": {
key: "6",
name: '医疗',
show: true
},
"4": {
key: "4",
name: '市政',
show: true
},
"5": {
key: "5",
name: '应急',
show: true
},
"6": {
key: "6",
name: '医疗',
show: true
},
},
"7": {
key: "7",
name: '铁道',

View File

@ -334,26 +334,22 @@
},
dic: {
sta_VoiceType: {
"1": {
key: "1",
name: '消防',
show: true
},
"0": {
key: "0",
name: '公安',
show: true
},
"1": {
key: "1",
name: '消防',
show: true
},
"3": {
key: "3",
name: '交警',
show: true
},
"4": {
key: "4",
name: '市政',
show: true
},
"2": {
key: "2",
name: '应急',
@ -364,6 +360,11 @@
name: '医疗',
show: true
},
"4": {
key: "4",
name: '市政',
show: true
},
"5": {
key: "5",
name: '铁道',

View File

@ -184,7 +184,8 @@
isLock: false,
empty: {
tip: '暂无数据',
hideScroll: false
hideScroll: false,
icon: '/static/images/common/empty.png'
}
},
page: 1, // 当前页码

View File

@ -192,7 +192,8 @@
isLock: false,
empty: {
tip: "暂无数据",
hideScroll: false,
hideScroll: false,
icon: '/static/images/common/empty.png'
},
textNoMore: "没有更多数据了",
},

View File

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

View File

@ -291,7 +291,8 @@
MsgClose,
MsgWarning,
showPop,
MsgInfo
MsgInfo,
MsgClear
} from '@/utils/MsgPops.js'
const pagePath = "/pages/4877/BJQ4877";
@ -1180,6 +1181,7 @@
if (receive.deviceId !== this.formData.deviceId) {
return;
}
console.log("收到设备的数据", receive)
let data = recei.ReceiveData(receive, device, pagePath, recArr);
console.log("处理后的数据:", data);
@ -1206,6 +1208,7 @@
}
if (msg.length) {
msg = msg.join(",");
MsgClear(these);
this.showMsg(msg);
}
@ -1349,23 +1352,13 @@
},
showMsg(msg, isSucc) {
let icoUrl = '/static/images/common/uploadErr.png';
let borderColor = "#e034344d";
let buttonBgColor = "#E03434";
showMsg(msg, isSucc) {
if (isSucc) {
icoUrl = '/static/images/common/success.png';
borderColor = "#BBE600";
buttonBgColor = "#BBE600";
MsgSuccess(msg,'',this);
}
else{
MsgError(msg,'',this);
}
showPop({
message: msg,
iconUrl: icoUrl,
borderColor: borderColor,
buttonBgColor: buttonBgColor,
buttonText: '确定',
okCallback: null
},this);
}
}
}

View File

@ -39,14 +39,7 @@
</view>
</view>
<view class="warnnig" :class="formData.sta_ShakeBit!=0 ?'':'displayNone'">
<view>{{formData.sta_ShakeBit==3?'设备疑似受到外力碰撞':'设备声光报警中'}}</view>
<view @click.stop="SOSToggle()">
<uni-icons type="closeempty" color="#FFFFFFde" size="16"></uni-icons>
</view>
</view>
@ -119,8 +112,15 @@
</view>
</view>
</view>
<view class="warnnig" :class="formData.sta_ShakeBit!=0 ?'':'displayNone'">
<view>{{formData.sta_ShakeBit==3?'设备疑似受到外力碰撞':'设备声光报警中'}}</view>
<view @click.stop="SOSToggle()">
<uni-icons type="closeempty" color="#FFFFFFde" size="16"></uni-icons>
</view>
</view>
<view class="lamp">
<view class="title">
<text>灯光亮度</text>
@ -223,10 +223,7 @@
<text class="lbl">职位</text>
<input class="value" v-model="formData.job" placeholder="请输入职位" placeholder-class="usrplace" />
</view>
<view class="item">
<text class="lbl">ID号</text>
<input class="value" v-model="formData.usrid" placeholder="请输入ID" placeholder-class="usrplace" />
</view>
</view>
</view>
@ -625,7 +622,7 @@
borderColor: "#e034344d",
buttonBgColor: "#E03434",
buttonText: '确定',
buttonTextColor: '#232323de',
buttonTextColor: '#FFFFFFde',
showCancel: false,
showHeader: false,
visibleClose: true,
@ -1128,7 +1125,7 @@
uni.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ['album'],
sourceType: ['album','camera'],
success: function(res) {
uni.navigateTo({
url: "/pages/common/ImgCrop/ImgCrop",
@ -1426,7 +1423,7 @@
borderColor: "#e034344d",
buttonBgColor: "#E03434",
buttonText: '确定',
buttonTextColor: '#232323de',
buttonTextColor: '#FFFFFFde',
showCancel: true,
buttonCancelText: '取消',
okCallback: send
@ -1463,7 +1460,7 @@
borderColor: "#e034344d",
buttonBgColor: "#E03434",
buttonText: '确定',
buttonTextColor: '#232323de',
buttonTextColor: '#FFFFFFde',
showCancel: true,
showHeader: true,
visibleClose: false,
@ -1522,9 +1519,7 @@
}
this.formData.textLines = [this.formData.company, this.formData.usrname, this.formData.job, this.formData
.usrid
];
this.formData.textLines = [this.formData.company, this.formData.usrname, this.formData.job];
console.log("data=", this.formData.textLines);
showLoading(these, {
text: "发送中"
@ -1590,11 +1585,14 @@
let sendPacket = () => {
if (combinedData.length === curr - 1) {
holdHand('transmit complete', 200).then(res => {
setTimeout(()=>{
holdHand('transmit complete', 200).then(res => {
MsgSuccess("人员信息发送成功", "确定", these);
hideLoading(these);
this.setBleFormData();
});
},300);
hideLoading();
return;
}
@ -1608,7 +1606,7 @@
curr++;
console.log("发送成功", curr);
updateLoading(these, {
text: '发送中,' + (curr - 1) + '/' + 4
text: '发送中,' + (curr - 1) + '/' + combinedData.length
})
setTimeout(sendPacket, 250);
}).catch(err => {

View File

@ -865,7 +865,7 @@
uni.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ['album'],
sourceType: ['album','camera'],
success: function(res) {
uni.navigateTo({
url: "/pages/common/ImgCrop/ImgCrop",

View File

@ -903,7 +903,7 @@
uni.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ['album'],
sourceType: ['album','camera'],
success: function(res) {
uni.navigateTo({
url: "/pages/common/ImgCrop/ImgCrop",

View File

@ -31,7 +31,7 @@
<view class="battery-v1">
<image src="/static/images/common/time.png" class="dlIMG" mode="aspectFit"></image>
<view>
<view class="battery-v2">{{ deviceInfo.batteryRemainingTime || '0' }}分钟</view>
<view class="battery-v2">{{remainTime}}</view>
<view class="battery-v3">续航时间</view>
</view>
</view>
@ -54,13 +54,13 @@
</view>
<view class="info-row" v-if="itemInfo.deviceMac" @click="bleStatuToggle">
<text class="info-label">蓝牙状态</text>
<text class="info-value status-running" :class="formData.bleStatu?'green':'red'" >
<text class="info-value status-running" :class="formData.bleStatu?'green':'red'">
{{getbleStatu}}
</text>
</view>
<view class="info-row" v-if="itemInfo.deviceMac" @click="bleStatuToggle">
<text class="info-label">充电状态</text>
<text class="info-value status-running" >
<text class="info-value status-running">
{{deviceInfo.chargeState != 0?'充电中':'未充电'}}
</text>
</view>
@ -112,7 +112,7 @@
</view>
</view>
</view>
<view class="mode-v1" v-if="hasPermission('2')">
<view class="mode-v1" v-if="hasPermission('2')" :class="{'active':isLaserOn}">
<view class="mode-v2" @click="lasermode">
<image src="/static/images/6170/jg.png" class="setIMG" mode="aspectFit"></image>
<view>
@ -121,17 +121,20 @@
</view>
</view>
</view>
<view class="mode-v1" :class="{'active':itemInfo.alarmStatus===1 || itemInfo.alarmStatus==='1'}" >
<view class="mode-v1"
:class="{'active':itemInfo.alarmStatus===1 || itemInfo.alarmStatus==='1'}">
<view class="mode-v2" @click="warnToggle">
<image v-show="itemInfo.alarmStatus!=1" src="/static/images/common/sg.png" class="setIMG" mode="aspectFit"></image>
<image v-show="itemInfo.alarmStatus==1" src="/static/images/common/sgActive.png" class="setIMG" mode="aspectFit"></image>
<image v-show="itemInfo.alarmStatus!=1" src="/static/images/common/sg.png"
class="setIMG" mode="aspectFit"></image>
<image v-show="itemInfo.alarmStatus==1" src="/static/images/common/sgActive.png"
class="setIMG" mode="aspectFit"></image>
<view>
<view class="battery-v2">{{itemInfo.alarmStatus==1?'解除报警':'强制报警'}}</view>
<view class="battery-v2">{{itemInfo.alarmStatus==1?'解除报警':'强制报警'}}</view>
</view>
</view>
</view>
<view class="mode-v1" v-if="hasPermission('3')">
<view class="mode-v2" @click="uploadStartup">
<image src="/static/images/common/path7.png" class="setIMG" mode="aspectFit"></image>
@ -147,7 +150,7 @@
<!-- 人员信息登记 -->
<view class="form-section" v-if="hasPermission('4')">
<TextToHexV2 class="TextToHex" ref="textToHex" :txts="formData.textLines" :bgColor="'#FFFFFF'"
:color="'#000000'" :fontSize="14" :returnType="10" />
:color="'#000000'" :fontSize="12" :returnType="10" />
<view class="mode-buttons">
<view class="section-title">人员信息登记</view>
@ -161,17 +164,16 @@
<view class="form-row">
<text class="form-label">单位</text>
<input class="form-input" placeholder="请输入单位" v-model="personnelInfo.unitName"
:maxlength="15" />
:maxlength="8" />
</view>
<view class="form-row">
<text class="form-label">姓名</text>
<input class="form-input" placeholder="请输入姓名" v-model="personnelInfo.name"
:maxlength="15" />
<input class="form-input" placeholder="请输入姓名" v-model="personnelInfo.name" :maxlength="8" />
</view>
<view class="form-row">
<text class="form-label">职位</text>
<input class="form-input" placeholder="请输入职位" v-model="personnelInfo.position"
:maxlength="15" />
:maxlength="8" />
</view>
<view class="form-row">
<text class="form-label">ID</text>
@ -180,7 +182,7 @@
</view>
</view>
</view>
<!-- 人员信息登记 -->
<!-- 发送信息-->
<view class="form-section" v-if="hasPermission('5')">
<view class="mode-buttons">
<view class="section-title">发送信息</view>
@ -193,7 +195,7 @@
</view>
<!-- 产品信息 -->
<ProParams :id="itemInfo.id"></ProParams>
</view>
<!-- 弹框 -->
<view class="agreement-mask" v-if="lightModeA" @click.stop="closePopup">
@ -276,15 +278,17 @@
<CustomPopup v-if="popupType === 'cancel'" :show="showPopupFlag"
popupBorder="1rpx solid rgba(224, 52, 52, 0.3)" :message="popupMessage"
icon="/static/images/6170/svg.png" :confirm-text="popupConfirmText" :show-cancel="true"
@confirm="onPopupConfirmPolice" confirmBtnBg="rgba(224, 52, 52, 1)" confirmBtnColor="#fff" />
@cancel="onPopupConfirm" @confirm="onPopupConfirmPolice" confirmBtnBg="rgba(224, 52, 52, 1)"
confirmBtnColor="#fff" />
<!-- 强制报警 -->
<CustomPopup v-if="popupType === 'openWarn'" :show="showPopupFlag"
popupBorder="1rpx solid rgba(224, 52, 52, 0.3)" :message="popupMessage"
icon="/static/images/6170/svg.png" :confirm-text="popupConfirmText" :show-cancel="true"
@confirm="OpenWarn(1)" confirmBtnBg="rgba(224, 52, 52, 1)" confirmBtnColor="#fff" />
@cancel="onPopupConfirm" @confirm="OpenWarn(1)" confirmBtnBg="rgba(224, 52, 52, 1)"
confirmBtnColor="#fff" />
<MsgBox ref="msgPop" />
<global-loading ref="loading" />
</view>
@ -306,7 +310,8 @@
MsgError,
MsgClose,
MsgWarning,
showPop
showPop,
MsgInfo
} from '@/utils/MsgPops.js';
import Common from '@/utils/Common.js';
@ -355,7 +360,7 @@
navTitle: "",
sliderValue: 25,
lightModeA: false,
currentMainMode: '强光',
currentMainMode: '关闭',
currentlaserMode: "关闭",
lightModeB: false,
lightModeC: false, //激光提示框
@ -402,7 +407,7 @@
rgb565Data: null,
selectedItemIndex: 0,
popupType: 'person', //弹框类型
isLaserOn: false,
isLaserOn: false, //激光开启状态
isSending: false,
isProcessing: false,
isPolling: false, // 轮询状态
@ -418,6 +423,9 @@
}
},
computed: {
remainTime() {
return Common.formatTime(this.deviceInfo.batteryRemainingTime);
},
computedDeviceId() {
return this.apiType === 'listA' ? this.deviceID : this.itemInfo.deviceId;
},
@ -442,7 +450,8 @@
}
},
methods: {
onReceive(deviceState){//蓝牙/Mq通用消息处理
onReceive(deviceState, parsedMessage) { //蓝牙/Mq通用消息处理
switch (deviceState[0]) {
// 1设备切换灯光实时返回
case 1:
@ -452,13 +461,21 @@
this.sliderValue = deviceState[2];
this.deviceInfo.batteryRemainingTime = deviceState[3];
break;
case 6:
if(deviceState[1]==50){
this.popupType = 'person';
this.showPopupFlag = true;
this.popupMessage = '信息发送成功';
uni.hideLoading();
}
break;
// 12为设备实时上报
case 12:
this.currentMainMode = this.getMainLightModeLabel(
deviceState[
1]);
this.currentMainMode = this.getMainLightModeLabel(deviceState[1]);
this.isLaserOn = deviceState[2] === 1; //第3位表示当时激光灯档位
this.currentlaserMode = this.isLaserOn ? "开启" : "关闭";
this.deviceInfo.alarmStatus= deviceState[6];//报警状态
this.itemInfo.alarmStatus= deviceState[6];
if (this.deviceInfo) {
this.deviceInfo.batteryPercentage = deviceState[3]; //第4位电量百分比
this.deviceInfo.chargeState = deviceState[4]; //第5位为充电状态0没有充电1正在充电2为已充满
@ -501,19 +518,19 @@
});
return;
}
if (this.formData.bleStatu === false || this.formData.bleStatu === 'err') {
these.formData.bleStatu = 'connecting';
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
these.formData.bleStatu = true;
}).catch(ex => {
these.formData.bleStatu = 'err';
MsgError("连接错误:"+ex.msg,"确定",these);
MsgError("连接错误:" + ex.msg, "确定", these);
});
return;
}
},
getDevice: function() {
if (ble) {
@ -556,7 +573,7 @@
borderColor: "#e034344d",
buttonBgColor: "#E03434",
buttonText: '去连接',
buttonTextColor: '#FFFFFFde',
buttonTextColor: '#FFFFFFde',
showCancel: true,
okCallback: function() {
console.log("1111");
@ -583,10 +600,15 @@
return;
}
let data = rec.ReceiveData(receive, device, pagePath, recArr);
console.log("蓝牙收到消息", data)
this.onReceive(data.state);
let keys = Object.keys(data);
if (keys.length && "state" in data) {
this.onReceive(data.state, receive.str);
} else {
console.log("不是状态数据,丢弃", data);
}
},
bleStateBreak() {
if (this.Status.pageHide) {
return;
@ -620,7 +642,7 @@
text: ex.msg
})
these.formData.bleStatu = 'err';
MsgError("连接错误:"+ex.msg,"确定",these);
MsgError("连接错误:" + ex.msg, "确定", these);
}).finally(() => {
setTimeout(() => {
hideLoading(these);
@ -737,60 +759,62 @@
});
},
onSliderChanging(e) {
if (!this.cardRect) return;
let value = e.detail.value;
if (value < 10) {
value = 10;
}
this.sliderValue = value; // 实时更新UI
const now = Date.now();
// 使用节流防止指令发送过于频繁
if (now - this.lastBrightnessTime > 200) { // 200毫秒节流
this.lastBrightnessTime = now;
return;
// const now = Date.now();
// // 使用节流防止指令发送过于频繁
// if (now - this.lastBrightnessTime > 200) { // 200毫秒节流
// this.lastBrightnessTime = now;
let mqSend = () => {
// let mqSend = () => {
// 增加轻微的震动反馈,提升手感
uni.vibrateShort({
type: 'light'
});
// // 增加轻微的震动反馈,提升手感
// uni.vibrateShort({
// type: 'light'
// });
let data = {
deviceId: this.computedDeviceId,
instructValue: this.sliderValue + '.00',
deviceImei: this.itemInfo.deviceImei,
}
lightBrightnessSettings(data).then((res) => {
if (res.code !== 200) {
// 可以在这里处理错误但滑动中不建议用toast
}
})
}
// let data = {
// deviceId: this.computedDeviceId,
// instructValue: this.sliderValue + '.00',
// deviceImei: this.itemInfo.deviceImei,
// }
// lightBrightnessSettings(data).then((res) => {
// if (res.code !== 200) {
// // 可以在这里处理错误但滑动中不建议用toast
// }
// })
// }
if (ble && this.itemInfo.deviceMac) {
let f = this.getDevice();
if (f) {
let json = {
instruct: [5, 0, 0, 0, 0]
};
json.instruct[1] = parseInt(this.sliderValue);
// if (ble && this.itemInfo.deviceMac) {
// let f = this.getDevice();
// if (f) {
// let json = {
// instruct: [5, 0, 0, 0, 0]
// };
// json.instruct[1] = parseInt(this.sliderValue);
ble.sendString(f.deviceId, json).then(res => {
// ble.sendString(f.deviceId, json).then(res => {
}).catch(ex => {
mqSend();
});
} else {
mqSend();
}
return;
} else {
mqSend();
}
}
// }).catch(ex => {
// mqSend();
// });
// } else {
// mqSend();
// }
// return;
// } else {
// mqSend();
// }
// }
},
onSliderChangeEnd(e) {
if (this.deviceInfo.alarmStatus == 1) {
MsgError('请先解除强制报警', '', these);
return;
}
let value = e.detail.value;
if (value < 10) {
value = 10;
@ -847,6 +871,10 @@
}
},
selectMode(type) {
if (this.deviceInfo.alarmStatus == 1) {
MsgError('请先解除强制报警', '', these);
return;
}
this.modeType = type;
this.lightModeA = true;
if (type === 'main') {
@ -906,7 +934,10 @@
},
// 灯光模式的确认
handleSumbit() {
if (this.deviceInfo.alarmStatus == 1) {
MsgError('请先解除强制报警', '', these);
return;
}
if (this.selectedItemIndex === null) return;
const selectedItem = this.items[this.selectedItemIndex];
@ -928,8 +959,13 @@
};
lightModeSettings(data).then((res) => {
if (res.code == 200) {
this.currentMainMode = this.pendingMainMode;
this.selectedItemIndex = selectedItem;
this.currentMainMode = this.getMainLightModeLabel(selectedItem.instructValue);
this.isLaserOn = false; //第3位表示当时激光灯档位
this.currentlaserMode = "关闭";
uni.showToast({
title: res.msg,
icon: 'none'
@ -959,8 +995,11 @@
json.instruct[1] = parseInt(selectedItem.instructValue);
ble.sendString(f.deviceId, json).then(res => {
console.log("ble send success",json);
console.log("ble send success", json);
this.lightModeA = false;
this.currentMainMode = this.getMainLightModeLabel(selectedItem.instructValue);
this.isLaserOn = false;
this.currentlaserMode = "关闭";
}).catch(ex => {
console.error("ble send fail,mqsending....")
mqSend();
@ -976,15 +1015,23 @@
},
// 激光模式
lasermode() {
if (this.deviceInfo.alarmStatus == 1) {
MsgError('请先解除强制报警', '', these);
return;
}
this.lightModeC = true
},
// 激光确认框提交
handleBtn() {
if (this.deviceInfo.alarmStatus == 1) {
MsgError('请先解除强制报警', '', these);
return;
}
const instructValue = this.isLaserOn ? 0 : 1;
let mqSend = () => {
@ -1011,6 +1058,10 @@
// 更新状态
this.isLaserOn = !this.isLaserOn;
this.currentlaserMode = this.isLaserOn ? "开启" : "关闭";
this.currentMainMode = this.getMainLightModeLabel(0);
this.lightModeC = false;
} else {
uni.showToast({
@ -1035,6 +1086,8 @@
this.lightModeC = false;
this.isLaserOn = !this.isLaserOn;
this.currentlaserMode = this.isLaserOn ? "开启" : "关闭";
this.currentMainMode = this.getMainLightModeLabel(0);
}).catch(ex => {
mqSend();
});
@ -1052,7 +1105,12 @@
},
// 上传开机画面
uploadStartup() {
this.lightModeB = true
if (this.deviceInfo.alarmStatus == 1) {
MsgError('请先解除强制报警', '', these);
return;
}
this.lightModeB = true;
this.selectedImage=null;
},
// 上传开机画面
checkImgUpload() {
@ -1102,6 +1160,10 @@
});
return;
}
if (this.deviceInfo.alarmStatus == 1) {
MsgError('请先解除强制报警', '', these);
return;
}
let mqSend = () => {
if (this.deviceInfo.onlineStatus !== 1) {
@ -1264,9 +1326,9 @@
dataView.setUint8(0, 0x55); // 帧头
dataView.setUint8(1, 0x02); // 帧类型:开机画面
dataView.setUint8(2, currentPacket); // 包序号
dataView.setUint16(3, packetData.length*2,false); // 包t长度
dataView.setUint16(3, packetData.length * 2, false); // 包t长度
// 填充数据每个RGB565值占2字节
for (let i = 0; i < packetData.length; i++) {
@ -1338,11 +1400,11 @@
});
}
setTimeout(()=> {
setTimeout(() => {
sendImagePackets().catch(() => {
}).finally(()=>{
this.lightModeB=false;
}).finally(() => {
this.lightModeB = false;
});
}, 0)
}
@ -1373,6 +1435,11 @@
},
// 发送人员信息
sendPersonnelInfo() {
if (this.deviceInfo.alarmStatus == 1) {
MsgError('请先解除强制报警', '', these);
return;
}
let mqSend = async () => {
if (this.isSending) return;
const requiredFields = [{
@ -1532,9 +1599,9 @@
hideLoading();
return;
}
let packData = combinedData[curr - 1];
let array = {
instruct: [2, curr].concat(combinedData[curr - 1])
instruct: [2, curr, packData.length].concat(packData)
};
@ -1574,15 +1641,17 @@
setTimeout(() => {
Promise.allSettled([holdHand('word transmit start', 2200), drawText()]).then(
results => {
console.log("results=", results);
if (results[0].status == 'rejected') {
MsgError(results[0].reason.code + ':' + results[0].reason.msg, '',
these);
setTimeout(() => {
hideLoading(these)
}, 500);
return;
}
if (results[1].status == 'rejected') {
MsgError("无法完成文字取模", '', these);
return;
}
@ -1615,32 +1684,36 @@
this.showPopupFlag = true;
// this.popupConfirmText="";
},
OpenWarn(val){//开启/解除强制报警
debugger;
OpenWarn(val) { //开启/解除强制报警
debugger;
const topic = `B/${this.itemInfo.deviceImei}`;
let message={"instruct":[7,val,0,0,0,0]};
message=JSON.stringify(message);
let flag=this.mqttClient.publish(topic, message, {
let message = {
"instruct": [7, val, 0, 0, 0, 0]
};
message = JSON.stringify(message);
let flag = this.mqttClient.publish(topic, message, {
qos: 1
});
if(flag){
this.itemInfo.alarmStatus=val;
}else{
MsgError("操作没有成功",'确定',this);
if (flag) {
this.itemInfo.alarmStatus = val;
this.deviceInfo.alarmStatus = val;
} else {
MsgError("操作没有成功", '确定', this);
}
this.showPopupFlag = false;
this.onPopupConfirm();
},
warnToggle(){
if(this.itemInfo.alarmStatus==1){
warnToggle() {
if (this.itemInfo.alarmStatus == 1) {
this.popupType = 'cancel';
this.popupMessage = '确认解除报警状态';
}else{
} else {
this.popupType = 'openWarn';
this.popupMessage = '确认开启报警状态';
}
this.showPopupFlag = true;
// this.popupConfirmText="开启";
@ -1650,25 +1723,25 @@
// val=0;
// msg="确认解除强制报警?";
// }
// let mqSend=()=>{
// const topic = `B/${this.itemInfo.deviceImei}`;
// let message={"instruct":[7,val,0,0,0,0]};
// message=JSON.stringify(message);
// let flag=this.mqttClient.publish(topic, message, {
// qos: 1
// });
// if(flag){
// this.itemInfo.alarmStatus=val;
// }
// }
},
// 解除报警逻辑
async onPopupConfirmPolice() {
if (this.deviceInfo.onlineStatus !== 1) {
@ -1676,7 +1749,7 @@
// title: '设备已离线',
// icon: 'none'
// });
this.OpenWarn(0);//走mq直发
this.OpenWarn(0); //走mq直发
return;
}
this.isPolling = true; // 标记开始轮询
@ -1701,14 +1774,18 @@
// title: registerRes.msg,
// icon: 'none'
// })
this.OpenWarn(0);
return
}
this.itemInfo.alarmStatus=0;
this.itemInfo.alarmStatus = 0;
this.deviceInfo.alarmStatus = 0;
uni.hideLoading();
this.showPopupFlag = false
// 4. 获取设备状态FunctionAccessBatchStatusRule 批量
let deviceImei = this.itemInfo.deviceImei
let typeName = this.itemInfo.typeName
const statusRes = await getdeviceSTatus({
getdeviceSTatus({
functionMode: 2,
batchId,
typeName: 'FunctionAccessBatchStatusRule',
@ -1716,22 +1793,26 @@
interval: 500
},
deviceRealTimeStatus
);
if (statusRes.data.functionAccess === 'OK') {
uni.showToast({
title: statusRes.msg,
icon: 'none'
});
uni.$emit('deviceStatusUpdate', {});
this.showPopupFlag = false
if (this.apiType === 'listA') {
this.fetchDeviceDetail(this.computedDeviceId)
} else {
// 分享权限详情
this.fetchSharedDeviceDetail(this.itemInfo.id)
}
).then(statusRes => {
if (statusRes.data.functionAccess === 'OK') {
uni.showToast({
title: statusRes.msg,
icon: 'none'
});
uni.$emit('deviceStatusUpdate', {});
if (this.apiType === 'listA') {
this.fetchDeviceDetail(this.computedDeviceId)
} else {
// 分享权限详情
this.fetchSharedDeviceDetail(this.itemInfo.id)
}
}
}).catch(ex => {
console.error("出现错误", ex);
});
}
} catch (error) {
uni.showToast({
title: error.message,
@ -1751,6 +1832,12 @@
});
return;
}
if (this.deviceInfo.alarmStatus == 1) {
MsgError('请先解除强制报警', '', these);
return;
}
// 防重复提交
if (this.isSending) return;
if (!this.messageToSend) {
@ -1801,9 +1888,9 @@
);
// 只有当状态为'OK'时才显示成功弹窗
if (statusRes.data.functionAccess === 'OK') {
this.popupType = 'person';
this.showPopupFlag = true;
this.popupMessage = '信息发送成功';
// this.popupType = 'person';
// this.showPopupFlag = true;
// this.popupMessage = '信息发送成功';
}
} catch (error) {
uni.showToast({
@ -1899,7 +1986,7 @@
}
}
},
// 发送mqtt查询设备信息
queryDeviceStatus() {
if (this.mqttClient && this.mqttClient.isConnected()) {
@ -1955,14 +2042,30 @@
this.mqttClient.subscribe(statusTopic, (payload) => {
try {
console.log(`收到来自 ${statusTopic} 的消息:`, payload);
console.log("typeof payload=", typeof payload);
const parsedMessage = typeof payload === 'string' ? JSON.parse(
payload) :
payload;
const deviceState = parsedMessage.state; // 直接取 state 数组
// 切换主灯光模式,亮度值设备同步
if (!deviceState) return;
this.onReceive(deviceState);
payload) : payload;
let keys = Object.keys(parsedMessage);
if("sta_BreakNews" in parsedMessage){
console.error("收到确认消息")
if(parsedMessage.sta_BreakNews=='I get it'){
MsgSuccess("用户已确认收到紧急通知","",this);
}
}
else if (keys.length && "state" in parsedMessage) {
const deviceState = parsedMessage.state; // 直接取 state 数组
// 切换主灯光模式,亮度值设备同步
if (!deviceState || !deviceState instanceof Array) {
return;
}
this.onReceive(deviceState, parsedMessage);
}else{
console.error("丢弃的消息",payload)
}
} catch (error) {
console.log('解析MQTT消息失败:', error, '原始消息:', payload);
}
@ -1999,10 +2102,10 @@
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(
res => {
these.formData.bleStatu = true;
}).catch(ex=>{
these.formData.bleStatu = 'err';
MsgError("连接错误:"+ex.msg,"确定",these);
});
}).catch(ex => {
these.formData.bleStatu = 'err';
MsgError("连接错误:" + ex.msg, "确定", these);
});
}
}
@ -2022,8 +2125,8 @@
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
console.log("连接成功")
this.formData.bleStatu = true;
}).catch(ex=>{
MsgError("连接错误:"+ex.msg,"确定",these);
}).catch(ex => {
MsgError("连接错误:" + ex.msg, "确定", these);
});
}
},
@ -2261,8 +2364,9 @@
box-sizing: border-box;
border: 1rpx solid #00000000;
}
.mode-v1.active{
border:1rpx solid #bbe600 !important;
.mode-v1.active {
border: 1rpx solid #bbe600 !important;
}
.mode-v2 {

View File

@ -758,7 +758,7 @@
uni.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ['album'],
sourceType: ['album','camera'],
success: function(res) {
uni.navigateTo({
url: "/pages/common/ImgCrop/ImgCrop",

View File

@ -23,10 +23,11 @@
<view class="p100">
<view class="lblTitle">配对设备</view>
<view class="list" style="margin-bottom: 30rpx;">
<view class="item " @click.stop="disConnect(item,index)" v-for="item, index in PairEquip" v-show="PairEquip.length>0">
<view class="item " @click.stop="disConnect(item,index)" v-for="item, index in PairEquip"
v-show="PairEquip.length>0">
<view class="leftImg ">
<image src="/static/images/common/bluetooth.png" class="titleIco filterNone"
mode="heightFix">
@ -34,7 +35,7 @@
</view>
<view class="centertxt ">
<view class="name" v-text="item.name"></view>
</view>
<view class="rightIco center">
<image src="/static/images/BLEAdd/linked.png" class="img" mode="aspectFit">
@ -50,10 +51,8 @@
<text>发现设备:{{deviceCnt}}</text>
<view @click="refreshBleList()">刷新</view>
</view>
<view class="lblTitle">
<input class="uni-input" v-model="search" placeholder="名称筛选" />
<!-- <uni-easyinput :styles="{color:'#ffffffde',borderColor:'#cbcbcba8'}" :clearable="true" class="uni-mt-5" :trim="'both'"
prefixIcon="search" v-model="search" placeholder="名称筛选"></uni-easyinput> -->
<view class="">
<input class="uni-input" v-model="search" placeholder="名称筛选" />
</view>
<view class="list searchList">
<view class="item" v-on:click="Link(item,index)" v-for="item, index in EquipMents"
@ -165,7 +164,7 @@
},
search: '', //筛选
PairEquip: [], //已配对设备
tmpLink:[],//本次已配对
tmpLink: [], //本次已配对
EquipMents: [], //搜索出来的设备
device: null,
item: {
@ -224,8 +223,8 @@
const systemInfo = uni.getSystemInfoSync();
// Ensure ble is initialized
// Ensure ble is initialized
if (systemInfo.uniPlatform == 'web') {
@ -253,15 +252,15 @@
];
console.error("1111111111")
this.PairEquip=[this.EquipMents[0]];
this.PairEquip = [this.EquipMents[0]];
return;
}
ble = bleTool.getBleTool();
this.refreshLinked();
this.refreshLinked();
let StartSubsrib = () => {
these.EquipMents = [];
if (!ble) {
ble = bleTool.getBleTool();
@ -366,31 +365,31 @@
these.EquipMents.sort((a, b) => b.RSSI - a.RSSI); //信号好的排前面,一般信号好的是目标设备
}
}, pagePath);
//蓝牙连接已恢复的回调
ble.addRecoveryCallback(res => {
if (these.Status.isPageHidden) {
return;
}
these.refreshLinked();
// hideLoading(these);
if (!these.device) {
if (!these.device) {
hideLoading(these);
}else{
} else {
clearInterval(this.Status.intval);
these.DeviceVerdict(res.deviceId);
}
}, pagePath);
}
let startValidDevice = () => {
if (these.device) {
console.log("进入配对模式,启用连接恢复和验证逻辑。");
//收到设备的消息回调
ble.addReceiveCallback((receivData, f, path, arr) => {
@ -412,7 +411,7 @@
showLoading(these, {
text: '正在验证设备'
});
setTimeout(() => {
these.DeviceVerdict(f.deviceId);
}, 0);
@ -424,7 +423,7 @@
StartSubsrib();
},
@ -437,19 +436,19 @@
this.refreshLinked();
},
methods: {
refreshLinked(){
if(ble){
let arr=[];
arr=ble.data.LinkedList.filter(v=>{
refreshLinked() {
if (ble) {
let arr = [];
arr = ble.data.LinkedList.filter(v => {
return v.Linked;
});
this.PairEquip=arr;
this.PairEquip = arr;
}
},
checkAndRequestLocationPermission() {
return new Promise((resolve) => {
@ -500,7 +499,8 @@
}
const hasPermission = await this.checkAndRequestLocationPermission();
if (!hasPermission) {
console.log("缺少定位权限,已中止蓝牙扫描。");
MsgError('缺少定位权限,已中止蓝牙扫描', '', this);
return;
}
@ -524,19 +524,19 @@
time = setTimeout(() => {
these.EquipMents = [];
ble.StartSearch().then(result => {
// console.log("开始搜索成功", result);
these.Status.BottomMenu.show=false;
these.Status.BottomMenu.show = false;
}).catch(err => {
console.error("开始搜索失败:", err);
if (err.code === 10001) {
these.showOpenSetting();
} else {
MsgClear(these);
MsgError('出现错误:' + err.msg, '确定', these);
MsgError('出现错误:' + err.msg, '确定', these, () => {
MsgClear(these);
});
}
}).finally(() => {
@ -580,9 +580,9 @@
ble.showBlueSetting(false);
},
DeviceVerdict(deviceId) { //判断是否是目标设备
if (these.Status.isPageHidden) {
return;
}
if (these.Status.isPageHidden) {
return;
}
console.log("deviceid=", deviceId);
console.log("these.device=", these.device)
if (these.device) { //从设备详情过来的,回设备详情去
@ -681,7 +681,7 @@
text: "等待设备上报Mac地址," + these.Status.time + 's'
});
clearInterval(this.Status.intval);
this.Status.intval = null;
@ -708,7 +708,7 @@
}
updateLoading(these, {
text: "等待设备上报Mac地址," + these.Status.time + 's'
});
@ -729,7 +729,7 @@
let index = 1;
let total = 5;
let linkCallback = (res) => {
let linkCallback = (res) => {
console.log("连接成功", these.device);
if (!these.device) {
console.log("跳转到绑定")
@ -746,12 +746,12 @@
});
return;
}
}
let execLink = () => {
return new Promise((resolve, reject) => {
if (index > total) {
reject({
msg: "连接超时"
@ -759,7 +759,7 @@
return;
}
ble.LinkBlue(item.deviceId).then((res) => {
this.tmpLink=[item];
this.tmpLink = [item];
console.log("连接成功");
ble.StopSearch();
resolve(res);
@ -767,9 +767,9 @@
if (index == total) {
console.log("连接了N次都没连上");
reject(ex);
updateLoading(this, {
text: ex.msg
})
updateLoading(this, {
text: ex.msg
})
return;
}
index++;
@ -786,7 +786,7 @@
execLink().then((res) => {
console.log("res=", res);
if(this.Status.isPageHidden){
if (this.Status.isPageHidden) {
return;
}
linkCallback(res);
@ -802,21 +802,21 @@
},
disConnect:function(item,index){
disConnect: function(item, index) {
// #ifdef H5|WEB
this.PairEquip.splice(index,1);
this.PairEquip.splice(index, 1);
// #endif
// #ifdef APP|APP-PLUS
if(ble){
ble.disconnectDevice(item.deviceId).catch(ex=>{
console.error("无法断开连接",ex);
if (ble) {
ble.disconnectDevice(item.deviceId).catch(ex => {
console.error("无法断开连接", ex);
});
}
// #endif
}
}
}

View File

@ -486,13 +486,11 @@
MsgError('蓝牙不可用','',these);
these.EquipMents.filter((v, i) => {
these.$set(these.EquipMents[i], 'link', false);
});
these.EquipMents=[];
}, pagePath);
ble.addStateRecoveryCallback(() => {
these.ReSearch();
MsgSuccess('蓝牙恢复可用','',these,()=>{
MsgClear(these);
})
@ -557,6 +555,7 @@
setTimeout(()=>{
debugger;
MsgInfo("如需要在PC上查看此数据,请复制链接后通过微信发送到PC,在PC端打开然后点右上角扫码授权","复制链接",these,true,()=>{
console.log("执行复制");
uni.setClipboardData({
@ -566,10 +565,18 @@
title:'已复制链接'
});
// #ifdef APP
plus.runtime.openURL('weixin://', (err) => {
MsgError("打开微信失败,请手动打开微信,发送至'文件传输助手'");
});
// #endif
// #ifndef APP
MsgInfo("已复制链接,请打开浏览器查看","",these);
setTimeout(()=>{
MsgClear(these);
},1200)
// #endif
},
fail(ex){
console.error("无法复制",ex)
@ -878,9 +885,10 @@
},
ReSearch() {
if (!ble) {
MsgError('蓝牙模块未初始化','',this);
return;
}
showLoading(this,{text:'请稍候...'});
ble.disconnectDevice().finally(dis => {
ble.StopSearch().finally(res => {
@ -893,6 +901,8 @@
}).catch(err => {
console.error("err=", err);
MsgError("出现错误:" + err.msg, '', these);
}).finally(()=>{
hideLoading(these);
});
},200);

View File

@ -9,57 +9,64 @@
</view>
</view>
</scroll-view>
<scroll-view class="device-list" scroll-y @scrolltolower="onScrollToLower" :lower-threshold="100"
style="height:80vh">
<view v-if="deviceList.length>0">
<view v-for="(group, groupIndex) in groupedDevices" :key="groupIndex">
<view class="share-header">
<text>{{
<view style="height: calc(100% - 200rpx);">
<mescroll-uni class="device-list" @init="mescrollInit" @down="downCallback" @up="upCallback"
:up="upOption" :down="downOption" :fixed="false">
<!-- <scroll-view class="device-list" scroll-y @scrolltolower="onScrollToLower" :lower-threshold="100"
style="height:80vh"> -->
<view v-if="deviceList.length>0">
<view v-for="(group, groupIndex) in groupedDevices" :key="groupIndex">
<view class="share-header">
<text>{{
tabs[activeTab].name === '我的分享'
? `分享给“${group.sharedTo}”的设备`
: `来自“${group.othersharedTo}”分享的设备`
}}</text>
<text class="edit-btn"
@click="toggleEdit(groupIndex)">{{editingGroup === groupIndex ? '完成' : '编辑'}}</text>
</view>
<block>
<text class="edit-btn"
@click="toggleEdit(groupIndex)">{{editingGroup === groupIndex ? '完成' : '编辑'}}</text>
</view>
<block>
<view class="device-card" v-for="(item, index) in group.devices" :key="index"
:ref="'swipeItem_' + index">
<view class="checkbox" v-if="editingGroup === groupIndex">
<uni-icons @click="handleDelete(item)" type="minus" size="20"
color="#FF4D4F"></uni-icons>
</view>
<view class="device-content" @click.stop="handleFile(item)">
<view class="device-header">
<view class="deviceIMG">
<image :src="item.devicePic" class="IMG" mode="aspectFit"></image>
</view>
<view class="device-name">
<view>设备:{{item.deviceName}}</view>
<view class="ID">
<view class="device-card" v-for="(item, index) in group.devices" :key="index"
:ref="'swipeItem_' + index">
<view class="checkbox" v-if="editingGroup === groupIndex">
<uni-icons @click="handleDelete(item)" type="minus" size="20"
color="#FF4D4F"></uni-icons>
</view>
<view class="device-content" @click.stop="handleFile(item)">
<view class="device-header">
<view class="deviceIMG">
<image :src="item.devicePic" class="IMG" mode="aspectFit"></image>
</view>
<view class="device-name">
<view>设备:{{item.deviceName}}</view>
<view class="ID">
ID:{{item.deviceImei}}</view>
<!-- 在线状态 -->
<view class="onlines" v-if="item.onlineStatus==1">在线</view>
<!-- 离线状态 -->
<view class="offlines" v-if="item.onlineStatus==0">离线</view>
<view>电量{{item.battery || '0'}}%</view>
<view class="ID">
ID:{{item.deviceImei}}</view>
<!-- 在线状态 -->
<view class="onlines" v-if="item.onlineStatus==1">在线</view>
<!-- 离线状态 -->
<view class="offlines" v-if="item.onlineStatus==0">离线</view>
<view>电量{{item.battery || '0'}}%</view>
</view>
</view>
</view>
</view>
</view>
</view>
</block>
</block>
</view>
</view>
</view>
<view v-else class="noDATA">
<!-- <view v-else class="noDATA">
<view>
<uni-icons type="image-filled" size="120" color="rgba(255, 255, 255, 0.9)"></uni-icons>
</view>
暂无数据
</view>
</scroll-view>
</view> -->
<!-- </scroll-view> -->
</mescroll-uni>
</view>
</view>
<!-- 删除弹框 -->
<view class="agreement-mask" v-if="deleteShow" @click="closePopup('delete')">
@ -81,6 +88,7 @@
</template>
<script>
var timeout=null;
import {
deviceShareList,
otherDeviceShareList,
@ -89,6 +97,23 @@
export default {
data() {
return {
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: [],
tabs: [{
name: '我的分享',
@ -131,6 +156,28 @@
},
methods: {
mescrollInit(mescroll) {
this.mescroll = mescroll;
},
// 下拉刷新
downCallback() {
if (this.mescroll) {
this.mescroll.resetUpScroll(false);
this.mescroll.scrollTo(0, 0);
}
this.getData();
},
// 上拉加载
upCallback() {
this.getData();
},
// 点击弹框外的区域关闭
closePopup(type) {
if (type === 'delete') {
@ -142,12 +189,13 @@
let url = item.detailPageUrl;
uni.navigateTo({
// url: "/pages/6170/deviceControl/index",
url:url,
url: url,
success: (res) => {
// 页面跳转成功后的回调函数
res.eventChannel.emit('detailData', {
data: item,
apiType:this.activeTab===0?'listA':'listB' // 自定义标识 // 自定义标识,详情哪里根据这个参数不同信息
apiType: this.activeTab === 0 ? 'listA' :
'listB' // 自定义标识 // 自定义标识,详情哪里根据这个参数不同信息
});
}
})
@ -200,43 +248,59 @@
},
// 获取设备列表
getData(tab) {
//console.log(tab.name, 'tab');
if (this.loading) return;
this.loading = true;
let data = {
pageNum: this.page,
pageSize: this.size,
}
// 根据当前tab决定调用哪个接口
const apiCall = tab.name === '我的分享' ? deviceShareList : otherDeviceShareList;
console.log('nihao');
apiCall(data).then((res) => {
if (res.code == 200) {
const newDevices = res.rows.map(device => ({
...device,
showConfirm: false,
sharedTo: device.phonenumber,
othersharedTo: device.otherPhonenumber
}));
// 分页处理
if (this.page === 1) {
this.deviceList = newDevices;
} else {
this.deviceList = [...this.deviceList, ...newDevices];
}
this.total = res.total;
// 判断是否已加载全部数据
if (res.rows.length < this.size || this.deviceList.length >= this.total) {
this.finished = true;
} else {
this.page++;
}
let task = () => {
if (this.loading) return;
this.loading = true;
let data = {
pageNum: this.mescroll.num,
pageSize: this.size,
}
}).finally(() => {
this.loading = false;
});
if (!data.pageNum) {
this.mescroll.endSuccess(0, false);
return;
}
// 根据当前tab决定调用哪个接口
const apiCall = this.tabs[this.activeTab].name === '我的分享' ? deviceShareList : otherDeviceShareList;
console.log('nihao');
apiCall(data).then((res) => {
if (res.code == 200) {
const newDevices = res.rows.map(device => ({
...device,
showConfirm: false,
sharedTo: device.phonenumber,
othersharedTo: device.otherPhonenumber
}));
// 分页处理
if (this.page === 1) {
this.deviceList = newDevices;
} else {
this.deviceList = [...this.deviceList, ...newDevices];
}
this.total = res.total;
let hasNext = true;
// 判断是否已加载全部数据
if (res.rows.length < this.size || this.deviceList.length >= this.total) {
this.finished = true;
hasNext = false;
} else {
this.page++;
hasNext = true;
}
this.mescroll.endSuccess(res.rows.length, hasNext);
}else{
this.mescroll.endSuccess(0, false);
}
}).finally(() => {
this.loading = false;
});
}
clearTimeout(timeout);
timeout = setTimeout(task, 50);
},
// 滚动触底事件处理
@ -254,7 +318,7 @@
},
beforeDestroy() {
// 组件销毁前移除监听器
},
}
</script>
@ -267,6 +331,9 @@
min-height: 100vh;
background-color: rgb(18, 18, 18);
padding: 30rpx;
width: 100%;
height: 100vh;
box-sizing: border-box;
}
.tab-bar {

View File

@ -196,7 +196,8 @@
isLock: false,
empty: {
tip: '暂无数据',
hideScroll: false
hideScroll: false,
icon: '/static/images/common/empty.png'
}
},
page: 1, // 当前页码

View File

@ -117,6 +117,13 @@
sendApi: deviceSendAlarmMessage,
statusTypeName: '',
sendType: 'XSSend'
},
,
{
type: ['HBY018A'],
sendApi: deviceSendAlarmMessage,
statusTypeName: '',
sendType: 'CommonSend'
}
]
},
@ -134,7 +141,8 @@
isLock: false,
empty: {
tip: '暂无数据',
hideScroll: false
hideScroll: false,
icon: '/static/images/common/empty.png'
},
textNoMore: '没有更多数据了'
},

View File

@ -29,10 +29,10 @@
<view v-if="deviceList.length>0">
<uni-swipe-action ref="swipeAction" >
<block v-for="(item, index) in deviceList" :key="index" :ref="'swipeItem_' + index">
<uni-swipe-action-item :right-options="Options"
<uni-swipe-action-item :right-options="Options" :show="item.showOption"
@click="handleSwipeClick($event, item, index)" class="device-card"
:style="{ border: item.communicationMode==0 && item.onlineStatus==1 && item.alarmStatus==1 ? '1px solid rgba(224, 52, 52, 1)' : 'none' }">
<view @click.stop="handleFile(item)">
<view @click.stop="handleFile(item,index)">
<view class="device-header">
<view class="deviceIMG">
<image :src="item.devicePic" class="IMG" mode="aspectFit"></image>
@ -62,7 +62,7 @@
</view>
</view>
</view>
<image src="/static/images/common/cires.png" class="circle" mode="aspectFit"></image>
<image @click.stop="swipeToggle(item,index)" src="/static/images/common/cires.png" class="circle" mode="aspectFit"></image>
</uni-swipe-action-item>
</block>
</uni-swipe-action>
@ -242,7 +242,8 @@
isLock: false,
empty: {
tip: '暂无数据',
hideScroll: false
hideScroll: false,
icon: '/static/images/common/empty.png'
},
textNoMore: '没有更多数据了'
},
@ -697,13 +698,20 @@
}
})
},
swipeToggle(item,index){
if(!item.showOption || item.showOption=='none'){
this.$set(this.deviceList[index],'showOption','right');
return;
}
this.$set(this.deviceList[index],'showOption','none');
},
// 列表跳转
handleFile(item) {
let url = item.detailPageUrl;
// url="/pages/6075/BJQ6075L";
// if(!url){
// url="/pages/6075/BJQ6075"
// }
handleFile(item,index) {
if(item.showOption=='right'){
this.$set(this.deviceList[index],'showOption','none');
return;
}
let url = item.detailPageUrl;
uni.navigateTo({
url: url,
events: {
@ -773,7 +781,7 @@
});
// 监听设备状态更新事件
uni.$on('deviceStatusUpdate', (data) => {
console.log('列表收到消息了么');
// console.log('列表收到消息了么');
this.downCallback();
});
ble = bleTool.getBleTool();
@ -805,9 +813,9 @@
//接收到消息的回调
ble.addReceiveCallback((receive, device, path, recArr) => {
console.error("首页收到消息了");
// console.error("首页收到消息了");
let json=recei.ReceiveData(receive, device, path, recArr);
console.error("消息内容",json);
// console.error("消息内容",json);
this.updateBleStatu();
}, pagePath);
@ -1148,7 +1156,7 @@
border-radius: 40rpx;
padding: 30rpx;
text-align: center;
border: 1px solid #E034344d;
border: 1px solid #E0343480;
}
@ -1161,7 +1169,7 @@
}
.agreement-popupC .cancelBtn{
border:1rpx solid #E034344d;
border:1rpx solid #E03434;
color:#E03434;
}

View File

@ -113,7 +113,8 @@
isLock: false,
empty: {
tip: '暂无数据',
hideScroll: false
hideScroll: false,
icon: '/static/images/common/empty.png'
},
textNoMore: '没有更多数据了'
},

View File

@ -0,0 +1,398 @@
<template>
<view class="maincontent contentBg">
<view class='btnAdd' @click="showEdit(null,null)">添加</view>
<view class="clear"></view>
<view v-for="item,index in list" v-if="item" class="item">
<view class="itemTitle">紧急联系人{{index+1}}</view>
<view class="center main">
<view class="phone">{{item}}</view>
<view class="btns">
<view class="btnEdit" @click.stop="showEdit(item,index)">修改</view>
<view class="btnDrop" @click.stop="dropPerson(item,index)">删除</view>
</view>
</view>
<view class="line" v-if="index%2==0"></view>
</view>
<mescroll-empty v-show="calcList.length==0" :option="Status.optEmpty"></mescroll-empty>
<!-- 编辑弹窗 -->
<MsgBox ref="editPop">
<view>
修改紧急联系人
</view>
<view class="w60">
<input type="text" placeholder="输入手机号" class="uni-input" v-model="cEdit.txt" />
</view>
</MsgBox>
<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,
MsgPrompt
} from '@/utils/MsgPops.js'
import Common from '@/utils/Common.js';
var these = null;
var eventChannel = null;
export default {
data() {
return {
list: ['', ''],
cEdit: {
txt: '',
index: -1
},
Status: {
optEmpty: {
tip: '暂无数据',
icon: '/static/images/common/empty.png'
}
},
device: {
id: "",
deviceName: "",
deviceImei: "",
deviceMac: "",
communicationMode: 0,
devicePic: "",
typeName: "",
bluetoothName: null,
deviceStatus: null,
bindingTime: "",
onlineStatus: 0,
battery: "0",
latitude: null,
longitude: null,
alarmStatus: null,
detailPageUrl: "/pages/650/HBY650",
showConfirm: false
}
}
},
computed: {
calcList() {
let f = this.list.filter((v, i) => {
return v;
});
return f;
}
},
onUnload() {
},
onShow() {
},
onHide: function() {
},
onLoad() {
these = this;
eventChannel = this.getOpenerEventChannel();
eventChannel.on('device', (data) => {
console.log("收到父页面的参数:" + JSON.stringify(data));
these.device = data;
this.list[0] = data.contact1Phone;
this.list[1] = data.contact2Phone;
});
},
methods: {
notifyPrevPage(){//通知上一个页面
if (eventChannel) {
eventChannel.emit('linkManOver', this.list);
}
},
saveData(json) {
return request({
url: "/app/hby018a/device/SetContactPhone",
method: 'POST',
data:json
});
},
dropPerson(item, index) {
showPop({
iconUrl: '/static/images/common/dell.png',
borderColor: "#e034344d",
buttonBgColor: "#E03434",
bgColor: '#383934cc',
buttonTextColor: '#FFFFFFde',
message: "确定删除紧急联系人" + (index + 1),
buttonText: '确定',
showSlot: false,
showCancel: true,
buttonCancelText: '取消',
okCallback: () => {
let url = '/app/hby018a/device/SetContactPhone';
if (!url) {
this.$set(this.list,index,"");
return;
}
let json = {
deviceId: this.device.id,
contact1Phone:index == 0 ? "" : this.list[0],
contact2Phone: index == 0 ? this.list[1] : ""
};
showLoading(these,{text:'请稍候...'});
this.saveData(json).then(res => {
if (res && res.code == 200) {
this.$set(this.list,index,"");
this.notifyPrevPage();
return;
}
MsgError(res.msg, '', these);
}).catch(ex => {
MsgError(ex.msg, '', these);
}).finally(() => {
hideLoading(these)
});
}
}, these, false);
},
showEdit(item, index) {
if (!item && this.calcList.length >= 2) {
MsgError('紧急联系人数量达到上限', '', these);
return;
}
if (item) {
this.cEdit.txt = item;
this.cEdit.index = index;
} else {
this.cEdit.index = this.calcList.length;
}
MsgPrompt(these, 'editPop', () => {
if (this.cEdit.txt.replace(/ /g, '') == '') {
MsgError('请输入联系人号码', '', these);
return true;
}
let reg = /^1\d{10}$/;
if (!reg.test(this.cEdit.txt)) {
MsgError('手机号格式不正确', '', these);
return true;
}
if (item) {
let f = this.list.find((v, i) => {
if (i == index) {
return false;
}
if (v == this.cEdit.txt) {
return true;
}
return false;
});
if (f) {
MsgError('已设置了相同的手机号', '', these);
return true;
}
}
let requestCall = () => {
this.$set(this.list, this.cEdit.index, this.cEdit.txt)
this.cEdit.txt = "";
this.cEdit.index = -1;
}
let url = '/app/hby018a/device/SetContactPhone';
if (!url) {
requestCall();
return;
}
let json = {
deviceId: this.device.id,
contact1Phone: this.cEdit.index == 0 ? this.cEdit.txt : this.list[0],
contact2Phone: this.cEdit.index == 0 ? this.list[1] : this.cEdit.txt
};
showLoading(these,{text:'请稍候...'});
this.saveData(json).then(res => {
if (res && res.code == 200) {
requestCall();
this.notifyPrevPage();
return;
}
MsgError(res.msg, '', these);
}).catch(ex => {
MsgError(ex.msg, '', these);
}).finally(() => {
hideLoading(these)
});
}, false);
}
}
}
</script>
<style>
.item .main {
margin-top: 10rpx;
}
.line {
width: 100%;
height: 0rpx;
border-bottom: 1px solid rgba(255, 255, 255, 0.06);
margin: 30rpx 0rpx 20rpx 0rpx;
}
.phone {
border-radius: 8px;
background: rgba(26, 26, 26, 1);
width: calc(100% - 160rpx);
height: 80rpx;
line-height: 80rpx;
text-indent: 20rpx;
}
.btns .btnEdit {
color: rgba(255, 255, 255, 0.87);
margin-right: 20rpx;
}
.btns .btnDrop {
color: rgba(224, 52, 52, 1);
}
.btns {
width: 160rpx;
height: 80rpx;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-content: center;
align-items: center;
justify-content: flex-end;
font-family: "PingFang SC";
font-style: Regular;
font-size: 28rpx;
font-weight: 400;
letter-spacing: 0.07px;
text-align: left;
}
.itemTitle {
color: rgba(255, 255, 255, 0.87);
font-family: "PingFang SC";
font-style: Regular;
font-size: 28rpx;
font-weight: 400;
line-height: 40rpx;
height: 40rpx;
letter-spacing: 0.07px;
text-align: left;
}
.w60 {
width: 70%;
margin-left: 15%;
}
.uni-input {
margin: 30rpx 0rpx 0rpx 0rpx;
background-color: #121212;
width: 100%;
height: 60rpx;
color: #ffffffde;
border: 1rpx solid #BBE600de;
border-radius: 8rpx;
font-size: 26rpx;
text-indent: 8rpx;
font-family: "PingFang SC";
line-height: 60rpx;
caret-color: #BBE600;
font-weight: 200;
text-align: left;
text-indent: 10rpx;
}
.btnAdd {
float: right;
color: rgba(255, 255, 255, 0.87);
font-family: "PingFang SC";
font-style: Regular;
font-size: 28rpx;
font-weight: 400;
line-height: 40rpx;
height: 40rpx;
letter-spacing: 0.07px;
text-align: left;
}
.content {
padding: 30rpx;
width: 100%;
min-height: 100vh;
height: auto;
}
.navbarRight .img {
width: 35rpx;
height: 35rpx;
margin-right: 20rpx;
}
.uni-navbar--fixed {
top: 0rpx;
}
/deep/ .uni-navbar--fixed {
top: 0px;
}
/deep/ .uni-navbar__placeholder {
display: none !important;
}
</style>

View File

@ -0,0 +1,251 @@
<template>
<view class="maincontent contentBg">
<view class="text-content">
<view class="uni-textarea">
<textarea class="textarea" v-model="txt" placeholder-class="placehoderClass"
placeholder="SOS求救短信内容二十字以内" :auto-height="true" maxlength="20" cursor-color="#BBE600" />
</view>
</view>
<view class="footBtn">
<view class="fright convert" @click.stop="saveTxt()">保存</view>
<view class="clear"></view>
</view>
<view class="title">常用短信</view>
<view class="staItem" v-for="item,index in list" @click="copyTo(item,index)">{{item}}</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;
var eventChannel = null;
export default {
data() {
return {
txt: '',
oldTxt:'',
list: ['出现危险,速来救我!', '被困险境,万分危急,求援!', '生死关头,请立刻报警'],
device: {
id: "",
deviceName: "",
deviceImei: "",
deviceMac: "",
communicationMode: 0,
devicePic: "",
typeName: "",
bluetoothName: null,
deviceStatus: null,
bindingTime: "",
onlineStatus: 0,
battery: "0",
latitude: null,
longitude: null,
alarmStatus: null,
detailPageUrl: "",
showConfirm: false
}
}
},
computed: {
},
onUnload() {
},
onShow() {
},
onHide: function() {
},
onLoad() {
these = this;
eventChannel = this.getOpenerEventChannel();
eventChannel.on('device', (data)=> {
console.log("收到父页面的参数:" + JSON.stringify(data));
these.device = data;
if(data.sosSmsMsg){
this.txt=data.sosSmsMsg;
}
});
},
methods: {
copyTo(item, index) {
this.txt = item;
},
saveTxt() {
if (this.txt.replace(/ /g, '') == '') {
MsgError('请输入通知内容', '', these);
return;
}
showLoading(this, {
text: '请稍候...'
});
console.log("this.device=",this.device);
request({
url: '/app/hby018a/device/SetSmsMsg',
method: 'POST',
data: {
sendMsg: this.txt,
deviceIds: [this.device.id]
}
}).then(res => {
if (res && res.code == 200) {
MsgSuccess('操作成功', '', these);
if(eventChannel){
eventChannel.emit('MsgOver', this.txt);
}
return;
}
MsgError(res.msg, '', these);
}).catch(ex => {
MsgError('出现错误,操作失败', '', these);
}).finally(() => {
hideLoading(these)
})
}
}
}
</script>
<style>
.staItem {
width: 100%;
height: 80rpx;
line-height: 80rpx;
border-radius: 8px;
background: rgba(26, 26, 26, 1);
text-indent: 30rpx;
color: rgba(255, 255, 255, 0.6);
font-family: "PingFang SC";
font-style: Regular;
font-size: 28rpx;
font-weight: 400;
letter-spacing: 0.07px;
margin-bottom: 25rpx;
}
.title {
color: rgba(255, 255, 255, 0.87);
margin: 15rpx 0rpx;
font-family: "PingFang SC";
font-style: Regular;
font-size: 28rpx;
font-weight: 400;
line-height: 40rpx;
width: 100%;
height: 40rpx;
letter-spacing: 0.07px;
text-align: left;
}
.footBtn .convert {
/* 组合 99 */
width: 130rpx;
height: 55rpx;
line-height: 55rpx;
border-radius: 180px;
color: #232323;
background-color: #AED600;
text-align: center;
font-family: 'PingFang SC';
font-size: 24rpx;
font-weight: 400;
letter-spacing: 12rpx;
}
.placehoderClass {
color: rgba(255, 255, 255, 0.6);
font-family: PingFang SC;
font-size: 32rpx;
font-weight: 400;
line-height: 44rpx;
letter-spacing: 0.14px;
}
.textarea {
min-height: 200rpx;
width: 100%;
box-sizing: border-box;
}
.text-content {
border-radius: 16rpx;
background: rgba(26, 26, 26, 1);
width: 100%;
height: auto;
box-sizing: border-box;
padding: 20rpx;
margin-bottom: 20rpx;
}
.content {
padding: 30rpx;
width: 100%;
min-height: 100vh;
height: auto;
}
.navbarRight .img {
width: 35rpx;
height: 35rpx;
margin-right: 20rpx;
}
.uni-navbar--fixed {
top: 0rpx;
}
/deep/ .uni-navbar--fixed {
top: 0px;
}
/deep/ .uni-navbar__placeholder {
display: none !important;
}
</style>

View File

@ -1,7 +1,7 @@
<template>
<view class="pageContent">
<image src="/static/images/common/login.png" mode="" class="login-bg"></image>
<view class="content_con">
<view class="content_con" @click="account">
<view class="user_logo">
<image src="/static/images/common/logo.png" class="logo"></image>
</view>
@ -37,14 +37,14 @@
<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">
<!-- <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> -->
<view class="menu-item" @click="account">
<image src="/static/images/common/wm.png" class="icon"></image>
<text class="title">账号安全</text>
<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">