6155添加分享

This commit is contained in:
liub
2026-01-29 14:40:20 +08:00
parent d6ca84170f
commit 1e971292cd
8 changed files with 596 additions and 419 deletions

178
App.vue
View File

@ -1,178 +0,0 @@
<script>
import bleTool from '@/utils/BleHelper.js'
import upgrade from '@/utils/update.js'
export default {
onLaunch: function() {
//以下代码仅在开发时使用,否则会出现不可预知的问题。
//清除登陆之外的所有信息;
// let store=uni.getStorageInfoSync();
// store.keys.forEach((val,index,array)=>{
// if(val=="tokenTime"){
// let time=uni.getStorageSync(val);
// if(!time){
// time=0;
// }
// let currTime=new Date().getTime();
// if(currTime>=time){
// uni.removeStorageSync(val);
// uni.removeStorageSync("token");
// uni.removeStorageSync("clientID");
// }
// }
// else if(val=="token" || val=="clientID" || val=='phone'){
// console.log("忽略登陆信息");
// }else{
// uni.removeStorageSync(val);
// }
// });
// uni.clearStorageSync();
//以上代码仅在开发时使用,否则会出现不可预知的问题。
// #ifdef APP-PLUS
var appid = plus.runtime.appid;
console.log('应用的 appid 为:' + appid);
// #endif
},
onShow: function() {
console.log('App Show');
//将检查更新换到onshow,因为苹果用户喜欢一直挂着
uni.getSystemInfo({
success: function(res) {
if (res.uniPlatform == 'app') {
bleTool.getBleTool();
let appid = plus.runtime.appid;
if (appid !== 'HBuilder') {
console.log("appid=", appid);
upgrade.checkAndUpdateWgt();
}
}
}
});
},
onHide: function() {
console.log('App Hide');
},
onError(ex) {
console.error("出现了未知的异常",ex);
}
}
</script>
<style lang="scss">
@import 'vk-uview-ui/index.scss';
/* #ifdef APP-ANDROID */
//苹果应用以下样式后Slider不可拖动
uni-slider .uni-slider-handle-wrapper {
border-radius: 20rpx;
}
uni-slider .uni-slider-thumb {
width: 66rpx !important;
height: 80rpx !important;
margin-top: -40rpx !important;
border-radius: 16rpx !important;
margin-left: -72rpx !important;
}
uni-slider .uni-slider-handle-wrapper {
height: 88rpx;
position: relative;
// }
/* #endif */
.custom-file-picker .file-picker__box-content {
background: rgba(26, 26, 26, 1);
border: none !important;
border-radius: 45rpx;
width: 180rpx;
height: 180rpx;
}
.uni-file-picker.custom-file-picker {
overflow: inherit !important;
}
.custom-file-picker .icon-add {
height: 5rpx !important;
width: 70rpx !important;
}
.uni-picker-view-mask {
background: rgba(42, 42, 42, 1);
z-index: -1;
}
.uni-picker-view-content {
position: inherit;
}
.uni-picker-view-wrapper {
background: rgba(42, 42, 42, 1);
}
.green {
color: #aed600 !important;
}
.red {
color: #FF0000 !important;
}
.maincontent {
width: 100%;
min-height: 100vh;
height: auto;
padding: 30rpx;
box-sizing: border-box;
}
.contentBg {
background-color: #121212;
color: #ffffffde;
}
.fleft {
float: left;
}
.fright {
float: right;
}
.clear {
clear: both;
}
.displayNone {
display: none !important;
}
.visibilityHidden{
visibility: hidden !important;
}
.center {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-content: center;
justify-content: center;
align-items: center;
}
@font-face {
font-family: "PingFang SC";
src: url("~@/static/fonts/PingFangSC.ttf") format("opentype");
}
@font-face {
font-family: "PingFangBold";
src: url("~@/static/fonts/PingFangBold.ttf") format("opentype");
}
</style>

View File

@ -156,7 +156,8 @@
{
"path": "pages/6155/deviceDetail",
"style": {
"navigationBarTitleText": "HBY 6155"
"navigationBarTitleText": "HBY 6155",
"navigationStyle": "custom"
}
},
{
@ -375,7 +376,8 @@
"path" : "pages/6155/BJQ6155",
"style" :
{
"navigationBarTitleText" : "BJQ6155"
"navigationBarTitleText" : "BJQ6155",
"navigationStyle": "custom"
}
},
{

View File

@ -1,5 +1,26 @@
<template>
<view class="content contentBg">
<uni-nav-bar class="nvbar" leftIcon="left" @clickLeft="navigatorBack">
<view slot="left">
<uni-icons type="back" size="23" color="#FFFFFF"></uni-icons>
</view>
<view slot="default" class="center uninavebartext">
{{Status.navbar.title}}
</view>
<view slot="right">
<view class="navbarRight center">
<view class="imgContent" :class="{'visibilityHidden':Status.apiType!=item.apiType}" @click.stop="handleRightClick(item,index)"
v-for="item,index in Status.navbar.icons">
<image class="img" :src="item.src" mode="aspectFit"></image>
<view class="baber" v-if="item.math">{{item.math>9?'9+':item.math}}</view>
</view>
</view>
</view>
</uni-nav-bar>
<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>
@ -168,6 +189,7 @@
import TextToHexV1 from '@/components/TextToHex/TextToHexV1.vue';
import bleTool from '@/utils/BleHelper.js';
import usrApi from '@/api/670/HBY670.js'
import Common from '@/utils/Common.js';
import {
showLoading,
hideLoading,
@ -192,6 +214,16 @@
data() {
return {
Status: {
apiType: '',
navbar: {
icons: [{
src: '/static/images/common/shape.png',
callback: this.gotoShare,
apiType:'listA'
}],
title: 'BJQ6155'
},
lightMode: {
},
@ -276,6 +308,7 @@
},
videoHexArray: [],
rgb565Data: [],
permissions: [],
dic: {
menuItems: [{
text: '强光',
@ -325,52 +358,7 @@
these = this;
recei = BleReceive.getBleReceive();
ble = bleTool.getBleTool();
// let bleName = 'FB_Site_UART'; //JQZM-EF4651 FB_Site_UART
// let f = ble.data.LinkedList.find((v) => {
// if (v.name == bleName) {
// console.log("找到设备了", v);
// these.formData.deviceId = v.deviceId;
// return true;
// }
// return false;
// });
// let link = () => {
// if (bleName == 'FB_Site_UART') {
// ble.LinkBlue(f.deviceId, '0000AE30-0000-1000-8000-00805F9B34FB',
// '0000AE03-0000-1000-8000-00805F9B34FB', '0000AE02-0000-1000-8000-00805F9B34FB');
// } else {
// ble.LinkBlue(f.deviceId, '0000FFE0-0000-1000-8000-00805F9B34FB',
// '0000FFE1-0000-1000-8000-00805F9B34FB', '0000FFE2-0000-1000-8000-00805F9B34FB');
// }
// }
// if (!f) {
// ble.addDeviceFound((res) => {
// // console.log("发现新设备", res);
// f = res.devices.find((v) => {
// return v.name == bleName;
// });
// if (f) {
// console.log("找到目标设备了", f);
// these.formData.deviceId = f.deviceId;
// link();
// ble.StopSearch();
// }
// });
// ble.StartSearch();
// } else {
// link();
// }
console.log("6155");
ble.addReceiveCallback(these.bleValueNotify, pagePath);
ble.addStateBreakCallback(these.bleStateBreak, pagePath);
ble.addStateRecoveryCallback(these.bleStateRecovry, pagePath);
@ -384,7 +372,17 @@
let device = data.data;
these.device = device;
these.Status.apiType = data.apiType;
these.Status.navbar.title=device.deviceName;
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(',');
}
}
});
}
let f = ble.data.LinkedList.find((v) => {
if (v.macAddress == device.deviceMac) {
console.log("找到设备了", v);
@ -441,6 +439,36 @@
},
methods: {
handleRightClick(item, s) {
if (item && item.callback) {
item.callback(item, s);
} else {
uni.showModal({
content: '敬请期待'
})
}
},
navigatorBack() {
uni.navigateBack();
},
gotoShare(item, s) {
uni.navigateTo({
url: '/pages/common/share/index',
events: {
ack: function(data) {}
},
success: (res) => {
let json = {
persissonType: '6155'
};
Object.assign(json, this.device);
res.eventChannel.emit('share', {
data: json
});
}
})
},
getMode(type) {
let txt = "关闭";
@ -869,6 +897,18 @@
},
UploadOpenVideo: function() { //开机动画
if (!this.permissions.includes('3') && this.Status.apiType !== 'listA') {
this.showPop({
message: '无操作权限',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
okCallback: null,
buttonText: "确定"
})
return;
}
let f = these.getDevice();
if (!f) {
@ -1215,6 +1255,18 @@
},
UploadOpenImg: function() {
if (!this.permissions.includes('3') && this.Status.apiType !== 'listA') {
this.showPop({
message: '无操作权限',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
okCallback: null,
buttonText: "确定"
})
return;
}
//上传开机画面
this.Status.BottomMenu.menuItems = [];
this.Status.BottomMenu.title = "上传开机画面";
@ -1259,6 +1311,18 @@
this.Status.BottomMenu.show = false;
},
btnClick(item, index) {
if (!this.permissions.includes('1') && this.Status.apiType !== 'listA') {
this.showPop({
message: '无操作权限',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
okCallback: null,
buttonText: "确定"
})
return;
}
if (parseInt(this.Status.BottomMenu.activeIndex) === NaN) {
uni.showToast('请选择模式');
@ -1440,6 +1504,18 @@
these.Status.Pop.showPop = true;
},
sendUsr() {
if (!this.permissions.includes('4') && this.Status.apiType !== 'listA') {
this.showPop({
message: '无操作权限',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
okCallback: null,
buttonText: "确定"
})
return;
}
let f = this.getDevice();
if (!f) {
these.showBleUnConnect()
@ -1669,6 +1745,19 @@
},
sliderChange: function(evt) {
if (!this.permissions.includes('1') && this.Status.apiType !== 'listA') {
this.showPop({
message: '无操作权限',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
okCallback: null,
buttonText: "确定"
})
return;
}
let f = this.getDevice();
if (!f) {
these.showBleUnConnect()
@ -1716,8 +1805,8 @@
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 30).then(res => {
this.setBleFormData();
}).catch(err=>{
}).catch(err => {
});
}
@ -2163,4 +2252,70 @@
left: -99999rpx;
visibility: hidden;
}
.navbarRight {
width: 40px;
height: 100%;
}
.navbarRight .imgContent {
width: 36rpx;
height: 36rpx;
position: relative;
}
.navbarRight .imgContent:first-child {
width: 38rpx !important;
height: 38rpx !important;
margin-top: -2rpx;
}
.navbarRight .imgContent .baber {
position: absolute;
z-index: 100;
width: 30rpx;
height: 30rpx;
line-height: 30rpx;
right: -15rpx;
top: -15rpx;
border-radius: 50%;
background: #f12828;
color: #ffffff;
font-family: 'PingFang SC';
font-style: Regular;
font-size: 20rpx;
font-weight: 400;
text-align: center;
overflow: hidden;
white-space: nowrap;
}
.navbarRight .imgContent .img {
width: 100%;
height: 100%;
box-sizing: border-box;
position: relative;
}
.navbarRight .imgContent .img:last-child {
padding: 1rpx;
}
.nvbar {
top: 0px;
}
/deep/ .uni-navbar--fixed {
top: 0px;
}
.uninavebartext {
width: 100%;
font-size: 32rpx;
}
</style>

View File

@ -1,5 +1,27 @@
<template>
<view class="content contentBg">
<uni-nav-bar class="nvbar" leftIcon="left" @clickLeft="navigatorBack">
<view slot="left">
<uni-icons type="back" size="23" color="#FFFFFF"></uni-icons>
</view>
<view slot="default" class="center uninavebartext">
{{Status.navbar.title}}
</view>
<view slot="right">
<view class="navbarRight center">
<view class="imgContent" :class="{'visibilityHidden':Status.apiType!=item.apiType}"
@click.stop="handleRightClick(item,index)" v-for="item,index in Status.navbar.icons">
<image class="img" :src="item.src" mode="aspectFit"></image>
<view class="baber" v-if="item.math">{{item.math>9?'9+':item.math}}</view>
</view>
</view>
</view>
</uni-nav-bar>
<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>
@ -167,7 +189,8 @@
<script>
import TextToHexV1 from '@/components/TextToHex/TextToHexV1.vue';
import bleTool from '@/utils/BleHelper.js';
import usrApi from '@/api/670/HBY670.js'
import usrApi from '@/api/670/HBY670.js';
import Common from '@/utils/Common.js';
import {
showLoading,
hideLoading,
@ -192,7 +215,18 @@
data() {
return {
Status: {
pageHide: false,
apiType: '',
navbar: {
icons: [{
src: '/static/images/common/shape.png',
callback: this.gotoShare,
apiType: 'listA'
}],
title: 'BJQ6155'
},
Pop: {
showPop: false, //是否显示弹窗
popType: 'custom',
@ -260,10 +294,11 @@
deviceId: '',
textLines: ['', '', ''],
mode: '',
light:null,
light: null,
bleStatu: ''
},
inteval: 80,
permissions: [],
device: {
id: "",
deviceName: "",
@ -293,52 +328,8 @@
these = this;
recei = BleReceive.getBleReceive();
ble = bleTool.getBleTool();
// let bleName = 'FB_Site_UART'; //JQZM-EF4651 FB_Site_UART
// let f = ble.data.LinkedList.find((v) => {
// if (v.name == bleName) {
// console.log("找到设备了", v);
// these.formData.deviceId = v.deviceId;
// return true;
// }
// return false;
// });
// let link = () => {
// if (bleName == 'FB_Site_UART') {
// ble.LinkBlue(f.deviceId, '0000AE30-0000-1000-8000-00805F9B34FB',
// '0000AE03-0000-1000-8000-00805F9B34FB', '0000AE02-0000-1000-8000-00805F9B34FB');
// } else {
// ble.LinkBlue(f.deviceId, '0000FFE0-0000-1000-8000-00805F9B34FB',
// '0000FFE1-0000-1000-8000-00805F9B34FB', '0000FFE2-0000-1000-8000-00805F9B34FB');
// }
// }
// if (!f) {
// ble.addDeviceFound((res) => {
// // console.log("发现新设备", res);
// f = res.devices.find((v) => {
// return v.name == bleName;
// });
// if (f) {
// console.log("找到目标设备了", f);
// these.formData.deviceId = f.deviceId;
// link();
// ble.StopSearch();
// }
// });
// ble.StartSearch();
// } else {
// link();
// }
console.log("6155");
ble.addReceiveCallback(these.bleValueNotify, pagePath);
ble.addStateBreakCallback(these.bleStateBreak, pagePath);
ble.addStateRecoveryCallback(these.bleStateRecovry, pagePath);
@ -352,7 +343,16 @@
let device = data.data;
these.device = device;
these.Status.apiType = data.apiType;
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(',');
}
}
});
}
let f = ble.data.LinkedList.find((v) => {
if (v.macAddress == device.deviceMac) {
console.log("找到设备了", v);
@ -422,6 +422,36 @@
},
methods: {
handleRightClick(item, s) {
if (item && item.callback) {
item.callback(item, s);
} else {
uni.showModal({
content: '敬请期待'
})
}
},
navigatorBack() {
uni.navigateBack();
},
gotoShare(item, s) {
uni.navigateTo({
url: '/pages/common/share/index',
events: {
ack: function(data) {}
},
success: (res) => {
let json = {
persissonType: '6155'
};
Object.assign(json, this.device);
res.eventChannel.emit('share', {
data: json
});
}
})
},
getMode(type) {
let txt = "关闭";
@ -441,16 +471,16 @@
}
break;
case 2:
if (type == 'main' && this.formData.mode == 'main') {
txt = "爆闪";
}
if (type == 'main' && this.formData.mode == 'main') {
txt = "爆闪";
}
break;
case 3:
if (type == 'main' && this.formData.mode == 'main') {
txt = "关闭";
}
if (type == 'main' && this.formData.mode == 'main') {
txt = "关闭";
}
break;
default:
txt = "关闭";
@ -899,6 +929,19 @@
},
UploadOpenVideo: function() { //开机动画
if (!this.permissions.includes('3') && this.Status.apiType !== 'listA') {
this.showPop({
message: '无操作权限',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
okCallback: null,
buttonText: "确定"
})
return;
}
let f = these.getDevice();
if (!f) {
@ -1276,6 +1319,18 @@
},
UploadOpenImg: function() {
if (!this.permissions.includes('3') && this.Status.apiType !== 'listA') {
this.showPop({
message: '无操作权限',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
okCallback: null,
buttonText: "确定"
})
return;
}
//上传开机画面
this.Status.BottomMenu.menuItems = [];
this.Status.BottomMenu.title = "上传开机画面";
@ -1284,7 +1339,7 @@
},
ModeSetting: function(type) {
let items = [];
let title = '';
@ -1326,16 +1381,16 @@
];
break;
}
this.Status.BottomMenu.menuItems = items;
this.Status.BottomMenu.title = title;
this.Status.BottomMenu.type = type;
this.Status.BottomMenu.show = true;
if(this.formData.mode != type){
this.Status.BottomMenu.activeIndex =null;
}
if (this.formData.mode != type) {
this.Status.BottomMenu.activeIndex = null;
}
},
showMenu(flag) {
this.Status.BottomMenu.show = true;
@ -1344,7 +1399,18 @@
this.Status.BottomMenu.show = false;
},
btnClick(item, index) {
if (!this.permissions.includes('1') && this.Status.apiType !== 'listA') {
this.showPop({
message: '无操作权限',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
okCallback: null,
buttonText: "确定"
})
return;
}
if (parseInt(this.Status.BottomMenu.activeIndex) === NaN) {
uni.showToast('请选择模式');
return;
@ -1522,6 +1588,20 @@
these.Status.Pop.showPop = true;
},
sendUsr() {
if (!this.permissions.includes('4') && this.Status.apiType !== 'listA') {
this.showPop({
message: '无操作权限',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
okCallback: null,
buttonText: "确定"
})
return;
}
let f = this.getDevice();
if (!f) {
these.showBleUnConnect()
@ -1675,6 +1755,20 @@
clearTimeout(BrighInteval)
//给蓝牙设备发送信号更新亮度
BrighInteval = setTimeout(() => {
if (!this.permissions.includes('1') && this.Status.apiType !== 'listA') {
this.showPop({
message: '无操作权限',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
okCallback: null,
buttonText: "确定"
})
return;
}
this.sendBrightness();
this.setBleFormData();
}, 100);
@ -2178,4 +2272,70 @@
left: -99999rpx;
visibility: hidden;
}
.navbarRight {
width: 40px;
height: 100%;
}
.navbarRight .imgContent {
width: 36rpx;
height: 36rpx;
position: relative;
}
.navbarRight .imgContent:first-child {
width: 38rpx !important;
height: 38rpx !important;
margin-top: -2rpx;
}
.navbarRight .imgContent .baber {
position: absolute;
z-index: 100;
width: 30rpx;
height: 30rpx;
line-height: 30rpx;
right: -15rpx;
top: -15rpx;
border-radius: 50%;
background: #f12828;
color: #ffffff;
font-family: 'PingFang SC';
font-style: Regular;
font-size: 20rpx;
font-weight: 400;
text-align: center;
overflow: hidden;
white-space: nowrap;
}
.navbarRight .imgContent .img {
width: 100%;
height: 100%;
box-sizing: border-box;
position: relative;
}
.navbarRight .imgContent .img:last-child {
padding: 1rpx;
}
.nvbar {
top: 0px;
}
/deep/ .uni-navbar--fixed {
top: 0px;
}
.uninavebartext {
width: 100%;
font-size: 32rpx;
}
</style>

View File

@ -120,7 +120,7 @@
var ble = null;
var these = null;
var eventChannel = null;
export default {
data() {
return {
@ -164,9 +164,9 @@
}
},
computed: {
deviceCnt:function(){
let arr=this.EquipMents.filter(item=>{
return item.name.toLowerCase().indexOf(this.search.toLowerCase())>-1;
deviceCnt: function() {
let arr = this.EquipMents.filter(item => {
return item.name.toLowerCase().indexOf(this.search.toLowerCase()) > -1;
});
return arr.length;
}
@ -226,36 +226,36 @@
"linkStatu": false
},
{
"RSSI": -55,
"advertisData": "",
"advertisServiceUUIDs": [
"0000FFE0-0000-1000-8000-00805F9B34FB"
],
"deviceId": "EBDA4E6F-3A28-FF65-A845-AE8CC7B78375",
"name": "HBY670-BF74EA",
"linkStatu": false
},
{
"RSSI": -61,
"advertisData": "",
"advertisServiceUUIDs": [
"0000FFE0-0000-1000-8000-00805F9B34FB"
],
"deviceId": "469FB381-B47E-1E40-8073-EF50B5704AAB",
"name": "EF4651",
"linkStatu": false,
"isTarget": true
},
{
"RSSI": -69,
"advertisData": "",
"advertisServiceUUIDs": [
"0000FFE0-0000-1000-8000-00805F9B34FB"
],
"deviceId": "4F0DAC91-4391-CB07-905E-72D7F03EFCD3",
"name": "4877-BF743D",
"linkStatu": false
},{
"RSSI": -55,
"advertisData": "",
"advertisServiceUUIDs": [
"0000FFE0-0000-1000-8000-00805F9B34FB"
],
"deviceId": "EBDA4E6F-3A28-FF65-A845-AE8CC7B78375",
"name": "HBY670-BF74EA",
"linkStatu": false
},
{
"RSSI": -61,
"advertisData": "",
"advertisServiceUUIDs": [
"0000FFE0-0000-1000-8000-00805F9B34FB"
],
"deviceId": "469FB381-B47E-1E40-8073-EF50B5704AAB",
"name": "EF4651",
"linkStatu": false,
"isTarget": true
},
{
"RSSI": -69,
"advertisData": "",
"advertisServiceUUIDs": [
"0000FFE0-0000-1000-8000-00805F9B34FB"
],
"deviceId": "4F0DAC91-4391-CB07-905E-72D7F03EFCD3",
"name": "4877-BF743D",
"linkStatu": false
}, {
"RSSI": -55,
"advertisData": "",
"advertisServiceUUIDs": [
@ -320,14 +320,17 @@
if (these.Status.isPageHidden) {
return;
}
console.log("处理蓝牙断开连接");
hideLoading(these);
// console.log("处理蓝牙断开连接");
these.PairEquip.find(function(v, ind) {
these.PairEquip.splice(ind, 1);
return v.deviceId == res.deviceId;
});
setTimeout(() => {
hideLoading(these);
}, 1500);
}, pagePath);
@ -378,8 +381,8 @@
}
these.EquipMents.push(device);
}
these.EquipMents.sort((a, b) => b.RSSI - a.RSSI);//信号好的排前面,一般信号好的是目标设备
these.EquipMents.sort((a, b) => b.RSSI - a.RSSI); //信号好的排前面,一般信号好的是目标设备
}
}, pagePath);
}
@ -418,19 +421,17 @@
//收到设备的消息回调
ble.addReceiveCallback((receivData, f, path, arr) => {
console.log("000000",receivData);
console.log("000000", receivData);
if (these.Status.isPageHidden) {
return;
}
if(receivData.bytes[0]===0xFC && receivData.hexs.length>=7){
console.log("22222222");
}
if(receivData.str.indexOf('mac address:')>-1 || receivData.str.indexOf('sta_address')>-1
|| (receivData.bytes[0]===0xFC && receivData.bytes.length>=7))
{
console.log("1111111");
if (receivData.str.indexOf('mac address:') > -1 || receivData.str.indexOf(
'sta_address') > -1 ||
(receivData.bytes[0] === 0xFC && receivData.bytes.length >= 7)) {
if (f.macAddress && these.device) {
console.log("222222");
clearInterval(this.Status.intval);
this.Status.intval = null;
this.Status.time = null;
@ -454,11 +455,11 @@
console.log("接收到父页面的参数:", rec);
these.device = rec.data;
if (rec.data.bluetoothName) {
these.search = rec.data.bluetoothName.replace('JQZM-', '');
these.search = rec.data.bluetoothName;
}
startValidDevice();
});
},
@ -508,8 +509,8 @@
});
},
async refreshBleList() {
const systemInfo = uni.getSystemInfoSync();
if (systemInfo.uniPlatform == 'web') {
return;
@ -528,42 +529,42 @@
return;
}
}
ble.StopSearch().finally(() => {
let disconnectPromises = [];
if (ble.data && ble.data.LinkedList) {
ble.data.LinkedList.forEach(device => {
console.log(`Requesting disconnect for ${device.deviceId}`);
disconnectPromises.push(ble.disconnectDevice(device.deviceId));
});
}
Promise.allSettled(disconnectPromises).finally(() => {
these.EquipMents = [];
these.PairEquip = [];
ble.StartSearch().then(result => {
console.log("Fresh scan started successfully.");
}).catch(err => {
console.error("Failed to start fresh scan:", err);
if (err.code === 10001) {
these.showOpenSetting();
} else {
uni.showModal({
title: '提示',
content: '开始搜索失败:' + err.msg
});
}
});
ble.StopSearch().finally(() => {
let disconnectPromises = [];
if (ble.data && ble.data.LinkedList) {
ble.data.LinkedList.forEach(device => {
console.log(`Requesting disconnect for ${device.deviceId}`);
disconnectPromises.push(ble.disconnectDevice(device.deviceId));
});
}
Promise.allSettled(disconnectPromises).finally(() => {
these.EquipMents = [];
these.PairEquip = [];
ble.StartSearch().then(result => {
console.log("Fresh scan started successfully.");
}).catch(err => {
console.error("Failed to start fresh scan:", err);
if (err.code === 10001) {
these.showOpenSetting();
} else {
uni.showModal({
title: '提示',
content: '开始搜索失败:' + err.msg
});
}
});
});
});
},
isItemLink: function(item, index) {
let src = '/static/images/BLEAdd/noLink.png';
@ -614,28 +615,71 @@
}
}
console.log("f=", f);
if (f && f.macAddress) {
if (f.macAddress != these.device.deviceMac) {
removeLink();
updateLoading(these, {
text: "设备Mac地址错误,请重选设备连接"
});
setTimeout(() => {
hideLoading(these);
}, 1000)
return;
} else {
}
//不是目标设备的处理方法
let deviceInvalid = () => {
console.error("连接的设备不是目标设备");
removeLink();
updateLoading(these, {
text: "设备Mac地址错误,请重选设备连接"
});
setTimeout(() => {
hideLoading(these);
}, 1500)
return;
}
//找到目标设备的处理方法
let deviceOK = () => {
hideLoading(these);
eventChannel.emit('BindOver', these.device);
ble.updateCache();
uni.navigateBack();
}
if (f && f.macAddress) {
if (!this.device.deviceMac) { //走服务端验证
console.error("走服务端验证")
request({
url: '/app/device/getDeviceInfoByDeviceMac',
method: 'GET',
data: {
deviceMac: f.macAddress
}
}).then(res => {
if (res && res.code == 200) {
let data = res.data;
//服务端验证要验证id而不是mac地址了
if (data.id != these.device.id) {
deviceInvalid();
return;
} else {
deviceOK();
}
} else {
this.serverDevice = null;
deviceInvalid();
}
}).catch((ex) => {
deviceInvalid();
});
return;
} else if (f.macAddress != these.device.deviceMac) { //直接验证上层传过来的数据
console.log("客户端验证失败");
deviceInvalid();
return;
}
else if (f.macAddress == these.device.deviceMac){
console.log("客户端验证成功");
deviceOK();
}
return true;
} else {
@ -664,14 +708,8 @@
return false;
});
if (!(f && f.macAddress)) {
removeLink();
updateLoading(these, {
text: "出现错误,未收到设备Mac地址"
});
setTimeout(() => {
hideLoading(these)
}, 1500);
deviceInvalid()
return;
}
return;
}
@ -1113,20 +1151,20 @@
-webkit-filter: none !important;
}
.uni-input{
.uni-input {
background-color: #121212;
width:100%;
width: 100%;
height: 60rpx;
color: #ffffffde;
border:1rpx solid #cbcbcbde;
border: 1rpx solid #cbcbcbde;
border-radius: 8rpx;
font-size: 26rpx;
text-indent: 8rpx;
font-family: "PingFang SC";
line-height: 60rpx;
caret-color:#BBE600;
caret-color: #BBE600;
font-weight: 200;
}
</style>

View File

@ -783,31 +783,31 @@ import BleReceive from '@/utils/BleReceive';
recei = BleReceive.getBleReceive();
//蓝牙连接成功的回调
ble.addRecoveryCallback((res) => {
console.log("蓝牙连接成功的回调");
// console.log("蓝牙连接成功的回调");
this.bleRecovery(res);
}, pagePath);
//蓝牙断开连接的回调
ble.addDisposeCallback((res) => {
console.log("蓝牙断开连接的回调");
// console.log("蓝牙断开连接的回调");
this.bleBreak(res);
}, pagePath);
//蓝牙适配器恢复可用的回调,一般是重连设备
ble.addStateRecoveryCallback(res => {
console.log("蓝牙适配器恢复可用的回调");
// console.log("蓝牙适配器恢复可用的回调");
this.bleStateRecovery();
}, pagePath);
//蓝牙适配器不可用的回调
ble.addStateBreakCallback(res => {
console.error("蓝牙适配器不可用的回调");
// console.error("蓝牙适配器不可用的回调");
this.bleStateBreak();
}, pagePath);
//接收到消息的回调
ble.addReceiveCallback((receive, device, path, recArr) => {
console.error("首页收到消息了");
// console.error("首页收到消息了");
recei.ReceiveData(receive, device, path, recArr);
this.updateBleStatu();
}, pagePath);

View File

@ -160,7 +160,7 @@ class BleHelper {
} else {
if (bleId && item.deviceId == bleId) {
console.error("找到要删除的设备1,", item)
// console.error("找到要删除的设备1,", item)
this.data.LinkedList.splice(i, 1);
this.disconnectDevice(item.deviceId);
flag = true;
@ -896,12 +896,12 @@ class BleHelper {
return;
}
}
console.log("蓝牙连接状态变化了", res);
// console.log("蓝牙连接状态变化了", res);
clearTimeout(stateTimeout);
stateTimeout=setTimeout(() => {
if (!res.connected) {
console.error("蓝牙已断开", res);
// console.error("蓝牙已断开", res);
let f = this.data.LinkedList.find((
v) => {
if (v.deviceId == res
@ -939,7 +939,7 @@ class BleHelper {
(c) => {
try {
c.callback(res);
console.log("执行蓝牙断开连接的回调成功");
// console.log("执行蓝牙断开连接的回调成功");
} catch (error) {
console.error(
"执行蓝牙断开连接的回调出现异常,",
@ -1168,7 +1168,7 @@ class BleHelper {
//订阅消息
subScribe(deviceId, state) {
console.log("开始订阅消息", deviceId, state);
// console.log("开始订阅消息", deviceId, state);
return new Promise((resolve, reject) => {
setTimeout(() => {
@ -1791,7 +1791,7 @@ class BleHelper {
uni.closeBLEConnection({
deviceId: id,
success: (res) => {
console.log("用户主动断开了蓝牙:" + id);
// console.log("用户主动断开了蓝牙:" + id);
this.subScribe(id, false);
this.data.Disconnect.push(id);
resolve();

View File

@ -218,7 +218,7 @@ export default {
value: "1",
label: "灯光模式",
checked: false,
type: ['6170', '670','102']
type: ['6170', '670','102','6155']
},
{
value: "2",
@ -230,13 +230,13 @@ export default {
value: "3",
label: "开机画面",
checked: false,
type: ['210', '6170', '670']
type: ['210', '6170', '670','6155']
},
{
value: "4",
label: "人员信息登记",
checked: false,
type: ['210', '6170', '670']
type: ['210', '6170', '670','6155']
},
{
value: "5",