diff --git a/App.vue b/App.vue
index edb4820..eb826f1 100644
--- a/App.vue
+++ b/App.vue
@@ -3,7 +3,7 @@
import upgrade from '@/utils/update.js'
export default {
- onLaunch: function() {
+ onLaunch: function() {
//以下代码仅在开发时使用,否则会出现不可预知的问题。
//清除登陆之外的所有信息;
// let store=uni.getStorageInfoSync();
@@ -28,24 +28,29 @@
// });
// 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 @@
+ 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");
+ }
+
\ No newline at end of file
diff --git a/manifest.json b/manifest.json
index 12cf937..282ed38 100644
--- a/manifest.json
+++ b/manifest.json
@@ -132,7 +132,7 @@
"quickapp" : {},
/* 小程序特有相关 */
"mp-weixin" : {
- "appid" : "",
+ "appid" : "wxe16dcf57e925a6b5",
"setting" : {
"urlCheck" : false
},
diff --git a/pages.json b/pages.json
index 96309dc..4498b63 100644
--- a/pages.json
+++ b/pages.json
@@ -263,12 +263,66 @@
"navigationBarTitleText": "BJQ6331"
}
},
+
{
- "path": "pages/6331/AudioManager",
+ "path": "pages/4877/BJQ4877",
"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",
"style": {
diff --git a/pages/100/HBY100.vue b/pages/100/HBY100.vue
index 7744731..4dcc609 100644
--- a/pages/100/HBY100.vue
+++ b/pages/100/HBY100.vue
@@ -1,9 +1,9 @@
-
-
+
+
+
@@ -16,196 +16,221 @@
- {{formData.xuhang}}
- 续航时间
+ {{formData.sta_system?dic.sta_system[formData.sta_system]:"" }}
+ 设备状态
-
- 蓝牙名称
- {{formData.blename}}
-
+
设备名称
- {{formData.deviceName}}
+ {{device.deviceName}}
+
+
+ Mac地址
+ {{device.deviceMac}}
+
+
+ 蓝牙名称
+ {{device.bluetoothName}}
蓝牙状态
{{formData.bleStatu?'已连接':'未连接'}}
+
+
+
+
+
+ {{formData.sta_SOSType===1?'报警中':'强制报警'}}
+
+ 解除
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{item.name}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 语音播报
+
+
+
+
+
+
+
+
+
+
+ 播放语音
+
+
+
+
+
+
+
+
+
+ 语音管理
+
+
+
+
+
- SOS
-
-
-
+ 警示灯
+
-
+
-
-
+
+
+
- {{item['text']}}
+ {{item.name}}
+
+
+
-
-
diff --git a/pages/6331/BJQ6331.vue b/pages/6331/BJQ6331.vue
index 8a5fcc9..300a0c4 100644
--- a/pages/6331/BJQ6331.vue
+++ b/pages/6331/BJQ6331.vue
@@ -1,8 +1,8 @@
-
-
+
+
@@ -22,15 +22,19 @@
-
+
+ 设备名称
+ {{device.deviceName}}
+
+
+ Mac地址
+ {{device.deviceMac}}
+
蓝牙名称
- {{formData.blename}}
-
-
- 设备名称
- {{formData.deviceName}}
+ {{device.bluetoothName}}
+
蓝牙状态
{{formData.bleStatu?'已连接':'未连接'}}
@@ -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 => {
diff --git a/pages/650/HBY650.vue b/pages/650/HBY650.vue
index 641c8a3..62eea59 100644
--- a/pages/650/HBY650.vue
+++ b/pages/650/HBY650.vue
@@ -1,8 +1,8 @@
-
-
+
+
@@ -24,11 +24,15 @@
蓝牙名称
- {{formData.blename}}
+ {{device.bluetoothName}}
+
+
+ Mac地址
+ {{device.deviceMac}}
设备名称
- {{formData.deviceName}}
+ {{device.deviceName}}
蓝牙状态
@@ -40,14 +44,14 @@
-
+
警告!环境存在漏电电源!
-
-
-
-
-
+
+
+
+
+
@@ -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 => {
diff --git a/pages/670/HBY670.vue b/pages/670/HBY670.vue
index fed16ce..6374408 100644
--- a/pages/670/HBY670.vue
+++ b/pages/670/HBY670.vue
@@ -2,10 +2,12 @@
-
+
+
+
-
-
+
+
@@ -25,13 +27,22 @@
+
+ 设备名称
+ {{device.deviceName}}
+
设备IMEI
{{device.deviceImei}}
+
- 设备名称
- {{device.deviceName}}
+ Mac地址
+ {{device.deviceMac}}
+
+
+ 蓝牙名称
+ {{device.bluetoothName}}
蓝牙状态
@@ -69,17 +80,17 @@
-
+
警告!设备静止报警中!
-
-
-
-
-
+
+
+
+
+
-
设备强制报警中!
@@ -378,6 +389,7 @@
bleLinkCnt: 0
},
formData: {
+ img:'/static/images/common/HBY670.png',
battary: "", //电量
xuhang: "", //续航
imei: "", //imei
@@ -514,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];
}
}
diff --git a/pages/7305/BJQ7305.vue b/pages/7305/BJQ7305.vue
index 47c2e16..5c92671 100644
--- a/pages/7305/BJQ7305.vue
+++ b/pages/7305/BJQ7305.vue
@@ -1,1945 +1,1771 @@
-
-
-
-
-
-
-
-
-
-
- {{formData.battary}}%
- 电量
-
-
-
-
-
- {{formData.xuhang}}
- 续航时间
-
-
-
-
-
-
- 蓝牙名称
- {{formData.blename}}
-
-
- 设备名称
- {{formData.deviceName}}
-
-
- 充电状态
- {{formData.statu}}
-
-
- 蓝牙状态
- {{formData.bleStatu?'已连接':'未连接'}}
-
-
-
-
- 灯光亮度
- {{formData.liangDu}}%
-
-
-
-
-
-
-
-
-
-
-
-
-
- 主灯模式
- {{getMode}}
-
-
-
-
-
-
-
-
- 开机画面
- 上传
-
-
-
-
-
-
- 人员信息登记
- 发送
-
-
-
-
-
- 单位:
-
-
-
- 部门:
-
-
-
- 姓名:
-
-
-
-
-
- 产品信息
-
-
-
- 产品参数
-
-
-
- 操作说明
-
-
-
- 操作视频
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/pages/common/addBLE/LinkBle.vue b/pages/common/addBLE/LinkBle.vue
index b3d95a3..9977b67 100644
--- a/pages/common/addBLE/LinkBle.vue
+++ b/pages/common/addBLE/LinkBle.vue
@@ -6,21 +6,21 @@
- 蓝牙名:{{device.name}}
+ 蓝牙名:{{serverDevice?serverDevice['bluetoothName']: device.name}}
状态:{{deviceStatu}}
- 设备名:{{device.deviceName}}
+ 设备名:{{serverDevice?serverDevice['deviceName']:device.deviceName}}
- 设备Mac:{{device.macAddress}}
+ 设备Mac:{{serverDevice?serverDevice['deviceMac']:device.macAddress}}
- 设备IMEI:{{device.imei}}
+ 设备IMEI:{{serverDevice?serverDevice['deviceImei']:device.imei}}
-
+
{{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();
}
@@ -297,21 +311,21 @@
},
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;
diff --git a/pages/common/audioManager/AudioList.vue b/pages/common/audioManager/AudioList.vue
new file mode 100644
index 0000000..21f05f1
--- /dev/null
+++ b/pages/common/audioManager/AudioList.vue
@@ -0,0 +1,1237 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{index+1}}:{{ item.name }}
+
+ {{item.createTime}}
+ {{item.time}}秒
+
+
+
+
+
+ {{item.isApply ?'使用中':'使用'}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/common/audioManager/Recording.vue b/pages/common/audioManager/Recording.vue
new file mode 100644
index 0000000..5a283c6
--- /dev/null
+++ b/pages/common/audioManager/Recording.vue
@@ -0,0 +1,1557 @@
+
+
+
+
+
+
+ 导入文档
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{getFormatSeconds(cEdit.currTime)}}
+
+
+ {{getFormatSeconds(cEdit.time)}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 保存
+ 取消
+
+
+
+
+
+
+ 点击下方红色录制按钮开始录音,吐字清晰,语句流畅
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/common/index/index.vue b/pages/common/index/index.vue
index f5777b8..3330da0 100644
--- a/pages/common/index/index.vue
+++ b/pages/common/index/index.vue
@@ -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,
@@ -541,10 +586,10 @@
// 列表跳转
handleFile(item) {
let url = item.detailPageUrl;
-
+
// url="/pages/6331/BJQ6331";
-
-
+
+
uni.navigateTo({
url: url,
success: (res) => {
diff --git a/static/images/100/light.png b/static/images/100/light.png
new file mode 100644
index 0000000..b4e4fad
Binary files /dev/null and b/static/images/100/light.png differ
diff --git a/static/images/100/lightActive.png b/static/images/100/lightActive.png
new file mode 100644
index 0000000..016b55b
Binary files /dev/null and b/static/images/100/lightActive.png differ
diff --git a/static/images/100/record.png b/static/images/100/record.png
new file mode 100644
index 0000000..b3ec5d5
Binary files /dev/null and b/static/images/100/record.png differ
diff --git a/static/images/100/txtToAudio.png b/static/images/100/txtToAudio.png
new file mode 100644
index 0000000..10e7b5d
Binary files /dev/null and b/static/images/100/txtToAudio.png differ
diff --git a/static/images/100/upload.png b/static/images/100/upload.png
new file mode 100644
index 0000000..62aa192
Binary files /dev/null and b/static/images/100/upload.png differ
diff --git a/static/images/100/volume.png b/static/images/100/volume.png
new file mode 100644
index 0000000..7d51a10
Binary files /dev/null and b/static/images/100/volume.png differ
diff --git a/static/images/4877/4877equip.png b/static/images/common/BJQ4877.png
similarity index 100%
rename from static/images/4877/4877equip.png
rename to static/images/common/BJQ4877.png
diff --git a/static/images/common/BJQ6331.png b/static/images/common/BJQ6331.png
new file mode 100644
index 0000000..29d8b22
Binary files /dev/null and b/static/images/common/BJQ6331.png differ
diff --git a/static/images/common/HBY100J.png b/static/images/common/HBY100J.png
new file mode 100644
index 0000000..f763f4b
Binary files /dev/null and b/static/images/common/HBY100J.png differ
diff --git a/static/images/common/HBY6155.png b/static/images/common/HBY6155.png
new file mode 100644
index 0000000..2835c0c
Binary files /dev/null and b/static/images/common/HBY6155.png differ
diff --git a/static/images/common/HBY650.png b/static/images/common/HBY650.png
new file mode 100644
index 0000000..4f866fd
Binary files /dev/null and b/static/images/common/HBY650.png differ
diff --git a/static/images/common/HBY670.png b/static/images/common/HBY670.png
new file mode 100644
index 0000000..8f83e53
Binary files /dev/null and b/static/images/common/HBY670.png differ
diff --git a/static/images/common/gou.png b/static/images/common/gou.png
new file mode 100644
index 0000000..6486254
Binary files /dev/null and b/static/images/common/gou.png differ
diff --git a/static/images/common/next.png b/static/images/common/next.png
new file mode 100644
index 0000000..e4fd98b
Binary files /dev/null and b/static/images/common/next.png differ
diff --git a/static/images/common/pause.png b/static/images/common/pause.png
new file mode 100644
index 0000000..0b24061
Binary files /dev/null and b/static/images/common/pause.png differ
diff --git a/static/images/common/pauseActive.png b/static/images/common/pauseActive.png
new file mode 100644
index 0000000..cd9ecd4
Binary files /dev/null and b/static/images/common/pauseActive.png differ
diff --git a/static/images/common/play.png b/static/images/common/play.png
new file mode 100644
index 0000000..2864745
Binary files /dev/null and b/static/images/common/play.png differ
diff --git a/static/images/common/prev.png b/static/images/common/prev.png
new file mode 100644
index 0000000..0f8454e
Binary files /dev/null and b/static/images/common/prev.png differ
diff --git a/static/images/common/uploadCloud.png b/static/images/common/uploadCloud.png
new file mode 100644
index 0000000..f5a06a3
Binary files /dev/null and b/static/images/common/uploadCloud.png differ
diff --git a/uni_modules/xe-upload/changelog.md b/uni_modules/xe-upload/changelog.md
new file mode 100644
index 0000000..386ab44
--- /dev/null
+++ b/uni_modules/xe-upload/changelog.md
@@ -0,0 +1,7 @@
+## 1.0.2(2023-11-01)
+更换App端转换本地链接的方法;
+添加App端文件拓展名过滤;
+## 1.0.1(2023-09-04)
+优化部分逻辑
+## 1.0.0(2023-09-03)
+支持图片、视频选择上传;H5、微信小程序,App支持文件选择上传
diff --git a/uni_modules/xe-upload/components/xe-upload/xe-upload.vue b/uni_modules/xe-upload/components/xe-upload/xe-upload.vue
new file mode 100644
index 0000000..5480de4
--- /dev/null
+++ b/uni_modules/xe-upload/components/xe-upload/xe-upload.vue
@@ -0,0 +1,285 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/uni_modules/xe-upload/package.json b/uni_modules/xe-upload/package.json
new file mode 100644
index 0000000..46f27a7
--- /dev/null
+++ b/uni_modules/xe-upload/package.json
@@ -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"
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/uni_modules/xe-upload/readme.md b/uni_modules/xe-upload/readme.md
new file mode 100644
index 0000000..7f63c5a
--- /dev/null
+++ b/uni_modules/xe-upload/readme.md
@@ -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、具体使用可下载示例项目运行查看完整示例
diff --git a/uni_modules/xe-upload/tools/apis.js b/uni_modules/xe-upload/tools/apis.js
new file mode 100644
index 0000000..5fc1371
--- /dev/null
+++ b/uni_modules/xe-upload/tools/apis.js
@@ -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);
+ });
+};
diff --git a/uni_modules/xe-upload/tools/tools.js b/uni_modules/xe-upload/tools/tools.js
new file mode 100644
index 0000000..27d2fa6
--- /dev/null
+++ b/uni_modules/xe-upload/tools/tools.js
@@ -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);
+ });
+ });
+};
diff --git a/utils/BleHelper.js b/utils/BleHelper.js
index bba40b3..6c77356 100644
--- a/utils/BleHelper.js
+++ b/utils/BleHelper.js
@@ -511,9 +511,11 @@ class BleHelper {
uni.onBluetoothAdapterStateChange((state) => {
// console.log('蓝牙状态发生变化:' + JSON.stringify(state));
+ this.data.discovering = state.discovering;
+
if (this.data.available !== state.available) {
this.data.available = state.available;
- this.data.discovering = state.discovering;
+
if (this.data.available && this.data
.isOpenBlue) { //蓝牙状态再次可用,重连所有设备
@@ -792,7 +794,7 @@ class BleHelper {
}
try {
- console.log("11111");
+ // console.log("11111");
let recData = {
deviceId: receive.deviceId,
serviceId: receive.serviceId,
@@ -801,7 +803,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) {
@@ -875,10 +877,7 @@ class BleHelper {
return Promise.resolve();
}
return new Promise((resolve, reject) => {
- this.data.available = false;
- this.data.discovering = false;
- this.data.isOpenBlue = false;
- this.data.searchList = [];
+
this.StopSearch();
@@ -887,15 +886,19 @@ class BleHelper {
uni.closeBluetoothAdapter({
success: () => {
// console.log("蓝牙模块已关闭");
-
+ this.data.available = false;
+ this.data.discovering = false;
+ this.data.isOpenBlue = false;
+ this.data.searchList = [];
+ resolve();
},
fail: (ex) => {
console.error('无法关闭蓝牙模块:', ex);
ex = this.getError(ex);
-
+ reject(ex);
},
complete: () => {
- resolve();
+
}
});
@@ -968,7 +971,8 @@ class BleHelper {
//停止搜索
StopSearch() {
- if (this.data.platform == 'web') {
+ if (this.data.platform == 'web' || !this.data.discovering) {
+ console.error("web平台或当前没有搜索,直接返回");
return Promise.resolve();
}
let p1 = new Promise((resolve, reject) => {
@@ -1485,7 +1489,9 @@ class BleHelper {
// 处理 MTU 设置
if (plus.os.name === 'Android') {
- this.setMtu(deviceId);
+ this.setMtu(deviceId).catch(ex=>{
+ console.error("mtu设置失败=",ex);
+ });
}
resolve(true);
@@ -1593,12 +1599,11 @@ class BleHelper {
_succ(mtuRes);
},
fail: (ex) => {
- console.error(
- "mtu设置失败", ex);
+
ex = this.getError(ex);
_err(
ex
- ); // MTU设置失败不影响连接成功
+ );
},
complete() {
console.log("设置mtu完毕");
diff --git a/utils/BleReceive.js b/utils/BleReceive.js
index 5394ef8..6f558ac 100644
--- a/utils/BleReceive.js
+++ b/utils/BleReceive.js
@@ -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)
};
}
@@ -47,6 +47,7 @@ class BleReceive {
let devKey = f.device.detailPageUrl ? f.device.detailPageUrl.replace(/\//g, '').toLowerCase() : '';
console.log("查找handler - detailPageUrl:", f.device.detailPageUrl, "转换后:", devKey);
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();
if (key == devKey) {
handler = this.HandlerMap[keys[index]];
@@ -153,8 +154,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) {
@@ -321,8 +322,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) { //有静止报警
@@ -474,8 +475,11 @@ class BleReceive {
let recCnt = recArr.find(v => {
- return v.key.replace(/\//g, '').toLowerCase() === f.device.detailPageUrl.replace(
- /\//g, '').toLowerCase();
+ return v.key.replace(/\//g, "").toLowerCase() === f.device.detailPageUrl.replaceAll(
+ '/', '').toLowerCase();
+
+
+
});
if (!recCnt) {
if (batteryLevel <= 20) {
@@ -503,12 +507,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) {
@@ -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;
+
+ }
+
+
}
diff --git a/utils/Common.js b/utils/Common.js
index 5fa6c55..5b95b4d 100644
--- a/utils/Common.js
+++ b/utils/Common.js
@@ -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",
@@ -222,7 +223,7 @@ export default {
{
value: "2",
label: "激光模式",
- checked: false,
+ checked: false,
type: ['210', '6170']
},
{
@@ -260,53 +261,106 @@ export default {
type: ['670']
}
]
-
- 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;
- }
-
- // 转为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;
- }
-
- // 分割为字节数组(每2位一个字节)
- const bytes = [];
- for (let i = 0; i < hex.length; i += 2) {
- bytes.push(hex.substr(i, 2));
- }
-
- // 是否反转字节顺序(低位在前)并拼接
- if(revers){
+ decimalToHexLittleEndian(num, byteCount, revers) {
+ // 处理负数(如果需要支持负数,可先转为补码)
+ if (num < 0) {
+ num = 0xFFFFFFFF + num + 1;
+ }
+
+ // 转为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;
+ }
+
+ // 分割为字节数组(每2位一个字节)
+ let bytes = [];
+ for (let i = 0; i < hex.length; i += 2) {
+ bytes.push(hex.substr(i, 2));
+ }
+
+ // 是否反转字节顺序(低位在前)并拼接
+ 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); // 核心问题!
+ }
+ );
+ });
+ },
+
}
\ No newline at end of file