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/pages.json b/pages.json
index 2382871..c89a492 100644
--- a/pages.json
+++ b/pages.json
@@ -252,34 +252,71 @@
}
},
{
- "path" : "pages/6331/BJQ6331",
- "style" :
- {
- "navigationBarTitleText" : "BJQ6331"
+ "path": "pages/6331/BJQ6331",
+ "style": {
+ "navigationBarTitleText": "BJQ6331"
+ }
+ },
+
+ {
+ "path": "pages/4877/BJQ4877",
+ "style": {
+ "navigationBarTitleText": "BJQ 4877"
}
},
{
- "path" : "pages/6331/AudioManager",
- "style" :
- {
- "navigationBarTitleText" : "语音管理"
+ "path": "pages/100/HBY100",
+ "style": {
+ "navigationBarTitleText": "HBY 100"
}
},
{
- "path" : "pages/4877/BJQ4877",
- "style" :
- {
- "navigationBarTitleText" : "BJQ 4877"
+ "path": "pages/common/audioManager/AudioList",
+ "style": {
+ "navigationBarTitleText": "语音管理",
+ "disableScroll":true,
+ "app-plus": {
+ "bounce":"none",
+ "titleNView": {
+ "buttons": [
+
+ {
+ "color": "#00000000",
+ "text": "删",
+ "fontSize": "10",
+ "float": "right",
+ "fontWeight": "normal"
+
+ },
+ {
+ "color": "#ffffffde",
+ "text": "编辑",
+ "fontSize": "14",
+ "float": "right",
+ "fontWeight": "normal"
+
+ },
+ {
+ "color": "#ffffffde",
+ "text": "取消",
+ "fontSize": "14",
+ "float": "right",
+ "fontWeight": "normal"
+
+ }
+ ]
+ }
+ }
}
},
{
- "path" : "pages/100/HBY100",
+ "path" : "pages/common/audioManager/Recording",
"style" :
{
- "navigationBarTitleText" : "HBY 100"
+ "navigationBarTitleText" : "录制语音"
}
}
-
+
],
"tabBar": {
diff --git a/pages/100/HBY100.vue b/pages/100/HBY100.vue
index 56849d9..334b9ca 100644
--- a/pages/100/HBY100.vue
+++ b/pages/100/HBY100.vue
@@ -1,9 +1,9 @@
-
-
+
+
+
@@ -16,18 +16,22 @@
- {{formData.xuhang}}
- 续航时间
+ {{formData.sta_system?dic.sta_system[formData.sta_system]:"" }}
+ 设备状态
-
+
设备名称
{{device.deviceName}}
+
+ Mac地址
+ {{device.deviceMac}}
+
蓝牙名称
{{device.bluetoothName}}
@@ -36,149 +40,170 @@
蓝牙状态
{{formData.bleStatu?'已连接':'未连接'}}
+
+
+
+
+
+ {{formData.sta_SOSType===1?'报警中':'强制报警'}}
+
+ 解除
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{item.name}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 语音播报
+
+
+
+
+
+
+
+
+
+
+ 播放语音
+
+
+
+
+
+
+
+
+
+ 语音管理
+
+
+
+
+
- SOS
-
-
-
+ 警示灯
+
-
+
-
-
+
+
+
- {{item['text']}}
+ {{item.name}}
+
-
-
-
- 单色配组
-
-
-
-
-
-
-
-
-
-
-
-
-
- {{item['text']}}
-
-
-
-
-
-
-
-
-
- 箭头模式
-
- 箭头朝向
+
+
-
-
-
+
-
-
-
-
-
-
-
-
- 红色朝前
-
-
-
-
-
-
-
-
-
- 绿色朝后
-
+
+
-
+
+
-
-
-
- 双向频闪
+
+
-
-
-
+
+
-
-
-
-
-
-
-
-
- 红色双向
-
-
-
-
-
-
-
-
-
- 绿色双向
-
+
+
+
-
-
产品信息
@@ -236,17 +261,22 @@
baseURL
} from '../../utils/request';
- import usrApi from '@/api/670/HBY670.js'
- const pagePath = "/pages/4877/BJQ4877";
+ import Common from '@/utils/Common.js'
+ const pagePath = "/pages/100/HBY100";
var ble = null;
var these = null;
var recei = null;
var interval = null;
+ var brightnessTimer = null;
+ var volumeTimer = null;
+ var hzTimer = null;
export default {
data() {
return {
Status: {
+ curr: 0,
+ total: 0,
pageHide: false,
Pop: {
showPop: false, //是否显示弹窗
@@ -272,18 +302,9 @@
show: false,
showHeader: true,
menuItems: [{
- text: '强光',
- icon: '/static/images/6155/DeviceDetail/qiang.png'
- },
- {
- text: '弱光',
- icon: '/static/images/6155/DeviceDetail/ruo.png'
- },
- {
- text: '爆闪',
- icon: '/static/images/6155/DeviceDetail/shan.png'
- }
- ],
+ text: '强光',
+ icon: '/static/images/6155/DeviceDetail/qiang.png'
+ }],
activeIndex: -1,
bgColor: '#2a2a2a',
itemBgColor: '#3a3a3a',
@@ -304,10 +325,10 @@
maskBgColor: '#00000066',
showClose: false
},
- usrToggle: true,
+ usrToggle: false,
},
formData: {
- img: '/static/images/4877/4877equip.png',
+ img: '/static/images/common/HBY100J.png',
sta_battery: '',
xuhang: '',
blename: '',
@@ -319,44 +340,114 @@
bleStatu: false,
sta_address: '',
sta_VoiceType: '',
- sta_VoiceVolume: '',
+ sta_VoiceVolume: 1,
sta_LightType: '',
- sta_LightFreq: '',
- sta_LightDimmer: '',
- sta_system: ''
+ sta_LightFreq: 0.5,
+ sta_LightDimmer: 10,
+ sta_system: '',
+ warnTime: 0,
+ sta_SOSType: 0
},
dic: {
sta_VoiceType: {
- "0": '关闭',
- "1": '消防',
- "2": '公安',
- "3": '交警',
- "4": '市政',
- "5": '应急',
- "6": '医疗',
- "7": '铁道',
- "8": 'app语音',
+ "1": {
+ key: "1",
+ name: '消防',
+ show: true
+ },
+ "2": {
+ key: "2",
+ name: '公安',
+ show: true
+ },
+ "3": {
+ key: "3",
+ name: '交警',
+ show: true
+ },
+ "4": {
+ key: "4",
+ name: '市政',
+ show: true
+ },
+ "5": {
+ key: "5",
+ name: '应急',
+ show: true
+ },
+ "6": {
+ key: "6",
+ name: '医疗',
+ show: true
+ },
+ "7": {
+ key: "7",
+ name: '铁道',
+ show: true
+ },
+ "8": {
+ key: "8",
+ name: 'app语音',
+ show: false
+ },
+ "0": {
+ key: "0",
+ name: '关闭',
+ show: false
+ }
},
-
- sta_LightType: {
- "0": '关闭',
- "1": '红蓝闪',
- "2": '红闪',
- "3": '黄闪',
- "4": '蓝闪',
- "5": '红流水',
- "6": '黄流水',
- "7": '蓝流水'
- },
-
-
+
+ sta_LightType: [{
+ key: "1",
+ name: '红蓝',
+ show: true
+ },
+ {
+ key: "2",
+ name: '红闪',
+ show: true
+ },
+ {
+ key: "3",
+ name: '黄闪',
+ show: true
+ },
+ {
+ key: "4",
+ name: '蓝闪',
+ show: true
+ },
+ {
+ key: "5",
+ name: '红流水',
+ show: true
+ },
+ {
+ key: "6",
+ name: '黄流水',
+ show: true
+ },
+ {
+ key: "7",
+ name: '蓝流水',
+ show: true
+ },
+ {
+ key: "0",
+ name: '关闭',
+ show: false
+ }
+ ],
+
+
sta_system: {
"0": '关机',
"1": '仅充电',
"2": '开机未充电',
- "3": '开机且充电'
+ "3": '开机且充电',
+ "": ""
}
-
+
},
device: {
id: "",
@@ -377,6 +468,11 @@
detailPageUrl: "/pages/650/HBY650",
showConfirm: false
},
+
+ audioData: {
+ packetCtn: 0,
+ hexs: []
+ }
}
},
@@ -429,7 +525,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 => {
@@ -452,48 +548,394 @@
},
methods: {
- ArrowSet(val) {
+ audioManager() {
+
+ uni.navigateTo({
+ url: '/pages/common/audioManager/AudioList',
+ events: {
+ audioApply: function(id) {
+ //应用某个语音时,将数据发送给设备
+ console.log("准备发送数据", id);
+ showLoading(these, {
+ text: '准备发送数据'
+ });
+
+ these.audioData.hexs = uni.getStorageSync(Common.pcmStorageKey + "_" + id);
+ console.log("hexs.length=", these.audioData.hexs.length)
+ these.HoldYouHand();
+ }
+ },
+ success(res) {
+ let channel = res.eventChannel;
+ let f = these.getDevice();
+ channel.emit("deviceData", {
+ ble: f,
+ device: these.device
+ });
+ }
+ });
+ },
+ sendHex(repeatNo) {
let f = this.getDevice();
+ var task = () => {
+ try {
+ console.log("开始发送数据");
+ if (!(this.audioData.hexs.length > 0 && this.audioData.packetCtn > 0)) {
+ console.log("没有数据发送");
+ uni.showModal({
+ title: '提示',
+ content: '没有数据发送'
+ })
+ return;
+ }
+ console.log("11111");
+ let curr = repeatNo ? repeatNo : 1;
+ let total = repeatNo ? repeatNo : this.audioData.packetCtn;
+ let packetSize = 482;
+ this.Status.curr = 0;
+ this.Status.total = total;
+ console.log("131212122");
+ let sendNextPacket = () => {
+ try {
+ if (curr > total) {
+ console.log("发送完成1111");
+ if (!repeatNo) {
+
+ setTimeout(() => {
+ let cmd = {
+ ins_VoiceDate: "end"
+ };
+ ble.sendString(f.deviceId, cmd).then(res => {
+
+ updateLoading(these, {
+ text: "发送完成,等待设备响应"
+ });
+ }).catch(er => {
+ hideLoading(these);
+ uni.showModal({
+ title: '错误',
+ content: er.msg
+ });
+ });
+ }, 2000);
+
+
+ } else {
+ updateLoading(these, {
+ text: "补发完成,等待设备响应"
+ });
+
+ }
+
+ return;
+ }
+ let start = (curr - 1) * packetSize;
+ let end = curr * packetSize;
+
+ let orderNo = Common.decimalToHexLittleEndian(curr, 4, true);
+ let json = "ins_VoiceDate:" + orderNo;
+ let pcmData = this.audioData.hexs.slice(start, end);
+ for (var p = 0; p < pcmData.length; p++) {
+ json += pcmData[p];
+ }
+ // console.log("准备发送数据:", json)
+ let header = [0x69, 0x6E, 0x73, 0x5F, 0x56, 0x6F, 0x69, 0x63, 0x65, 0x44, 0x61,
+ 0x74, 0x65, 0x3A
+ ];
+
+ let bufferSize = pcmData.length + 16;
+ let buffer = new ArrayBuffer(bufferSize);
+ let dataView = new DataView(buffer);
+
+
+ for (let i = 0; i < header.length; i++) {
+ dataView.setUint8(i, header[i]);
+ }
+ console.log("curr=" + curr + "orderNo=", orderNo);
+ dataView.setUint8(14, '0x' + orderNo.substring(0, 2));
+ dataView.setUint8(15, '0x' + orderNo.substring(2, 4));
+
+ for (let i = 0; i < pcmData.length; i++) {
+ dataView.setUint8(16 + i, '0x' + pcmData[i]);
+ }
+
+ let intval = 20;
+ if (plus.os.name == 'iOS') {
+ intval += 12;
+ }
+
+ ble.sendData(f.deviceId, buffer, null, null, intval)
+ .then(res => {
+ if (repeatNo) {
+
+
+ updateLoading(these, {
+ text: "补发成功"
+ });
+ } else {
+
+ updateLoading(these, {
+ text: "发送成功," + curr + "/" + total
+ });
+ }
+
+ console.log("发送成功," + curr + "/" + total);
+ this.Status.curr = curr;
+ curr++;
+
+ setTimeout(sendNextPacket, intval);
+ }).catch(ex => {
+ if (ex.code == '10007') {
+ // console.error("发送第" + curr + "包失败");
+ setTimeout(sendNextPacket, intval);
+ } else {
+ // console.error("发送第" + curr + "包失败", ex);
+ hideLoading(this);
+
+ uni.showModal({
+ title: '错误',
+ content: ex.msg
+ });
+ }
+ });
+ } catch (errr) {
+ console.error('errr=', errr)
+ }
+ }
+
+ sendNextPacket();
+ } catch (arg) {
+ console.error("arg=", arg)
+ }
+ }
+
+ setTimeout(task, 0);
+ },
+ HoldYouHand() {
+
+ console.log("this.audioData.hexs=", this.audioData.hexs);
+ console.log("this.audioData.hexs.length=", this.audioData.hexs.length);
+ let cnt = Math.ceil(this.audioData.hexs.length / 482);
+ console.log("cnt=", cnt)
+
+ this.audioData.packetCtn = cnt;
+ let json = {
+ ins_VoiceDate: [this.audioData.packetCtn]
+ }
+
+
+ let f = this.getDevice();
+ ble.sendString(f.deviceId, json).then(res => {
+ updateLoading(these, {
+ text: "握手成功,等待设备响应"
+ });
+ }).catch(ex => {
+ this.showMsg(ex.msg);
+ });
+ },
+
+
+ //频率
+ onFreqChanging(e) {
+ let f = this.getDevice();
+ // #ifdef APP-PLUS
if (!f) {
this.showBleUnConnect();
return;
}
- if (this.formData.sta_ArrowType === val) {
- this.formData.sta_ArrowType = 'arrow_off';
- } else {
- this.formData.sta_ArrowType = val;
+ // #endif
+ // #ifdef H5
+ f = {
+ deviceId: '12345'
+ }
+ // #endif
+ this.formData.sta_LightFreq = e.detail.value;
+
+ // 清除之前的定时器
+ if (hzTimer) {
+ clearTimeout(hzTimer);
}
- var json = {
- ins_ArrowType: this.formData.sta_ArrowType
- }
- json = JSON.stringify(json);
- ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30)
- .catch(ex => {
- this.showMsg(ex.msg);
+ // 设置新的定时器,控制发送频率
+ hzTimer = setTimeout(() => {
+
+
+
+ let arr = (this.formData.sta_LightFreq + '').split('.');
+
+ let json = {
+ ins_LightFreq: [parseInt(arr[0]), parseInt(arr.length > 1 ? arr[1] : '0')]
+ }
+
+
+ ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
+ these.setBleFormData();
+ }).catch(ex => {
+ uni.showModal({
+ title: '错误',
+ content: ex.msg
+ })
});
+
+
+
+ }, 100);
},
- groupSetting(item, index) {
+ //音量
+ onVolumeChanging(e) {
let f = this.getDevice();
+ // #ifdef APP-PLUS
if (!f) {
this.showBleUnConnect();
return;
}
- if (this.formData.sta_GroupType === item.val) {
- this.formData.sta_GroupType = '';
- } else {
- this.formData.sta_GroupType = item.val;
+ // #endif
+ // #ifdef H5
+ f = {
+ deviceId: '12345'
+ }
+ // #endif
+ this.formData.sta_VoiceVolume = e.detail.value;
+
+ // 清除之前的定时器
+ if (volumeTimer) {
+ clearTimeout(volumeTimer);
}
- var json = {
- ins_GroupType: this.formData.sta_GroupType
+ // 设置新的定时器,控制发送频率
+ volumeTimer = setTimeout(() => {
+
+ let json = {
+ ins_VoiceVolume: [e.detail.value]
+ }
+
+ ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
+ these.setBleFormData();
+ }).catch(ex => {
+ uni.showModal({
+ title: '错误',
+ content: ex.msg
+ })
+ });
+
+
+
+ }, 100);
+ },
+ // 亮度调节
+ onBrightnessChanging(e) {
+ let f = this.getDevice();
+ // #ifdef APP-PLUS
+ if (!f) {
+ this.showBleUnConnect();
+ return;
}
- json = JSON.stringify(json);
+ // #endif
+ // #ifdef H5
+ f = {
+ deviceId: '12345'
+ }
+ // #endif
+ this.formData.sta_LightDimmer = e.detail.value;
+
+ // 清除之前的定时器
+ if (brightnessTimer) {
+ clearTimeout(brightnessTimer);
+ }
+
+ // 设置新的定时器,控制发送频率
+ brightnessTimer = setTimeout(() => {
+
+ let json = {
+ ins_LightDimmer: [e.detail.value]
+ }
+
+ ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
+ these.setBleFormData();
+ }).catch(ex => {
+ uni.showModal({
+ title: '错误',
+ content: ex.msg
+ })
+ });
+
+
+
+ }, 100);
+ },
+ lightTypeSet(item, index) {
+ let f = this.getDevice();
+ // #ifdef APP-PLUS
+ if (!f) {
+ this.showBleUnConnect();
+ return;
+ }
+ // #endif
+ // #ifdef H5
+ f = {
+ deviceId: '12345'
+ }
+ // #endif
+ let val = item.key;
+ if (this.formData.sta_LightType === val) {
+ val = '0';
+ }
+
+ let json = {
+ ins_LightType: [parseInt(val)]
+ }
+
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30)
+ .then(res => {
+ this.formData.sta_LightType = val;
+ these.setBleFormData();
+ })
.catch(ex => {
+ uni.showModal({
+ title: '错误',
+ content: ex.msg
+ })
+ });
+
+
+ },
+ setUsrToggle() {
+ this.Status.usrToggle = !this.Status.usrToggle;
+ },
+ openVolume(item, index) {
+ let f = this.getDevice();
+ // #ifdef APP-PLUS
+ if (!f) {
+ this.showBleUnConnect();
+ return;
+ }
+ // #endif
+ // #ifdef H5
+ f = {
+ deviceId: '12345'
+ }
+ // #endif
+ if (!item) {
+ item = this.dic.sta_VoiceType[index];
+ }
+ console.log("item=", item);
+ let val = item.key;
+ if (this.formData.sta_VoiceType === val) {
+ val = '0';
+ }
+ var json = {
+ ins_VoiceType: [parseInt(val)]
+ }
+
+ ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30)
+ .then(res => {
+ this.formData.sta_VoiceType = val;
+ these.setBleFormData();
+ }).catch(ex => {
this.showMsg(ex.msg);
});
},
+
showUnWarn(val) {
this.showPop({
message: '确定解除声光报警模式?',
@@ -501,11 +943,9 @@
borderColor: "#e034344d",
buttonBgColor: "#E03434",
okCallback: () => {
- clearInterval(interval);
- this.sosSetting({
- val: val
- });
+
+ this.sosSetting(val, true);
},
buttonText: "解除",
showCancel: true,
@@ -513,56 +953,77 @@
});
},
- sosSetting(item, index) {
+ sosSetting(item, isOk) {
+ if (item === 0 && this.formData.sta_SOSType === item) {
+ return;
+ }
+
let f = this.getDevice();
+
+ // #ifdef APP-PLUS
if (!f) {
this.showBleUnConnect();
return;
}
+ // #endif
+ // #ifdef H5
+ f = {
+ deviceId: '12345'
+ }
+ // #endif
+
let task = () => {
-
-
var json = {
- ins_SOSType: this.formData.sta_SOSType == item.val ? 'sos_off' : item.val
+ ins_warning: [parseInt(item)]
}
json = JSON.stringify(json);
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
- if (this.formData.sta_SOSType === item.val) {
- this.formData.sta_SOSType = 'sos_off';
+ if (this.formData.sta_SOSType === item) {
+ this.formData.sta_SOSType = 0;
} else {
- this.formData.sta_SOSType = item.val;
+ this.formData.sta_SOSType = item;
}
- if (this.formData.sta_SOSType == 'sos') {
+ if (this.formData.sta_SOSType == 1) {
this.formData.warnTime = 0;
clearInterval(interval);
interval = setInterval(() => {
this.formData.warnTime += 1;
}, 1000)
+ } else {
+ this.formData.warnTime = 0;
+ clearInterval(interval);
}
-
+ this.setBleFormData();
})
.catch(ex => {
this.showMsg(ex.msg);
});
}
- if (item.val === 'sos') {
- this.showPop({
- message: '确定开启声光报警模式?',
- iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
- borderColor: "#e034344d",
- buttonBgColor: "#E03434",
- okCallback: task,
- buttonText: "开启",
- showCancel: true,
- buttonCancelText: '取消'
- });
+
+ if (item === 1) {
+ if (item === this.formData.sta_SOSType && !isOk) {
+ this.showUnWarn(0);
+
+ } else {
+ this.showPop({
+ message: '确定开启强制报警?',
+ iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
+ borderColor: "#e034344d",
+ buttonBgColor: "#E03434",
+ okCallback: task,
+ buttonText: "开启",
+ showCancel: true,
+ buttonCancelText: '取消'
+ });
+ }
+
} else {
- if (index !== undefined && this.formData.sta_SOSType == 'sos') {
- this.showUnWarn(item.val);
+ if (this.formData.sta_SOSType === 1 && !isOk) {
+ this.showUnWarn(item);
} else {
task();
}
@@ -650,43 +1111,15 @@
urls: [img]
})
},
- getWarnStyle(index) {
- let className = "";
- switch (this.formData.warnLevel) {
- case "无预警":
- break;
- case "弱预警":
- if (index <= 1) {
- className = "active";
- }
- break;
- case "中预警":
- if (index <= 3) {
- className = "active";
- }
- break;
- case "强预警":
- if (index <= 4) {
- className = "active";
- }
- break;
- case "非常强预警":
- if (index <= 5) {
- className = "active";
- }
- break;
- }
- return className;
- },
bleValueNotify: function(receive, device, path, recArr) { //订阅消息
if (receive.deviceId !== this.formData.deviceId) {
return;
}
- console.log("收到设备的数据", receive)
+
let json = recei.ReceiveData(receive, device, pagePath, recArr);
-
+ // console.log("收到设备的数据", json)
let key = 'sta_VoiceDate';
if (key in json) {
@@ -694,22 +1127,23 @@
console.log("22222", val)
if (val === 'start') {
//开始发包
-
+ updateLoading(these, {
+ text: "开始发送"
+ });
this.sendHex();
return;
} else if (val === 'finish') {
- uni.showModal({
- title: '提示',
- content: "发送完成"
+ updateLoading(these, {
+ text: "发送成功"
});
+ setTimeout(() => {
+ hideLoading(this);
+ }, 1500)
return;
} else {
//重新发送某一包
-
-
-
if (val > this.audioData.packetCtn) {
return;
@@ -724,17 +1158,14 @@
keys.forEach(key => {
if (key in this.formData) {
- this.formData[key] = json[key];
+ // console.log("key=",key+",value=",json[key]);
+ this.formData[key] = json[key]+"" ;
}
-
-
- })
-
-
-
-
-
-
+ });
+
+ if(this.formData.sta_battery<=20){
+ this.showMsg("设备电量低");
+ }
},
getDevice: function() {
@@ -840,7 +1271,7 @@
}
},
showPop: function(option) {
- hideLoading(this);
+ // hideLoading(this);
let def = {
showPop: true, //是否显示弹窗
popType: 'custom',
@@ -1356,10 +1787,10 @@
.modeSetting {
display: flex;
flex-direction: row;
- flex-wrap: nowrap;
+ flex-wrap: wrap;
align-content: center;
- justify-content: space-around;
align-items: center;
+ justify-content: flex-start;
}
@@ -1370,13 +1801,13 @@
align-content: center;
justify-content: center;
align-items: center;
-
+ width: calc(100% / 3);
+ margin-bottom: 25rpx;
}
.modeSetting .arrow .text {
- margin-top: 15rpx;
- color: rgba(255, 255, 255, 0.6);
+ color: rgba(255, 255, 255, 0.6);
font-family: PingFang SC;
font-size: 24rpx;
font-weight: 400;
@@ -1385,9 +1816,14 @@
}
+ .modeSetting .arrow.active .text {
+ color: rgba(35, 35, 35, 0.87);
+
+ }
+
.modeSetting .arrow .outCircle {
- width: 150rpx;
- height: 150rpx;
+ width: 130rpx;
+ height: 130rpx;
box-sizing: border-box;
display: flex;
flex-direction: row;
@@ -1545,34 +1981,6 @@
width: 50rpx;
}
- .net {
- width: 7rpx;
- background: rgba(255, 255, 255, 0.3);
- }
-
- .net.netone {
- height: 11rpx;
- }
-
- .net.nettwo {
- height: 17rpx;
- }
-
- .net.netsiri {
- height: 23rpx;
- }
-
- .net.netfour {
- height: 29rpx;
- }
-
- .net.netfive {
- height: 35rpx;
- }
-
- .net.active {
- background: #FFFFFF !important;
- }
.marginTop10 {
margin-top: 20rpx;
@@ -1598,4 +2006,103 @@
justify-content: space-between;
align-items: center;
}
+
+ .sosContent {
+ width: 100%;
+ height: 110rpx;
+ display: flex;
+ flex-direction: row;
+ flex-wrap: nowrap;
+ align-content: center;
+ align-items: center;
+ justify-content: space-between;
+ box-sizing: border-box;
+ padding-top: 24rpx;
+ }
+
+ .btnSos {
+ border-radius: 92rpx;
+ height: 100%;
+ color: rgba(255, 255, 255, 0.87);
+ font-family: PingFang SC;
+ font-size: 28rpx;
+ font-weight: 400;
+ line-height: 110rpx;
+ letter-spacing: 0.014rpx;
+ text-align: center;
+
+ }
+
+ .openSos {
+ width: 62%;
+ background: #1a1a1a;
+ color: #e03434;
+ box-sizing: border-box;
+ border: 1rpx solid #e03434;
+ }
+
+ .openSos.active {
+ background: #e03434 !important;
+ color: rgba(255, 255, 255, 0.87) !important;
+ }
+
+
+ .closeSos {
+ width: 32%;
+ background: #1a1a1a;
+ }
+
+ .warn {
+ border-radius: 16rpx;
+ background: #1a1a1a;
+ width: 100%;
+ box-sizing: border-box;
+ margin-top: 25rpx;
+ }
+
+ .warn .header {
+ width: 100%;
+ box-sizing: border-box;
+ padding: 20rpx 25rpx;
+ display: flex;
+ flex-direction: row;
+ flex-wrap: nowrap;
+ align-content: center;
+ align-items: center;
+ justify-content: space-between;
+
+ }
+
+ .paddingTop0 {
+ padding: 0rpx 25rpx !important;
+ }
+
+ .line {
+ width: calc(100% - 50rpx);
+ height: 0rpx;
+ border-bottom: 1rpx solid rgba(255, 255, 255, 0.06);
+ margin: 30rpx 25rpx
+ }
+
+ .sliderTxt {
+ color: rgba(255, 255, 255, 0.6);
+
+ font-family: PingFang SC;
+ font-size: 24rpx;
+ font-weight: 400;
+
+ letter-spacing: 0.07px;
+
+ }
+
+ .sliderVal {
+ color: rgba(174, 214, 0, 1);
+
+ font-family: PingFang SC;
+ font-size: 24rpx;
+ font-weight: 400;
+
+ letter-spacing: 0.07px;
+
+ }
\ No newline at end of file
diff --git a/pages/4877/BJQ4877.vue b/pages/4877/BJQ4877.vue
index 8e37021..6b197bd 100644
--- a/pages/4877/BJQ4877.vue
+++ b/pages/4877/BJQ4877.vue
@@ -1,8 +1,8 @@
-
-
+
@@ -27,6 +27,10 @@
设备名称
{{device.deviceName}}
+
+ Mac地址
+ {{device.deviceMac}}
+
蓝牙名称
{{device.bluetoothName}}
@@ -312,7 +316,7 @@
usrToggle: true,
},
formData: {
- img: '/static/images/4877/4877equip.png',
+ img: '/static/images/common/BJQ4877.png',
sta_PowerPercent: '',
xuhang: '',
blename: '',
@@ -439,7 +443,7 @@
}
these.formData.blename = f.name ? f.name : "Unname";
these.formData.deviceName = device.deviceName;
- these.formData.img = device.devicePic;
+
these.formData.bleStatu = false;
these.formData.deviceId = f.deviceId;
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
diff --git a/pages/6155/deviceDetail.vue b/pages/6155/deviceDetail.vue
index ecc5333..80af6e5 100644
--- a/pages/6155/deviceDetail.vue
+++ b/pages/6155/deviceDetail.vue
@@ -1,8 +1,9 @@
-
-
+
+
+
@@ -27,6 +28,10 @@
设备名称
{{device.deviceName}}
+
+ Mac地址
+ {{device.deviceMac}}
+
设备状态
{{formData.statu}}
@@ -228,7 +233,7 @@
}
},
formData: {
- img: '',
+ img: '/static/images/common/HBY6155.png',
battary: '',
xuhang: '',
deviceName: '',
@@ -355,7 +360,7 @@
}
these.formData.blename = f.name ? f.name : "Unname";
these.formData.deviceName = device.deviceName;
- these.formData.img = device.devicePic;
+
these.formData.id = device.id;
these.formData.deviceId = f.deviceId;
these.formData.bleStatu = false;
diff --git a/pages/6331/AudioManager.vue b/pages/6331/AudioManager.vue
deleted file mode 100644
index 8183fd0..0000000
--- a/pages/6331/AudioManager.vue
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/pages/6331/BJQ6331.vue b/pages/6331/BJQ6331.vue
index c5a3c0e..300a0c4 100644
--- a/pages/6331/BJQ6331.vue
+++ b/pages/6331/BJQ6331.vue
@@ -1,8 +1,8 @@
-
-
+
+
@@ -26,6 +26,10 @@
设备名称
{{device.deviceName}}
+
+ Mac地址
+ {{device.deviceMac}}
+
蓝牙名称
{{device.bluetoothName}}
@@ -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 9c495a7..62eea59 100644
--- a/pages/650/HBY650.vue
+++ b/pages/650/HBY650.vue
@@ -1,8 +1,8 @@
-
-
+
+
@@ -26,6 +26,10 @@
蓝牙名称
{{device.bluetoothName}}
+
+ Mac地址
+ {{device.deviceMac}}
+
设备名称
{{device.deviceName}}
@@ -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 64f81f7..b6bcf6e 100644
--- a/pages/670/HBY670.vue
+++ b/pages/670/HBY670.vue
@@ -2,10 +2,12 @@
-
+
+
+
-
-
+
+
@@ -25,13 +27,18 @@
+
+ 设备名称
+ {{device.deviceName}}
+
设备IMEI
{{device.deviceImei}}
+
- 设备名称
- {{device.deviceName}}
+ Mac地址
+ {{device.deviceMac}}
蓝牙名称
@@ -382,6 +389,7 @@
bleLinkCnt: 0
},
formData: {
+ img:'/static/images/common/HBY670.png',
battary: "", //电量
xuhang: "", //续航
imei: "", //imei
@@ -518,6 +526,7 @@
let keys = Object.keys(form);
for (var i = keys.length; i >= 0; i--) {
let key = keys[i];
+
these.formData[key] = form[key];
}
}
diff --git a/pages/7305/BJQ7305.vue b/pages/7305/BJQ7305.vue
index c571ca5..5c92671 100644
--- a/pages/7305/BJQ7305.vue
+++ b/pages/7305/BJQ7305.vue
@@ -1,8 +1,8 @@
-
-
+
+
@@ -26,6 +26,10 @@
设备名称
{{device.deviceName}}
+
+ Mac地址
+ {{device.deviceMac}}
+
设备状态
{{formData.statu}}
@@ -229,7 +233,7 @@
}
},
formData: {
- img: '',
+ img: '/static/images/common/HBY6155.png',
battary: '',
xuhang: '',
deviceName: '',
@@ -310,7 +314,7 @@
}
these.formData.blename = f.name ? f.name : "Unname";
these.formData.deviceName = device.deviceName;
- these.formData.img = device.devicePic;
+
these.formData.id = device.id;
these.formData.deviceId = f.deviceId;
these.formData.bleStatu = false;
diff --git a/pages/common/addBLE/LinkBle.vue b/pages/common/addBLE/LinkBle.vue
index 2596e2b..9977b67 100644
--- a/pages/common/addBLE/LinkBle.vue
+++ b/pages/common/addBLE/LinkBle.vue
@@ -6,19 +6,19 @@
- 蓝牙名:{{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/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/4877/4877equip.png b/static/images/4877/4877equip.png
deleted file mode 100644
index dff8be2..0000000
Binary files a/static/images/4877/4877equip.png and /dev/null differ
diff --git a/utils/BleHelper.js b/utils/BleHelper.js
index 337f7b7..dc2619c 100644
--- a/utils/BleHelper.js
+++ b/utils/BleHelper.js
@@ -789,7 +789,7 @@ class BleHelper {
}
try {
- console.log("11111");
+ // console.log("11111");
let recData = {
deviceId: receive.deviceId,
serviceId: receive.serviceId,
@@ -798,7 +798,7 @@ class BleHelper {
str: str,
hexs: hexs
};
- console.log("监听到特征值:" + JSON.stringify(recData));
+ // console.log("监听到特征值:" + JSON.stringify(recData));
if (this.cfg.receivDataCallback) {
if (this.cfg.receivDataCallback.length > 0) {
diff --git a/utils/BleReceive.js b/utils/BleReceive.js
index 3897d3f..c0c2fa6 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)
};
}
@@ -45,8 +45,9 @@ class BleReceive {
let handler = null;
let keys = Object.keys(this.HandlerMap);
for (let index = 0; index < keys.length; index++) {
- let key = keys[index].replaceAll('/', '').toLowerCase();
- let devKey = f.device.detailPageUrl ? f.device.detailPageUrl.replaceAll('/', '').toLowerCase() : '';
+
+ let key = keys[index].replace(/\//g, "").toLowerCase();
+ let devKey = f.device.detailPageUrl ? f.device.detailPageUrl.replace(/\//g, "").toLowerCase() : '';
if (key == devKey) {
handler = this.HandlerMap[keys[index]];
break;
@@ -150,8 +151,8 @@ class BleReceive {
this.setBleFormData(formData, f);
let recCnt = recArr.find(v => {
- return v.key.replaceAll('/', '').toLowerCase() == f.device.detailPageUrl
- .replaceAll('/', '').toLowerCase();
+ return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
+ .replace(/\//g, "").toLowerCase();
});
if (!recCnt) {
@@ -318,8 +319,8 @@ class BleReceive {
this.setBleFormData(receiveData, f);
console.log("recArr=", recArr);
let recCnt = recArr.find(v => {
- return v.key.replaceAll('/', '').toLowerCase() == f.device.detailPageUrl
- .replaceAll('/', '').toLowerCase();
+ return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
+ .replace(/\//g, "").toLowerCase();
});
if (!recCnt) {
if (this.formData.staticWarn) { //有静止报警
@@ -470,7 +471,7 @@ class BleReceive {
let recCnt = recArr.find(v => {
- return v.key.replaceAll('/', '').toLowerCase() === f.device.detailPageUrl.replaceAll(
+ return v.key.replace(/\//g, "").toLowerCase() === f.device.detailPageUrl.replaceAll(
'/', '').toLowerCase();
});
if (!recCnt) {
@@ -497,12 +498,12 @@ class BleReceive {
try {
- console.log("str=",receive.str);
+ // console.log("str=",receive.str);
receiveData = JSON.parse(receive.str);
let recCnt = recArr.find(v => {
- return v.key.replaceAll('/', '').toLowerCase() == f.device.detailPageUrl
- .replaceAll('/', '').toLowerCase();
+ return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
+ .replace(/\//g, "").toLowerCase();
});
if (!recCnt) {
if (receiveData.sta_PowerPercent<=20) {
@@ -521,7 +522,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