This commit is contained in:
fengerli
2025-11-08 10:33:20 +08:00
44 changed files with 6742 additions and 2545 deletions

192
App.vue
View File

@ -3,7 +3,7 @@
import upgrade from '@/utils/update.js' import upgrade from '@/utils/update.js'
export default { export default {
onLaunch: function() { onLaunch: function() {
//以下代码仅在开发时使用,否则会出现不可预知的问题。 //以下代码仅在开发时使用,否则会出现不可预知的问题。
//清除登陆之外的所有信息; //清除登陆之外的所有信息;
// let store=uni.getStorageInfoSync(); // let store=uni.getStorageInfoSync();
@ -28,24 +28,29 @@
// }); // });
// uni.clearStorageSync(); // uni.clearStorageSync();
//以上代码仅在开发时使用,否则会出现不可预知的问题。 //以上代码仅在开发时使用,否则会出现不可预知的问题。
// #ifdef APP-PLUS
var appid = plus.runtime.appid;
console.log('应用的 appid 为:' + appid);
// #endif
}, },
onShow: function() { onShow: function() {
console.log('App Show'); console.log('App Show');
//将检查更新换到onshow,因为苹果用户喜欢一直挂着 //将检查更新换到onshow,因为苹果用户喜欢一直挂着
uni.getSystemInfo({success:function(res){ uni.getSystemInfo({
if(res.uniPlatform=='app'){ success: function(res) {
bleTool.getBleTool(); if (res.uniPlatform == 'app') {
let appid=plus.runtime.appid; bleTool.getBleTool();
if(appid!=='HBuilder'){ let appid = plus.runtime.appid;
console.log("appid=",appid); if (appid !== 'HBuilder') {
console.log("appid=", appid);
upgrade.checkAndUpdateWgt(); upgrade.checkAndUpdateWgt();
} }
} }
}}); }
});
}, },
onHide: function() { onHide: function() {
console.log('App Hide'); console.log('App Hide');
@ -55,66 +60,117 @@
<style lang="scss"> <style lang="scss">
@import 'vk-uview-ui/index.scss'; @import 'vk-uview-ui/index.scss';
/* #ifdef APP-ANDROID */ /* #ifdef APP-ANDROID */
//苹果应用以下样式后Slider不可拖动 //苹果应用以下样式后Slider不可拖动
uni-slider .uni-slider-handle-wrapper { uni-slider .uni-slider-handle-wrapper {
border-radius: 20rpx; 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; .uni-file-picker.custom-file-picker {
height: 80rpx !important; overflow: inherit !important;
margin-top: -40rpx !important; }
border-radius: 16rpx !important;
margin-left: -72rpx !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; .contentBg {
position: relative; background-color: #121212;
// } color: #ffffffde;
/* #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;
}
@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-face {
font-family: "PingFangBold"; font-family: "PingFang SC";
src: url("~@/static/fonts/PingFangBold.ttf") format("opentype"); src: url("~@/static/fonts/PingFangSC.ttf") format("opentype");
} }
</style> @font-face {
font-family: "PingFangBold";
src: url("~@/static/fonts/PingFangBold.ttf") format("opentype");
}
</style>

View File

@ -132,7 +132,7 @@
"quickapp" : {}, "quickapp" : {},
/* */ /* */
"mp-weixin" : { "mp-weixin" : {
"appid" : "", "appid" : "wxe16dcf57e925a6b5",
"setting" : { "setting" : {
"urlCheck" : false "urlCheck" : false
}, },

View File

@ -263,12 +263,66 @@
"navigationBarTitleText": "BJQ6331" "navigationBarTitleText": "BJQ6331"
} }
}, },
{ {
"path": "pages/6331/AudioManager", "path": "pages/4877/BJQ4877",
"style": { "style": {
"navigationBarTitleText": "语音管理" "navigationBarTitleText": "BJQ 4877"
} }
}, },
{
"path": "pages/100/HBY100",
"style": {
"navigationBarTitleText": "HBY 100"
}
},
{
"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/common/audioManager/Recording",
"style" :
{
"navigationBarTitleText" : "录制语音"
}
},
{ {
"path": "pages/4877/BJQ4877", "path": "pages/4877/BJQ4877",
"style": { "style": {

File diff suppressed because it is too large Load Diff

View File

@ -240,7 +240,7 @@
</view> </view>
</view> </view>
<!-- ======各个弹框类型======= --> <!-- ======各个弹框类型======= -->
<CustomPopup :show="currentPopup.show" v-bind="currentPopup.config" @confirm="handleConfirm" <CustomPopup :show="currentPopup.show" ="currentPopup.config" @confirm="handleConfirm"
@cancel="handleCancel" /> @cancel="handleCancel" />
</view> </view>
</view> </view>

View File

@ -1,8 +1,8 @@
<template> <template>
<view class="content contentBg"> <view class="content contentBg">
<view class="eq"> <view class="eq">
<view class="leftImg" @click.stop="previewImg(formData.img)"> <view class="leftImg" @click.stop="previewImg(device.devicePic?device.devicePic:formData.img)">
<image class="img" :src="formData.img?formData.img:'/static/images/4877/4877equip.png'" <image class="img" :src="device.devicePic?device.devicePic:formData.img"
mode="aspectFit"></image> mode="aspectFit"></image>
</view> </view>
<view class="rightTxt"> <view class="rightTxt">
@ -24,20 +24,24 @@
</view> </view>
<view class="eqinfo"> <view class="eqinfo">
<view class="item"> <view class="item">
<text class="lbl">蓝牙名称</text> <text class="lbl">设备名称</text>
<text class="value">{{formData.blename}}</text> <text class="value">{{device.deviceName}}</text>
</view> </view>
<view class="item"> <view class="item">
<text class="lbl">设备名称</text> <text class="lbl">Mac地址</text>
<text class="value">{{formData.deviceName}}</text> <text class="value">{{device.deviceMac}}</text>
</view> </view>
<view class="item">
<text class="lbl">蓝牙名称</text>
<text class="value">{{device.bluetoothName}}</text>
</view>
<view class="item"> <view class="item">
<text class="lbl">蓝牙状态</text> <text class="lbl">蓝牙状态</text>
<text class="value" :class="formData.bleStatu?'green':'red'">{{formData.bleStatu?'已连接':'未连接'}}</text> <text class="value" :class="formData.bleStatu?'green':'red'">{{formData.bleStatu?'已连接':'未连接'}}</text>
</view> </view>
</view> </view>
<view class="warnnig" v-bind:class="formData.sta_SOSType=='sos'?'':'displayNone'" <view class="warnnig" :class="formData.sta_SOSType=='sos'?'':'displayNone'"
@click.stop="showUnWarn('sos_off')"> @click.stop="showUnWarn('sos_off')">
<view>设备强制报警中</view> <view>设备强制报警中</view>
<view class="netContent"> <view class="netContent">
@ -312,7 +316,7 @@
usrToggle: true, usrToggle: true,
}, },
formData: { formData: {
img: '/static/images/4877/4877equip.png', img: '/static/images/common/BJQ4877.png',
sta_PowerPercent: '', sta_PowerPercent: '',
xuhang: '', xuhang: '',
blename: '', blename: '',
@ -439,7 +443,7 @@
} }
these.formData.blename = f.name ? f.name : "Unname"; these.formData.blename = f.name ? f.name : "Unname";
these.formData.deviceName = device.deviceName; these.formData.deviceName = device.deviceName;
these.formData.img = device.devicePic;
these.formData.bleStatu = false; these.formData.bleStatu = false;
these.formData.deviceId = f.deviceId; these.formData.deviceId = f.deviceId;
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => { ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {

View File

@ -1,8 +1,9 @@
<template> <template>
<view class="content contentBg"> <view class="content contentBg">
<view class="eq"> <view class="eq">
<view class="leftImg" @click.stop="previewImg(formData.img)"> <view class="leftImg" @click.stop="previewImg(device.devicePic?device.devicePic:formData.img)">
<image class="img" :src="formData.img" mode="aspectFit"></image> <image class="img" :src="device.devicePic?device.devicePic:formData.img" mode="aspectFit"></image>
</view> </view>
<view class="rightTxt"> <view class="rightTxt">
<view class="row"> <view class="row">
@ -22,18 +23,23 @@
</view> </view>
</view> </view>
<view class="eqinfo"> <view class="eqinfo">
<view class="item">
<text class="lbl">蓝牙名称</text>
<text class="value">{{formData.blename}}</text>
</view>
<view class="item"> <view class="item">
<text class="lbl">设备名称</text> <text class="lbl">设备名称</text>
<text class="value">{{formData.deviceName}}</text> <text class="value">{{device.deviceName}}</text>
</view> </view>
<view class="item"> <view class="item">
<text class="lbl">充电状态</text> <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> <text class="value">{{formData.statu}}</text>
</view> </view>
<view class="item">
<text class="lbl">蓝牙名称</text>
<text class="value">{{device.bluetoothName}}</text>
</view>
<view class="item"> <view class="item">
<text class="lbl">蓝牙状态</text> <text class="lbl">蓝牙状态</text>
<text class="value" :class="formData.bleStatu?'green':'red'">{{formData.bleStatu?'已连接':'未连接'}}</text> <text class="value" :class="formData.bleStatu?'green':'red'">{{formData.bleStatu?'已连接':'未连接'}}</text>
@ -227,7 +233,7 @@
} }
}, },
formData: { formData: {
img: '', img: '/static/images/common/HBY6155.png',
battary: '', battary: '',
xuhang: '', xuhang: '',
deviceName: '', deviceName: '',
@ -354,7 +360,7 @@
} }
these.formData.blename = f.name ? f.name : "Unname"; these.formData.blename = f.name ? f.name : "Unname";
these.formData.deviceName = device.deviceName; these.formData.deviceName = device.deviceName;
these.formData.img = device.devicePic;
these.formData.id = device.id; these.formData.id = device.id;
these.formData.deviceId = f.deviceId; these.formData.deviceId = f.deviceId;
these.formData.bleStatu = false; 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> <template>
<view class="content contentBg"> <view class="content contentBg">
<view class="eq"> <view class="eq">
<view class="leftImg" @click.stop="previewImg(formData.img)"> <view class="leftImg" @click.stop="previewImg(device.devicePic?device.devicePic:formData.img)">
<image class="img" :src="formData.img" mode="aspectFit"></image> <image class="img" :src="device.devicePic?device.devicePic:formData.img" mode="aspectFit"></image>
</view> </view>
<view class="rightTxt"> <view class="rightTxt">
<view class="row"> <view class="row">
@ -22,15 +22,19 @@
</view> </view>
</view> </view>
<view class="eqinfo"> <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>
<view class="item"> <view class="item">
<text class="lbl">蓝牙名称</text> <text class="lbl">蓝牙名称</text>
<text class="value">{{formData.blename}}</text> <text class="value">{{device.bluetoothName}}</text>
</view>
<view class="item">
<text class="lbl">设备名称</text>
<text class="value">{{formData.deviceName}}</text>
</view> </view>
<view class="item"> <view class="item">
<text class="lbl">蓝牙状态</text> <text class="lbl">蓝牙状态</text>
<text class="value" :class="formData.bleStatu?'green':'red'">{{formData.bleStatu?'已连接':'未连接'}}</text> <text class="value" :class="formData.bleStatu?'green':'red'">{{formData.bleStatu?'已连接':'未连接'}}</text>
@ -308,7 +312,7 @@
usrToggle: true, usrToggle: true,
}, },
formData: { formData: {
img: '/static/images/6155/DeviceDetail/equip.png', img: '/static/images/common/BJQ6331.png',
battary: '', battary: '',
xuhang: '', xuhang: '',
blename: '', blename: '',
@ -395,7 +399,7 @@
} }
these.formData.blename = f.name ? f.name : "Unname"; these.formData.blename = f.name ? f.name : "Unname";
these.formData.deviceName = device.deviceName; these.formData.deviceName = device.deviceName;
these.formData.img = device.devicePic;
these.formData.deviceId = f.deviceId; these.formData.deviceId = f.deviceId;
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => { ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {

View File

@ -1,8 +1,8 @@
<template> <template>
<view class="content contentBg"> <view class="content contentBg">
<view class="eq"> <view class="eq">
<view class="leftImg" @click.stop="previewImg(formData.img)"> <view class="leftImg" @click.stop="previewImg(device.devicePic?device.devicePic:formData.img)">
<image class="img" :src="formData.img" mode="aspectFit"></image> <image class="img" :src="device.devicePic?device.devicePic:formData.img" mode="aspectFit"></image>
</view> </view>
<view class="rightTxt"> <view class="rightTxt">
<view class="row"> <view class="row">
@ -24,11 +24,15 @@
<view class="eqinfo"> <view class="eqinfo">
<view class="item"> <view class="item">
<text class="lbl">蓝牙名称</text> <text class="lbl">蓝牙名称</text>
<text class="value">{{formData.blename}}</text> <text class="value">{{device.bluetoothName}}</text>
</view>
<view class="item">
<text class="lbl">Mac地址</text>
<text class="value">{{device.deviceMac}}</text>
</view> </view>
<view class="item"> <view class="item">
<text class="lbl">设备名称</text> <text class="lbl">设备名称</text>
<text class="value">{{formData.deviceName}}</text> <text class="value">{{device.deviceName}}</text>
</view> </view>
<view class="item"> <view class="item">
<text class="lbl">蓝牙状态</text> <text class="lbl">蓝牙状态</text>
@ -40,14 +44,14 @@
</view> </view>
</view> </view>
<view class="warnnig" v-bind:class="formData.iswarn?'':'displayNone'"> <view class="warnnig" :class="formData.iswarn?'':'displayNone'">
<view>警告!环境存在漏电电源</view> <view>警告!环境存在漏电电源</view>
<view class="netContent"> <view class="netContent">
<view v-bind:class="getWarnStyle(1)" class="net netone"></view> <view :class="getWarnStyle(1)" class="net netone"></view>
<view v-bind:class="getWarnStyle(2)" class="net nettwo"></view> <view :class="getWarnStyle(2)" class="net nettwo"></view>
<view v-bind:class="getWarnStyle(3)" class="net netsiri"></view> <view :class="getWarnStyle(3)" class="net netsiri"></view>
<view v-bind:class="getWarnStyle(4)" class="net netfour"></view> <view :class="getWarnStyle(4)" class="net netfour"></view>
<view v-bind:class="getWarnStyle(5)" class="net netfive"></view> <view :class="getWarnStyle(5)" class="net netfive"></view>
</view> </view>
</view> </view>
@ -250,7 +254,7 @@
usrToggle: true, usrToggle: true,
}, },
formData: { formData: {
img: '/static/images/6155/DeviceDetail/equip.png', img: '/static/images/common/HBY650.png',
battary: '', battary: '',
xuhang: '', xuhang: '',
blename: '', blename: '',
@ -344,7 +348,7 @@
} }
these.formData.blename = f.name ? f.name : "Unname"; these.formData.blename = f.name ? f.name : "Unname";
these.formData.deviceName = device.deviceName; these.formData.deviceName = device.deviceName;
these.formData.img = device.devicePic;
these.formData.bleStatu = false; these.formData.bleStatu = false;
these.formData.deviceId = f.deviceId; these.formData.deviceId = f.deviceId;
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => { ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {

View File

@ -2,10 +2,12 @@
<view class="content contentBg"> <view class="content contentBg">
<custom-navbar :title="Status.navbar.title" :showBack="Status.navbar.showBack" color="#FFFFFF" <custom-navbar :title="Status.navbar.title" :showBack="Status.navbar.showBack" color="#FFFFFF"
:rightIcons="Status.navbar.icons" @icon-click="handleRightClick"></custom-navbar> :rightIcons="Status.navbar.icons" @icon-click="handleRightClick"></custom-navbar>
<view>
</view>
<view class="eq" :style="{marginTop:Status.navbar.height+'px'}"> <view class="eq" :style="{marginTop:Status.navbar.height+'px'}">
<view class="leftImg" @click.stop="previewImg(device['devicePic'])"> <view class="leftImg" @click.stop="previewImg(device.devicePic?device.devicePic:formData.img)">
<image class="img" :src="device['devicePic']" mode="aspectFit"></image> <image class="img" :src="device.devicePic?device.devicePic:formData.img" mode="aspectFit"></image>
</view> </view>
<view class="rightTxt"> <view class="rightTxt">
<view class="row"> <view class="row">
@ -25,13 +27,22 @@
</view> </view>
</view> </view>
<view class="eqinfo"> <view class="eqinfo">
<view class="item">
<text class="lbl">设备名称</text>
<text class="value valueFont">{{device.deviceName}}</text>
</view>
<view class="item"> <view class="item">
<text class="lbl">设备IMEI</text> <text class="lbl">设备IMEI</text>
<text class="value valueFont">{{device.deviceImei}}</text> <text class="value valueFont">{{device.deviceImei}}</text>
</view> </view>
<view class="item"> <view class="item">
<text class="lbl">设备名称</text> <text class="lbl">Mac地址</text>
<text class="value valueFont">{{device.deviceName}}</text> <text class="value">{{device.deviceMac}}</text>
</view>
<view class="item">
<text class="lbl">蓝牙名称</text>
<text class="value valueFont">{{device.bluetoothName}}</text>
</view> </view>
<view class="item"> <view class="item">
<text class="lbl">蓝牙状态</text> <text class="lbl">蓝牙状态</text>
@ -69,17 +80,17 @@
</view> </view>
</view> </view>
<view class="warnnig" v-bind:class="formData.staticWarn?'':'displayNone'"> <view class="warnnig" :class="formData.staticWarn?'':'displayNone'">
<view>警告设备静止报警中</view> <view>警告设备静止报警中</view>
<view class="netContent"> <view class="netContent">
<view v-bind:class="getWarnStyle(1)" class="net netone"></view> <view :class="getWarnStyle(1)" class="net netone"></view>
<view v-bind:class="getWarnStyle(2)" class="net nettwo"></view> <view :class="getWarnStyle(2)" class="net nettwo"></view>
<view v-bind:class="getWarnStyle(3)" class="net netsiri"></view> <view :class="getWarnStyle(3)" class="net netsiri"></view>
<view v-bind:class="getWarnStyle(4)" class="net netfour"></view> <view :class="getWarnStyle(4)" class="net netfour"></view>
<view v-bind:class="getWarnStyle(5)" class="net netfive"></view> <view :class="getWarnStyle(5)" class="net netfive"></view>
</view> </view>
</view> </view>
<view class="warnnig" v-bind:class="(formData.qzwarn && Status.staticWarn.time)?'':'displayNone'" <view class="warnnig" :class="(formData.qzwarn && Status.staticWarn.time)?'':'displayNone'"
@click="CloseWarn(true)"> @click="CloseWarn(true)">
<view>设备强制报警中</view> <view>设备强制报警中</view>
<view class="netContent"> <view class="netContent">
@ -378,6 +389,7 @@
bleLinkCnt: 0 bleLinkCnt: 0
}, },
formData: { formData: {
img:'/static/images/common/HBY670.png',
battary: "", //电量 battary: "", //电量
xuhang: "", //续航 xuhang: "", //续航
imei: "", //imei imei: "", //imei
@ -514,6 +526,7 @@
let keys = Object.keys(form); let keys = Object.keys(form);
for (var i = keys.length; i >= 0; i--) { for (var i = keys.length; i >= 0; i--) {
let key = keys[i]; let key = keys[i];
these.formData[key] = form[key]; these.formData[key] = form[key];
} }
} }

File diff suppressed because it is too large Load Diff

View File

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

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -333,8 +333,8 @@
this.total = 0; // 重置总数 this.total = 0; // 重置总数
const deviceType = tab.id === '' ? undefined : tab.id; const deviceType = tab.id === '' ? undefined : tab.id;
this.$nextTick(() => { this.$nextTick(() => {
this.getSystemInfoSyncH(); this.getSystemInfoSyncH();
}); });
this.getData(deviceType); this.getData(deviceType);
if (this.mescroll) { if (this.mescroll) {
this.mescroll.resetUpScroll(); this.mescroll.resetUpScroll();
@ -400,9 +400,54 @@
case 'scan': case 'scan':
uni.scanCode({ uni.scanCode({
success: (res) => { success: (res) => {
const cleanedResult = res.result.trim(); let cleanedResult = res.result.trim();
uni.navigateTo({ console.log("scanResult=", cleanedResult);
url: `/pages/common/qrcode/qrcode?deviceId=${encodeURIComponent(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) => { fail: (err) => {
@ -456,9 +501,9 @@
if (this.$refs.swipeAction) { if (this.$refs.swipeAction) {
this.$refs.swipeAction.closeAll(); this.$refs.swipeAction.closeAll();
} }
console.log("111111",this.deviceId); console.log("111111", this.deviceId);
console.log("ble==null,",ble) console.log("ble==null,", ble)
ble && ble.DropDevice(null,this.deviceId.id); ble && ble.DropDevice(null, this.deviceId.id);
} else { } else {
uni.showToast({ uni.showToast({
title: res.msg, title: res.msg,
@ -541,10 +586,10 @@
// 列表跳转 // 列表跳转
handleFile(item) { handleFile(item) {
let url = item.detailPageUrl; let url = item.detailPageUrl;
// url="/pages/6331/BJQ6331"; // url="/pages/6331/BJQ6331";
uni.navigateTo({ uni.navigateTo({
url: url, url: url,
success: (res) => { success: (res) => {

BIN
static/images/100/light.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 424 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 433 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 867 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -0,0 +1,7 @@
## 1.0.22023-11-01
更换App端转换本地链接的方法
添加App端文件拓展名过滤
## 1.0.12023-09-04
优化部分逻辑
## 1.0.02023-09-03
支持图片、视频选择上传H5、微信小程序App支持文件选择上传

View File

@ -0,0 +1,285 @@
<!-- eslint-disable -->
<template>
<view>
<!-- #ifdef APP-PLUS -->
<view class="xe-upload" v-html="renderInput" :props="mergeProps" :change:props="XeUpload.renderProps"></view>
<!-- #endif -->
</view>
</template>
<script>
import {
chooseMedia,
chooseFile,
chooseMessageFile,
uploadFile,
} from '../../tools/apis';
import {
deepMerge,
awaitWrap,
base64ToPath,
isArray,
} from '../../tools/tools';
export default {
name: 'XeUpload',
props: {
options: {
default: () => ({}),
type: Object,
},
},
data() {
return {
id: 0, // APP上传框ID
renderInput: '', // APP上传框
};
},
computed: {
mergeOptions({ options = {} }) {
const tmpOptions = {
name: 'file',
};
return deepMerge(tmpOptions, options);
},
mergeProps({ id, renderInput, mergeOptions }) {
return {
id,
renderInput,
upload: mergeOptions,
};
},
},
methods: {
// 上传事件
async upload(type, config = {}) {
let tmpResult = [];
if (['image', 'video'].includes(type)) {
const [err, res] = await chooseMedia(type, config);
if (err) return this.handleError(err);
tmpResult = res?.tempFiles || [];
}
// H5 || APP-PLUS || MP-WEIXIN
if (['file'].includes(type)) {
let tmpFiles = {};
let tmpErr = null;
// #ifdef H5
[tmpErr, tmpFiles] = await chooseFile(config);
// #endif
// #ifdef MP-WEIXIN
[tmpErr, tmpFiles] = await chooseMessageFile(config);
// #endif
// #ifdef APP-PLUS
this.id = Math.floor(Math.random() * 100000000 + 1);
this.initInput(config.extension);
// #endif
if (tmpErr) return this.handleError(tmpErr);
tmpResult = tmpFiles?.tempFiles || [];
}
this.handleUpload(tmpResult);
},
// 初始化上传框
initInput(extension) {
const { id } = this;
let accept = extension;
if (isArray(extension)) {
accept = extension.join(',');
}
this.renderInput = `<input type="file" id="xe-upload-${id}" name="xe-upload" ${accept ? 'accept="' + accept + '"' : ''} />`;
},
// 文件上传没有传入上传url时返回本地链接
async handleUpload(files = []) {
if (files.filter((e) => Boolean(e)).length === 0) return;
const { mergeOptions } = this;
if (!mergeOptions.url) {
return this.handleEmits({
type: 'choose',
data: files,
});
}
const tmpUploads = files.map((e) =>
uploadFile(
{
...mergeOptions,
filePath: e.tempFilePath,
},
e,
)
);
const [err, res] = await awaitWrap(Promise.all(tmpUploads));
if (err) return this.handleError(err);
this.handleEmits({
type: 'success',
data: res,
});
},
// 处理失败事件
handleError(error) {
this.handleEmits({
type: 'warning',
data: error,
});
},
// 处理响应事件
async handleEmits(e) {
// #ifdef APP-PLUS
if (e.type === 'choose') {
// 将base64转为本地链接
for (let i = 0; i < e.data.length; i += 1) {
const item = e.data[i];
if (!item.base64Url) {
continue;
}
const [parseError, parseUrl] = await awaitWrap(base64ToPath(item.base64Url, item.name));
if (!parseError) {
e.data[i].tempFilePath = parseUrl;
} else {
e.data[i].tempFilePath = item.base64Url;
}
delete e.data[i].base64Url;
}
}
// #endif
this.$emit('callback', e);
},
},
};
</script>
<!-- #ifdef APP-PLUS -->
<script module="XeUpload" lang="renderjs">
import {
appUploadFile,
} from '../../tools/apis';
import {
awaitWrap,
fileToBase64,
} from '../../tools/tools';
export default {
data() {
return {
id: 0, // 上传框ID
uploadOptions: {}, // 上传配置
};
},
methods: {
// 处理 XeUpload 传入 renderjs 数据,以及调起上传框
renderProps(info) {
const { id, renderInput, upload } = info;
if (!renderInput) return;
this.id = id;
this.uploadOptions = upload;
this.$nextTick(() => {
const dom = document.getElementById(`xe-upload-${id}`);
dom.addEventListener('change', () => {
this.handleUpload();
});
dom?.click?.();
});
},
// 处理文件上传(没有传入url时返回本地链接)
async handleUpload() {
const {
url,
name,
header = {},
formData = {},
} = this.uploadOptions || {};
const dom = document.getElementById(`xe-upload-${this.id}`);
if (!dom.files[0]) return;
const tmpFileList = Array.from(dom.files);
const tmpUploads = [];
for (let i = 0; i < tmpFileList.length; i += 1) {
const e = tmpFileList[i];
let tmpType = 'file';
if (e.type.includes('image')) {
tmpType = 'image';
}
if (e.type.includes('video')) {
tmpType = 'video';
}
const tmpExts = {
size: e.size,
name: e.name,
type: e.type,
fileType: tmpType,
tempFilePath: '',
base64Url: '',
};
// 没有传入上传url时直接返回本地链接
if (!url) {
const [parseError, parseUrl] = await awaitWrap(fileToBase64(dom.files[i]));
if (!parseError) {
tmpExts.base64Url = parseUrl;
}
tmpUploads.push(tmpExts);
continue;
};
const tmpData = new FormData();
tmpData.append(name, dom.files[i], e.name);
for (let key in formData) {
tmpData.append(key, formData[key]);
}
// 上传进度
const onprogress = (ev) => {
if(ev.lengthComputable) {
var result = (ev.loaded / ev.total) * 100;
this.handleRenderEmits({
type: 'onprogress',
data: {
progress: Math.floor(result),
current: i + 1,
total: tmpFileList.length,
},
});
};
}
tmpUploads.push(appUploadFile({
url,
header,
formData: tmpData
}, tmpExts, onprogress ));
}
// 没有传入上传url时直接返回本地链接列表
if (!url) {
return this.handleRenderEmits({
type: 'choose',
data: tmpUploads,
});
}
this.handleRenderEmits({
type: 'onprogress',
data: {
progress: 0,
current: 1,
total: tmpFileList.length,
},
});
// 处理上传文件
const [err, res] = await awaitWrap(Promise.all(tmpUploads));
if (err) {
return this.handleRenderEmits({
type: 'warning',
data: err,
});
}
this.handleRenderEmits({
type: 'success',
data: res,
});
},
// 数据传输到XeUpload组件
handleRenderEmits(data) {
this.$ownerInstance.callMethod('handleEmits', data);
},
},
};
</script>
<!-- #endif -->
<style scoped>
.xe-upload {
display: none;
}
</style>

View File

@ -0,0 +1,81 @@
{
"id": "xe-upload",
"displayName": "文件选择、文件上传组件(图片,视频,文件等)",
"version": "1.0.2",
"description": "H5、微信小程序、App端支持图片视频文件选择上传其他端暂不支持文件选择上传",
"keywords": [
"App、H5、微信小程序、图片视频文件上传"
],
"repository": "",
"engines": {
"HBuilderX": "^3.1.0"
},
"dcloudext": {
"type": "component-vue",
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "无",
"permissions": "无"
},
"npmurl": ""
},
"uni_modules": {
"dependencies": [],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y"
},
"client": {
"Vue": {
"vue2": "y",
"vue3": "u"
},
"App": {
"app-vue": "y",
"app-nvue": "u"
},
"H5-mobile": {
"Safari": "y",
"Android Browser": "y",
"微信浏览器(Android)": "y",
"QQ浏览器(Android)": "y"
},
"H5-pc": {
"Chrome": "y",
"IE": "u",
"Edge": "y",
"Firefox": "y",
"Safari": "y"
},
"小程序": {
"微信": "y",
"阿里": "y",
"百度": "y",
"字节跳动": "y",
"QQ": "y",
"钉钉": "y",
"快手": "y",
"飞书": "y",
"京东": "y"
},
"快应用": {
"华为": "y",
"联盟": "y"
}
}
}
}
}

View File

@ -0,0 +1,78 @@
# xe-upload
## 说明
不占用页面位置的上传组件;
H5、APP、微信小程序中可上传图片视频和文件其他端暂时只能上传图片和视频
> 上传图片通过[chooseMedia](https://uniapp.dcloud.net.cn/api/media/video.html#choosemedia)及[chooseImage](https://uniapp.dcloud.net.cn/api/media/image.html#chooseimage)实现
> 上传视频通过[chooseMedia](https://uniapp.dcloud.net.cn/api/media/video.html#choosemedia)及[chooseVideo](https://uniapp.dcloud.net.cn/api/media/video.html#choosevideo)实现
> H5端上传文件通过[chooseFile](https://uniapp.dcloud.net.cn/api/media/file.html#wx-choosemessagefile)实现
> APP上传文件通过[renderjs](https://uniapp.dcloud.net.cn/tutorial/renderjs.html#renderjs)实现
> 微信小程序上传文件通过[chooseMessageFile](https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.chooseMessageFile.html)实现
## 使用
Attributes
| 参数 | 说明 | 类型 | 默认值 |
| ----------- | ----------- | ----------- | ----------- |
| options | 请求配置(参数与uni.uploadFile的参数一致) | object | { name: 'file' } |
Events
| 事件名 | 说明 | 参数 |
| ----------- | ----------- | ----------- |
| callback | 接收数据 | { type, data } |
callback type
| 参数 | 说明 |
| ----------- | ----------- |
| warning | 提示信息下文称warning回调 |
| success | 上传成功下文称success回调 |
| choose | 选择文件下文称choose回调 |
callback data
```
'callback.type === success' : [
{
"size": 176579, // 选择的文件的大小
"name": "Kafka.pdf", // 选择的文件的名称(小程序端可能会没有)
"type": "application/pdf",
"tempFilePath": "blob:http://192.168.137.1:8080/2585769b-3195-4f3d-b9f8-d9e99f55deec", // 临时路路径
"fileType": "file", // 文件类型[image, video, file]
"response": {
"result": {
"fileName": "Kafka.pdf",
"filePath": `http://localhost:3000/upload/e51d814b649122fc64892d0bc6383d07.pdf`,
},
"success": true,
}, // 上传返回的信息
}
]
'callback.type === choose' : [
{
"size": 176579, // 选择的文件的大小
"name": "Kafka.pdf", // 选择的文件的名称(小程序端可能会没有)
"type": "application/pdf",
"tempFilePath": "blob:http://192.168.137.1:8080/4204e460-f185-4fc9-9f4d-1bc50ab06981", // 文件临时路径
"fileType": "file", // 文件类型[image, video, file]
}
]
```
## 注意事项
#### 1、options入参中如果url为空则choose回调的data列表中只有选择文件能得到的信息和临时路径临时路径可用于自定义上传方法APP除外传入url选择文件后会自动上传到服务器此时choose回调不会触发而是执行success回调success回调的data列表会包括选择文件能得到的信息
#### 2、APP端文件建议直接上传到服务器拿到文件上传后的地址再进行其他操作(目前测试APP端file转换后的Blob Url无法用于uni.uploadFile所以建议APP文件直接上传)
#### 3、APP端文件暂时支持单个上传
#### 4、当uni.chooseMedia可用时会优先使用uni.chooseMedia
#### 5、具体使用可下载示例项目运行查看完整示例

View File

@ -0,0 +1,177 @@
// eslint-disable
import { awaitWrap } from './tools';
/**
* 从本地相册选择图片或使用相机拍照
* @param {object} config 参数详情 => https://uniapp.dcloud.net.cn/api/media/image.html#chooseimage
* @returns
*/
export const chooseImage = (config) => {
return awaitWrap(
new Promise((r, j) => {
uni.chooseImage({
...config,
success: (res) => {
const tmpFiles = res?.tempFiles.map((e) => ({
tempFilePath: e.path,
tempFile: e,
size: e.size,
name: e.name,
type: e.type,
fileType: 'image',
}));
return r({ type: 'image', ...res, tempFiles: tmpFiles });
},
fail: (err) => j({ mode: 'chooseImage', data: err }),
});
})
);
};
/**
* 拍摄视频或从手机相册中选视频,返回视频的临时文件路径
* @param {object} config 参数详情 => https://uniapp.dcloud.net.cn/api/media/video.html#choosevideo
* @returns
*/
export const chooseVideo = (config) => {
return awaitWrap(
new Promise((r, j) => {
uni.chooseVideo({
...config,
success: (res) => {
const tmpFiles = [{
...res,
tempFilePath: res.tempFilePath,
tempFile: res.tempFile ?? {},
size: res.size,
name: res.name,
type: res.tempFile?.type,
fileType: 'video',
}];
return r({ type: 'video', tempFiles: tmpFiles });
},
fail: (err) => j({ mode: 'chooseVideo', data: err }),
});
})
);
};
/**
* 拍摄或从手机相册中选择图片或视频
* @param {object} config 参数详情 => https://uniapp.dcloud.net.cn/api/media/video.html#choosemedia
* @returns
*/
export const chooseMedia = (type, config) => {
if (!type) return console.error('chooseMedia type cannot be empty');
if (!uni.chooseMedia && type === 'image') return chooseImage(config);
if (!uni.chooseMedia && type === 'video') return chooseVideo(config);
return awaitWrap(
new Promise((r, j) => {
uni.chooseMedia({
...config,
mediaType: [type],
success: (res) => r(res),
fail: (err) => j({ mode: 'chooseMedia', data: err }),
});
})
);
};
/**
* 从本地选择文件(h5)
* @param {object} config 参数详情 => https://uniapp.dcloud.net.cn/api/media/file.html#wx-choosemessagefile
* @returns
*/
export const chooseFile = (config) => {
return awaitWrap(
new Promise((r, j) => {
uni.chooseFile({
...config,
success: (res) => {
const tmpFiles = res?.tempFiles.map((e) => {
let tmpType = 'file';
if (e.type.includes('image')) {
tmpType = 'image';
}
if (e.type.includes('video')) {
tmpType = 'video';
}
return {
tempFilePath: e.path,
tempFile: e,
size: e.size,
name: e.name,
type: e.type,
fileType: tmpType,
};
});
return r({ type: 'file', ...res, tempFiles: tmpFiles });
},
fail: (err) => j({ mode: 'chooseFile', data: err }),
});
})
);
};
/**
* 从本地选择文件(微信小程序)
* @param {object} config 参数详情 => https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.chooseMessageFile.html
* @returns
*/
export const chooseMessageFile = (config) => {
return awaitWrap(
new Promise((r, j) => {
wx.chooseMessageFile({
...config,
success: (res) => {
const tmpFiles = res?.tempFiles.map((e) => ({
...e,
tempFilePath: e.path,
fileType: e.type ?? 'file',
}));
return r({ type: 'file', ...res, tempFiles: tmpFiles });
},
fail: (err) => j({ mode: 'chooseMessageFile', data: err }),
});
})
);
};
/**
* 上传
* @param {object} config 参数详情 => https://uniapp.dcloud.net.cn/api/request/network-file.html#uploadfile
* @param {object} exts 选择的文件的数据
* @returns {object} exts + response
*/
export const uploadFile = (config, exts = {}) => {
return new Promise((r, j) => {
uni.uploadFile({
...config,
success: (res) => r({ ...exts, response: JSON.parse(res.data) }),
fail: (err) => j({ mode: 'uploadFile', data: err }),
});
});
};
export const appUploadFile = (config, exts = {}, onprogress) => {
const { url, header, formData } = config;
return new Promise((r, j) => {
const xhr = new XMLHttpRequest();
xhr.open('POST', url, true);
for (let key in header) {
xhr.setRequestHeader(key, header[key]);
}
if (onprogress) {
xhr.upload.onprogress = onprogress;
}
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
r({ ...exts, response: JSON.parse(xhr.responseText) });
} else {
j({ mode: 'uploadFile', data: { data: xhr.responseText, errMsg: 'uploadFile fail.' } });
}
}
}
xhr.send(formData);
});
};

View File

@ -0,0 +1,180 @@
// eslint-disable
export const isObject = (obj) => {
return obj
? Object.prototype.toString.call(obj) === "[object Object]"
: false;
};
export const isArray = (arr) => {
return arr ? Array.isArray(arr) : false;
};
/**
* handle async await
* @param {*} promise promise
*/
export const awaitWrap = (promise) =>
promise.then((res) => [null, res]).catch((err) => [err, {}]);
/**
* 深拷贝
* @param {*} source
*/
export const deepClone = (source) => {
if (!isObject(source) && !isArray(source)) return source;
const targetObj = isArray(source) ? [] : {}; // 判断复制的目标是数组还是对象
for (let keys in source) {
// 遍历目标
if (source.hasOwnProperty(keys)) {
if (source[keys] && typeof source[keys] === "object") {
// 如果值是对象,就递归一下
targetObj[keys] = isArray(source[keys]) ? [] : {};
targetObj[keys] = deepClone(source[keys]);
} else {
// 如果不是,就直接赋值
targetObj[keys] = source[keys];
}
}
}
return targetObj;
};
/**
* @description JS对象深度合并
* @param {object} target 需要拷贝的对象
* @param {object} source 拷贝的来源对象
* @returns {object|boolean} 深度合并后的对象或者false入参有不是对象
*/
export const deepMerge = (target = {}, source = {}) => {
target = deepClone(target);
if (typeof target !== "object" || typeof source !== "object") return false;
for (const prop in source) {
if (!source.hasOwnProperty(prop)) continue;
if (prop in target) {
if (typeof target[prop] !== "object") {
target[prop] = source[prop];
} else if (typeof source[prop] !== "object") {
target[prop] = source[prop];
} else if (target[prop].concat && source[prop].concat) {
target[prop] = target[prop].concat(source[prop]);
} else {
target[prop] = deepMerge(target[prop], source[prop]);
}
} else {
target[prop] = source[prop];
}
}
return target;
};
/**
* 将File对象转为 Blob Url
* @param {File} File对象
* @returns Blob Url
*/
export const fileToBlob = (file) => {
if (!file) return;
const fileType = file.type;
const blob = new Blob([file], { type: fileType || 'application/*' });
const blobUrl = window.URL.createObjectURL(blob);
return blobUrl;
};
/**
* 将File对象转为 base64
* @param {File} File对象
* @returns base64
*/
export const fileToBase64 = (file) => {
if (!file) return;
return new Promise((r, j) => {
const reader = new FileReader();
reader.onloadend = () => {
const base64String = reader.result;
r(base64String);
};
reader.onerror = () => {
j({ mode: 'fileToBase64', data: { errMsg: 'File to base64 fail.' } });
};
reader.readAsDataURL(file);
});
};
/**
* base64转临时路径(改自https://github.com/zhetengbiji/image-tools/blob/master/index.js)
* @param base64
* @returns
*/
function dataUrlToBase64(str) {
var array = str.split(',');
return array[array.length - 1];
};
function biggerThan(v1, v2) {
var v1Array = v1.split('.');
var v2Array = v2.split('.');
var update = false;
for (var index = 0; index < v2Array.length; index++) {
var diff = v1Array[index] - v2Array[index];
if (diff !== 0) {
update = diff > 0;
break;
}
}
return update;
};
var index = 0;
function getNewFileId() {
return Date.now() + String(index++);
};
export const base64ToPath = (base64, name = '') => {
return new Promise((r, j) => {
if (typeof plus !== 'object') {
return j(new Error('not support'));
}
var fileName = '';
if (name) {
const names = name.split('.');
const extName = names.splice(-1);
fileName = `${names.join('.')}-${getNewFileId()}.${extName}`;
} else {
const names = base64.split(',')[0].match(/data\:\S+\/(\S+);/);
if (!names) {
j(new Error('base64 error'));
}
const extName = names[1];
fileName = `${getNewFileId()}.${extName}`;
}
var basePath = '_doc';
var dirPath = 'uniapp_temp';
var filePath = `${basePath}/${dirPath}/${fileName}`;
if (!biggerThan(plus.os.name === 'Android' ? '1.9.9.80627' : '1.9.9.80472', plus.runtime.innerVersion)) {
plus.io.resolveLocalFileSystemURL(basePath, function (entry) {
entry.getDirectory(dirPath, {
create: true,
exclusive: false,
}, function (entry) {
entry.getFile(fileName, {
create: true,
exclusive: false,
}, function (entry) {
entry.createWriter(function (writer) {
writer.onwrite = function () {
r(filePath);
}
writer.onerror = j;
writer.seek(0);
writer.writeAsBinary(dataUrlToBase64(base64));
}, j)
}, j)
}, j)
}, j)
return;
}
var bitmap = new plus.nativeObj.Bitmap(fileName);
bitmap.loadBase64Data(base64, function () {
bitmap.save(filePath, {}, function () {
bitmap.clear();
r(filePath);
}, function (error) {
bitmap.clear();
j(error);
});
}, function (error) {
bitmap.clear();
j(error);
});
});
};

View File

@ -511,9 +511,11 @@ class BleHelper {
uni.onBluetoothAdapterStateChange((state) => { uni.onBluetoothAdapterStateChange((state) => {
// console.log('蓝牙状态发生变化:' + JSON.stringify(state)); // console.log('蓝牙状态发生变化:' + JSON.stringify(state));
this.data.discovering = state.discovering;
if (this.data.available !== state.available) { if (this.data.available !== state.available) {
this.data.available = state.available; this.data.available = state.available;
this.data.discovering = state.discovering;
if (this.data.available && this.data if (this.data.available && this.data
.isOpenBlue) { //蓝牙状态再次可用,重连所有设备 .isOpenBlue) { //蓝牙状态再次可用,重连所有设备
@ -792,7 +794,7 @@ class BleHelper {
} }
try { try {
console.log("11111"); // console.log("11111");
let recData = { let recData = {
deviceId: receive.deviceId, deviceId: receive.deviceId,
serviceId: receive.serviceId, serviceId: receive.serviceId,
@ -801,7 +803,7 @@ class BleHelper {
str: str, str: str,
hexs: hexs hexs: hexs
}; };
console.log("监听到特征值:" + JSON.stringify(recData)); // console.log("监听到特征值:" + JSON.stringify(recData));
if (this.cfg.receivDataCallback) { if (this.cfg.receivDataCallback) {
if (this.cfg.receivDataCallback.length > 0) { if (this.cfg.receivDataCallback.length > 0) {
@ -875,10 +877,7 @@ class BleHelper {
return Promise.resolve(); return Promise.resolve();
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.data.available = false;
this.data.discovering = false;
this.data.isOpenBlue = false;
this.data.searchList = [];
this.StopSearch(); this.StopSearch();
@ -887,15 +886,19 @@ class BleHelper {
uni.closeBluetoothAdapter({ uni.closeBluetoothAdapter({
success: () => { success: () => {
// console.log("蓝牙模块已关闭"); // console.log("蓝牙模块已关闭");
this.data.available = false;
this.data.discovering = false;
this.data.isOpenBlue = false;
this.data.searchList = [];
resolve();
}, },
fail: (ex) => { fail: (ex) => {
console.error('无法关闭蓝牙模块:', ex); console.error('无法关闭蓝牙模块:', ex);
ex = this.getError(ex); ex = this.getError(ex);
reject(ex);
}, },
complete: () => { complete: () => {
resolve();
} }
}); });
@ -968,7 +971,8 @@ class BleHelper {
//停止搜索 //停止搜索
StopSearch() { StopSearch() {
if (this.data.platform == 'web') { if (this.data.platform == 'web' || !this.data.discovering) {
console.error("web平台或当前没有搜索,直接返回");
return Promise.resolve(); return Promise.resolve();
} }
let p1 = new Promise((resolve, reject) => { let p1 = new Promise((resolve, reject) => {
@ -1485,7 +1489,9 @@ class BleHelper {
// 处理 MTU 设置 // 处理 MTU 设置
if (plus.os.name === 'Android') { if (plus.os.name === 'Android') {
this.setMtu(deviceId); this.setMtu(deviceId).catch(ex=>{
console.error("mtu设置失败=",ex);
});
} }
resolve(true); resolve(true);
@ -1593,12 +1599,11 @@ class BleHelper {
_succ(mtuRes); _succ(mtuRes);
}, },
fail: (ex) => { fail: (ex) => {
console.error(
"mtu设置失败", ex);
ex = this.getError(ex); ex = this.getError(ex);
_err( _err(
ex ex
); // MTU设置失败不影响连接成功 );
}, },
complete() { complete() {
console.log("设置mtu完毕"); console.log("设置mtu完毕");

View File

@ -7,7 +7,7 @@ class BleReceive {
'/pages/650/HBY650': this.Receive_650.bind(this), '/pages/650/HBY650': this.Receive_650.bind(this),
'/pages/670/HBY670': this.Receive_670.bind(this), '/pages/670/HBY670': this.Receive_670.bind(this),
'/pages/4877/BJQ4877': this.Receive_4877.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)
}; };
} }
@ -47,6 +47,7 @@ class BleReceive {
let devKey = f.device.detailPageUrl ? f.device.detailPageUrl.replace(/\//g, '').toLowerCase() : ''; let devKey = f.device.detailPageUrl ? f.device.detailPageUrl.replace(/\//g, '').toLowerCase() : '';
console.log("查找handler - detailPageUrl:", f.device.detailPageUrl, "转换后:", devKey); console.log("查找handler - detailPageUrl:", f.device.detailPageUrl, "转换后:", devKey);
for (let index = 0; index < keys.length; index++) { for (let index = 0; index < keys.length; index++) {
let devKey = f.device.detailPageUrl ? f.device.detailPageUrl.replace(/\//g, "").toLowerCase() : '';
let key = keys[index].replace(/\//g, '').toLowerCase(); let key = keys[index].replace(/\//g, '').toLowerCase();
if (key == devKey) { if (key == devKey) {
handler = this.HandlerMap[keys[index]]; handler = this.HandlerMap[keys[index]];
@ -153,8 +154,8 @@ class BleReceive {
this.setBleFormData(formData, f); this.setBleFormData(formData, f);
let recCnt = recArr.find(v => { let recCnt = recArr.find(v => {
return v.key.replaceAll('/', '').toLowerCase() == f.device.detailPageUrl return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
.replaceAll('/', '').toLowerCase(); .replace(/\//g, "").toLowerCase();
}); });
if (!recCnt) { if (!recCnt) {
@ -321,8 +322,8 @@ class BleReceive {
this.setBleFormData(receiveData, f); this.setBleFormData(receiveData, f);
console.log("recArr=", recArr); console.log("recArr=", recArr);
let recCnt = recArr.find(v => { let recCnt = recArr.find(v => {
return v.key.replaceAll('/', '').toLowerCase() == f.device.detailPageUrl return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
.replaceAll('/', '').toLowerCase(); .replace(/\//g, "").toLowerCase();
}); });
if (!recCnt) { if (!recCnt) {
if (this.formData.staticWarn) { //有静止报警 if (this.formData.staticWarn) { //有静止报警
@ -474,8 +475,11 @@ class BleReceive {
let recCnt = recArr.find(v => { let recCnt = recArr.find(v => {
return v.key.replace(/\//g, '').toLowerCase() === f.device.detailPageUrl.replace( return v.key.replace(/\//g, "").toLowerCase() === f.device.detailPageUrl.replaceAll(
/\//g, '').toLowerCase(); '/', '').toLowerCase();
}); });
if (!recCnt) { if (!recCnt) {
if (batteryLevel <= 20) { if (batteryLevel <= 20) {
@ -503,12 +507,12 @@ class BleReceive {
try { try {
console.log("str=",receive.str); // console.log("str=",receive.str);
receiveData = JSON.parse(receive.str); receiveData = JSON.parse(receive.str);
let recCnt = recArr.find(v => { let recCnt = recArr.find(v => {
return v.key.replaceAll('/', '').toLowerCase() == f.device.detailPageUrl return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
.replaceAll('/', '').toLowerCase(); .replace(/\//g, "").toLowerCase();
}); });
if (!recCnt) { if (!recCnt) {
if (receiveData.sta_PowerPercent<=20) { if (receiveData.sta_PowerPercent<=20) {
@ -527,7 +531,36 @@ 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"; import request from "@/utils/request.js";
export default { export default {
audioStorageKey: "audioStorageKey",
pcmStorageKey: "pcmStorageKey",
guid: function generateUUID() { guid: function generateUUID() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
const r = Math.random() * 16 | 0; let r = Math.random() * 16 | 0;
const v = c === 'x' ? r : (r & 0x3 | 0x8); let v = c === 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16); return v.toString(16);
}); });
}, },
@ -137,7 +138,7 @@ export default {
checkLAN: function(succ, error) { checkLAN: function(succ, error) {
uni.getNetworkType({ uni.getNetworkType({
success: (res) => { success: (res) => {
const networkType = res.networkType; let networkType = res.networkType;
// 判断网络是否连接 // 判断网络是否连接
@ -182,7 +183,7 @@ export default {
} }
// 定义格式化映射 // 定义格式化映射
const formatMap = { let formatMap = {
'yyyy': date.getFullYear(), 'yyyy': date.getFullYear(),
'MM': String(date.getMonth() + 1).padStart(2, '0'), 'MM': String(date.getMonth() + 1).padStart(2, '0'),
'dd': String(date.getDate()).padStart(2, '0'), 'dd': String(date.getDate()).padStart(2, '0'),
@ -203,15 +204,15 @@ export default {
return formatMap[match]; return formatMap[match];
}); });
}, },
getdeviceShareId(id) {//获取设备分享信息 getdeviceShareId(id) { //获取设备分享信息
return request({ return request({
url: `/app/deviceShare/${id}`, url: `/app/deviceShare/${id}`,
method: 'get', method: 'get',
}) })
}, },
getPermissions(type) { getPermissions(type) {
if (!type) { if (!type) {
type='6170'; type = '6170';
} }
let array = [{ let array = [{
value: "1", value: "1",
@ -222,7 +223,7 @@ export default {
{ {
value: "2", value: "2",
label: "激光模式", label: "激光模式",
checked: false, checked: false,
type: ['210', '6170'] type: ['210', '6170']
}, },
{ {
@ -260,53 +261,106 @@ export default {
type: ['670'] type: ['670']
} }
] ]
let arr=[]; let arr = [];
for (let i = 0; i < array.length; i++) { for (let i = 0; i < array.length; i++) {
let item = array[i]; let item = array[i];
if(!item){ if (!item) {
continue; continue;
} }
if(!item.type){ if (!item.type) {
continue; continue;
} }
let typeContais=item.type.find(v=>{ let typeContais = item.type.find(v => {
return v.includes(type); return v.includes(type);
}); });
if(typeContais){ if (typeContais) {
let json={}; let json = {};
Object.assign(json,item); Object.assign(json, item);
arr.push(json); arr.push(json);
} }
} }
return arr; return arr;
}, },
//10进制转换为16进制字符串 //10进制转换为16进制字符串
decimalToHexLittleEndian(num, byteCount,revers) { decimalToHexLittleEndian(num, byteCount, revers) {
// 处理负数(如果需要支持负数,可先转为补码) // 处理负数(如果需要支持负数,可先转为补码)
if (num < 0) { if (num < 0) {
num = 0xFFFFFFFF + num + 1; num = 0xFFFFFFFF + num + 1;
} }
// 转为16进制去除前缀0x转为大写 // 转为16进制去除前缀0x转为大写
let hex = num.toString(16).toUpperCase(); let hex = num.toString(16).toUpperCase();
// 计算需要补充的0的数量确保每个字节占2位 // 计算需要补充的0的数量确保每个字节占2位
let padLength = (byteCount || Math.ceil(hex.length / 2) * 2) - hex.length; let padLength = (byteCount || Math.ceil(hex.length / 2) * 2) - hex.length;
if (padLength > 0) { if (padLength > 0) {
hex = '0'.repeat(padLength) + hex; hex = '0'.repeat(padLength) + hex;
} }
// 分割为字节数组每2位一个字节 // 分割为字节数组每2位一个字节
const bytes = []; let bytes = [];
for (let i = 0; i < hex.length; i += 2) { for (let i = 0; i < hex.length; i += 2) {
bytes.push(hex.substr(i, 2)); bytes.push(hex.substr(i, 2));
} }
// 是否反转字节顺序(低位在前)并拼接 // 是否反转字节顺序(低位在前)并拼接
if(revers){ if (revers) {
return bytes.reverse().join(''); 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); // 核心问题!
}
);
});
},
} }