1
0
forked from dyf/APP
Files
APP/pages/670/HBY670.vue

3313 lines
82 KiB
Vue
Raw Normal View History

2025-08-27 11:06:49 +08:00
<template>
<view class="content contentBg">
2025-08-28 14:05:06 +08:00
<custom-navbar :title="Status.navbar.title" :showBack="Status.navbar.showBack" color="#FFFFFF"
:rightIcons="Status.navbar.icons" @icon-click="handleRightClick"></custom-navbar>
<view>
</view>
2025-08-28 14:05:06 +08:00
<view class="eq" :style="{marginTop:Status.navbar.height+'px'}">
2025-11-07 11:57:35 +08:00
<view class="leftImg" @click.stop="previewImg(device.devicePic?device.devicePic:formData.img)">
<image class="img" :src="device.devicePic?device.devicePic:formData.img" mode="aspectFit"></image>
2025-08-27 11:06:49 +08:00
</view>
<view class="rightTxt">
<view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/battry.png" mode="aspectFit"></image>
<view class="txt">
<view class="bigTxt">{{formData.battary}}%</view>
<view class="smallTxt">电量</view>
</view>
</view>
<view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/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">
2025-11-07 11:57:35 +08:00
<view class="item">
<text class="lbl">设备名称</text>
<text class="value valueFont">{{device.deviceName}}</text>
</view>
2025-08-27 11:06:49 +08:00
<view class="item">
<text class="lbl">设备IMEI</text>
<text class="value valueFont">{{device.deviceImei}}</text>
2025-08-27 11:06:49 +08:00
</view>
2025-08-27 11:06:49 +08:00
<view class="item">
2025-11-07 11:57:35 +08:00
<text class="lbl">Mac地址</text>
<text class="value">{{device.deviceMac}}</text>
2025-08-27 11:06:49 +08:00
</view>
<view class="item">
<text class="lbl">蓝牙名称</text>
<text class="value valueFont">{{device.bluetoothName}}</text>
2025-08-27 11:06:49 +08:00
</view>
<view class="item">
<text class="lbl">蓝牙状态</text>
<text class="value" :class="formData.bleStatu?'green':'red'">{{formData.bleStatu?'已连接':'未连接'}}</text>
</view>
<view class="item">
<text class="lbl">设备状态</text>
<text class="value valueFont">{{formData.sta_system}}</text>
</view>
2025-08-27 11:06:49 +08:00
<view class="item">
<text class="lbl">定位信息</text>
<view class="multiValue" @click.stop="gotoMap()">
<view class="valueItem valueFont">
{{formData.Lon}}
</view>
<view class="valueItem valueFont">
{{formData.Lat}}
</view>
<view class="valueItem">
<view style="width:80%;float: right;text-align: right;" class="valueFont">
2025-09-24 11:34:15 +08:00
<uni-icons type="location" size="17" color="rgba(255, 255, 255, 0.8)"
style="vertical-align: bottom;" />
{{formData.address}}
</view>
<view class="clear"></view>
</view>
2025-08-27 11:06:49 +08:00
</view>
2025-08-27 11:06:49 +08:00
</view>
</view>
<view class="warnnig" :class="formData.staticWarn?'':'displayNone'">
<view>警告设备静止报警中</view>
2025-08-28 14:05:06 +08:00
<view class="netContent">
<view :class="getWarnStyle(1)" class="net netone"></view>
<view :class="getWarnStyle(2)" class="net nettwo"></view>
<view :class="getWarnStyle(3)" class="net netsiri"></view>
<view :class="getWarnStyle(4)" class="net netfour"></view>
<view :class="getWarnStyle(5)" class="net netfive"></view>
2025-08-28 14:05:06 +08:00
</view>
2025-08-27 11:06:49 +08:00
</view>
<view class="warnnig" :class="(formData.qzwarn && Status.staticWarn.time)?'':'displayNone'"
2025-08-28 14:46:04 +08:00
@click="CloseWarn(true)">
<view>设备强制报警中</view>
2025-08-28 14:46:04 +08:00
<view class="netContent">
{{Status.staticWarn.time}}s
</view>
</view>
2025-08-28 14:05:06 +08:00
2025-08-27 11:06:49 +08:00
<view class="optTitle">
档位
</view>
<view class="modeSetting">
<view class="item" :class="formData.modeCurr=='low'?'active':''"
@click="GearSetting('low','staticBattery')">
<view class="p100 center">低档</view>
</view>
<view class="item " :class="formData.modeCurr=='center'?'active':''"
@click="GearSetting('center','staticBattery')">
<view class="p100 center">中档</view>
</view>
<view class="item " :class="formData.modeCurr=='hight'?'active':''"
@click="GearSetting('hight','staticBattery')">
<view class="p100 center">高档</view>
</view>
<view class="item " :class="formData.modeCurr=='close'?'active':''"
@click="GearSetting('close','staticBattery')">
<view class="p100 center">关闭</view>
</view>
2025-08-28 14:05:06 +08:00
2025-08-27 11:06:49 +08:00
</view>
<view class="optTitle">
2025-08-28 14:05:06 +08:00
报警
2025-08-27 11:06:49 +08:00
</view>
<view class="sosContent">
<view class="item" @click="sosSetting('sg')" :class="formData.SOS=='sg'?'active':''">
<view class="imgContent center">
2025-08-28 14:05:06 +08:00
<image class="img"
:src="formData.SOS=='sg'?'/static/images/670/sgActive.png':'/static/images/670/sg.png'"
mode="aspectFit"></image>
2025-08-27 11:06:49 +08:00
</view>
<view :class="(formData.qzwarn && Status.staticWarn.time)?'':'displayNone'">
报警中{{Status.staticWarn.time}}</view>
<view :class="(formData.qzwarn && Status.staticWarn.time)?'displayNone':''" class="txt">声光报警</view>
2025-08-27 11:06:49 +08:00
</view>
2025-08-28 14:05:06 +08:00
<view class="item" @click="sosSetting('rb')" :class="formData.SOS=='rb'?'active':''">
2025-08-27 11:06:49 +08:00
<view class="imgContent center">
2025-08-28 14:05:06 +08:00
<image class="img"
:src="formData.SOS=='rb'?'/static/images/670/rbActive.png':'/static/images/670/rb.png'"
mode="aspectFit"></image>
2025-08-27 11:06:49 +08:00
</view>
<view class="txt">红蓝闪烁</view>
</view>
</view>
<view class="optTitle">
照明模式
</view>
<view class="lightMode">
<view class="item" @click="lightSetting('qiang')" :class="formData.lightCurr=='qiang'?'active':''">
<view class="imgContent center">
2025-08-28 14:05:06 +08:00
<image class="img"
:src="formData.lightCurr=='qiang'?'/static/images/670/qiangActive.png':'/static/images/670/qiang.png'"
mode="aspectFit"></image>
2025-08-27 11:06:49 +08:00
</view>
<view class="txt">强光</view>
</view>
2025-08-28 14:05:06 +08:00
<view class="item" @click="lightSetting('ruo')" :class="formData.lightCurr=='ruo'?'active':''">
2025-08-27 11:06:49 +08:00
<view class="imgContent center">
2025-08-28 14:05:06 +08:00
<image class="img"
:src="formData.lightCurr=='ruo'?'/static/images/670/ruoActive.png':'/static/images/670/ruo.png'"
mode="aspectFit"></image>
2025-08-27 11:06:49 +08:00
</view>
<view class="txt">弱光</view>
</view>
2025-08-28 14:05:06 +08:00
<view class="item" @click="lightSetting('close')" :class="formData.lightCurr=='close'?'active':''">
2025-08-27 11:06:49 +08:00
<view class="imgContent center">
2025-08-28 14:05:06 +08:00
<image class="img"
:src="formData.lightCurr=='close'?'/static/images/670/jieNActive.png':'/static/images/670/jieN.png'"
mode="aspectFit"></image>
2025-08-27 11:06:49 +08:00
</view>
<view class="txt">关闭</view>
</view>
</view>
2025-08-28 14:05:06 +08:00
2025-08-27 11:06:49 +08:00
<view class="usrinfo">
<view @click="Status.usrToggle=!Status.usrToggle">
<text class="usrtitle fleft">人员信息登记</text>
<view class="image fright" :style="{transform:Status.usrToggle?'rotate(0deg)':'rotate(180deg)' }">
<image class="img" src="/static/images/6155/DeviceDetail/slideToggle.png" mode="aspectFit"></image>
</view>
<view class="clear"></view>
</view>
<view :class="Status.usrToggle?'':'displayNone'">
<view style="margin: 20rpx 0rpx;">
<view class="btnSend fright" v-on:click.stop="sendUsr(null)">发送</view>
<view class="clear"></view>
</view>
<view class="item">
<text class="lbl">单位</text>
<input class="value" v-model="formData.company" placeholder="请输入单位" placeholder-class="usrplace" />
</view>
<view class="item">
<text class="lbl">姓名</text>
<input class="value" v-model="formData.usrname" placeholder="请输入姓名" placeholder-class="usrplace" />
</view>
<view class="item">
<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>
2025-08-28 14:05:06 +08:00
2025-08-27 11:06:49 +08:00
<view class="usrinfo">
2025-08-28 14:05:06 +08:00
<view>
2025-08-27 11:06:49 +08:00
<text class="usrtitle fleft">发送信息</text>
2025-08-28 14:05:06 +08:00
<view class="btnSend fright" v-on:click.stop="sendUrgent(null)">发送</view>
2025-08-27 11:06:49 +08:00
<view class="clear"></view>
</view>
2025-08-28 14:05:06 +08:00
<view>
<view class="item">
<input maxlength="16" class="value" style="text-indent: 20rpx;" v-model="formData.msgTxt" placeholder="请输入文字"
2025-08-28 14:05:06 +08:00
placeholder-class="usrplace" />
2025-08-27 11:06:49 +08:00
</view>
2025-08-28 14:05:06 +08:00
2025-08-27 11:06:49 +08:00
</view>
</view>
2025-08-28 14:05:06 +08:00
2025-08-27 11:06:49 +08:00
<view class="usrinfo picVideo">
2025-08-28 14:05:06 +08:00
<view>
2025-08-27 11:06:49 +08:00
<text class="usrtitle fleft">开机画面</text>
2025-08-28 14:05:06 +08:00
2025-08-27 11:06:49 +08:00
<view class="clear"></view>
</view>
<view v-on:click.stop="ShowUpload()" class="btnImg center">
2025-08-28 14:05:06 +08:00
2025-08-27 11:06:49 +08:00
<image class="img" src="/static/images/6155/DeviceDetail/add.png" mode="aspectFit"></image>
2025-08-28 14:05:06 +08:00
2025-08-27 11:06:49 +08:00
</view>
</view>
2025-08-28 14:05:06 +08:00
2025-08-27 11:06:49 +08:00
<view class="proinfo lamp">
<text class="title">产品信息</text>
<view class="itemcontent">
2025-09-23 13:54:38 +08:00
<view class="item" @click="proDetail('productDes')">
2025-08-27 11:06:49 +08:00
<image class="img" src="/static/images/6155/DeviceDetail/param.png" mode="aspectFit"></image>
<text class="txt">产品参数</text>
</view>
2025-09-23 13:54:38 +08:00
<view class="item" @click="proDetail('operatingInstruct')">
2025-08-27 11:06:49 +08:00
<image class="img" src="/static/images/6155/DeviceDetail/remark.png" mode="aspectFit"></image>
<text class="txt">操作说明</text>
</view>
2025-09-23 13:54:38 +08:00
<view class="item" @click="proDetail('operationVideo')">
2025-08-27 11:06:49 +08:00
<image class="img" src="/static/images/6155/DeviceDetail/video.png" mode="aspectFit"></image>
<text class="txt">操作视频</text>
</view>
</view>
</view>
<!-- 弹窗通知 -->
<MessagePopup :visible="Status.Pop.showPop" :type="Status.Pop.popType" :bgColor="Status.Pop.bgColor"
:borderColor="Status.Pop.borderColor" :textColor="Status.Pop.textColor"
:buttonBgColor="Status.Pop.buttonBgColor" :buttonTextColor="Status.Pop.buttonTextColor"
:iconUrl="Status.Pop.iconUrl" :message="Status.Pop.message" :buttonText="Status.Pop.buttonText"
2025-08-28 14:05:06 +08:00
@buttonClick="HidePop" @closePop="closePop" @cancelPop="closePop" :visiblePrompt="Status.Pop.visiblePrompt"
:promptTitle="Status.Pop.promptTitle" v-model="Status.Pop.modelValue" :showCancel="Status.Pop.showCancel"
:buttonCancelText="Status.Pop.buttonCancelText" />
2025-08-27 11:06:49 +08:00
<!-- 下方菜单 -->
<BottomSlideMenuPlus :config="Status.BottomMenu" @close="closeMenu" @itemClick="handleItemClick"
@btnClick="btnClick">
<view>
<view class="addIco">
<view class="icoContent center" v-on:click.stop="checkImgUpload()">
<image mode="aspectFit" class="img" src="/static/images/6155/DeviceDetail/add.png"></image>
</view>
</view>
</view>
</BottomSlideMenuPlus>
<global-loading ref="loading" />
</view>
</template>
<script>
import gbk from '@/utils/gbk.js'
import BleTool from '@/utils/BleHelper.js'
import BleReceive from '@/utils/BleReceive';
import api from '@/api/670/HBY670.js';
2025-08-28 14:05:06 +08:00
import MqttClient from '@/utils/mqtt.js';
2025-09-23 13:54:38 +08:00
import Common from '@/utils/Common.js'
2025-08-27 11:06:49 +08:00
import {
showLoading,
hideLoading,
updateLoading
} from '@/utils/loading.js'
import {
request,
baseURL
} from '../../utils/request';
import lnglatConvert from '@/utils/wgs84_to_gcj02.js'
const pagePath = "/pages/670/HBY670";
2025-08-27 11:06:49 +08:00
var ble = null;
var these = null;
var recei = null;
2025-08-28 14:05:06 +08:00
var mqttClient = null;
2025-08-27 11:06:49 +08:00
export default {
data() {
return {
Status: {
msgOkIntval: null, //紧急通知等待的时间
msgOkTime: null, //
pageHide: false,
2025-08-28 14:46:04 +08:00
apiType: "listA",
2025-08-28 14:05:06 +08:00
navbar: {
icons: [{
src: '/static/images/common/msg.png'
},
{
src: '/static/images/common/shape.png'
}
],
title: 'HBY670',
showBack: true,
height: 90
},
staticWarn: {
time: 0,
inteval: null
2025-08-27 11:06:49 +08:00
},
Pop: {
showPop: false, //是否显示弹窗
2025-08-27 11:06:49 +08:00
popType: 'custom',
bgColor: '#383934bd',
borderColor: '#BBE600',
textColor: '#ffffffde',
buttonBgColor: '#BBE600',
buttonTextColor: '#232323DE',
2025-08-27 11:06:49 +08:00
iconUrl: '',
message: '您确定要这样做吗?',
buttonText: '确定',
showCancel: false,
buttonCancelText: '取消',
2025-08-27 11:06:49 +08:00
clickEvt: '',
visiblePrompt: false,
promptTitle: '设备名称',
modelValue: '',
visibleClose: false,
okCallback: null
2025-08-27 11:06:49 +08:00
},
BottomMenu: {
show: false,
showHeader: true,
menuItems: [{
text: '强光',
icon: '/static/images/6155/DeviceDetail/qiang.png'
},
{
text: '弱光',
icon: '/static/images/6155/DeviceDetail/ruo.png'
},
{
text: '爆闪',
icon: '/static/images/6155/DeviceDetail/shan.png'
}
],
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
},
usrToggle: true,
bleLinkCnt: 0
2025-08-27 11:06:49 +08:00
},
formData: {
img: '/static/images/common/HBY670.png',
2025-08-28 14:05:06 +08:00
battary: "", //电量
xuhang: "", //续航
imei: "", //imei
Lon: "", //经度
Lat: "", //纬度
address: "", //地址
modeCurr: "", //档位
SOS: "", //sos
2025-08-28 14:05:06 +08:00
lightCurr: "qiang", //照明模式
company: "湖北消防总队", //单位
usrname: "胡红军", //姓名
job: "中队长", //职位
2025-08-28 14:05:06 +08:00
usrid: "", //id
msgTxt: "", //消息1
qzwarn: false, //是否强制报警
warnLevel: "", //报警级别
staticWarn: false, //静止报警
fourGStrenth: 0, //4G信号强度
deviceId: "",
sta_system: "", //设备状态0关机1仅充电2开机未充电,3开机且充电
bleStatu: false
2025-08-27 11:06:49 +08:00
},
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/670/HBY670",
showConfirm: false
},
rgb565Data: [],
videoHexArray: [],
picPath: "",
permissions: [], //权限列表
detailData: {
deviceId: null,
deviceName: null,
deviceImei: null,
deviceMac: null,
communicationMode: null,
devicePic: null,
typeName: null,
bluetoothName: null,
deviceStatus: null,
personnelInfo: null,
onlineStatus: null,
longitude: null,
latitude: null,
address: null,
staDetectGrade: null,
staLightGrade: null,
staSOSGrade: null,
staPowerTime: null,
staPowerPercent: null,
staDetectResult: null
}
2025-08-27 11:06:49 +08:00
}
},
2025-08-28 14:05:06 +08:00
created() {
this.Status.navbar.height = uni.getSystemInfoSync().statusBarHeight + 20;
},
2025-08-27 11:06:49 +08:00
onUnload() {
console.log("页面卸载,释放资源");
2025-08-28 14:05:06 +08:00
let statusTopic = `A/${this.formData.imei?this.formData.imei:this.device.deviceImei}`;
2025-11-20 16:40:14 +08:00
clearInterval(these.Status.staticWarn.inteval);
clearInterval(this.Status.msgOkIntval);
ble.removeAllCallback(pagePath);
2025-08-28 14:05:06 +08:00
if (mqttClient) {
mqttClient.unsubscribe(statusTopic);
mqttClient.disconnect();
mqttClient = null;
}
2025-08-27 11:06:49 +08:00
},
onLoad: function() {
2025-09-24 11:34:15 +08:00
2025-08-27 11:06:49 +08:00
these = this;
recei = BleReceive.getBleReceive();
ble = BleTool.getBleTool();
ble.addReceiveCallback(these.bleValueNotify, pagePath);
ble.addStateBreakCallback(these.bleStateBreak, pagePath);
ble.addStateRecoveryCallback(these.bleStateRecovry, pagePath);
ble.addDisposeCallback(these.deviceDispose, pagePath);
ble.addRecoveryCallback(these.deviceRecovry, pagePath);
2025-08-27 11:06:49 +08:00
let eventChannel = this.getOpenerEventChannel();
eventChannel.on('detailData', function(data) {
console.log("收到父页面的参数:" + JSON.stringify(data));
var device = data.data;
2025-08-28 14:46:04 +08:00
these.Status.apiType = data.apiType;
2025-08-28 14:05:06 +08:00
these.device = device;
these.formData.usrid = device.deviceImei;
2025-09-23 16:57:31 +08:00
if (data.apiType !== 'listA') {
Common.getdeviceShareId(data.data.id).then(res => {
if (res.code == 200) {
if (res.data.permission) {
these.permissions = res.data.permission.split(',');
}
}
});
}
2025-08-28 14:05:06 +08:00
if (these.device.deviceImei) {
2025-08-27 11:06:49 +08:00
these.initMQ();
}
let f = ble.data.LinkedList.find((v) => {
if (v.macAddress == device.deviceMac) {
console.log("找到设备了", v);
2025-08-28 14:05:06 +08:00
these.formData.deviceId = v.deviceId;
2025-08-27 11:06:49 +08:00
return true;
}
return false;
});
if (!f) {
these.showBleUnConnect();
these.getDetail();
2025-08-27 11:06:49 +08:00
return;
}
let form = f.formData;
if (form) {
let keys = Object.keys(form);
for (var i = keys.length; i >= 0; i--) {
let key = keys[i];
2025-08-27 11:06:49 +08:00
these.formData[key] = form[key];
}
}
2025-08-28 14:05:06 +08:00
if (these.formData['imei'] && !these.device.deviceImei) {
2025-08-27 11:06:49 +08:00
these.initMQ();
2025-08-28 14:05:06 +08:00
} else if (these.device.deviceImei) {
these.formData['imei'] = these.device.deviceImei;
2025-08-27 11:06:49 +08:00
}
these.getDetail();
these.formData.bleStatu = false;
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
these.formData.bleStatu = true;
});
2025-08-27 11:06:49 +08:00
});
},
onShow() {
this.Status.pageHide = false;
},
2025-08-27 11:06:49 +08:00
onHide: function() {
this.Status.pageHide = true;
2025-08-27 11:06:49 +08:00
},
onBackPress(e) {
ble.removeReceiveCallback(pagePath);
},
computed: {
},
methods: {
deviceRecovry(res) {
if (this.Status.pageHide) {
return;
}
if (res.deviceId == these.formData.deviceId) {
this.formData.bleStatu = true;
setTimeout(() => {
hideLoading(these, 1000);
});
uni.showToast({
icon: 'success',
title: '蓝牙连接成功'
});
}
},
deviceDispose(res) {
if (this.Status.pageHide) {
return;
}
if (res.deviceId == these.formData.deviceId) {
this.formData.bleStatu = false;
setTimeout(() => {
hideLoading(these, 1000);
});
uni.showToast({
icon: 'fail',
title: '蓝牙连接已断开'
});
}
},
bleStateBreak() {
if (this.Status.pageHide) {
return;
}
//蓝牙适配器不可用
this.formData.bleStatu = false;
uni.showToast({
icon: 'fail',
title: '蓝牙已不可用'
})
hideLoading(this);
},
bleStateRecovry() {
console.log("蓝牙可用");
if (this.Status.pageHide) {
return;
}
console.log("蓝牙可用");
//蓝牙适配器再次可用,尝试恢复连接
showLoading(this, {
text: "蓝牙恢复可用,正在连接设备"
});
ble.LinkBlue(these.formData.deviceId).then(() => {
these.formData.bleStatu = true;
updateLoading(these, {
text: '连接成功'
});
}).catch(ex => {
updateLoading(these, {
text: ex.msg
})
}).finally(() => {
setTimeout(() => {
hideLoading(these);
}, 1000);
});
},
previewImg(img) {
if (!img) {
return;
}
uni.previewImage({
urls: [img]
})
},
showBleUnConnect() {
this.Status.bleLinkCnt++;
if (this.Status.bleLinkCnt > 3) {
return;
}
this.showPop({
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备,取消" + (4 - this.Status.bleLinkCnt) + "次后不再提醒",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
buttonText: '去连接',
buttonTextColor: '#232323de',
showCancel: true,
cancelCallback: () => {
// this.closePop();
},
okCallback: function() {
console.log("1111");
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);
}
})
}
});
},
gotoMap() {
let lnglat = lnglatConvert.wgs84_to_gcj02(this.formData.Lon, this.formData.Lat);
this.detailData.longitude = lnglat[0];
this.detailData.latitude = lnglat[1];
uni.navigateTo({
url: '/pages/common/map/index',
events: {
ack: function(data) {}
},
success: (res) => {
res.eventChannel.emit('Map', {
data: this.detailData
});
}
})
},
getDetail() {
var that = this;
api.getDetail(this.device.id).then(res => {
if (res && res.code == 200) {
res = res.data;
let json = res;
this.detailData = json;
console.log("res=", res);
that.formData.Lon = res.longitude;
that.formData.Lat = res.latitude;
that.formData.address = res.address;
let personnelInfo = res.personnelInfo;
if (personnelInfo) {
that.formData.company = personnelInfo.unitName;
that.formData.usrname = personnelInfo.name;
that.formData.job = personnelInfo.position;
that.formData.usrid = personnelInfo.code
}
that.formData.imei = res.deviceImei;
these.device.deviceImei = res.deviceImei;
if (that.formData.imei) {
that.initMQ();
}
let dic = {
"3": "hight",
"2": "center",
"1": "low",
"0": "close",
};
let staticLevelText = dic[json.staDetectGrade];
that.formData.modeCurr = staticLevelText;
dic = {
"0": "none",
"1": "ruo",
"2": "center",
"3": "hight",
"4": "veryhight",
};
let warn = dic[json.staDetectResult];
that.formData.warnLevel = warn;
let lightingLevelText = json.staLightGrade === 1 ? 'hight' : json.staLightGrade === 2 ?
'low' :
'close';
that.formData.lightCurr = lightingLevelText;
that.formData.battary = json.staPowerPercent
let hours = Math.floor(json.staPowerTime / 60);
let remainingMinutes = json.staPowerTime % 60;
let xuhang = '0分';
// 处理不同情况的显示
if (hours === 0) {
xuhang = `${remainingMinutes}`;
} else if (remainingMinutes === 0) {
xuhang = `${hours}小时`;
} else {
xuhang = `${hours}小时${remainingMinutes}`;
}
that.formData.xuhang = xuhang;
let sosText = json.staSOSGrade === 2 ? 'rb' : json.staSOSGrade === 1 ? "sg" : "close";
that.formData.SOS = sosText;
}
});
},
2025-08-28 14:05:06 +08:00
getWarnStyle(index) {
let className = "";
2025-08-28 14:46:04 +08:00
2025-08-28 14:05:06 +08:00
switch (this.formData.warnLevel) {
case "none":
break;
case "ruo":
if (index <= 1) {
className = "active";
}
break;
case "center":
if (index <= 3) {
className = "active";
}
break;
case "hight":
if (index <= 4) {
className = "active";
}
break;
case "veryhight":
if (index <= 5) {
className = "active";
}
break;
}
2025-08-28 14:46:04 +08:00
2025-08-28 14:05:06 +08:00
return className;
},
handleRightClick: function(s, e) {
if (s === 0) {
console.log("消息");
uni.navigateTo({
url: '/pages/670/History',
success: (res) => {
res.eventChannel.emit('detailData', {
data: these.device,
});
}
})
return;
} else if (s === 1) {
console.log("分享");
uni.navigateTo({
2025-09-23 13:54:38 +08:00
url: '/pages/common/share/index',
2025-08-28 14:05:06 +08:00
events: {
ack: function(data) {}
},
success: (res) => {
2025-09-23 16:57:31 +08:00
let json = {
persissonType: '670'
};
Object.assign(json, this.device);
2025-08-28 14:05:06 +08:00
res.eventChannel.emit('share', {
2025-09-23 16:57:31 +08:00
data: json
2025-08-28 14:05:06 +08:00
});
}
})
}
},
initMQ() {
2025-08-28 14:46:04 +08:00
2025-08-27 11:06:49 +08:00
return new Promise((resolve, reject) => {
2025-08-28 14:46:04 +08:00
2025-08-27 11:06:49 +08:00
if (mqttClient) {
// console.log("无需再次初始化")
2025-08-27 11:06:49 +08:00
resolve();
return;
}
2025-08-28 14:05:06 +08:00
console.log("正在初始化MQtt")
2025-08-27 11:06:49 +08:00
mqttClient = new MqttClient();
mqttClient.connect(() => {
console.log("连接成功,开始订阅消息")
// 订阅来自设备的状态更新
2025-08-28 14:05:06 +08:00
const statusTopic =
`A/${this.formData.imei?this.formData.imei:this.device.deviceImei}`;
2025-08-27 11:06:49 +08:00
mqttClient.subscribe(statusTopic, (payload, receive) => {
2025-08-28 14:05:06 +08:00
2025-08-27 11:06:49 +08:00
try {
2025-08-28 14:05:06 +08:00
2025-08-27 11:06:49 +08:00
let json = JSON.parse(payload);
let keys = Object.keys(json);
2025-08-28 14:05:06 +08:00
// console.log("keys=", keys);sta_DetectGrade
2025-08-27 11:06:49 +08:00
if (keys.indexOf('sta_DetectGrade') > -1) { //上报的报文
console.log("收到设备上报的数据", payload);
2025-08-28 14:05:06 +08:00
this.parseDataMQ(json);
}
//以下操作已改到后端
2025-08-27 11:06:49 +08:00
// else if (keys.indexOf('sta_PicTrans') > -1) { //发送开机画面
// console.log("收到开机画面答复", payload);
// // this.SendImgMQ(json);
// }
// else if (keys.indexOf('sta_TexTrans') > -1) { //发送文本信息
// console.log("收到文本回复", payload);
// // this.SendTxtMQ(json);
// }
if (keys.indexOf('sta_BreakNews') > -
1) { //紧急通知
if (json.sta_BreakNews ===
'I get it') // && this.Status.msgOkTime && this.Status.msgOkIntval){
2025-11-20 16:40:14 +08:00
{
these.showPop({
showPop: true,
message: "用户已确认收到紧急通知",
iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png"
});
2025-11-20 16:40:14 +08:00
// this.Status.msgOkTime=null
// clearInterval(this.Status.msgOkIntval);
2025-11-20 16:40:14 +08:00
}
}
2025-08-27 11:06:49 +08:00
// else {
// console.log("收到不能处理的数据", payload);
// }
2025-08-28 14:05:06 +08:00
2025-08-27 11:06:49 +08:00
} catch (error) {
console.log("无法解析此消息", error);
}
});
resolve();
});
});
},
2025-08-28 14:05:06 +08:00
2025-09-24 11:34:15 +08:00
sendMQ(json, url) {
let message = JSON.stringify(json);
2025-08-28 14:05:06 +08:00
console.log("imei=", this.formData.imei ? this.formData.imei : this.device.deviceImei);
2025-08-27 11:06:49 +08:00
const topic = `B/${this.formData.imei?this.formData.imei:this.device.deviceImei}`;
return new Promise((resolve, reject) => {
if (!mqttClient) {
reject("MQTT未连接");
console.log("MQTT未连接")
return;
}
try {
let flag = mqttClient.publish(topic, message, {
qos: 1
});
if (flag) {
resolve({
code: 200,
msg: 'MQTT直连发送成功'
});
2025-08-27 11:06:49 +08:00
return;
}
console.log("MQTT未连接无法发布消息")
reject("MQTT未连接无法发布消息");
} catch (error) {
2025-08-28 14:05:06 +08:00
console.log("出现了异常", error);
mqttClient.unsubscribe(
`A/${this.formData.imei?this.formData.imei:this.device.deviceImei}`);
2025-08-27 11:06:49 +08:00
mqttClient.disconnect();
this.initMQ();
reject(error);
}
});
2025-09-24 11:34:15 +08:00
2025-08-27 11:06:49 +08:00
},
2025-08-28 14:05:06 +08:00
parseDataMQ(json) {
let receiveData = {};
let dic = {};
if ("sta_DetectGrade" in json) {
dic = {
"3": "hight",
"2": "center",
"1": "low",
"0": "close",
2025-08-28 14:05:06 +08:00
};
let staticLevelText = dic[json.sta_DetectGrade];
receiveData.modeCurr = staticLevelText;
}
2025-08-28 14:46:04 +08:00
if ("sta_LightGrade" in json) {
2025-08-28 14:46:04 +08:00
let lightingLevelText = json.sta_LightGrade === 1 ? 'hight' : json.sta_LightGrade === 2 ? 'low' :
'close';
receiveData.lightCurr = lightingLevelText;
}
2025-08-28 14:46:04 +08:00
if ("sta_DetectResult" in json) {
2025-08-28 14:46:04 +08:00
dic = {
"0": "none",
"1": "ruo",
"2": "center",
"3": "hight",
"4": "veryhight",
};
let warn = dic[json.sta_DetectResult];
receiveData.warnLevel = warn;
}
if ("sta_SOSGrade" in json) {
let sosText = json.sta_SOSGrade === 2 ? 'rb' : json.sta_SOSGrade === 1 ? "sg" : "close";
2025-08-28 14:05:06 +08:00
receiveData.SOS = sosText;
}
if ("sta_ShakeBit" in json) {
let staticWarn = json.sta_ShakeBit === 1;
receiveData.staticWarn = staticWarn;
}
2025-08-28 14:46:04 +08:00
if ("sta_PowerTime" in json) {
let hours = Math.floor(json.sta_PowerTime / 60);
let remainingMinutes = json.sta_PowerTime % 60;
let xuhang = '0分';
// 处理不同情况的显示
if (hours === 0) {
xuhang = `${remainingMinutes}`;
} else if (remainingMinutes === 0) {
xuhang = `${hours}小时`;
} else {
xuhang = `${hours}小时${remainingMinutes}`;
}
receiveData.xuhang = xuhang;
}
2025-08-28 14:05:06 +08:00
("sta_PowerPercent" in json) && (receiveData.battary = json.sta_PowerPercent);
("sta_4gSinal" in json) && (receiveData.fourGStrenth = json.sta_4gSinal);
("sta_imei" in json) && (receiveData.imei = json.sta_imei);
("sta_longitude" in json) && (receiveData.Lon = json.sta_longitude);
("sta_latitude" in json) && (receiveData.Lat = json.sta_latitude);
if ("sta_system" in json) {
dic = {
"0": "关机",
"1": "仅充电",
"2": "开机未充电",
"3": "开机且充电"
}
receiveData.sta_system = dic[json.sta_system];
}
2025-08-28 14:46:04 +08:00
this.refreshFormData(receiveData, 'auto');
2025-08-28 14:05:06 +08:00
return receiveData;
},
bleValueNotify: function(receive, device, path, recArr) { //订阅消息
if (receive.deviceId !== this.formData.deviceId) {
return;
}
let data = recei.ReceiveData(receive, device, pagePath, recArr);
2025-08-28 14:46:04 +08:00
console.log("收到设备的数据", data)
2025-08-27 11:06:49 +08:00
if (data) {
if ("staBlue_picture" in data) {
//重发图片
console.log("收到重新发送图片的命令");
this.checkImgUpload('img', data.staBlue_picture);
return;
} else if ("staBlue_text" in data) {
//重发文本
console.log("收到重新发送文本的命令");
this.sendUsr(data.staBlue_text);
return;
} else if ("staBlue_vidio" in data) {
//重发视频
console.log("收到重新发送视频的命令");
this.checkImgUpload('video', data.staBlue_vidio);
return;
} else if ("staBlue" in data) {
if (data.staBlue == "finish") {
console.log("收到设备回复,全部传输完成");
}
return;
}
2025-08-28 14:46:04 +08:00
this.refreshFormData(data, 'auto');
2025-08-28 14:05:06 +08:00
2025-08-27 11:06:49 +08:00
}
},
2025-08-28 14:46:04 +08:00
refreshFormData(data, type) {
2025-08-27 11:06:49 +08:00
let keys = Object.keys(data);
for (var i = 0; i < keys.length; i++) {
let key = keys[i];
if (key in these.formData) {
this.formData[key] = data[key];
2025-08-27 11:06:49 +08:00
}
}
2025-08-28 14:05:06 +08:00
if (this.formData.imei) {
2025-08-27 11:06:49 +08:00
this.initMQ();
}
if (this.formData.staticWarn) { //有静止报警
this.showPop({
message: "设备静止报警中",
2025-08-27 11:06:49 +08:00
iconUrl: "/static/images/6155/DeviceDetail/warnning.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
2025-08-28 14:05:06 +08:00
buttonText: "确定",
clickEvt: "staticWarn"
2025-08-27 11:06:49 +08:00
});
}
2025-08-28 14:05:06 +08:00
this.setBleFormData();
2025-08-27 11:06:49 +08:00
},
getDevice: function() {
console.log("LinkedList=", ble.data.LinkedList);
console.log("this.device=", this.device);
2025-08-27 11:06:49 +08:00
let f = ble.data.LinkedList.find((v) => {
return v.macAddress == these.device.deviceMac;
2025-08-27 11:06:49 +08:00
});
return f;
},
setBleFormData() {
2025-08-28 14:05:06 +08:00
let f = ble.data.LinkedList.find((v) => {
2025-08-27 11:06:49 +08:00
if (v.deviceId == these.formData.deviceId) {
v.formData = these.formData;
return true;
}
return false;
});
2025-08-28 14:05:06 +08:00
if (f) {
uni.setStorageSync(ble.StorageKey, ble.data.LinkedList);
2025-08-27 11:06:49 +08:00
}
2025-08-28 14:05:06 +08:00
2025-08-27 11:06:49 +08:00
},
2025-08-28 14:05:06 +08:00
lightSetting: function(type) {
2025-09-23 16:57:31 +08:00
if (!this.permissions.includes('1') && this.Status.apiType !== 'listA') {
2025-09-23 13:54:38 +08:00
this.showPop({
message: '无操作权限',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
okCallback: null,
buttonText: "确定"
})
return;
}
2025-08-27 11:06:49 +08:00
if (this.formData.lightCurr == type) {
return;
}
showLoading(this, {
text: "请稍候..."
});
let task = () => {
this.formData.lightCurr = type;
let dic = {
ble: {
qiang: 0x6D,
ruo: 0x6E,
2025-08-28 14:05:06 +08:00
jieneng: 0x6E,
2025-08-27 11:06:49 +08:00
close: 0x6F
},
mqtt: {
qiang: 1,
ruo: 2,
2025-08-28 14:05:06 +08:00
jieneng: 2,
2025-08-27 11:06:49 +08:00
close: 0
}
};
2025-08-28 14:05:06 +08:00
console.log("type=", type);
let json = {
ins_LightGrade: [dic.mqtt[type]]
};
2025-08-27 11:06:49 +08:00
2025-08-28 14:05:06 +08:00
let requestSend = () => {
this.sendMQ(json).then((res) => {
2025-08-27 11:06:49 +08:00
console.log("4g发送成功");
2025-08-28 14:05:06 +08:00
}).catch((ex) => {
2025-08-28 14:46:04 +08:00
console.log("ex=", ex);
2025-08-27 11:06:49 +08:00
these.showPop({
message: "通信异常,请检查手机或设备网络",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
});
2025-08-28 14:05:06 +08:00
}).finally(() => {
2025-08-27 11:06:49 +08:00
hideLoading(these);
these.setBleFormData();
});
2025-08-28 14:05:06 +08:00
2025-08-27 11:06:49 +08:00
}
let f = this.getDevice();
2025-08-28 14:05:06 +08:00
let buffer = null;
2025-08-27 11:06:49 +08:00
if (f) {
// 发送数据
buffer = new ArrayBuffer(6);
let dataView = new DataView(buffer);
dataView.setUint8(0, 0x55); // 帧头
dataView.setUint8(1, 0x01); // 帧类型
dataView.setUint8(2, 0x01); // 包序号
dataView.setUint8(3, 0x00); // 数据长度
dataView.setUint8(4, 0x01); // 数据长度
dataView.setUint8(5, dic.ble[type]); // 数据
2025-08-28 14:05:06 +08:00
2025-08-27 11:06:49 +08:00
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 10).then(() => {
console.log("蓝牙发送成功了");
hideLoading(these);
these.setBleFormData();
}).catch((ex) => {
//使用4G发送
2025-08-28 14:05:06 +08:00
console.log("蓝牙发送失败,转4g发送", ex);
2025-08-27 11:06:49 +08:00
requestSend();
});
} else {
2025-08-28 14:05:06 +08:00
requestSend();
these.showBleUnConnect();
2025-08-27 11:06:49 +08:00
}
}
setTimeout(task, 0);
},
CloseWarn: function(ispop) { //解除强制报警
let closeEvt = () => {
these.Status.Pop.showPop = false;
these.formData.qzwarn = false;
clearInterval(these.Status.staticWarn.inteval);
let requestCloseSOS = () => {
let json = {
ins_SOSGrade: [0]
};
this.sendMQ(json).then((res) => {
console.log("4g发送成功");
}).catch((ex) => {
console.log("ex=", ex);
these.showPop({
message: "通信异常,请检查手机或设备网络",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
});
}).finally(() => {
hideLoading(these);
this.formData.SOS = 'close';
these.setBleFormData();
});
}
let f = this.getDevice();
let buffer = null;
if (f) {
// 发送数据
buffer = new ArrayBuffer(6);
let dataView = new DataView(buffer);
dataView.setUint8(0, 0x55); // 帧头
dataView.setUint8(1, 0x05); // 帧类型
dataView.setUint8(2, 0x01); // 包序号
dataView.setUint8(3, 0x00); // 数据长度
dataView.setUint8(4, 0x01); // 数据长度
dataView.setUint8(5, 0x6A); // 数据
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 10).then(
() => {
console.log("关闭强制报警成功")
}).catch(ex => {
requestCloseSOS();
}).finally(() => {
this.formData.SOS = 'close';
these.setBleFormData();
});
} else {
requestCloseSOS();
these.showBleUnConnect();
2025-08-28 14:46:04 +08:00
}
2025-08-28 14:46:04 +08:00
}
if (!ispop) {
2025-08-28 14:46:04 +08:00
closeEvt();
return;
}
this.showQzWarn(closeEvt);
},
showQzWarn(callback) {
let message = '持续报警时间' + this.Status.staticWarn.time;
if (this.Status.Pop.clickEvt == 'time' && this.Status.Pop.showPop) {
this.Status.Pop.message = message
return;
}
2025-08-28 14:46:04 +08:00
this.showPop({
showHeader: true,
headerTxt: "强制报警",
message: message,
2025-08-28 14:46:04 +08:00
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
buttonText: "解除报警",
okCallback: () => {
if (callback) {
callback();
}
this.Status.Pop.okCallback = null;
},
clickEvt: 'time'
2025-08-28 14:46:04 +08:00
});
},
2025-08-28 14:05:06 +08:00
sosSetting: function(type) {
debugger;
2025-09-23 16:57:31 +08:00
if (!this.permissions.includes('42') && this.Status.apiType !== 'listA') {
2025-09-23 13:54:38 +08:00
this.showPop({
message: '无操作权限',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
okCallback: null,
buttonText: "确定"
})
return;
}
2025-09-23 16:57:31 +08:00
2025-08-27 11:06:49 +08:00
if (this.formData.SOS == type) {
console.log("111111");
2025-08-28 14:05:06 +08:00
type = "close";
2025-08-27 11:06:49 +08:00
}
showLoading(this, {
text: "请稍候..."
});
let task = () => {
2025-08-27 11:06:49 +08:00
let dic = {
2025-08-28 14:05:06 +08:00
ble: {
rb: 0x68,
sg: 0x69,
close: 0x6A
},
mqtt: {
sg: 1,
rb: 2,
close: 0
}
2025-08-27 11:06:49 +08:00
2025-08-28 14:05:06 +08:00
}
console.log("type=", type);
let json = {
ins_SOSGrade: [dic.mqtt[type]]
};
2025-08-27 11:06:49 +08:00
let message = {
instructValue: json.ins_SOSGrade[0]
};
message.deviceId = these.device.id;
message.deviceImei = these.device.deviceImei;
let requestSend = (callback) => {
debugger;
message.isBluetooth = false;
api.sendSos(message).then((res) => {
console.log("res=>", res);
if (res && res.code == 200) {
console.log("接口发送SOS指令成功");
if (callback) {
callback();
}
return Promise.resolve({
code: 200,
msg: '操作成功'
});
} else {
return this.sendMQ(json);
}
}).then((res) => {
console.log("res=", res);
if (callback) {
callback();
}
2025-08-28 14:05:06 +08:00
}).catch((ex) => {
2025-08-28 14:46:04 +08:00
console.log("ex=", ex);
2025-08-27 11:06:49 +08:00
these.showPop({
message: "通信异常,请检查手机或设备网络",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
});
2025-08-28 14:05:06 +08:00
}).finally(() => {
2025-08-27 11:06:49 +08:00
hideLoading(these);
these.setBleFormData();
});
2025-08-28 14:05:06 +08:00
2025-08-27 11:06:49 +08:00
}
let bleSendCmd = (callback) => {
2025-08-28 14:05:06 +08:00
let f = this.getDevice();
let buffer = null;
if (f) {
// 发送数据
buffer = new ArrayBuffer(6);
let dataView = new DataView(buffer);
dataView.setUint8(0, 0x55); // 帧头
dataView.setUint8(1, 0x05); // 帧类型
dataView.setUint8(2, 0x01); // 包序号
dataView.setUint8(3, 0x00); // 数据长度
dataView.setUint8(4, 0x01); // 数据长度
dataView.setUint8(5, dic.ble[type]); // 数据
console.log("type=", type);
2025-08-28 14:05:06 +08:00
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 10).then(
2025-08-28 14:46:04 +08:00
() => {
console.log("蓝牙发送成功了");
hideLoading(these);
these.setBleFormData();
message.isBluetooth = true;
// api.sendSos(message);
if (callback) {
callback();
}
2025-08-28 14:46:04 +08:00
}).catch((ex) => {
2025-08-28 14:05:06 +08:00
//使用4G发送
console.log("蓝牙发送失败,转4g发送", ex);
requestSend(callback);
2025-08-28 14:05:06 +08:00
});
} else {
console.log("找不到蓝牙设备");
requestSend(callback);
these.showBleUnConnect();
2025-08-28 14:05:06 +08:00
}
2025-08-27 11:06:49 +08:00
}
2025-08-28 14:05:06 +08:00
let OpenSOS = () => {
let execSos = () => {
these.formData.qzwarn = true; //标记为强制报警了
these.Status.staticWarn.time = 180;
this.formData.SOS = type;
let loopFunc = () => {
if (these.Status.staticWarn.inteval === null) {
return;
}
if (these.Status.staticWarn.time === 0) {
clearInterval(these.Status.staticWarn.inteval);
these.Status.staticWarn.inteval = null;
these.formData.qzwarn = false;
if (this.Status.Pop.okCallback) {
these.CloseWarn(false);
these.formData.SOS = 'close';
}
return;
}
these.Status.staticWarn.time = these.Status.staticWarn
.time - 1;
if (these.Status.Pop.clickEvt == 'time' && this.Status.Pop.showPop) {
console.log("111111");
this.showQzWarn(this.Status.Pop.okCallback);
}
}
these.Status.staticWarn.inteval = setInterval(() => {
loopFunc();
}, 1000);
}
bleSendCmd(execSos);
}
if (type == 'rb') { //红蓝报警
2025-09-23 16:57:31 +08:00
console.log("11111");
let sendRb = () => {
this.formData.SOS = type;
bleSendCmd();
2025-09-23 16:57:31 +08:00
these.formData.qzwarn = false;
this.Status.staticWarn.time = 0;
return;
}
if (these.formData.qzwarn && these.Status.staticWarn.inteval && these.Status.staticWarn
.time) {
2025-09-23 16:57:31 +08:00
console.log("222222");
this.Status.Pop.okCallback = null;
these.showQzWarn(sendRb);
} else {
sendRb();
}
} else if (type == 'sg') //强制报警
{
2025-08-28 14:46:04 +08:00
this.showPop({
message: '确定开启声光报警模式?',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
okCallback: OpenSOS,
buttonText: "开启"
});
return;
} else if (type == 'close') {
2025-09-23 16:57:31 +08:00
if (this.formData.SOS = 'sg' && this.Status.staticWarn.inteval) { //解除声光报警
this.CloseWarn(true);
} else {
this.formData.SOS = type;
bleSendCmd();
}
2025-08-28 14:46:04 +08:00
}
2025-08-27 11:06:49 +08:00
}
setTimeout(task, 0);
},
2025-08-28 14:05:06 +08:00
GearSetting: function(type) { //档位设置
2025-09-23 16:57:31 +08:00
if (!this.permissions.includes('41') && this.Status.apiType !== 'listA') {
2025-09-23 13:54:38 +08:00
this.showPop({
message: '无操作权限',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
okCallback: null,
buttonText: "确定"
})
return;
}
2025-08-27 11:06:49 +08:00
if (this.formData.modeCurr == type) {
return;
2025-08-27 11:06:49 +08:00
}
showLoading(this, {
text: "请稍候..."
});
let task = () => {
this.formData.modeCurr = type;
let dic = {
ble: {
hight: 0x65,
center: 0x66,
low: 0x67,
close: 0x64
2025-08-27 11:06:49 +08:00
},
mqtt: {
hight: 3,
center: 2,
low: 1,
close: 0
}
}
2025-08-28 14:05:06 +08:00
console.log("type=", type);
let json = {
2025-08-27 11:06:49 +08:00
ins_DetectGrade: [dic.mqtt[type]]
}
2025-08-28 14:05:06 +08:00
let requestSend = () => {
this.sendMQ(json).then((res) => {
2025-08-27 11:06:49 +08:00
console.log("4g发送成功");
2025-08-28 14:05:06 +08:00
}).catch((ex) => {
2025-08-28 14:46:04 +08:00
console.log("ex=", ex)
2025-08-27 11:06:49 +08:00
these.showPop({
message: "通信异常,请检查手机或设备网络",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
});
2025-08-28 14:05:06 +08:00
}).finally(() => {
2025-08-27 11:06:49 +08:00
hideLoading(these);
these.setBleFormData();
});
2025-08-28 14:05:06 +08:00
2025-08-27 11:06:49 +08:00
}
let f = this.getDevice();
2025-08-28 14:05:06 +08:00
let buffer = null;
2025-08-27 11:06:49 +08:00
if (f) {
// 发送数据
buffer = new ArrayBuffer(6);
let dataView = new DataView(buffer);
2025-08-28 14:05:06 +08:00
2025-08-27 11:06:49 +08:00
dataView.setUint8(0, 0x55); // 帧头
dataView.setUint8(1, 0x00); // 帧类型
dataView.setUint8(2, 0x01); // 包序号
dataView.setUint8(3, 0x00); // 数据长度
dataView.setUint8(4, 0x01); // 数据长度
dataView.setUint8(5, dic.ble[type]); // 数据
2025-08-28 14:05:06 +08:00
2025-08-27 11:06:49 +08:00
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 10).then(() => {
console.log("蓝牙发送成功了");
hideLoading(these);
these.setBleFormData();
}).catch((ex) => {
//使用4G发送
if (ex.code == 10007) {
console.log("蓝牙发送失败,正在重试");
task();
} else {
console.log("蓝牙发送失败,转4g发送", ex);
requestSend();
}
2025-08-27 11:06:49 +08:00
});
} else {
2025-08-28 14:05:06 +08:00
console.log("找不到蓝牙设备使用4G发送")
requestSend();
these.showBleUnConnect();
2025-08-27 11:06:49 +08:00
}
}
setTimeout(task, 0);
},
2025-09-23 16:57:31 +08:00
proDetail: function(type) {
if (!this.permissions.includes('41') && this.Status.apiType !== 'listA') {
this.showPop({
message: '无操作权限',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
okCallback: null,
buttonText: "确定"
})
return;
}
2025-08-27 11:06:49 +08:00
uni.navigateTo({
2025-09-23 16:57:31 +08:00
url: '/pages/common/' + type + '/index?id=' + this.device.id,
2025-08-27 11:06:49 +08:00
success(ev) {
2025-09-23 16:57:31 +08:00
2025-08-27 11:06:49 +08:00
}
});
},
2025-09-23 16:57:31 +08:00
2025-08-27 11:06:49 +08:00
checkImgUpload: function(type, index) {
console.log("123213213213");
let f = these.getDevice();
2025-08-28 14:05:06 +08:00
var sendImgByRequest = () => {
return new Promise((resolve, reject) => {
2025-08-27 11:06:49 +08:00
api.sendPic({
2025-08-28 14:05:06 +08:00
picPath: these.picPath,
deviceId: these.device.id,
deviceImei: these.device.deviceImei
}).then((res) => {
2025-08-27 11:06:49 +08:00
if (res.code == 200) {
these.showPop({
showPop: true,
message: "上传成功",
2025-08-28 14:05:06 +08:00
iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png",
2025-08-27 11:06:49 +08:00
});
resolve();
return;
} else {
2025-08-28 14:05:06 +08:00
2025-08-27 11:06:49 +08:00
these.showPop({
2025-08-28 14:05:06 +08:00
message: res.errMsg ? res.errMsg : "未知的原因上传失败了",
2025-08-27 11:06:49 +08:00
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
});
reject(res);
}
2025-08-28 14:05:06 +08:00
}).catch((ex) => {
console.log("图片上传失败了", ex);
2025-08-27 11:06:49 +08:00
reject(ex)
2025-08-28 14:05:06 +08:00
}).finally(() => {
2025-08-27 11:06:49 +08:00
hideLoading(these);
});
});
2025-08-28 14:05:06 +08:00
2025-08-27 11:06:49 +08:00
}
// 分包发送图片数据
var sendImagePackets = function(ReSendNo) {
return new Promise((resolve, reject) => {
// 总数据包数
let totalPackets = 52;
let currentPacket = 1;
if (ReSendNo) {
totalPackets = ReSendNo;
currentPacket = ReSendNo;
}
if (f) {
// 发送单个数据包
const sendNextPacket = () => {
if (currentPacket > totalPackets) {
hideLoading(these);
these.Status.BottomMenu.show = false;
these.showPop({
showPop: true,
message: "上传成功",
iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png",
});
if (!ReSendNo) {
setTimeout(() => {
these.HoldYouHand("transmit complete", 0, f
.deviceId, f
.writeServiceId, f.wirteCharactId);
}, 500);
}
resolve();
return;
}
// 计算当前包的数据
let packetSize = 250;
// if (currentPacket <= 51) {
// packetSize = 250; // 前51个包每个500字节
// } else {
// packetSize = 50; // 最后一个包100字节
// }
// 创建数据包
const startIndex = (currentPacket - 1) * packetSize;
const endIndex = Math.min(startIndex + packetSize, these.rgb565Data
.length);
if (startIndex > endIndex) {
return;
}
const packetData = these.rgb565Data.slice(startIndex,
endIndex);
// 构建数据包
const bufferSize = 505; // 5 + packetData.length * 2; // 头部5字节 + 数据部分
const buffer = new ArrayBuffer(bufferSize);
const dataView = new DataView(buffer);
// 填充头部
dataView.setUint8(0, 0x55); // 帧头
dataView.setUint8(1, 0x02); // 帧类型:开机画面
dataView.setUint8(2, '0x' + currentPacket.toString(16).padStart(2,
'0')); // 包序号
if (packetData.length == 250) {
dataView.setUint8(3, 0x01);
dataView.setUint8(4, 0xF4);
} else {
dataView.setUint8(3, 0x00);
dataView.setUint8(4, 0x64);
}
// 填充数据每个RGB565值占2字节
for (let i = 0; i < packetData.length; i++) {
dataView.setUint16(5 + i * 2, packetData[i], false); // 大端字节序
}
if (currentPacket > 51) { //第52包补FF
for (var i = 105; i < bufferSize; i++) {
dataView.setUint8(i, 0xFF);
}
}
//发送数据包
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId,
10)
.then(() => {
updateLoading(these, {
text: "正在发送:" + currentPacket + "/" +
totalPackets
});
currentPacket++;
setTimeout(sendNextPacket, 0);
}).catch(err => {
console.log("发送数据包失败了" + JSON.stringify(err));
if (err.code == '10007') {
setTimeout(sendNextPacket, 0);
return;
2025-08-28 14:05:06 +08:00
} else {
2025-08-27 11:06:49 +08:00
updateLoading(these, {
text: "蓝牙发送失败,正在使用4G发送"
});
sendImgByRequest().then(resolve).catch(reject);
}
// these.Status.BottomMenu.show = false;
// these.showPop({
// message: err.msg,
// iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
// borderColor: "#e034344d",
// buttonBgColor: "#E03434",
// });
// hideLoading(these);
// reject(err);
});
}
if (ReSendNo) {
sendNextPacket(ReSendNo);
return;
}
// 开始牵手
these.HoldYouHand("picture transmit start", 120, f.deviceId, f.writeServiceId,
f.wirteCharactId).then(() => {
sendNextPacket();
}).catch((err) => {
updateLoading(these, {
text: "蓝牙发送失败,正在使用4G发送"
});
sendImgByRequest().then(resolve).catch(reject);
2025-08-28 14:05:06 +08:00
2025-08-27 11:06:49 +08:00
});
2025-08-28 14:05:06 +08:00
} else {
sendImgByRequest().then(resolve).catch(reject);
2025-08-27 11:06:49 +08:00
}
});
}
//去图片裁剪
var gotoCutImg = (imgPath) => {
uni.navigateTo({
url: "/pages/6155/ImgCrop",
events: {
ImgCutOver: function(data) {
// console.log("我收到裁剪后的图片了,感谢老铁," + data)
showLoading(these, {
text: "正在发送..."
});
these.Status.BottomMenu.show = false;
2025-08-28 14:05:06 +08:00
these.picPath = data.picPath;
2025-08-27 11:06:49 +08:00
these.rgb565Data = ble.convertToRGB565(data.piexls);
setTimeout(function() {
2025-08-28 14:05:06 +08:00
2025-08-27 11:06:49 +08:00
sendImagePackets().catch(() => {
});
}, 0)
}
},
success(ev) {
ev.eventChannel.emit('checkImg', {
data: imgPath
});
these.Status.BottomMenu.show = false;
}
});
}
let sendVideoPackets = (ReSendNo) => {
console.log("开始发送分片数据");
return new Promise((resolve, reject) => {
if (f) {
// 总数据包数
var totalPackets = 1536;
let currentPacket = 1;
console.log("发送数据准备中,总共" + totalPackets);
if (ReSendNo) {
totalPackets = ReSendNo;
currentPacket = ReSendNo;
}
this.totalPackets = totalPackets;
// 发送单个数据包
const sendNextVideoPacket = () => {
console.log("准备发送一段数据");
if (currentPacket > totalPackets) {
if (!ReSendNo) {
setTimeout(() => {
these.HoldYouHand("transmit complete", 0, f
.deviceId, f
.writeServiceId, f.wirteCharactId).then(
2025-08-28 14:05:06 +08:00
() => {
2025-08-27 11:06:49 +08:00
console.log("全部发送完毕")
}).catch((ex) => {
console.log("出现异常", ex);
});
2025-09-15 11:55:44 +08:00
}, 3000);
2025-08-27 11:06:49 +08:00
}
these.Status.BottomMenu.show = false;
hideLoading(these);
these.showPop({
showPop: true,
message: "上传成功",
iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png"
});
resolve();
return;
}
// 计算当前包的数据
let packetSize = 500;
// 创建数据包
const startIndex = (currentPacket - 1) * packetSize;
const endIndex = Math.min(startIndex + packetSize, these.videoHexArray
.length);
if (startIndex > endIndex) {
resolve();
return;
}
////console.log("111111");
const packetData = these.videoHexArray.slice(startIndex, endIndex);
// 构建数据包
////console.log("packetData.length"+packetData.length);
const bufferSize = 506; // 头部5字节 + 数据部分
const buffer = new ArrayBuffer(bufferSize);
const dataView = new DataView(buffer);
let sortNo = currentPacket.toString(16).padStart(4, '0');
// 填充头部
dataView.setUint8(0, 0x55); // 帧头
dataView.setUint8(1, 0x04); // 帧类型:开机画面
dataView.setUint8(2, '0x' + sortNo.substring(0, 2)); // 包序号
dataView.setUint8(3, '0x' + sortNo.substring(2, 4)); // 包序号
dataView.setUint8(4, 0x01);
dataView.setUint8(5, 0xF4);
for (let i = 0; i < packetData.length; i++) {
dataView.setUint8(6 + i, '0x' + packetData[i]);
}
2025-08-27 11:06:49 +08:00
let inteval = 30;
console.log("开始发送一段视频"); //
ble.sendData(f.deviceId, buffer, f.writeServiceId, f
.wirteCharactId, 10).then(() => {
updateLoading(these, {
text: "正在发送:" + currentPacket + "/" +
totalPackets
})
currentPacket++;
console.log("发送一段成功,发送下一段");
setTimeout(sendNextVideoPacket, inteval);
}).catch(err => {
console.log("发送失败了");
if (err.code == '10007') { //遇到这个错误自动重新发送
console.log(err.errMsg + ",发送失败了,正在补偿:" +
currentPacket);
setTimeout(sendNextVideoPacket, inteval);
} else {
these.Status.BottomMenu.show = false;
hideLoading(these);
these.showPop({
showPop: true,
message: err.msg + ",发送失败了",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
buttonText: "确定",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png"
});
reject(err);
return;
}
});
};
sendNextVideoPacket();
} else {
console.log("Fail.......")
}
});
}
var sendVideo = (videoPath) => {
if (!f) {
these.showBleUnConnect();
return;
}
2025-08-27 11:06:49 +08:00
let uploadVideo = () => {
if (these.videoHexArray.length > 0) {
console.log("开始处理,无需上传");
shotVideoClick(these.videoHexArray);
return;
}
console.log("开始处理,正在上传", f);
const token = uni.getStorageSync('token');
const clientid = uni.getStorageSync('clientID');
2025-08-27 11:06:49 +08:00
showLoading(these, {
text: "上传中"
});
let p1 = these.HoldYouHand("video transmit start", 2200, f.deviceId, f.writeServiceId,
f.wirteCharactId);
let p2 = new Promise((succ, err) => {
if (!token) {
err({
code: 401,
msg: "请先登陆后再试"
});
hideLoading(these);
return;
}
console.log("baseURL=", baseURL);
2025-08-27 11:06:49 +08:00
uni.uploadFile({
2025-09-25 15:58:33 +08:00
// url: 'http://114.55.111.217/video/upload',
url: baseURL + "/app/video/upload",
2025-08-27 11:06:49 +08:00
filePath: videoPath,
name: 'file',
header: {
"Method": "POST",
"Content-Type": "multipart/form-data",
"Authorization": 'Bearer ' + token,
"clientid": clientid
2025-08-27 11:06:49 +08:00
},
timeout: 600000,
fail: (ex) => {
console.log("上传视频失败" + JSON.stringify(ex));
err(ex);
},
success: (res) => {
console.log("上传完成,向蓝牙设备发送");
succ(res);
}
});
});
Promise.all([p1, p2]).then((arr) => {
let res = arr[1];
res = JSON.parse(res.data);
if (res.data) {
these.videoHexArray = res.data;
updateLoading(these, {
text: "正在发送:0/1536"
});
these.Status.BottomMenu.show = false;
shotVideoClick(res.data);
} else {
console.log("服务器未返回正确的数据", arr);
2025-08-27 11:06:49 +08:00
these.showPop({
message: "与服务器连接出现异常,请检查网络设置",
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
});
}
}).catch((ex) => {
hideLoading(these);
these.showPop({
message: "出现异常," + ex.msg,
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
});
})
}
2025-08-27 11:06:49 +08:00
let shotVideoClick = () => {
console.log("正在开始发送");
sendVideoPackets().then(() => {
console.log("发送完成");
}).catch((ex1) => {
//console.log("出现了异常", ex1)
}).finally(() => {
hideLoading(these);
});
}
uploadVideo();
}
if (type) {
if (type == 'img') {
sendImagePackets(index);
} else if (type == 'video') {
sendVideoPackets(index);
}
return;
}
uni.chooseMedia({
count: 1,
mediaType: ['image', 'video'],
sourceType: ['album'],
maxDuration: 3,
sizeType: ['original'],
success: (res) => {
let file = res.tempFiles[0];
if (file.fileType == 'image') {
gotoCutImg(file.tempFilePath);
return;
}
if (file.fileType == 'video') {
if (file.duration < 2) {
this.alert('提示', "请选择2S及以上的视频");
return;
}
these.videoHexArray = [];
sendVideo(file.tempFilePath);
return;
}
}
});
},
ShowUpload: function() {
2025-09-23 16:57:31 +08:00
if (!this.permissions.includes('3') && this.Status.apiType !== 'listA') {
2025-09-23 13:54:38 +08:00
this.showPop({
message: '无操作权限',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
okCallback: null,
buttonText: "确定"
})
return;
}
2025-08-27 11:06:49 +08:00
//上传开机画面
this.Status.BottomMenu.menuItems = [];
this.Status.BottomMenu.title = "上传开机画面";
this.Status.BottomMenu.type = "checkImg";
2025-08-28 14:05:06 +08:00
this.Status.BottomMenu.show = true;
this.Status.BottomMenu.showBtn = false;
2025-08-27 11:06:49 +08:00
},
showMenu(flag) {
this.Status.BottomMenu.show = true;
},
closeMenu() {
this.Status.BottomMenu.show = false;
},
btnClick(item, index) {
},
setMode(mode) {
},
handleItemClick(item, index) {
switch (this.Status.BottomMenu.type) {
case "main":
break;
case "fu":
break;
}
this.Status.BottomMenu.activeIndex = index;
},
HidePop: function() {
if (this.Status.Pop.clickEvt == 'staticWarn') {
2025-08-28 14:05:06 +08:00
// this.Status.staticWarnTime=0;
// clearInterval(this.Status.staticWarn.inteval);
// this.formData.staticWarn=false;
2025-08-27 11:06:49 +08:00
}
2025-08-28 14:46:04 +08:00
if (this.Status.Pop.okCallback) {
2025-08-28 14:05:06 +08:00
console.log("执行点击按钮回调");
this.Status.Pop.okCallback();
}
2025-08-28 14:46:04 +08:00
2025-08-28 14:05:06 +08:00
this.Status.Pop.showPop = false;
},
closePop: function() {
2025-08-27 11:06:49 +08:00
this.Status.Pop.showPop = false;
2025-08-28 14:46:04 +08:00
if (this.Status.Pop.cancelCallback) {
2025-08-28 14:05:06 +08:00
this.Status.Pop.cancelCallback();
}
2025-08-27 11:06:49 +08:00
},
showPop: function(option) {
2025-08-28 14:05:06 +08:00
hideLoading(this);
let def = {
showPop: true, //是否显示弹窗
popType: 'custom',
bgColor: '#383934bd',
2025-08-28 14:46:04 +08:00
borderColor: '#BBE600',
textColor: '#ffffffde',
2025-08-28 14:46:04 +08:00
buttonBgColor: '#BBE600',
buttonTextColor: '#232323DE',
iconUrl: '',
message: '',
buttonText: '确定',
clickEvt: '',
visiblePrompt: false,
promptTitle: '',
modelValue: '',
visibleClose: false,
okCallback: null,
showSlot: false,
buttonCancelText: '',
showCancel: false,
2025-08-27 11:06:49 +08:00
}
let keys = Object.keys(def);
for (let i = 0; i < keys.length; i++) {
2025-08-28 14:05:06 +08:00
let key = keys[i];
2025-08-28 14:46:04 +08:00
if (key in option) {
2025-08-28 14:05:06 +08:00
continue;
}
this.Status.Pop[key] = def[key];
2025-08-27 11:06:49 +08:00
}
if (option) {
keys = Object.keys(option);
for (let i = 0; i < keys.length; i++) {
let key = keys[i];
2025-08-28 14:46:04 +08:00
this.Status.Pop[key] = option[key];
}
}
if (!option.borderColor) {
option.borderColor = '#BBE600';
option.buttonBgColor = '#BBE600';
}
these.Status.Pop.showPop = true;
2025-08-27 11:06:49 +08:00
},
sendUsr: function(ReSendNo) {
2025-09-23 16:57:31 +08:00
if (!this.permissions.includes('4') && this.Status.apiType !== 'listA') {
2025-09-23 13:54:38 +08:00
this.showPop({
message: '无操作权限',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
okCallback: null,
buttonText: "确定"
})
return;
}
2025-08-27 11:06:49 +08:00
2025-08-28 14:05:06 +08:00
let requestSend = () => {
2025-08-27 11:06:49 +08:00
let json = {
deviceId: this.device.id,
2025-08-28 14:05:06 +08:00
deviceImei: this.device.deviceImei ? this.device.deviceImei : this.formData.imei,
unitName: this.formData.company,
name: this.formData.usrname,
position: this.formData.job,
2025-08-28 14:05:06 +08:00
code: this.formData.usrid
2025-08-27 11:06:49 +08:00
};
2025-08-28 14:05:06 +08:00
api.sendUsr(json).then((res) => {
2025-08-27 11:06:49 +08:00
these.showPop({
showPop: true, //是否显示弹窗
popType: 'custom',
bgColor: '#383934bd',
borderColor: '#BBE600',
textColor: '#ffffffde',
buttonBgColor: '#BBE600',
buttonTextColor: '#232323DE',
iconUrl: '/static/images/6155/DeviceDetail/sendSucc.png',
message: '人员信息发送成功',
buttonText: '确定',
clickEvt: 'SendUsr',
visiblePrompt: false,
promptTitle: '',
modelValue: '',
visibleClose: true
});
these.setBleFormData();
2025-08-28 14:05:06 +08:00
}).catch((ex) => {
2025-08-27 11:06:49 +08:00
these.showPop({
message: "文字发送失败," + ex.msg,
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
});
2025-08-28 14:05:06 +08:00
}).finally(() => {
2025-08-27 11:06:49 +08:00
hideLoading(these);
});
}
var textLines = [
this.formData.company,
2025-08-28 14:05:06 +08:00
this.formData.usrname,
2025-08-27 11:06:49 +08:00
this.formData.job,
2025-08-28 14:05:06 +08:00
this.formData.usrid
2025-08-27 11:06:49 +08:00
];
let f = this.getDevice();
if (!f) {
//走4G通道
requestSend();
these.showBleUnConnect();
2025-08-27 11:06:49 +08:00
return;
}
showLoading(this, {
text: "请稍候..."
});
var sendText = function() {
// 总数据包数
let totalPackets = textLines.length;
let currentPacket = 1;
// console.log("currentPacket=",currentPacket);
// console.log("ReSendNo=",ReSendNo);
if (ReSendNo) {
totalPackets = ReSendNo;
currentPacket = ReSendNo;
}
// console.log("currentPacket=",currentPacket);
// 发送单个数据包
const sendNextPacket = () => {
if (currentPacket > totalPackets) {
if (!ReSendNo) {
setTimeout(() => {
these.HoldYouHand("transmit complete", 0, f.deviceId, f
.writeServiceId, f
.wirteCharactId);
}, 500);
}
these.showPop({
showPop: true, //是否显示弹窗
popType: 'custom',
bgColor: '#383934bd',
borderColor: '#BBE600',
textColor: '#ffffffde',
buttonBgColor: '#BBE600',
buttonTextColor: '#232323DE',
iconUrl: '/static/images/6155/DeviceDetail/sendSucc.png',
message: '人员信息发送成功',
buttonText: '确定',
clickEvt: 'SendUsr',
visiblePrompt: false,
promptTitle: '',
modelValue: '',
visibleClose: true
});
these.setBleFormData();
hideLoading(these);
// let json = {
// deviceId: these.device.id,
// name: these.formData.company,
// position: these.formData.usrname,
// unitName: these.formData.job,
// code: these.formData.usrid
// };
// api.sendUsr(json)
2025-08-27 11:06:49 +08:00
return;
}
// 获取当前行文字
const text = textLines[currentPacket - 1] || '';
let arr = gbk.encode(text)
console.log("arr=", arr);
2025-08-27 11:06:49 +08:00
let gbkData = gbk.arr2hex(arr);
console.log("gbkData=", gbkData);
2025-08-27 11:06:49 +08:00
// 构建数据包
const bufferSize = 5 + gbkData.length / 2; // 头部4字节 + 数据部分
const buffer = new ArrayBuffer(bufferSize);
const dataView = new DataView(buffer);
let s = (text.length * 2).toString(16);
let len = String(s).padStart(4, '0')
len = len.match(/.{1,2}/g);
2025-08-27 11:06:49 +08:00
// 填充头部
dataView.setUint8(0, 0x55); // 帧头
dataView.setUint8(1, 0x03); // 帧类型:文字
dataView.setUint8(2, currentPacket.toString(16)); // 包序号
dataView.setUint8(3, parseInt('0x' + len[0], 16)); // 数据长度
dataView.setUint8(4, parseInt('0x' + len[1], 16)); // 数据长度
2025-08-27 11:06:49 +08:00
// 填充数据
let index = 0;
for (var i = 0; i < gbkData.length; i += 2) {
let value = parseInt(gbkData[i] + "" + gbkData[i + 1], 16);
dataView.setUint8(5 + index, value);
index++;
}
// 发送数据包
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 10).then(() => {
// 更新进度
console.log(
`发送文字数据包 ${currentPacket}/${totalPackets}: ${text}`
);
// 发送下一个包
currentPacket++;
setTimeout(sendNextPacket, 200);
2025-08-27 11:06:49 +08:00
}).catch(err => {
2025-08-28 14:05:06 +08:00
if (err.code == '10007') {
setTimeout(sendNextPacket, 200);
2025-08-28 14:05:06 +08:00
} else {
requestSend();
}
2025-08-27 11:06:49 +08:00
}).finally(() => {
2025-08-28 14:05:06 +08:00
2025-08-27 11:06:49 +08:00
});
};
// 开始发送第一个包
sendNextPacket();
}
if (ReSendNo) {
sendText(ReSendNo);
return;
}
setTimeout(() => {
these.HoldYouHand("word transmit start", 120, f.deviceId, f.writeServiceId, f
.wirteCharactId).then(
() => {
setTimeout(sendText, 200);
2025-08-27 11:06:49 +08:00
}).catch((ex) => {
2025-08-28 14:05:06 +08:00
requestSend();
// console.log("握手没有成功", ex);
// hideLoading(these);
// these.showPop({
// message: ex.msg,
// iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
// borderColor: "#e034344d",
// buttonBgColor: "#E03434",
// });
2025-08-27 11:06:49 +08:00
});
}, 0);
},
sendUrgent(type) {
2025-09-23 16:57:31 +08:00
if (!this.permissions.includes('5') && this.Status.apiType !== 'listA') {
2025-09-23 13:54:38 +08:00
this.showPop({
message: '无操作权限',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
okCallback: null,
buttonText: "确定"
})
return;
}
2025-08-28 14:05:06 +08:00
if (!this.formData.msgTxt) {
2025-08-27 11:06:49 +08:00
return;
}
showLoading(this, {
text: "请稍候..."
});
this.setBleFormData();
2025-08-28 14:05:06 +08:00
let data = {
"sendMsg": this.formData.msgTxt,
2025-08-28 14:05:06 +08:00
"deviceIds": [
this.device.id
],
"deviceImeiList": [
this.device.deviceImei ? this.device.deviceImei : this.formData.imei
]
2025-08-27 11:06:49 +08:00
}
2025-08-28 14:05:06 +08:00
console.log("data=", data);
api.warnMsg(data).catch((ex) => {
console.log("ex=", ex);
}).then((res) => {
console.log("res=", res)
2025-08-27 11:06:49 +08:00
if (res.code == 200) {
2025-08-28 14:05:06 +08:00
these.showPop({
showPop: true, //是否显示弹窗
popType: 'custom',
bgColor: '#383934bd',
borderColor: '#BBE600',
textColor: '#ffffffde',
buttonBgColor: '#BBE600',
buttonTextColor: '#232323DE',
iconUrl: '/static/images/6155/DeviceDetail/sendSucc.png',
2025-11-20 16:40:14 +08:00
message: '发送成功,待用户确认',
2025-08-28 14:05:06 +08:00
buttonText: '确定',
clickEvt: 'SendUsr',
visiblePrompt: false,
promptTitle: '',
modelValue: '',
visibleClose: true
});
2025-11-20 16:40:14 +08:00
// clearInterval(this.Status.msgOkIntval);
2025-11-20 16:40:14 +08:00
// this.Status.msgOkTime=0;
// this.Status.msgOkIntval=setInterval(()=>{
// this.Status.msgOkTime++;
// if(this.Status.msgOkTime>180){
// this.Status.msgOkTime=null
// clearInterval(this.Status.msgOkIntval);
// this.Status.msgOkIntval=null;
// }
// });
2025-08-27 11:06:49 +08:00
} else {
these.showPop({
message: res.msg,
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
});
}
2025-08-28 14:05:06 +08:00
}).finally(() => {
2025-08-27 11:06:49 +08:00
hideLoading(this);
});
2025-08-28 14:05:06 +08:00
2025-08-27 11:06:49 +08:00
},
HoldYouHand(str, pauseTime, deviceid, serviceid, characid) {
if (!pauseTime) {
pauseTime = 0;
}
var promise = new Promise((resolve, reject) => {
// 1. 创建 ArrayBuffer 和 DataView
const buffer = new ArrayBuffer(str.length);
const dataView = new DataView(buffer);
// 2. 将字符串转换为 ASCII 码并写入 DataView
for (let i = 0; i < str.length; i++) {
dataView.setUint8(i, str.charCodeAt(i));
}
console.log("开始握手");
ble.sendData(deviceid, buffer, serviceid, characid, 10).then(
() => {
setTimeout(() => {
console.log("握手成功并完成了等待");
resolve(true);
}, pauseTime);
}).catch(err => {
2025-08-28 14:05:06 +08:00
2025-08-27 11:06:49 +08:00
console.log("握手没有成功", )
reject(err);
});
});
return promise;
},
ack: function() {
let eventChannel = this.getOpenerEventChannel();
eventChannel.emit('ack', {
data: '我已收到了您的消息,谢谢。'
});
}
}
}
</script>
<style>
.content {
padding: 30rpx;
box-sizing: border-box;
}
.eq {
width: 100%;
height: 250rpx;
border-radius: 8px;
background: rgba(26, 26, 26, 1);
box-sizing: border-box;
padding: 24rpx 28rpx;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-content: center;
justify-content: center;
align-items: center;
margin-bottom: 24rpx;
}
.eq .leftImg {
box-sizing: border-box;
padding: 36rpx;
border-radius: 16rpx;
background: rgba(42, 42, 42, 0.5);
}
.eq .leftImg,
.eq .rightTxt {
width: 50%;
height: 100%;
}
.eq .rightTxt {
display: flex;
flex-direction: column;
flex-wrap: nowrap;
align-content: flex-start;
justify-content: space-evenly;
align-items: flex-start;
}
.eq .leftImg .img {
width: 100%;
height: 100%;
}
.eq .rightTxt .img {
width: 52rpx;
height: 52rpx;
}
.eq .rightTxt .row {
width: 100%;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-content: center;
justify-content: flex-start;
align-items: center;
box-sizing: border-box;
padding-left: 50rpx;
}
.eq .rightTxt .row .txt {
padding-left: 20rpx;
}
.eq .bigTxt {
color: rgba(255, 255, 255, 0.87);
font-family: PingFang SC;
font-size: 28rpx;
font-weight: 400;
}
.eq .smallTxt {
color: rgba(255, 255, 255, 0.6);
font-family: PingFang SC;
font-size: 24rpx;
font-weight: 400;
}
.eqinfo {
border-radius: 16rpx;
background: rgba(26, 26, 26, 1);
box-sizing: border-box;
padding: 14rpx 0rpx;
}
.eqinfo .item {
width: 100%;
min-height: 60rpx;
height: auto;
2025-08-27 11:06:49 +08:00
line-height: 60rpx;
padding: 0rpx 28rpx;
box-sizing: border-box;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-content: center;
justify-content: space-between;
align-items: center;
}
.eqinfo .lbl {
color: rgba(255, 255, 255, 0.87);
font-family: PingFang SC;
font-size: 28rpx;
font-weight: 400;
width: 140rpx;
2025-08-27 11:06:49 +08:00
letter-spacing: 0.07px;
text-align: left;
}
.eqinfo .value {
color: rgba(255, 255, 255, 0.6);
font-family: 'PingFang SC';
font-size: 28rpx !important;
2025-08-27 11:06:49 +08:00
font-weight: 400;
letter-spacing: 0.07px;
text-align: left;
}
.eqinfo .valueFont {
font-family: 'PingFang SC';
font-size: 28rpx !important;
font-weight: 400;
color: rgba(255, 255, 255, 0.6);
}
.eqinfo .multiValue {
display: flex;
flex-direction: column;
flex-wrap: wrap;
align-content: flex-end;
align-items: flex-end;
justify-content: flex-start;
width: calc(100% - 140rpx)
}
.eqinfo .valueItem {
height: auto;
line-height: 40rpx;
color: rgba(255, 255, 255, 0.6);
font-family: PingFang SC;
font-size: 14px;
font-weight: 400;
letter-spacing: 0.07px;
}
2025-08-27 11:06:49 +08:00
.lamp {
margin-top: 24rpx;
}
.lamp .title {
width: 100%;
height: 60rpx;
line-height: 60rpx;
padding: 0rpx 28rpx;
box-sizing: border-box;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-content: center;
justify-content: space-between;
align-items: center;
font-size: 28rpx;
}
.lampMode {
padding: 30rpx 0rpx;
width: 100%;
box-sizing: border-box;
}
.lampMode .mode {
width: calc(calc(100% - 34rpx) / 2);
border-radius: 8px;
margin-top: 20rpx;
background: rgba(26, 26, 26, 1);
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-content: center;
align-items: center;
justify-content: flex-start;
padding: 30rpx;
box-sizing: border-box;
}
.lampMode .mode.active {
border: 1px solid rgba(174, 214, 0, 1);
}
.lampMode .mode.active .bigTxt {
color: rgba(174, 214, 0, 1) !important;
}
.mode.marginLeft {
margin-left: 34rpx !important;
}
.mode .leftImg .img {
width: 70rpx;
height: 70rpx;
}
.mode .rightTxt {
display: flex;
flex-direction: column;
flex-wrap: nowrap;
align-content: flex-start;
justify-content: center;
align-items: flex-start;
padding-left: 20rpx;
}
.mode .bigTxt {
color: rgba(255, 255, 255, 0.87);
font-family: PingFang SC;
font-size: 28rpx;
font-weight: 400;
letter-spacing: 0.07px;
}
.mode .smallTxt {
color: rgba(255, 255, 255, 0.6);
font-family: PingFang SC;
font-size: 24rpx;
font-weight: 400;
letter-spacing: 0.07px;
}
.usrinfo {
border-radius: 8px;
width: 100%;
box-sizing: border-box;
padding: 24rpx 28rpx;
background: rgba(26, 26, 26, 1);
2025-08-28 14:05:06 +08:00
margin-bottom: 20rpx;
2025-08-27 11:06:49 +08:00
}
.usrtitle {
color: rgba(255, 255, 255, 0.87);
font-family: PingFang SC;
font-size: 28rpx;
font-weight: 400;
height: 40rpx;
line-height: 40rpx;
letter-spacing: 0.07px;
}
.usrinfo .btnSend {
line-height: 65rpx;
border-radius: 8px;
width: 120rpx;
height: 65rpx;
color: rgba(35, 35, 35, 0.87);
font-family: PingFang SC;
font-size: 24rpx;
font-weight: 400;
letter-spacing: 0.15rpx;
text-align: center;
background-color: #BBE600;
}
.usrinfo .item {
border-radius: 8px;
width: 100%;
box-sizing: border-box;
line-height: 90rpx;
height: 90rpx;
background: rgba(42, 42, 42, 1);
margin-top: 24rpx;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-content: center;
justify-content: flex-start;
align-items: center;
}
.usrinfo .lbl {
width: 120rpx;
height: 100%;
padding-left: 24rpx;
box-sizing: border-box;
text-align: right;
color: rgba(255, 255, 255, 0.87);
font-family: PingFang SC;
font-size: 28rpx;
font-weight: 400;
letter-spacing: 0.07px;
}
.usrinfo .value {
width: calc(100% - 120rpx);
height: 100%;
font-size: 28rpx;
font-weight: 400;
letter-spacing: 0.07px;
text-align: left;
}
.usrinfo .value .uni-input-input {
color: rgba(255, 255, 255, 0.87);
font-family: PingFang SC;
}
.usrplace {
color: rgba(255, 255, 255, 0.4);
font-family: PingFang SC;
font-size: 28rpx;
font-weight: 400;
letter-spacing: 0.07px;
text-align: left;
}
.proinfo .itemcontent {
display: flex;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-content: center;
justify-content: space-evenly;
}
.proinfo .item {
width: 180rpx;
height: 180rpx;
box-sizing: border-box;
padding: 40rpx;
border-radius: 16rpx;
background: rgba(26, 26, 26, 1);
display: flex;
flex-direction: column;
flex-wrap: nowrap;
align-content: center;
justify-content: center;
align-items: center;
}
.proinfo .item .img {
width: 50rpx;
height: 50rpx;
}
.proinfo .item .txt {
color: rgba(255, 255, 255, 0.6);
font-family: PingFang SC;
font-size: 24rpx;
font-weight: 400;
margin-top: 20rpx;
letter-spacing: 0.07px;
text-align: left;
}
.slider-container {
padding: 0px;
}
.addIco {
width: 100%;
height: 360rpx;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-content: center;
justify-content: center;
align-items: center;
}
.icoContent {
width: 240rpx;
height: 240rpx;
border-radius: 8rpx;
background: rgba(58, 58, 58, 1);
}
.icoContent .img {
width: 70rpx;
height: 70rpx;
}
.modeSetting {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-content: center;
justify-content: space-around;
align-items: center;
border-radius: 8px;
background: rgba(26, 26, 26, 1);
box-sizing: border-box;
padding: 30rpx 0rpx;
}
.modeSetting .item {
width: 120rpx;
height: 120rpx;
background: rgba(42, 42, 42, 1);
border-radius: 50%;
color: rgba(255, 255, 255, 0.87);
2025-08-28 14:05:06 +08:00
2025-08-27 11:06:49 +08:00
font-family: PingFang SC;
font-size: 28rpx;
font-weight: 400;
line-height: 0px;
box-sizing: border-box;
}
.modeSetting .item.active {
border: 4rpx solid rgba(174, 214, 0, 1);
background: rgba(26, 26, 26, 1);
padding: 6rpx;
color: rgba(26, 26, 26, 0.87);
}
.modeSetting .item.active .p100 {
background: rgba(174, 214, 0, 1);
border-radius: 50%;
}
.usrinfo .image {
width: 30rpx;
height: 40rpx;
}
.usrinfo .img {
width: 30rpx;
height: 40rpx;
}
.content {
box-sizing: border-box;
width: 100%;
min-height: 100vh;
height: auto;
}
.contentBg {
background-color: #121212;
color: #ffffffde;
}
.fleft {
float: left;
}
.fright {
float: right;
}
.clear {
clear: both;
}
.displayNone {
display: none !important;
}
.p100 {
width: 100%;
height: 100%;
}
.center {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-content: center;
justify-content: center;
align-items: center;
}
.centerLeft {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-content: center;
justify-content: flex-start;
align-items: center;
}
.warnnig {
border-radius: 16rpx;
width: 100%;
height: 70rpx;
line-height: 70rpx;
background: rgba(224, 52, 52, 1);
box-sizing: border-box;
padding: 0rpx 30rpx;
margin-top: 20rpx;
color: rgba(255, 255, 255, 0.87);
font-family: 'PingFang SC';
font-size: 28rpx;
font-weight: 400;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-content: center;
justify-content: space-between;
align-items: center;
}
2025-08-28 14:05:06 +08:00
.optTitle {
2025-08-27 11:06:49 +08:00
color: rgba(255, 255, 255, 0.87);
2025-08-28 14:05:06 +08:00
font-family: 'PingFang SC';
font-size: 28rpx;
font-weight: 400;
2025-08-27 11:06:49 +08:00
2025-08-28 14:05:06 +08:00
letter-spacing: 0.14rpx;
text-align: left;
width: 100%;
box-sizing: border-box;
padding: 30rpx 0rpx 10rpx 30rpx;
2025-08-27 11:06:49 +08:00
}
2025-08-28 14:05:06 +08:00
.sosContent {
2025-08-27 11:06:49 +08:00
width: 100%;
height: 130rpx;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-content: center;
justify-content: space-between;
align-items: center;
}
2025-08-28 14:05:06 +08:00
.sosContent .item {
width: calc(calc(100% - 80rpx) / 2);
2025-08-27 11:06:49 +08:00
height: 100%;
box-sizing: border-box;
border-radius: 16rpx;
background: rgba(26, 26, 26, 1);
color: rgba(255, 255, 255, 0.87);
font-family: 'PingFang SC';
font-size: 28rpx;
font-weight: 400;
letter-spacing: 0.14rpx;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-content: center;
justify-content: center;
align-items: center;
}
2025-08-28 14:05:06 +08:00
.sosContent .item.active {
2025-08-27 11:06:49 +08:00
border: 1px solid rgba(224, 52, 52, 1);
color: rgba(224, 52, 52, 1);
}
2025-08-28 14:05:06 +08:00
.sosContent .imgContent {
2025-08-27 11:06:49 +08:00
width: 55rpx;
height: 55rpx;
background-color: #232323;
border-radius: 4rpx;
margin-right: 30rpx;
}
2025-08-28 14:05:06 +08:00
.sosContent .imgContent .img {
2025-08-27 11:06:49 +08:00
width: 70%;
height: 70%;
2025-08-28 14:05:06 +08:00
2025-08-27 11:06:49 +08:00
}
2025-08-28 14:05:06 +08:00
.sosContent .item.active .imgContent {
2025-08-27 11:06:49 +08:00
background-color: #E034340F;
}
2025-08-28 14:05:06 +08:00
.lightMode {
2025-08-27 11:06:49 +08:00
width: 100%;
height: 180rpx;
border-radius: 16rpx;
2025-08-28 14:05:06 +08:00
background: rgba(26, 26, 26, 1);
margin-bottom: 30rpx;
display: flex;
2025-08-27 11:06:49 +08:00
flex-direction: row;
flex-wrap: nowrap;
align-content: center;
justify-content: space-between;
align-items: center;
}
2025-08-28 14:05:06 +08:00
.lightMode .item {
width: calc(calc(100% - 90rpx) / 3);
2025-08-27 11:06:49 +08:00
height: 100%;
box-sizing: border-box;
border-radius: 16rpx;
2025-08-28 14:05:06 +08:00
2025-08-27 11:06:49 +08:00
color: rgba(255, 255, 255, 0.87);
font-family: 'PingFang SC';
font-size: 28rpx;
font-weight: 400;
letter-spacing: 0.14rpx;
display: flex;
2025-08-28 14:05:06 +08:00
flex-direction: column;
flex-wrap: nowrap;
align-content: center;
justify-content: space-evenly;
align-items: center;
2025-08-27 11:06:49 +08:00
}
2025-08-28 14:05:06 +08:00
.lightMode .item.active {
color: #AED600;
2025-08-27 11:06:49 +08:00
}
2025-08-28 14:05:06 +08:00
.lightMode .imgContent {
2025-08-27 11:06:49 +08:00
width: 80rpx;
2025-08-28 14:05:06 +08:00
height: 100rpx;
2025-08-27 11:06:49 +08:00
}
2025-08-28 14:05:06 +08:00
.lightMode .imgContent .img {
2025-08-27 11:06:49 +08:00
width: 100%;
height: 100%;
2025-08-28 14:05:06 +08:00
2025-08-27 11:06:49 +08:00
}
2025-08-28 14:05:06 +08:00
.picVideo .btnImg {
2025-08-27 11:06:49 +08:00
width: 100%;
2025-08-28 14:05:06 +08:00
height: 100rpx;
2025-08-27 11:06:49 +08:00
border-radius: 16rpx;
background: rgba(42, 42, 42, 1);
}
2025-08-28 14:05:06 +08:00
.picVideo .btnImg .img {
2025-08-27 11:06:49 +08:00
width: 40rpx;
2025-08-28 14:05:06 +08:00
height: 40rpx;
}
2025-08-28 14:46:04 +08:00
2025-08-28 14:05:06 +08:00
.netContent {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-content: flex-end;
justify-content: space-around;
align-items: flex-end;
width: 50rpx;
}
2025-08-28 14:46:04 +08:00
2025-08-28 14:05:06 +08:00
.net {
width: 7rpx;
background: rgba(255, 255, 255, 0.3);
}
2025-08-28 14:46:04 +08:00
2025-08-28 14:05:06 +08:00
.net.netone {
height: 11rpx;
}
2025-08-28 14:46:04 +08:00
2025-08-28 14:05:06 +08:00
.net.nettwo {
height: 17rpx;
}
2025-08-28 14:46:04 +08:00
2025-08-28 14:05:06 +08:00
.net.netsiri {
height: 23rpx;
}
2025-08-28 14:46:04 +08:00
2025-08-28 14:05:06 +08:00
.net.netfour {
height: 29rpx;
}
2025-08-28 14:46:04 +08:00
2025-08-28 14:05:06 +08:00
.net.netfive {
height: 35rpx;
}
2025-08-28 14:46:04 +08:00
2025-08-28 14:05:06 +08:00
.net.active {
background: #FFFFFF !important;
2025-08-27 11:06:49 +08:00
}
</style>