完成100

This commit is contained in:
liub
2025-11-07 11:57:35 +08:00
parent c39cbcb34d
commit 2493bb7113
16 changed files with 1278 additions and 527 deletions

174
App.vue
View File

@ -29,23 +29,28 @@
// 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);
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');
@ -55,66 +60,117 @@
<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-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-slider .uni-slider-thumb {
width: 66rpx !important;
height: 80rpx !important;
margin-top: -40rpx !important;
border-radius: 16rpx !important;
margin-left: -72rpx !important;
.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: #4CAF50 !important;
}
.red {
color: #FF0000 !important;
}
.maincontent {
width: 100%;
min-height: 100vh;
height: auto;
padding: 30rpx;
box-sizing: border-box;
}
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: #BBE600 !important;
}
.red{
color:#E03434 !important;
}
.contentBg {
background-color: #121212;
color: #ffffffde;
}
@font-face {
font-family: "PingFang SC";
src: url("~@/static/fonts/PingFangSC.ttf") format("opentype");
.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");
}
font-family: "PingFangBold";
src: url("~@/static/fonts/PingFangBold.ttf") format("opentype");
}
</style>

View File

@ -252,31 +252,68 @@
}
},
{
"path" : "pages/6331/BJQ6331",
"style" :
{
"navigationBarTitleText" : "BJQ6331"
"path": "pages/6331/BJQ6331",
"style": {
"navigationBarTitleText": "BJQ6331"
}
},
{
"path": "pages/4877/BJQ4877",
"style": {
"navigationBarTitleText": "BJQ 4877"
}
},
{
"path" : "pages/6331/AudioManager",
"style" :
{
"navigationBarTitleText" : "语音管理"
"path": "pages/100/HBY100",
"style": {
"navigationBarTitleText": "HBY 100"
}
},
{
"path" : "pages/4877/BJQ4877",
"style" :
{
"navigationBarTitleText" : "BJQ 4877"
"path": "pages/common/audioManager/AudioList",
"style": {
"navigationBarTitleText": "语音管理",
"disableScroll":true,
"app-plus": {
"bounce":"none",
"titleNView": {
"buttons": [
{
"color": "#00000000",
"text": "删",
"fontSize": "10",
"float": "right",
"fontWeight": "normal"
},
{
"color": "#ffffffde",
"text": "编辑",
"fontSize": "14",
"float": "right",
"fontWeight": "normal"
},
{
"color": "#ffffffde",
"text": "取消",
"fontSize": "14",
"float": "right",
"fontWeight": "normal"
}
]
}
}
}
},
{
"path" : "pages/100/HBY100",
"path" : "pages/common/audioManager/Recording",
"style" :
{
"navigationBarTitleText" : "HBY 100"
"navigationBarTitleText" : "录制语音"
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
<template>
<view class="content contentBg">
<view class="eq">
<view class="leftImg" @click.stop="previewImg(formData.img)">
<image class="img" :src="formData.img?formData.img:'/static/images/4877/4877equip.png'"
<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">
@ -27,6 +27,10 @@
<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>
<view class="item">
<text class="lbl">蓝牙名称</text>
<text class="value">{{device.bluetoothName}}</text>
@ -312,7 +316,7 @@
usrToggle: true,
},
formData: {
img: '/static/images/4877/4877equip.png',
img: '/static/images/common/BJQ4877.png',
sta_PowerPercent: '',
xuhang: '',
blename: '',
@ -439,7 +443,7 @@
}
these.formData.blename = f.name ? f.name : "Unname";
these.formData.deviceName = device.deviceName;
these.formData.img = device.devicePic;
these.formData.bleStatu = false;
these.formData.deviceId = f.deviceId;
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {

View File

@ -1,8 +1,9 @@
<template>
<view class="content contentBg">
<view class="eq">
<view class="leftImg" @click.stop="previewImg(formData.img)">
<image class="img" :src="formData.img" mode="aspectFit"></image>
<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">
@ -27,6 +28,10 @@
<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>
<view class="item">
<text class="lbl">设备状态</text>
<text class="value">{{formData.statu}}</text>
@ -228,7 +233,7 @@
}
},
formData: {
img: '',
img: '/static/images/common/HBY6155.png',
battary: '',
xuhang: '',
deviceName: '',
@ -355,7 +360,7 @@
}
these.formData.blename = f.name ? f.name : "Unname";
these.formData.deviceName = device.deviceName;
these.formData.img = device.devicePic;
these.formData.id = device.id;
these.formData.deviceId = f.deviceId;
these.formData.bleStatu = false;

View File

@ -1,22 +0,0 @@
<template>
<view>
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
}
}
</script>
<style>
</style>

View File

@ -1,8 +1,8 @@
<template>
<view class="content contentBg">
<view class="eq">
<view class="leftImg" @click.stop="previewImg(formData.img)">
<image class="img" :src="formData.img" mode="aspectFit"></image>
<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">
@ -26,6 +26,10 @@
<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>
<view class="item">
<text class="lbl">蓝牙名称</text>
<text class="value">{{device.bluetoothName}}</text>
@ -308,7 +312,7 @@
usrToggle: true,
},
formData: {
img: '/static/images/6155/DeviceDetail/equip.png',
img: '/static/images/common/BJQ6331.png',
battary: '',
xuhang: '',
blename: '',
@ -395,7 +399,7 @@
}
these.formData.blename = f.name ? f.name : "Unname";
these.formData.deviceName = device.deviceName;
these.formData.img = device.devicePic;
these.formData.deviceId = f.deviceId;
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {

View File

@ -1,8 +1,8 @@
<template>
<view class="content contentBg">
<view class="eq">
<view class="leftImg" @click.stop="previewImg(formData.img)">
<image class="img" :src="formData.img" mode="aspectFit"></image>
<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">
@ -26,6 +26,10 @@
<text class="lbl">蓝牙名称</text>
<text class="value">{{device.bluetoothName}}</text>
</view>
<view class="item">
<text class="lbl">Mac地址</text>
<text class="value">{{device.deviceMac}}</text>
</view>
<view class="item">
<text class="lbl">设备名称</text>
<text class="value">{{device.deviceName}}</text>
@ -250,7 +254,7 @@
usrToggle: true,
},
formData: {
img: '/static/images/6155/DeviceDetail/equip.png',
img: '/static/images/common/HBY650.png',
battary: '',
xuhang: '',
blename: '',
@ -344,7 +348,7 @@
}
these.formData.blename = f.name ? f.name : "Unname";
these.formData.deviceName = device.deviceName;
these.formData.img = device.devicePic;
these.formData.bleStatu = false;
these.formData.deviceId = f.deviceId;
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {

View File

@ -2,10 +2,12 @@
<view class="content contentBg">
<custom-navbar :title="Status.navbar.title" :showBack="Status.navbar.showBack" color="#FFFFFF"
:rightIcons="Status.navbar.icons" @icon-click="handleRightClick"></custom-navbar>
<view>
</view>
<view class="eq" :style="{marginTop:Status.navbar.height+'px'}">
<view class="leftImg" @click.stop="previewImg(device['devicePic'])">
<image class="img" :src="device['devicePic']" mode="aspectFit"></image>
<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">
@ -25,13 +27,18 @@
</view>
</view>
<view class="eqinfo">
<view class="item">
<text class="lbl">设备名称</text>
<text class="value valueFont">{{device.deviceName}}</text>
</view>
<view class="item">
<text class="lbl">设备IMEI</text>
<text class="value valueFont">{{device.deviceImei}}</text>
</view>
<view class="item">
<text class="lbl">设备名称</text>
<text class="value valueFont">{{device.deviceName}}</text>
<text class="lbl">Mac地址</text>
<text class="value">{{device.deviceMac}}</text>
</view>
<view class="item">
<text class="lbl">蓝牙名称</text>
@ -382,6 +389,7 @@
bleLinkCnt: 0
},
formData: {
img:'/static/images/common/HBY670.png',
battary: "", //电量
xuhang: "", //续航
imei: "", //imei
@ -518,6 +526,7 @@
let keys = Object.keys(form);
for (var i = keys.length; i >= 0; i--) {
let key = keys[i];
these.formData[key] = form[key];
}
}

