Merge branch 'liubiao-new-20250827'

This commit is contained in:
fengerli
2025-11-20 16:44:34 +08:00
31 changed files with 4703 additions and 465 deletions

View File

@ -172,7 +172,7 @@
<view class="slider-container">
<slider min="10" max="100" step="10" :disabled="false" :value="formData.sta_LightDimmer"
activeColor="#bbe600" backgroundColor="#00000000" block-size="20" block-color="#ffffffde"
activeColor="#bbe600" backgroundColor="#686767" block-size="20" block-color="#ffffffde"
@change="onBrightnessChanging" @changing="onBrightnessChanging" class="custom-slider" />
</view>
@ -184,7 +184,7 @@
<view class="slider-container">
<slider min="0.5" max="10" step="0.5" :disabled="false" :value="formData.sta_LightFreq"
activeColor="#bbe600" backgroundColor="#00000000" block-size="20" block-color="#ffffffde"
activeColor="#bbe600" backgroundColor="#686767" block-size="20" block-color="#ffffffde"
@change="onFreqChanging" @changing="onFreqChanging" class="custom-slider" />
</view>
@ -196,7 +196,7 @@
<view class="slider-container">
<slider min="1" max="8" step="1" :disabled="false" :value="formData.sta_VoiceVolume"
activeColor="#bbe600" backgroundColor="#00000000" block-size="20" block-color="#ffffffde"
activeColor="#bbe600" backgroundColor="#686767" block-size="20" block-color="#ffffffde"
@change="onVolumeChanging" @changing="onVolumeChanging" class="custom-slider" />
</view>
@ -1118,7 +1118,7 @@
let json = recei.ReceiveData(receive, device, pagePath, recArr);
// console.log("收到设备的数据", json)
console.log("收到设备的数据", json)
let key = 'sta_VoiceDate';
if (key in json) {
@ -1126,6 +1126,7 @@
console.log("22222", val)
if (val === 'start') {
//开始发包
console.log("开始发送数据");
updateLoading(these, {
text: "开始发送"
});

1735
pages/102/HBY102.vue Normal file

File diff suppressed because it is too large Load Diff

View File

@ -2,8 +2,7 @@
<view class="content contentBg">
<view class="eq">
<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>
<image class="img" :src="device.devicePic?device.devicePic:formData.img" mode="aspectFit"></image>
</view>
<view class="rightTxt">
<view class="row">
@ -28,27 +27,42 @@
<text class="value">{{device.deviceName}}</text>
</view>
<view class="item">
<text class="lbl">Mac地址</text>
<text class="value">{{device.deviceMac}}</text>
</view>
<text class="lbl">Mac地址</text>
<text class="value">{{device.deviceMac}}</text>
</view>
<view class="item">
<text class="lbl">蓝牙名称</text>
<text class="value">{{device.bluetoothName}}</text>
</view>
</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">信道:{{formData.sta_Channel}}</text>
<text class="value green" @click.stop="ShowChannelEdit()">修改</text>
</view>
</view>
<view class="warnnig" :class="formData.sta_SOSType=='sos'?'':'displayNone'"
@click.stop="showUnWarn('sos_off')">
<view class="warnnig" :class="formData.sta_SOSType=='sos'?'':'displayNone'" @click.stop="showUnWarn('sos_off')">
<view>设备强制报警中</view>
<view class="netContent">
{{formData.warnTime}}s
</view>
</view>
<!-- <view class="lamp">
<view class="title">
<text>信道设置</text>
<text>{{formData.sta_Channel}}</text>
</view>
</view>
<view class="lampMode">
<slider min="1" max="125" step="1" :disabled="false" :value="formData.sta_Channel" activeColor="#bbe600"
backgroundColor="#686767" block-size="20" block-color="#ffffffde" @change="onChannelChanging"
@changing="onChannelChanging" class="custom-slider" />
</view> -->
<view class="lamp">
<view class="title">
@ -85,25 +99,22 @@
<view class="lamp">
<view class="title">
<text>单色配组</text>
<view @click.stop="groupSetting({val:'off'})">
<image class="img" src="/static/images/common/close.png" mode="aspectFit"></image>
<view class="checkgroup" @click.stop="groupCheck()">
选择配组
</view>
</view>
</view>
<view class="lampMode">
<view class="mode fleft " v-for="item,index in dic.gropus"
:class="{active:formData.sta_GroupType===item.val,marginLeft:index%2==1}"
v-on:click.stop="groupSetting(item,index)">
<view class="leftImg">
<image class="img" :class="formData.sta_GroupType!==item.val?'':'displayNone'"
src="/static/images/4877/lightt.png" mode="aspectFit"></image>
<image class="img" :class="formData.sta_GroupType===item.val?'':'displayNone'" :src="item.activeImg"
mode="aspectFit"></image>
</view>
<view class="rightTxt">
<text class="bigTxt">{{item['text']}}</text>
<view class="colorContent">
<view v-for="item,index in dic.groups" class="item"
:class="{active:item.id===formData.sta_GroupType,marginNoLeft:index%3===0}"
@click.stop="groupSetting(item,index)">
<view class="polygon" :style="{backgroundColor:item.hex}">
</view>
<view class="text">{{item.name}}</view>
</view>
</view>
@ -213,19 +224,16 @@
:iconUrl="Status.Pop.iconUrl" :message="Status.Pop.message" :buttonText="Status.Pop.buttonText"
@buttonClick="HidePop" :visiblePrompt="Status.Pop.visiblePrompt" :promptTitle="Status.Pop.promptTitle"
v-model="Status.Pop.modelValue" @closePop="closePop" :buttonCancelText="Status.Pop.buttonCancelText"
:showCancel="Status.Pop.showCancel" @cancelPop="closePop" />
:showCancel="Status.Pop.showCancel" @cancelPop="closePop" :showSlot="Status.Pop.showSlot">
<view v-if="Status.ShowEditChannel" class="popup-prompt">
<text class="popup-prompt-title">修改信道</text>
<input class="popup-prompt-input" type="number" placeholder="1-125的整数"
placeholder-class="popup-prompt-input-placeHolder" v-model="formData.sta_Channel" />
<!-- 下方菜单 -->
<!-- <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> -->
</MessagePopup>
<global-loading ref="loading" />
</view>
@ -244,18 +252,23 @@
request,
baseURL
} from '../../utils/request';
import {
colors as groupColors
} from '@/api/4877/BJQ4877.js';
import usrApi from '@/api/670/HBY670.js'
const pagePath = "/pages/4877/BJQ4877";
var ble = null;
var these = null;
var recei = null;
var interval = null;
var slidTime = null;
export default {
data() {
return {
Status: {
ShowEditChannel: false,
pageHide: false,
Pop: {
showPop: false, //是否显示弹窗
@ -276,6 +289,7 @@
okCallback: null,
buttonCancelText: '',
showCancel: false,
showSlot: false
},
BottomMenu: {
show: false,
@ -327,13 +341,14 @@
macAddress: '',
bleStatu: false,
sta_SOSType: '', //sos
sta_GroupType: '', //配组
sta_GroupType: -1, //配组
sta_ArrowType: '', //箭头方向
warnTime: 0
warnTime: 0,
sta_Channel: 80
},
dic: {
SOS: [{
text: '声光报警',
text: 'SOS报警',
val: 'sos',
img: '/static/images/4877/sg.png',
activeImg: '/static/images/4877/sgActive.png'
@ -345,30 +360,7 @@
activeImg: '/static/images/4877/fanActive.png'
}
],
gropus: [{
text: '红配组',
val: 'red_group',
img: '/static/images/4877/light.png',
activeImg: '/static/images/4877/lightActive.png'
},
{
text: '蓝配组',
val: 'blue_group',
img: '/static/images/4877/light.png',
activeImg: '/static/images/4877/lightActive.png'
},
{
text: '绿配组',
val: 'green_group',
img: '/static/images/4877/light.png',
activeImg: '/static/images/4877/lightActive.png'
},
{
text: '黄配组',
val: 'yellow_group',
img: '/static/images/4877/light.png',
activeImg: '/static/images/4877/lightActive.png'
}
groups: [
]
},
@ -397,11 +389,14 @@
onUnload() {
console.log("页面卸载,释放资源");
ble.removeAllCallback(pagePath);
clearInterval(interval);
},
onLoad: function() {
these = this;
recei = BleReceive.getBleReceive();
ble = BleTool.getBleTool();
this.dic.gropus = [];
ble.addReceiveCallback(this.bleValueNotify, pagePath);
@ -415,7 +410,23 @@
eventChannel.on('detailData', function(data) {
// console.log("收到父页面的参数:" + JSON.stringify(data));
console.log("收到父页面的参数:" + JSON.stringify(data));
let checkIds = uni.getStorageSync("4877CheckColor_" + data.data.id);
if (checkIds && checkIds.length) {
let groups = groupColors.filter(v => {
let filt = checkIds.find(id => {
return id === v.id;
});
if (filt) {
return true;
}
return false;
});
these.dic.groups = groups;
}
var device = data.data;
these.device = device;
let f = ble.data.LinkedList.find((v) => {
@ -443,7 +454,7 @@
}
these.formData.blename = f.name ? f.name : "Unname";
these.formData.deviceName = device.deviceName;
these.formData.bleStatu = false;
these.formData.deviceId = f.deviceId;
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
@ -466,7 +477,71 @@
},
methods: {
ShowChannelEdit() {
this.Status.ShowEditChannel = true;
this.showPop({
showPop: true, //是否显示弹窗
popType: 'custom',
bgColor: '#383934bd',
borderColor: '#BBE600',
textColor: '#ffffffde',
buttonBgColor: '#BBE600',
buttonTextColor: '#232323DE',
iconUrl: '',
message: '',
buttonText: '确定',
clickEvt: '',
visiblePrompt: false,
promptTitle: '',
modelValue: '',
visibleClose: false,
okCallback: ()=>{
this.onChannelChanging();
this.Status.ShowEditChannel=false;
},
showSlot: true,
buttonCancelText: '取消',
showCancel: true,
cancelCallback:()=>{
this.Status.ShowEditChannel=false;
}
});
},
onChannelChanging() {
let regex = /^(0|([1-9]\d?)|1[01]\d|12[0-5])$/;
if (!regex.test(this.formData.sta_Channel)) {
this.showMsg("只能输入0-125整数");
return;
}
let f = this.getDevice();
if (!f) {
this.showBleUnConnect();
return;
}
clearTimeout(slidTime);
slidTime = setTimeout(() => {
console.log("11111");
let json = {
ins_channel: this.formData.sta_Channel
}
json = JSON.stringify(json);
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
console.log("发送成功");
this.setBleFormData();
}).catch(ex => {
this.showMsg(ex.msg);
});
}, 200)
},
ArrowSet(val) {
if (this.formData.sta_SOSType === 'sos') {
this.showMsg("设备强制报警中,请先关闭报警")
return;
}
let f = this.getDevice();
if (!f) {
this.showBleUnConnect();
@ -486,68 +561,124 @@
this.showMsg(ex.msg);
});
},
groupSetting(item, index) {
groupCheck() {
uni.navigateTo({
url: '/pages/4877/BJQ4877CheckColor',
events: {
CheckGroupOver: function(data) {
debugger;
let arr = groupColors.filter(v => {
let f = data.checkIds.find(item => {
return item === v.id;
})
if (f) {
return true;
}
return false;
});
these.dic.groups = arr;
these.CheckGroupOver(data.allFlag);
}
},
success(res) {
res.eventChannel.emit("CheckGroup", these.device)
}
});
},
CheckGroupOver(arr) { //选择了某些配组
debugger;
let f = this.getDevice();
if (!f) {
this.showBleUnConnect();
return;
}
if (this.formData.sta_GroupType === item.val) {
this.formData.sta_GroupType = '';
} else {
this.formData.sta_GroupType = item.val;
}
var json = {
ins_GroupType: this.formData.sta_GroupType
ins_GroupType: arr
}
json = JSON.stringify(json);
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30)
.catch(ex => {
this.showMsg(ex.msg);
});
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
}).catch(ex => {
this.showMsg(ex.msg);
});
},
showUnWarn(val) {
this.showPop({
message: '确定解除声光报警模式?',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
okCallback: () => {
// this.showPop({
// message: '确定解除声光报警模式?',
// iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
// borderColor: "#e034344d",
// buttonBgColor: "#E03434",
// okCallback: () => {
clearInterval(interval);
this.sosSetting({
val: val
});
},
buttonText: "解除",
showCancel: true,
buttonCancelText: '取消'
// },
// buttonText: "解除",
// showCancel: true,
// buttonCancelText: '取消'
});
// });
},
sosSetting(item, index) {
groupSetting(item, index) {
if (this.formData.sta_SOSType === 'sos') {
this.showMsg("设备强制报警中,请先关闭报警")
return;
}
if (this.formData.sta_GroupType === item.id) {
return;
}
let f = this.getDevice();
if (!f) {
this.showBleUnConnect();
return;
}
let groupSet = () => {
setTimeout(() => {
let buffer = {
ins_statusType: [item.id]
}
buffer = JSON.stringify(buffer);
console.error("发送命令:", buffer);
ble.sendString(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 30).then(
result => {
this.formData.sta_GroupType = item.id;
this.formData.sta_SOSType = 'sos_off'
console.log("配组设置成功");
});
}, 0);
}
groupSet();
},
sosSetting(item, index) {
let f = this.getDevice();
if (!f) {
this.showBleUnConnect();
return;
}
let task = () => {
var json = {
ins_SOSType: this.formData.sta_SOSType == item.val ? 'sos_off' : item.val
}
json = JSON.stringify(json);
console.error("发送指令:", json);
// let f={deviceId:'111111'}
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
if (this.formData.sta_SOSType === item.val) {
this.formData.sta_SOSType = 'sos_off';
} else {
this.formData.sta_SOSType = item.val;
}
this.formData.sta_GroupType = -1;
this.formData.sta_SOSType = json.ins_SOSType
if (this.formData.sta_SOSType == 'sos') {
this.formData.warnTime = 0;
clearInterval(interval);
@ -560,25 +691,44 @@
})
.catch(ex => {
this.showMsg(ex.msg);
});
}
if (item.val === 'sos') {
let confirmTask=()=>{
this.showPop({
message: '确定开启声光报警模式?',
message: '确定' + (this.formData.sta_SOSType === 'sos' ? '关闭' : '开启') + '声光报警模式?',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
okCallback: task,
buttonText: "开启",
buttonText: (this.formData.sta_SOSType === 'sos' ? '关闭' : '开启'),
showCancel: true,
buttonCancelText: '取消'
});
}
if (item.val === 'sos') {
confirmTask();
} else if (item.val === 'sos_off') {
if(this.formData.sta_SOSType === 'sos'){
confirmTask();
}else{
task();
}
} else {
if (index !== undefined && this.formData.sta_SOSType == 'sos') {
this.showUnWarn(item.val);
if (this.formData.sta_SOSType === 'sos') {
this.showMsg("设备强制报警中,请先关闭报警");
return;
} else {
task();
}
}
@ -753,7 +903,7 @@
return false;
});
uni.setStorageSync(ble.StorageKey, ble.data.LinkedList);
ble.updateCache();
},
showBleUnConnect() {
@ -1345,7 +1495,7 @@
border-radius: 16rpx;
background: rgba(26, 26, 26, 1);
width: 100%;
padding: 30rpx 0rpx;
padding: 10rpx 0rpx;
}
.modeSetting {
@ -1381,8 +1531,8 @@
}
.modeSetting .arrow .outCircle {
width: 150rpx;
height: 150rpx;
width: 120rpx;
height: 120rpx;
box-sizing: border-box;
display: flex;
flex-direction: row;
@ -1593,4 +1743,124 @@
justify-content: space-between;
align-items: center;
}
.checkgroup {
color: rgba(174, 214, 0, 1);
font-family: PingFang SC;
font-size: 28rpx;
font-weight: 400;
letter-spacing: 0.14px;
text-align: left;
}
.colorContent {
display: flex;
align-content: center;
justify-content: flex-start;
justify-items: center;
flex-direction: row;
flex-wrap: wrap;
align-items: center;
width: 100%;
box-sizing: border-box;
}
.colorContent .polygon {
width: 40rpx;
height: 40rpx;
border-radius: 8rpx;
}
.colorContent .text {
color: rgba(255, 255, 255, 0.87);
font-family: PingFang SC;
font-size: 30rpx;
font-weight: 400;
letter-spacing: 2rpx;
margin-left: 15rpx;
}
.colorContent .item {
background-color: #1A1A1A;
margin-left: 36rpx;
width: calc(calc(100% - 72rpx) / 3);
height: 110rpx;
margin-top: 24rpx;
box-sizing: border-box;
padding-left: 25rpx;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: flex-start;
align-items: center;
align-content: center;
border-width: 1rpx;
border-style: solid;
border-color: #00000000;
border-radius: 8rpx;
}
.colorContent .item.active {
border-color: #AED600 !important;
}
.colorContent .marginNoLeft {
margin-left: 0rpx !important;
}
.popup-prompt {
width: 100%;
box-sizing: border-box;
padding: 30rpx 15%;
}
.popup-prompt-title {
text-align: center;
width: 100%;
float: left;
box-sizing: border-box;
white-space: nowrap;
color: rgba(255, 255, 255, 0.87);
font-family: PingFang SC;
font-size: 28rpx;
font-weight: 400;
line-height: 40rpx;
letter-spacing: 0.14rpx;
}
.popup-prompt-input {
width: 100%;
height: 60rpx;
line-height: 60rpx;
color: rgba(255, 255, 255, 0.87);
box-sizing: border-box;
border-bottom: 2rpx solid rgba(255, 255, 255, 0.4);
font-size: 28rpx;
font-weight: 400;
letter-spacing: 0.14px;
}
.popup-prompt-input-placeHolder {
color: rgba(255, 255, 255, 0.4);
font-family: PingFang SC;
font-size: 28rpx;
font-weight: 400;
letter-spacing: 0.14px;
text-align: center;
}
</style>

View File

@ -0,0 +1,310 @@
<template>
<view class="contentBg mainContent">
<view class="colorContent">
<view v-for="item,index in colors" class="item" :class="{active:item.check,marginNoLeft:index%3===0}"
@click.stop="CheckGroup(item,index)">
<view class="polygon" :style="{backgroundColor:item.hex}">
</view>
<view class="text">{{item.name}}</view>
</view>
</view>
<view class="footer">
<view class="btnSave" @click.stop="CheckOver()">确定</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"
@buttonClick="HidePop" :visiblePrompt="Status.Pop.visiblePrompt" :promptTitle="Status.Pop.promptTitle"
v-model="Status.Pop.modelValue" @closePop="closePop" :buttonCancelText="Status.Pop.buttonCancelText"
:showCancel="Status.Pop.showCancel" @cancelPop="closePop" />
</view>
</template>
<script>
import {
colors
} from '@/api/4877/BJQ4877.js';
var eventChannel = null;
var these=null;
export default {
data() {
return {
Status: {
Pop: {
showPop: false, //是否显示弹窗
popType: 'custom',
bgColor: '#383934bd',
borderColor: '#BBE600',
textColor: '#ffffffde',
buttonBgColor: '#BBE600',
buttonTextColor: '#232323DE',
iconUrl: '',
message: '您确定要这样做吗?',
buttonText: '确定',
clickEvt: '',
visiblePrompt: false,
promptTitle: '设备名称',
modelValue: '',
visibleClose: false,
okCallback: null,
buttonCancelText: '',
showCancel: false,
}
},
colors: [
],
device:{
}
}
},
onLoad() {
these=this;
this.colors = Object.assign([], colors);
eventChannel = this.getOpenerEventChannel();
eventChannel.on('CheckGroup', function(data) {
debugger;
if (data && data.id) {
these.device=data;
uni.getStorage({
key: "4877CheckColor_" + data.id,
success: (res) => {
if (res.data) {
debugger;
for (var index = 0; index < these.colors.length; index++) {
let f=res.data.find(v=>{
return v===these.colors[index].id;
});
if(f){
these.$set(these.colors[index], 'check',true);
}else{
these.$set(these.colors[index], 'check',false);
}
}
}
}
})
}
});
},
methods: {
CheckOver() {
let arr = this.colors.map(v => {
return v.check ? 1 : 0;
})
if (!arr.length) {
this.showMsg("请选择至少1个颜色配组");
return;
}
let checks = this.colors.filter(v => {
return v.check
}).map(item => {
return item.id
});
console.log("checks=", checks);
eventChannel.emit('CheckGroupOver', {allFlag:arr,checkIds:checks});
uni.setStorage({
key: "4877CheckColor_" + this.device.id,
data: checks
});
uni.navigateBack();
},
CheckGroup(item, index) {
this.$set(this.colors[index], 'check', !item.check)
},
closePop: function() {
this.Status.Pop.showPop = false;
if (this.Status.Pop.cancelCallback) {
this.Status.Pop.cancelCallback();
}
},
HidePop: function() {
if (this.Status.Pop.clickEvt == 'SendUsr') {
}
this.Status.Pop.showPop = false;
if (this.Status.Pop.okCallback) {
this.Status.Pop.okCallback();
}
},
showPop: function(option) {
hideLoading(this);
let def = {
showPop: true, //是否显示弹窗
popType: 'custom',
bgColor: '#383934bd',
borderColor: '#BBE600',
textColor: '#ffffffde',
buttonBgColor: '#BBE600',
buttonTextColor: '#232323DE',
iconUrl: '',
message: '',
buttonText: '确定',
clickEvt: '',
visiblePrompt: false,
promptTitle: '',
modelValue: '',
visibleClose: false,
okCallback: null,
showSlot: false,
buttonCancelText: '',
showCancel: false,
}
let keys = Object.keys(def);
for (let i = 0; i < keys.length; i++) {
let key = keys[i];
if (key in option) {
continue;
}
this.Status.Pop[key] = def[key];
}
if (option) {
keys = Object.keys(option);
for (let i = 0; i < keys.length; i++) {
let key = keys[i];
this.Status.Pop[key] = option[key];
}
}
if (!option.borderColor) {
option.borderColor = '#BBE600';
option.buttonBgColor = '#BBE600';
}
these.Status.Pop.showPop = true;
},
showMsg(msg, isSucc) {
let icoUrl = '/static/images/6155/DeviceDetail/uploadErr.png';
let borderColor = "#e034344d";
let buttonBgColor = "#E03434";
if (isSucc) {
icoUrl = '/static/images/common/success.png';
borderColor = "#BBE600";
buttonBgColor = "#BBE600";
}
this.showPop({
message: msg,
iconUrl: icoUrl,
borderColor: borderColor,
buttonBgColor: buttonBgColor,
buttonText: '确定',
okCallback: null
});
}
}
}
</script>
<style>
.mainContent {
width: 100%;
min-height: 100vh;
box-sizing: border-box;
padding: 30rpx
}
.colorContent {
display: flex;
align-content: center;
justify-content: flex-start;
justify-items: center;
flex-direction: row;
flex-wrap: wrap;
align-items: center;
width: 100%;
box-sizing: border-box;
}
.polygon {
/* 矩形 235 */
width: 30rpx;
height: 30rpx;
border-radius: 8rpx;
}
.text {
color: rgba(255, 255, 255, 0.87);
font-family: PingFang SC;
font-size: 28rpx;
font-weight: 400;
letter-spacing: 2rpx;
margin-left: 15rpx;
}
.item {
background-color: #1A1A1A;
margin-left: 36rpx;
width: calc(calc(100% - 72rpx) / 3);
height: 90rpx;
margin-top: 24rpx;
box-sizing: border-box;
padding-left: 25rpx;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: flex-start;
align-items: center;
align-content: center;
border-width: 1rpx;
border-style: solid;
border-color: #00000000;
border-radius: 8rpx;
}
.item.active {
border-color: #AED600 !important;
}
.marginNoLeft {
margin-left: 0rpx !important;
}
.footer {
position: fixed;
bottom: 75px;
left: 00rpx;
width: 100%;
height: 100rpx;
box-sizing: border-box;
padding: 0rpx 120rpx;
}
.btnSave {
background-color: #BBE600;
color: #232323DE;
text-align: center;
border-radius: 60rpx;
width: 100%;
height: 100rpx;
font-family: PingFang SC;
font-size: 32rpx;
font-weight: 400;
line-height: 100rpx;
letter-spacing: 12rpx;
}
</style>

1596
pages/4877/BJQ4877V1.vue Normal file

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
<view class="eq">
<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>
</view>
<view class="rightTxt">
<view class="row">
@ -23,15 +23,15 @@
</view>
</view>
<view class="eqinfo">
<view class="item">
<text class="lbl">设备名称</text>
<text class="value">{{device.deviceName}}</text>
</view>
<view class="item">
<text class="lbl">Mac地址</text>
<text class="value">{{device.deviceMac}}</text>
</view>
<text class="lbl">Mac地址</text>
<text class="value">{{device.deviceMac}}</text>
</view>
<view class="item">
<text class="lbl">设备状态</text>
<text class="value">{{formData.statu}}</text>
@ -86,6 +86,15 @@
<text class="smallTxt">上传</text>
</view>
</view>
<view class="mode fleft marginLeft" v-on:click.stop="UploadOpenVideo()">
<view class="leftImg">
<image class="img" src="/static/images/common/video.png" mode="aspectFit"></image>
</view>
<view class="rightTxt">
<text class="bigTxt">开机视频</text>
<text class="smallTxt">上传</text>
</view>
</view>
<view class="clear"></view>
</view>
<view class="usrinfo">
@ -162,6 +171,10 @@
updateLoading
} from '@/utils/loading.js'
import BleReceive from '@/utils/BleReceive';
import {
baseURL
} from '@/utils/request.js';
var pagePath = "/pages/6155/HBY6155";
var ble = null;
@ -246,7 +259,7 @@
mode: '',
bleStatu: ''
},
inteval: 200,
inteval: 80,
device: {
id: "",
deviceName: "",
@ -360,7 +373,7 @@
}
these.formData.blename = f.name ? f.name : "Unname";
these.formData.deviceName = device.deviceName;
these.formData.id = device.id;
these.formData.deviceId = f.deviceId;
these.formData.bleStatu = false;
@ -617,18 +630,19 @@
var processAndSendImageData = function(pixels) {
return new Promise((resolve, reject) => {
// 创建RGB565格式的像素数据
// console.log("pixels=",pixels);
const arr = ble.convertToRGB565(pixels, 'bgr');
var list = [];
let index = 0; // 用于追踪arr的当前位置
let packetSize = 2048;
let cSize = 248;
let packetSize = 3200;
let cSize = 200;
// 外层循环7个主要元素i从1到7
for (let i = 1; i < 8; i++) {
for (let i = 1; i < 9; i++) {
let secondLevel = [];
let secondCnt = 0;
// 中层循环每个主要元素包含9个子数组j从1到9
for (let j = 1; j < 10; j++) {
for (let j = 1; j < 9; j++) {
// 确定当前子数组的长度前8个是254第9个是64
let thirdLevel = [];
@ -675,15 +689,18 @@
var sendImagePackets = function(imageData) {
return new Promise((resolve, reject) => {
// 总数据包数
const totalPackets = 7;
const totalPackets = 8;
let currentPacket = 1;
let childPacket = 1;
let totalChildPacket = 9;
let totalChildPacket = 8;
// 发送单个数据包
const sendNextPacket = () => {
if (currentPacket > totalPackets) {
updateLoading(these, {
text: '发送完成,等待设备30秒'
});
setTimeout(() => {
hideLoading(these);
these.Status.BottomMenu.show = false;
@ -696,57 +713,40 @@
});
resolve();
}, 20000)
}, 0)
return;
}
var packetData = imageData[currentPacket - 1][childPacket - 1];
// if (packetData.length == 0) {
// hideLoading(these);
// these.Status.BottomMenu.show = false;
// these.showPop({
// message: "上传成功",
// iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png"
// });
// resolve();
// return;
// }
console.log("childPacket=", childPacket);
console.log("packetData=", packetData);
let start = 0;
let bufferSize = packetData.length * 2;
if (currentPacket == 7) {
if (childPacket > 2 && childPacket < 9) {
bufferSize = 496;
} else if (childPacket == 9) {
bufferSize = 128;
}
}
if (childPacket == 1) {
bufferSize = bufferSize + 8
start = 8;
}
if (childPacket == 9) { //|| (currentPacket==7 && childPacket==3
if (childPacket == 8) { //|| (currentPacket==7 && childPacket==3
bufferSize = bufferSize + 1
}
//FA 09 10 04 FC 09 [00] [01] + 4096字节+FF 数据格式
//FA 09 0C 84 FB 09 00 [01~08] + 3200字节 +FF 数据格式
var buffer = new ArrayBuffer(bufferSize);
var dataView = new DataView(buffer);
if (childPacket == 1) {
dataView.setUint8(0, 0xFA); // 帧头
dataView.setUint8(1, 0x09); // 帧头
dataView.setUint8(2, 0x10); // 帧头
dataView.setUint8(3, 0x04); // 帧头
dataView.setUint8(4, 0xFC); // 帧头
dataView.setUint8(5, 0x09); // 帧头
dataView.setUint8(6, 0x00); // 图序号,图片固定0视频的话要写序号
dataView.setUint8(7, currentPacket); //子包序号
dataView.setUint8(2, 0x0C); // 帧头
dataView.setUint8(3, 0x84); // 帧头
dataView.setUint8(4, 0xFD); // 帧头
dataView.setUint8(5, 0x09);
dataView.setUint8(6, 0x00); // 帧头
dataView.setUint8(7, currentPacket); //包序号
}
for (let i = 0; i < packetData.length; i++) {
@ -754,7 +754,7 @@
}
console.log("packetData.length=", packetData.length);
console.log("bufferSize=", bufferSize)
if (childPacket == 9) { // || (currentPacket==7 && childPacket==3
if (childPacket == 8) { // || (currentPacket==7 && childPacket==3
dataView.setUint8(bufferSize - 1, 0xFF);
}
@ -768,10 +768,10 @@
console.log("第" + currentPacket + "大包,第" + childPacket +
"小包发送完成,总计:" + curr);
updateLoading(these, {
text: "正在发送" + curr + "/63"
text: "正在发送" + curr + "/64"
})
if (childPacket == 9) {
if (childPacket == 8) {
currentPacket++;
childPacket = 1;
} else {
@ -817,7 +817,7 @@
ImgCutOver: function(data) {
showLoading(these, {
text: "正在发送0/52"
text: "正在发送0/64"
});
these.Status.BottomMenu.show = false;
@ -843,6 +843,344 @@
}
});
},
UploadOpenVideo: function() { //开机动画
let f = these.getDevice();
if (!f) {
these.showBleUnConnect();
return;
}
let timeDelayCloseLoading = () => {
setTimeout(() => {
hideLoading(these);
}, 1500);
}
//视频上传
let uplploadVideo = (videoPath) => {
return new Promise((resolve, reject) => {
let start = new Date();
let token = uni.getStorageSync('token');
let clientid = uni.getStorageSync('clientID');
uni.uploadFile({
url: baseURL + "/app/video/upload",
filePath: videoPath,
name: 'file',
header: {
"Method": "POST",
"Content-Type": "multipart/form-data",
"Authorization": 'Bearer ' + token,
"clientid": clientid
},
formData: {
code: 2
},
timeout: 600000,
fail: (ex) => {
updateLoading(these, {
text: '视频文件上传失败了,请检查网络连接'
});
reject(ex);
},
success: (res) => {
// console.error(res);
let end = new Date();
var diff = (end.getTime() - start.getTime()) / 1000;
let s = diff % 60;
let m = parseInt((diff - s) / 60);
console.log("res.statusCode==", res.statusCode);
res.data = JSON.parse(res.data);
if (res.statusCode === 200) {
if (res.data.code == 200) {
console.log("上传完成,耗时:" + m + "分" + s + "秒");
updateLoading(these,{text:"上传完成,耗时:" + m + "分" + s + "秒,正在切片。"})
resolve(res.data);
return;
}
}
console.error("上传完成,耗时:" + m + "分" + s + "秒");
reject(res);
}
});
});
}
//视频切片
let videoCutPacket = (array) => {
return new Promise((resolve, reject) => {
try {
let imgSize = 25600;
let packetSize = 3200;
let tdSize = 500;
let results = [];
for (let i = 0; i < 30; i++) { //先切出30张每张25600字节
let packet = array.slice(0, imgSize);
array.splice(0, imgSize)
let secondLevel = [];
for (let j = 0; j < 8; j++) { //每张切8大包每包3200字节
let childPacket = packet.slice(0, packetSize);
packet.splice(0, packetSize);
let thirdLevel = [];
for (let k = 0; k < 7; k++) { //每1个大包切出7个小包前6包500字节第7包200字节共计56小包
let arr = childPacket.slice(0, tdSize);
childPacket.splice(0, tdSize)
thirdLevel.push(arr);
}
secondLevel.push(thirdLevel);
}
results.push(secondLevel);
}
updateLoading(these,{text:'切片完成,正在发送'});
resolve(results);
} catch (error) {
updateLoading(these, {
text: '视频切片发生异常'
});
reject(error);
}
});
}
//发送视频到设备
let shotVideoClick = (array, type, ReSendNo) => {
var sendImagePackets = () => {
return new Promise((resolve, reject) => {
this.currentPacket = 0;
// 总数据包数
var totalPackets = 1680;
this.totalPackets = totalPackets;
let currentPacket = 1;
let imgIndex = 0;
let imgPackIndex = 0;
let childPacketIndex = 0;
if (ReSendNo) {
this.currentPacket = ReSendNo - 1;
currentPacket = ReSendNo;
totalPackets = ReSendNo;
this.totalPackets = ReSendNo;
}
// 发送单个数据包
const sendNextPacket = () => {
// console.log("111111")
if (currentPacket > totalPackets) {
resolve();
return;
}
// console.log("111111")
// 计算当前包的数据
let packetSize = 500;
if ((currentPacket - 1) % 56 === 0) {
packetSize = 508;
}
if (childPacketIndex === 6) {
packetSize = 200;
}
if ((currentPacket - 1) % 56 === 55) {
packetSize = 201;
}
console.log("imgIndex=" + imgIndex + ",imgPackIndex=" +
imgPackIndex +
",childPacketIndex=" + childPacketIndex)
let packetData = array[imgIndex][imgPackIndex][childPacketIndex];
let buffer = new ArrayBuffer(packetSize);
let dataView = new DataView(buffer);
let sortNo = currentPacket.toString(16).padStart(4, '0');
// console.log("11111");
let start = 0;
if ((currentPacket - 1) % 56 === 0) {
// 填充头部
dataView.setUint8(0, 0xFA); // 帧头
dataView.setUint8(1, 0x09); // 帧类型:开机画面
dataView.setUint8(2, 0x0C);
dataView.setUint8(3, 0x84);
dataView.setUint8(4, 0xFD);
dataView.setUint8(5, 0x09);
dataView.setUint8(6, imgIndex);
dataView.setUint8(7, imgPackIndex + 1);
start = 8;
}
console.log("222222");
for (let i = 0; i < packetData.length; i++) {
dataView.setUint8(start + i, '0x' + packetData[i]);
}
// console.log("333333333");
if ((currentPacket - 1) % 56 === 55) {
dataView.setUint8(200, 0xFF);
}
// console.log("444444");
let inteval = parseInt(this.inteval ? this.inteval : 80);
ble.sendData(f.deviceId, buffer, f.writeServiceId, f
.wirteCharactId, ).then(() => {
if (ReSendNo) {
resolve();
return;
}
// 更新进度
this.currentPacket = currentPacket;
updateLoading(these,{
text:'正在发送:'+currentPacket+"/"+totalPackets
});
childPacketIndex++;
if (childPacketIndex == 7) {
imgPackIndex++;
if (imgPackIndex == 8) {
imgIndex++;
imgPackIndex = 0;
}
childPacketIndex = 0;
}
// 发送下一个包(添加延迟避免蓝牙缓冲区溢出)
currentPacket++;
setTimeout(sendNextPacket, inteval);
}).catch(err => {
if (err.code == 10007) {
console.error(err.errMsg + ",发送失败了,正在补偿:" +
currentPacket);
setTimeout(sendNextPacket, 100);
return;
}
console.error(err.errMsg + ",发送失败了" + currentPacket);
updateLoading(these,{text:"发送失败,"+err.errMsg});
reject(err);
});
};
// console.log("111111")
sendNextPacket();
});
}
return sendImagePackets();
}
uni.chooseVideo({
sourceType: ['album'],
success: function(res) {
console.log("res=",res);
let path = res.tempFilePath;
let width = res.width;
let height = res.height;
let duration = res.duration;
let err = [];
if (duration < 2) {
err.push("视频时长至少2秒");
}
if (width != 160 || height != 80) {
err.push("视频宽高必须是160*80");
}
if (err.length > 0) {
err = err.join(";");
these.showPop({
message: err,
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
});
return;
}
showLoading(these, {
text: '正在上传'
});
setTimeout(() => {
uplploadVideo(path).then(result => {
videoCutPacket(result.data).then(array => {
let start = new Date();
console.log("开始发送");
shotVideoClick(array).then(() => {
console.log("发送完成");
let end = new Date();
var diff = (end.getTime() - start.getTime()) / 1000;
let s =parseInt(diff % 60);
let m =parseInt((diff - s) / 60);
console.log("发送完成,耗时:" + m + "分" + s + "秒");
updateLoading(these,{
text: "发送完成,耗时:" + m + "分" + s + "秒",
});
}).catch((ex1) => {
console.log("出现了异常", ex1)
}).finally(() => {
timeDelayCloseLoading();
});
}).catch(err => {
timeDelayCloseLoading();
});
}).catch(ex => {
timeDelayCloseLoading();
});
}, 0);
}
});
},
UploadOpenImg: function() {
//上传开机画面
this.Status.BottomMenu.menuItems = [];

View File

@ -1007,7 +1007,7 @@
dataView.setUint8(6 + i, '0x' + packetData[i]);
}
let inteval = 50;
let inteval = 30;
console.log("开始发送一段视频"); //
ble.sendData(f.deviceId, buffer, f.writeServiceId, f
.wirteCharactId, 10).then(() => {

View File

@ -309,6 +309,8 @@
data() {
return {
Status: {
msgOkIntval:null,//紧急通知等待的时间
msgOkTime:null,//
pageHide: false,
apiType: "listA",
navbar: {
@ -465,6 +467,8 @@
onUnload() {
console.log("页面卸载,释放资源");
let statusTopic = `A/${this.formData.imei?this.formData.imei:this.device.deviceImei}`;
clearInterval(these.Status.staticWarn.inteval);
clearInterval(this.Status.msgOkIntval);
ble.removeAllCallback(pagePath);
if (mqttClient) {
mqttClient.unsubscribe(statusTopic);
@ -863,10 +867,22 @@
// console.log("收到文本回复", payload);
// // this.SendTxtMQ(json);
// }
// else if (keys.indexOf('sta_BreakNews') > -1) { //紧急通知
// console.log("收到紧急消息回复", payload);
// // this.sendUrgentMQ(json);
// }
if (keys.indexOf('sta_BreakNews') > -1) { //紧急通知
if(json.sta_BreakNews==='I get it')// && this.Status.msgOkTime && this.Status.msgOkIntval){
{
these.showPop({
showPop: true,
message: "用户已确认收到紧急通知",
iconUrl: "/static/images/6155/DeviceDetail/uploadSuccess.png"
});
// this.Status.msgOkTime=null
// clearInterval(this.Status.msgOkIntval);
}
}
// else {
// console.log("收到不能处理的数据", payload);
// }
@ -2498,7 +2514,7 @@
buttonBgColor: '#BBE600',
buttonTextColor: '#232323DE',
iconUrl: '/static/images/6155/DeviceDetail/sendSucc.png',
message: '发送成功',
message: '发送成功,待用户确认',
buttonText: '确定',
clickEvt: 'SendUsr',
visiblePrompt: false,
@ -2506,6 +2522,20 @@
modelValue: '',
visibleClose: true
});
// clearInterval(this.Status.msgOkIntval);
// 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;
// }
// });
} else {
these.showPop({
message: res.msg,

View File

@ -173,6 +173,7 @@
}
else{
try{
console.log("str=",receive.str)
let json=JSON.parse(receive.str);
let key = "sta_address";
if (key in json) {//100

View File

@ -328,7 +328,7 @@
these.EquipMents.push(arr[i]);
}
}
console.log("EquipMents=", these.EquipMents)
// console.log("EquipMents=", these.EquipMents)
}, pagePath);
//收到设备的消息回调
ble.addReceiveCallback((receivData, f, path, arr) => {
@ -386,11 +386,11 @@
Promise.allSettled(promis).finally(() => {
ble.StopSearch().finally(res => {
// console.log("停止搜索成功");
console.log("停止搜索成功");
these.EquipMents = [];
these.PairEquip = [];
ble.StartSearch().then(result => {
// console.log("开始搜索成功");
console.log("开始搜索成功");
}).catch(err => {
console.error("开始搜索失败,err=", err);
if (err.code === 10001) {
@ -604,7 +604,7 @@
console.log("res=", res);
linkCallback(res);
}).catch(ex => {
console.log("ex=", ex)
console.error("ex=", ex)
uni.showModal({
content: "连接失败:" + ex.msg
});

View File

@ -601,6 +601,8 @@
console.log("无文件删除");
return;
}
console.log("item=", item);
let delFile = (tempFilePath) => {
let promise = new Promise((resolve, reject) => {
@ -687,7 +689,7 @@
this.Status.isEdit = false;
this.showMsg("操作成功", true);
}, 100)
}, 0)
}