View File

@ -1,8 +1,8 @@
<template>
<view class="content contentBg">
<view class="eq">
<view class="leftImg" @click.stop="previewImg(formData.img)">
<image class="img" :src="formData.img" mode="aspectFit"></image>
<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">
@ -26,6 +26,10 @@
<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>
<view class="item">
<text class="lbl">设备状态</text>
<text class="value">{{formData.statu}}</text>
@ -229,7 +233,7 @@
}
},
formData: {
img: '',
img: '/static/images/common/HBY6155.png',
battary: '',
xuhang: '',
deviceName: '',
@ -310,7 +314,7 @@
}
these.formData.blename = f.name ? f.name : "Unname";
these.formData.deviceName = device.deviceName;
these.formData.img = device.devicePic;
these.formData.id = device.id;
these.formData.deviceId = f.deviceId;
these.formData.bleStatu = false;

View File

@ -6,19 +6,19 @@
</image>
</view>
<view class="deviceName">
蓝牙名:{{device.name}}
蓝牙名:{{serverDevice?serverDevice['bluetoothName']: device.name}}
</view>
<view class="deviceName">
状态:{{deviceStatu}}
</view>
<view class="deviceName">
设备名:{{device.deviceName}}
设备名:{{serverDevice?serverDevice['deviceName']:device.deviceName}}
</view>
<view class="deviceId">
设备Mac:{{device.macAddress}}
设备Mac:{{serverDevice?serverDevice['deviceMac']:device.macAddress}}
</view>
<view class="deviceId">
设备IMEI:{{device.imei}}
设备IMEI:{{serverDevice?serverDevice['deviceImei']:device.imei}}
</view>
<view class="bound" :class="boundStatu">
{{Statu.boundRemark}}
@ -84,17 +84,18 @@
}
},
deviceStatu: function() {
if (!this.device.name) {
debugger;
if (!this.device.name && !this.device.macAddress) {
return "";
}
if (!this.device.linkStatu) {
if (!this.device.linkStatu && !this.device.macAddress) {
return "蓝牙未连接";
}
if (!this.device.macAddress) {
return '等待设备上报Mac地址';
}
if (!this.device.deviceName) {
if (!this.device.deviceName && !(this.serverDevice && this.serverDevice.deviceName)) {
if (this.Statu.isSearch) {
return "无效设备";
} else {
@ -105,7 +106,10 @@
}
}
} else {
return "找到有效设备"
return "找到有效设备"
}
return "";
@ -192,30 +196,39 @@
}
}, pagePath);
eventChannel = this.getOpenerEventChannel();
eventChannel.on('LinkItem', function(data) {
console.log("data=", data);
let f = ble.data.LinkedList.find((v) => {
return v.deviceId == data.deviceId;
});
if (f) {
let keys = Object.keys(f);
keys.forEach((v, index) => {
these.device[v] = f[v];
})
// console.log("LinkedList=", ble.data.LinkedList)
// console.log("f=", f);
// console.log("获取到设备", these.device);
if (f.macAddress) {
these.device.macAddress = f.macAddress;
these.initDevice();
if(option.mac){
this.device.macAddress=option.mac;
these.initDevice();
}
else{
eventChannel.on('LinkItem', function(data) {
console.log("data=", data);
let f = ble.data.LinkedList.find((v) => {
return v.deviceId == data.deviceId;
});
if (f) {
let keys = Object.keys(f);
keys.forEach((v, index) => {
these.device[v] = f[v];
})
// console.log("LinkedList=", ble.data.LinkedList)
// console.log("f=", f);
// console.log("获取到设备", these.device);
if (f.macAddress) {
these.device.macAddress = f.macAddress;
these.initDevice();
}
} else {
console.log("未获取到设备");
}
} else {
console.log("未获取到设备");
}
})
})
let inteval = setInterval(this.initDevice, 10000);
}
let inteval = setInterval(this.initDevice, 10000);
},
methods: {
reLinkdevice() {
@ -281,6 +294,7 @@
deviceInvalid();
}
} else {
this.serverDevice =null;
deviceInvalid();
}
@ -298,20 +312,20 @@
Link() {
// 调用绑定设备接口
let f = ble.data.LinkedList.find((v) => {
return v.deviceId == these.device.deviceId;
});
if (!f) {
// let f = ble.data.LinkedList.find((v) => {
// return v.deviceId == these.device.deviceId;
// });
// if (!f) {
// these.Statu.bound = false;
// these.Statu.boundRemark = "蓝牙连接不成功";
// return;
// }
if (!this.device.macAddress) {
these.Statu.bound = false;
these.Statu.boundRemark = "蓝牙连接不成功";
these.Statu.boundRemark = "获取设备Mac地址异常";
return;
}
if (!f.macAddress) {
these.Statu.bound = false;
these.Statu.boundRemark = "设备上报Mac地址异常";
return;
}
if (!this.device.deviceName) {
if (!this.serverDevice) {
these.Statu.bound = false;
these.Statu.boundRemark = "设备未入库";
return;

View File

@ -333,8 +333,8 @@
this.total = 0; // 重置总数
const deviceType = tab.id === '' ? undefined : tab.id;
this.$nextTick(() => {
this.getSystemInfoSyncH();
});
this.getSystemInfoSyncH();
});
this.getData(deviceType);
if (this.mescroll) {
this.mescroll.resetUpScroll();
@ -400,9 +400,54 @@
case 'scan':
uni.scanCode({
success: (res) => {
const cleanedResult = res.result.trim();
uni.navigateTo({
url: `/pages/common/qrcode/qrcode?deviceId=${encodeURIComponent(cleanedResult)}`
let cleanedResult = res.result.trim();
console.log("scanResult=", cleanedResult);
let promise = new Promise((resolve, reject) => {
let url = '';
try {
let json = JSON.parse(cleanedResult);
console.log("json=", json);
if ('blue' in json) {
let mac = json.blue;
if (mac) {
if (!mac.includes(':')) {
mac = mac.replace(/(.{2})/g,'$1:').slice(0,-1)
}
url =`/pages/common/addBLE/LinkBle?mac=${encodeURIComponent(mac)}`;
console.log("蓝牙设备",mac);
}
} else if ('imei' in json) {
let imei = json.imei;
if (iemi) {
url =
`/pages/common/qrcode/qrcode?deviceId=${encodeURIComponent(imei)}`;
console.log("4G设备:",imei)
}
}
} catch (error) {
console.error("识别二维码失败,",error);
} finally {
if(!url){
url =
`/pages/common/qrcode/qrcode?deviceId=${encodeURIComponent(cleanedResult)}`
console.log("未知设备:",cleanedResult)
}
resolve(url);
}
});
promise.then(res => {
uni.navigateTo({
url: res
});
});
},
fail: (err) => {
@ -456,9 +501,9 @@
if (this.$refs.swipeAction) {
this.$refs.swipeAction.closeAll();
}
console.log("111111",this.deviceId);
console.log("ble==null,",ble)
ble && ble.DropDevice(null,this.deviceId.id);
console.log("111111", this.deviceId);
console.log("ble==null,", ble)
ble && ble.DropDevice(null, this.deviceId.id);
} else {
uni.showToast({
title: res.msg,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

View File

@ -789,7 +789,7 @@ class BleHelper {
}
try {
console.log("11111");
// console.log("11111");
let recData = {
deviceId: receive.deviceId,
serviceId: receive.serviceId,
@ -798,7 +798,7 @@ class BleHelper {
str: str,
hexs: hexs
};
console.log("监听到特征值:" + JSON.stringify(recData));
// console.log("监听到特征值:" + JSON.stringify(recData));
if (this.cfg.receivDataCallback) {
if (this.cfg.receivDataCallback.length > 0) {

View File

@ -7,7 +7,7 @@ class BleReceive {
'/pages/650/HBY650': this.Receive_650.bind(this),
'/pages/670/HBY670': this.Receive_670.bind(this),
'/pages/4877/BJQ4877': this.Receive_4877.bind(this),
'/pages/100/HBY100': this.Receive_4877.bind(this)
'/pages/100/HBY100': this.Receive_100.bind(this)
};
}
@ -45,8 +45,9 @@ class BleReceive {
let handler = null;
let keys = Object.keys(this.HandlerMap);
for (let index = 0; index < keys.length; index++) {
let key = keys[index].replaceAll('/', '').toLowerCase();
let devKey = f.device.detailPageUrl ? f.device.detailPageUrl.replaceAll('/', '').toLowerCase() : '';
let key = keys[index].replace(/\//g, "").toLowerCase();
let devKey = f.device.detailPageUrl ? f.device.detailPageUrl.replace(/\//g, "").toLowerCase() : '';
if (key == devKey) {
handler = this.HandlerMap[keys[index]];
break;
@ -150,8 +151,8 @@ class BleReceive {
this.setBleFormData(formData, f);
let recCnt = recArr.find(v => {
return v.key.replaceAll('/', '').toLowerCase() == f.device.detailPageUrl
.replaceAll('/', '').toLowerCase();
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
.replace(/\//g, "").toLowerCase();
});
if (!recCnt) {
@ -318,8 +319,8 @@ class BleReceive {
this.setBleFormData(receiveData, f);
console.log("recArr=", recArr);
let recCnt = recArr.find(v => {
return v.key.replaceAll('/', '').toLowerCase() == f.device.detailPageUrl
.replaceAll('/', '').toLowerCase();
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
.replace(/\//g, "").toLowerCase();
});
if (!recCnt) {
if (this.formData.staticWarn) { //有静止报警
@ -470,7 +471,7 @@ class BleReceive {
let recCnt = recArr.find(v => {
return v.key.replaceAll('/', '').toLowerCase() === f.device.detailPageUrl.replaceAll(
return v.key.replace(/\//g, "").toLowerCase() === f.device.detailPageUrl.replaceAll(
'/', '').toLowerCase();
});
if (!recCnt) {
@ -497,12 +498,12 @@ class BleReceive {
try {
console.log("str=",receive.str);
// console.log("str=",receive.str);
receiveData = JSON.parse(receive.str);
let recCnt = recArr.find(v => {
return v.key.replaceAll('/', '').toLowerCase() == f.device.detailPageUrl
.replaceAll('/', '').toLowerCase();
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
.replace(/\//g, "").toLowerCase();
});
if (!recCnt) {
if (receiveData.sta_PowerPercent<=20) {
@ -521,6 +522,35 @@ class BleReceive {
}
Receive_100(receive,f,path,recArr){
let receiveData={};
try {
// console.log("str=",receive.str);
receiveData = JSON.parse(receive.str);
let recCnt = recArr.find(v => {
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
.replace(/\//g, "").toLowerCase();
});
if (!recCnt) {
if (receiveData.sta_battery<=20) {
uni.showModal({
title: "提示",
content: "设备电量低",
showCancel: false
});
}
}
} catch (error) {
receiveData = {};
console.log("文本解析失败",error)
}
return receiveData;
}
}

View File

@ -1,10 +1,11 @@
import request from "@/utils/request.js";
export default {
audioStorageKey: "audioStorageKey",
pcmStorageKey: "pcmStorageKey",
guid: function generateUUID() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
const r = Math.random() * 16 | 0;
const v = c === 'x' ? r : (r & 0x3 | 0x8);
let r = Math.random() * 16 | 0;
let v = c === 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
},
@ -137,7 +138,7 @@ export default {
checkLAN: function(succ, error) {
uni.getNetworkType({
success: (res) => {
const networkType = res.networkType;
let networkType = res.networkType;
// 判断网络是否连接
@ -182,7 +183,7 @@ export default {
}
// 定义格式化映射
const formatMap = {
let formatMap = {
'yyyy': date.getFullYear(),
'MM': String(date.getMonth() + 1).padStart(2, '0'),
'dd': String(date.getDate()).padStart(2, '0'),
@ -203,15 +204,15 @@ export default {
return formatMap[match];
});
},
getdeviceShareId(id) {//获取设备分享信息
return request({
url: `/app/deviceShare/${id}`,
method: 'get',
})
getdeviceShareId(id) { //获取设备分享信息
return request({
url: `/app/deviceShare/${id}`,
method: 'get',
})
},
getPermissions(type) {
if (!type) {
type='6170';
type = '6170';
}
let array = [{
value: "1",
@ -261,52 +262,105 @@ export default {
}
]
let arr=[];
let arr = [];
for (let i = 0; i < array.length; i++) {
let item = array[i];
if(!item){
if (!item) {
continue;
}
if(!item.type){
if (!item.type) {
continue;
}
let typeContais=item.type.find(v=>{
let typeContais = item.type.find(v => {
return v.includes(type);
});
if(typeContais){
let json={};
Object.assign(json,item);
if (typeContais) {
let json = {};
Object.assign(json, item);
arr.push(json);
}
}
return arr;
},
//10进制转换为16进制字符串
decimalToHexLittleEndian(num, byteCount,revers) {
// 处理负数(如果需要支持负数,可先转为补码)
if (num < 0) {
num = 0xFFFFFFFF + num + 1;
}
decimalToHexLittleEndian(num, byteCount, revers) {
// 处理负数(如果需要支持负数,可先转为补码)
if (num < 0) {
num = 0xFFFFFFFF + num + 1;
}
// 转为16进制去除前缀0x转为大写
let hex = num.toString(16).toUpperCase();
// 转为16进制去除前缀0x转为大写
let hex = num.toString(16).toUpperCase();
// 计算需要补充的0的数量确保每个字节占2位
let padLength = (byteCount || Math.ceil(hex.length / 2) * 2) - hex.length;
if (padLength > 0) {
hex = '0'.repeat(padLength) + hex;
}
// 计算需要补充的0的数量确保每个字节占2位
let padLength = (byteCount || Math.ceil(hex.length / 2) * 2) - hex.length;
if (padLength > 0) {
hex = '0'.repeat(padLength) + hex;
}
// 分割为字节数组每2位一个字节
const bytes = [];
for (let i = 0; i < hex.length; i += 2) {
bytes.push(hex.substr(i, 2));
}
// 分割为字节数组每2位一个字节
let bytes = [];
for (let i = 0; i < hex.length; i += 2) {
bytes.push(hex.substr(i, 2));
}
// 是否反转字节顺序(低位在前)并拼接
if(revers){
// 是否反转字节顺序(低位在前)并拼接
if (revers) {
return bytes.reverse().join('');
}
return bytes.join('');
}
return bytes.join('');
},
//将相对路径的文件移动到_downloads文件夹中
moveFileToDownloads(tempFilePath) {
return new Promise((resolve, reject) => {
if(!tempFilePath){
console.log("无文件需要移动");
resolve(tempFilePath);
return;
}
//本来就在此目录时直接返回
if (tempFilePath.indexOf("_downloads") === 0) {
console.log("文件已存在,无需移动");
resolve(tempFilePath);
return;
}
//不是app直接返回
if (!uni.getSystemInfoSync().uniPlatform.includes('app')) {
resolve('仅支持 App 端操作');
return;
}
// console.log("tempFilePath=", tempFilePath);
var srcPath = plus.io.convertLocalFileSystemURL(tempFilePath);
// console.log("srcPath=", srcPath);
plus.io.resolveLocalFileSystemURL(srcPath,
(fileEntry) => {
plus.io.requestFileSystem(plus.io.PUBLIC_DOWNLOADS, (fs) => {
// console.log("fs=",fs.name);
// console.log("fs=",fs.root.fullPath);
fileEntry.moveTo(fs.root, fileEntry.name, (entry) => {
console.log("entry=", entry);
let relativePath = `_downloads/${entry.name}`;
resolve(relativePath);
}, (ex) => {
reject(ex)
});
}, (e) => {
console.error("请求download目录失败 " + e);
reject(e);
});
},
(error) => {
console.log('文件不存在/路径错误:', error.message); // 核心问题!
}
);
});
},
}