常规小优化
This commit is contained in:
17
App.vue
17
App.vue
@ -103,6 +103,14 @@
|
||||
if (appid !== 'HBuilder') {
|
||||
upgrade.checkAndUpdateWgt();
|
||||
}
|
||||
|
||||
uni.setKeepScreenOn({
|
||||
keepScreenOn:true
|
||||
}).then(res=>{
|
||||
console.log("已设置屏幕常亮");
|
||||
}).catch(ex=>{
|
||||
console.error("设置屏幕常亮失败,ex=",ex)
|
||||
})
|
||||
// #endif
|
||||
|
||||
|
||||
@ -110,6 +118,15 @@
|
||||
onHide: function() {
|
||||
console.log('App Hide');
|
||||
// #ifdef APP|APP-PLUS
|
||||
|
||||
uni.setKeepScreenOn({
|
||||
keepScreenOn:false
|
||||
}).then(res=>{
|
||||
console.log("已关闭屏幕常亮");
|
||||
}).catch(ex=>{
|
||||
console.error("设置屏幕常亮失败,ex=",ex)
|
||||
})
|
||||
|
||||
// 上传中不主动断开:语音上传进行中则不断开蓝牙
|
||||
let ble = bleTool.getBleTool();
|
||||
if (ble && ble.isVoiceUploading && ble.isVoiceUploading()) {
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
<image v-if="item.icon" :src="item.icon" mode="aspectFit"></image>
|
||||
</view>
|
||||
|
||||
<text class="itemTxt">{{ item.text }}</text>
|
||||
<text class="itemTxt" :class="(config.textAlign=='flex-start'&&!item.icon)?'txtIndent':''">{{ item.text }}</text>
|
||||
</view>
|
||||
|
||||
|
||||
@ -139,8 +139,8 @@
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.itemTxt{
|
||||
text-indent: 20rpx;
|
||||
.txtIndent{
|
||||
text-indent: 30rpx;
|
||||
}
|
||||
.message-popup {
|
||||
position: relative;
|
||||
|
||||
@ -14,7 +14,13 @@
|
||||
<view v-if="!visiblePrompt">
|
||||
<image v-if="iconUrl" :src="iconUrl" mode="aspectFit" class="popup-icon"
|
||||
:style="{ tintColor: textColor || getTypeStyle('textColor') }"></image>
|
||||
<view class="popup-message" :class="showSlot?'displayNone':''">{{ message }}</view>
|
||||
<view :class="showSlot?'displayNone':''">
|
||||
<view class="popup-message" v-if="typeof(message)=='string'">{{ message }}</view>
|
||||
<view class="popup-message" v-else>
|
||||
<view v-for="item,i in message">{{item}}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="popup-message" :class="showSlot?'':'displayNone'">
|
||||
<slot></slot>
|
||||
</view>
|
||||
@ -83,7 +89,7 @@
|
||||
buttonTextColor: String,
|
||||
iconUrl: String,
|
||||
message: {
|
||||
type: String,
|
||||
type: String|Array,
|
||||
default: ''
|
||||
},
|
||||
buttonText: {
|
||||
|
||||
@ -141,27 +141,35 @@
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
bgColor:'#383934cc',
|
||||
buttonTextColor:'#FFFFFFde'
|
||||
buttonTextColor:'#FFFFFFde',
|
||||
showCancel:true,
|
||||
buttonCancelText:'取消'
|
||||
},
|
||||
succ: {
|
||||
icoUrl: '/static/images/common/success.png',
|
||||
borderColor: "#BBE6004d",
|
||||
buttonBgColor: "#BBE600",
|
||||
buttonTextColor:'#232323de',
|
||||
bgColor:'#383934cc'
|
||||
bgColor:'#383934cc',
|
||||
showCancel:true,
|
||||
buttonCancelText:'取消'
|
||||
},
|
||||
warn: {
|
||||
icoUrl: '/static/images/common/warning.png',
|
||||
borderColor: "#FFC84E4d",
|
||||
buttonBgColor: "#FFC84E",
|
||||
buttonTextColor:'#FFFFFFde',
|
||||
bgColor:'#383934cc'
|
||||
bgColor:'#383934cc',
|
||||
showCancel:true,
|
||||
buttonCancelText:'取消'
|
||||
},
|
||||
info:{
|
||||
borderColor: "#BBE6004d",
|
||||
buttonBgColor: "#BBE600",
|
||||
bgColor:'#383934cc',
|
||||
buttonTextColor:'#232323de'
|
||||
buttonTextColor:'#232323de',
|
||||
showCancel:true,
|
||||
buttonCancelText:'取消'
|
||||
},
|
||||
prompt:{
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"name" : "星汉物联",
|
||||
"appid" : "__UNI__A21EF43",
|
||||
"description" : "设备管控",
|
||||
"versionName" : "1.0.25",
|
||||
"versionName" : "1.0.27",
|
||||
"versionCode" : 101,
|
||||
"transformPx" : false,
|
||||
/* 5+App特有相关 */
|
||||
@ -79,7 +79,8 @@
|
||||
"NSMicrophoneUsageDescription" : "App需要您的同意访问麦克风,用于上传语音包"
|
||||
},
|
||||
"idfa" : false,
|
||||
"urltypes" : ""
|
||||
"urltypes" : "",
|
||||
"urlschemewhitelist" : ""
|
||||
},
|
||||
/* SDK配置 */
|
||||
"sdkConfigs" : {
|
||||
@ -100,23 +101,19 @@
|
||||
},
|
||||
"push" : {
|
||||
"unipush" : {
|
||||
"version" : "2",
|
||||
"offline" : true,
|
||||
"hms" : {},
|
||||
"oppo" : {},
|
||||
"vivo" : {},
|
||||
"mi" : {},
|
||||
"meizu" : {},
|
||||
"honor" : {},
|
||||
"version" : "2",
|
||||
"icons" : {
|
||||
"small" : {
|
||||
"ldpi" : "unpackage/res/icons/18x18.png",
|
||||
"mdpi" : "unpackage/res/icons/24x24.png",
|
||||
"hdpi" : "unpackage/res/icons/36x36.png",
|
||||
"xhdpi" : "unpackage/res/icons/48x48.png",
|
||||
"xxhdpi" : "unpackage/res/icons/72x72.png"
|
||||
"hdpi" : "unpackage/res/icons/36x36.png"
|
||||
}
|
||||
},
|
||||
"meizu" : {}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -169,6 +169,7 @@
|
||||
"path": "pages/common/map/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "地图"
|
||||
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@ -65,7 +65,8 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="warnnig" v-show="formData.sta_ShakeBit!='' && formData.sta_ShakeBit!='0'">
|
||||
<view class="warnnig" v-show="formData.sta_ShakeBit!='' && formData.sta_ShakeBit!='0'"
|
||||
@click="showAction('map')">
|
||||
<view>{{ShakeBit}}</view>
|
||||
</view>
|
||||
|
||||
@ -135,6 +136,8 @@
|
||||
|
||||
<ProParams :id="device.id"></ProParams>
|
||||
|
||||
<BottomSlideMenuPlus v-for="item,index in dic.actionSheets" :config="item" @close="item.closeMenu"
|
||||
@itemClick="item.handleItemClick" @btnClick="item.btnClick"></BottomSlideMenuPlus>
|
||||
|
||||
<global-loading ref="loading" />
|
||||
|
||||
@ -188,7 +191,7 @@
|
||||
pageHide: false,
|
||||
|
||||
|
||||
usrToggle: false,
|
||||
usrToggle: false
|
||||
},
|
||||
formData: {
|
||||
img: '/static/images/common/HBY018A.png',
|
||||
@ -201,6 +204,7 @@
|
||||
sta_ShakeBit: 0, //报警状态
|
||||
sta_system: '', //0关机 1关机充电 2开机未充电 3开机充电
|
||||
bleStatu: '',
|
||||
|
||||
},
|
||||
dic: {
|
||||
sta_Side_Light: [
|
||||
@ -235,7 +239,8 @@
|
||||
sta_charge: {
|
||||
"0": '未充电',
|
||||
"1": '充电中'
|
||||
}
|
||||
},
|
||||
actionSheets: []
|
||||
|
||||
},
|
||||
device: {
|
||||
@ -251,8 +256,8 @@
|
||||
bindingTime: "",
|
||||
onlineStatus: 0,
|
||||
battery: "0",
|
||||
latitude: '30.495455',
|
||||
longitude: '114.409500',
|
||||
latitude: '',
|
||||
longitude: '',
|
||||
alarmStatus: null,
|
||||
detailPageUrl: "/pages/018A/HBY018A",
|
||||
showConfirm: false,
|
||||
@ -281,8 +286,8 @@
|
||||
ble.addDisposeCallback(this.deviceDispose, pagePath);
|
||||
ble.addRecoveryCallback(this.deviceRecovry, pagePath);
|
||||
|
||||
this.initWatch();
|
||||
|
||||
this.initActionData();
|
||||
|
||||
let eventChannel = this.getOpenerEventChannel();
|
||||
|
||||
@ -306,6 +311,9 @@
|
||||
these.formData[key] = form[key];
|
||||
}
|
||||
}
|
||||
|
||||
these.device.longitude = form.sta_longitude;
|
||||
these.device.latitude = form.sta_latitude;
|
||||
these.formData.blename = f.name ? f.name : "Unname";
|
||||
these.formData.deviceName = device.deviceName;
|
||||
|
||||
@ -322,7 +330,7 @@
|
||||
these.setBleFormData();
|
||||
|
||||
|
||||
|
||||
this.initWatch();
|
||||
});
|
||||
|
||||
},
|
||||
@ -365,7 +373,6 @@
|
||||
let dic = {
|
||||
"1": "设备SOS求救中",
|
||||
"2": "设备静止报警中",
|
||||
"6": "设备遇水报警中"
|
||||
};
|
||||
let keys = Object.keys(dic);
|
||||
let f = keys.find(key => {
|
||||
@ -382,23 +389,157 @@
|
||||
|
||||
},
|
||||
methods: {
|
||||
closeAction() {
|
||||
for (let index = 0; index < this.dic.actionSheets.length; index++) {
|
||||
let menu = this.dic.actionSheets[index];
|
||||
if (menu.show) {
|
||||
this.$set(this.dic.actionSheets[index], 'show', false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
showAction(name) {
|
||||
if (this.formData.sta_ShakeBit == 2) {
|
||||
for (let index = 0; index < this.dic.actionSheets.length; index++) {
|
||||
let menu = this.dic.actionSheets[index];
|
||||
if (menu.name == name) {
|
||||
this.$set(this.dic.actionSheets[index], 'show', true);
|
||||
if (index == 2) {
|
||||
this.$set(this.dic.actionSheets[index], 'value', '');
|
||||
this.$set(this.dic.actionSheets[index], 'activeIndex', -1);
|
||||
}
|
||||
} else {
|
||||
this.$set(this.dic.actionSheets[index], 'show', false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
initActionData() { //初始化ActionSheet菜单
|
||||
|
||||
let json = {
|
||||
name: '',
|
||||
show: false,
|
||||
showHeader: true,
|
||||
menuItems: [],
|
||||
activeIndex: -1,
|
||||
bgColor: '#2a2a2a',
|
||||
itemBgColor: '#3a3a3a',
|
||||
textColor: '#ffffffde',
|
||||
textAlign: 'flex-start',
|
||||
title: '请选择',
|
||||
value: '',
|
||||
valueMember: 'value',
|
||||
showDivider: false,
|
||||
dividerColor: '#00000000',
|
||||
dividerThickness: '0rpx',
|
||||
dividerMargin: '10rpx',
|
||||
itemHeight: '80rpx',
|
||||
type: '',
|
||||
showBtn: true,
|
||||
btnBgColor: "#bbe600",
|
||||
btnText: "确定",
|
||||
btnTextColor: "#232323de",
|
||||
showMask: true,
|
||||
maskBgColor: '#00000066',
|
||||
showClose: false,
|
||||
|
||||
closeMenu: these.closeAction,
|
||||
btnClick: (li, i) => {
|
||||
debugger;
|
||||
},
|
||||
handleItemClick: (li, i) => {
|
||||
debugger;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
let item = Object.assign({}, json);
|
||||
item.name = 'map';
|
||||
item.title = '选择地图'
|
||||
item.menuItems = [{
|
||||
text: '高德地图',
|
||||
icon: '/static/images/lightImg/qiang.png',
|
||||
value: 'amap',
|
||||
key: 'map'
|
||||
},
|
||||
{
|
||||
text: '百度地图',
|
||||
icon: '/static/images/lightImg/work.png',
|
||||
value: 'baidumap',
|
||||
key: 'map'
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
item.handleItemClick = (li, i) => {
|
||||
this.$set(this.dic.actionSheets[0], 'value', li.value);
|
||||
|
||||
};
|
||||
item.btnClick = (li, i) => {
|
||||
console.log("li=", li);
|
||||
this.$set(this.dic.actionSheets[0], 'show', false);
|
||||
console.log("device=", this.device);
|
||||
|
||||
if (this.device.longitude && this.device.latitude) {
|
||||
Common.MapNavi(this.device.longitude, this.device.latitude, '', li.value).catch(ex => {
|
||||
MsgError(ex, "", these);
|
||||
});
|
||||
} else {
|
||||
if (this.formData.sta_longitude && this.formData.sta_latitude) {
|
||||
// let promise = lnglatConvert.wgs84_to_gcj02(this.formData.sta_longitude, this.formData
|
||||
// .sta_latitude);
|
||||
// promise.then(lnglat => {
|
||||
|
||||
this.device.longitude = this.formData.sta_longitude;
|
||||
this.device.latitude = this.formData.sta_latitude;
|
||||
|
||||
|
||||
|
||||
// Common.regeo(lnglat[0], lnglat[1]).then(res => {
|
||||
// this.formData.address = res.regeocode.formatted_address;
|
||||
|
||||
Common.MapNavi(this.device.longitude, this.device.latitude, this.formData.address, li
|
||||
.value).catch(ex => {
|
||||
MsgError(ex, "", these);
|
||||
})
|
||||
// }).catch(ex => {
|
||||
// console.error("逆地理失败了")
|
||||
// });
|
||||
// }).catch(err => {
|
||||
// console.error("坐标转换失败了");
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.dic.actionSheets = [item];
|
||||
},
|
||||
getDeviceDetail() {
|
||||
api.getDetail(this.device.id).then(res => {
|
||||
|
||||
if (res && res.code == 200) {
|
||||
let data = res.data;
|
||||
let keys = Object.keys(data);
|
||||
let dKeys=Object.keys(this.device);
|
||||
let dKeys = Object.keys(this.device);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
let key = keys[i];
|
||||
|
||||
let dk=dKeys.find(k=>{
|
||||
return key.toLowerCase()==k.toLowerCase();
|
||||
|
||||
let dk = dKeys.find(k => {
|
||||
return key.toLowerCase() == k.toLowerCase();
|
||||
});
|
||||
if(dk){
|
||||
this.$set(this.device,dk,data[key]);
|
||||
}else{
|
||||
this.$set(this.device,key,data[key]);
|
||||
if (dk) {
|
||||
this.$set(this.device, dk, data[key]);
|
||||
} else {
|
||||
this.$set(this.device, key, data[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -445,19 +586,19 @@
|
||||
}
|
||||
});
|
||||
|
||||
this.$watch("formData.sta_longitude", (newVal, oldVal) => {
|
||||
if (newVal) {
|
||||
this.reGeo();
|
||||
}
|
||||
|
||||
|
||||
this.$watch("formData.sta_ShakeBit", (newVal, oldVal) => {
|
||||
this.routePlan();
|
||||
});
|
||||
|
||||
this.$watch("formData.sta_latitude", (newVal, oldVal) => {
|
||||
if (newVal) {
|
||||
this.reGeo();
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
routePlan() {
|
||||
if (this.formData.sta_ShakeBit == 2) {
|
||||
MsgError(["设备静止报警中!", "请注意接听设备来电和短信!"], "位置导航", these, () => {
|
||||
these.showAction('map');
|
||||
});
|
||||
}
|
||||
},
|
||||
reGeo() {
|
||||
console.log("经纬度发生变化,执行逆地理")
|
||||
@ -470,11 +611,13 @@
|
||||
this.device.longitude = lnglat[0];
|
||||
this.device.latitude = lnglat[1];
|
||||
|
||||
|
||||
|
||||
Common.regeo(lnglat[0], lnglat[1]).then(res => {
|
||||
this.formData.address = res.regeocode.formatted_address
|
||||
}).catch(ex => {
|
||||
console.error("逆地理失败了")
|
||||
})
|
||||
}).finally(this.routePlan);
|
||||
}).catch(err => {
|
||||
console.error("坐标转换失败了");
|
||||
});
|
||||
@ -493,13 +636,13 @@
|
||||
success(res) {
|
||||
res.eventChannel.emit('device', these.device);
|
||||
},
|
||||
events:{
|
||||
linkManOver:(data)=>{
|
||||
this.device.contact1Phone=data[0];
|
||||
this.device.contact2Phone=data[1];
|
||||
events: {
|
||||
linkManOver: (data) => {
|
||||
this.device.contact1Phone = data[0];
|
||||
this.device.contact2Phone = data[1];
|
||||
},
|
||||
MsgOver:(data)=>{
|
||||
this.device.sosSmsMsg=data;
|
||||
MsgOver: (data) => {
|
||||
this.device.sosSmsMsg = data;
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -622,23 +765,28 @@
|
||||
MsgError("获取设备位置异常", '', these);
|
||||
return;
|
||||
}
|
||||
let promise = lnglatConvert.wgs84_to_gcj02(this.formData.sta_longitude, this.formData.sta_latitude);
|
||||
promise.then(lnglat => {
|
||||
// let promise = lnglatConvert.wgs84_to_gcj02(this.formData.sta_longitude, this.formData.sta_latitude);
|
||||
// promise.then(lnglat => {
|
||||
// console.log("坐标转换成功", lnglat);
|
||||
this.device.longitude = this.formData.sta_longitude;
|
||||
this.device.latitude = this.formData.sta_latitude;
|
||||
|
||||
this.detailData.longitude = lnglat[0];
|
||||
this.detailData.latitude = lnglat[1];
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/map/index',
|
||||
events: {
|
||||
ack: function(data) {}
|
||||
},
|
||||
success: (res) => {
|
||||
res.eventChannel.emit('Map', {
|
||||
data: this.detailData
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
console.log("device=",this.device);
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/map/index',
|
||||
events: {
|
||||
ack: function(data) {}
|
||||
},
|
||||
success: (res) => {
|
||||
res.eventChannel.emit('Map', {
|
||||
data: this.device
|
||||
});
|
||||
},
|
||||
fail(ex) {
|
||||
console.error("跳转失败", ex);
|
||||
}
|
||||
})
|
||||
// });
|
||||
|
||||
},
|
||||
LighSetting(item, index) {
|
||||
@ -717,6 +865,20 @@
|
||||
}, these, false);
|
||||
|
||||
|
||||
},
|
||||
receivData(json) {
|
||||
let keys = Object.keys(json);
|
||||
|
||||
keys.forEach(key => {
|
||||
if (key in this.formData) {
|
||||
this.formData[key] = json[key];
|
||||
}
|
||||
});
|
||||
|
||||
if ('sta_longitude' in json) {
|
||||
this.reGeo();
|
||||
}
|
||||
these.setBleFormData();
|
||||
},
|
||||
deviceRecovry(res) {
|
||||
console.log("蓝牙连接成功", these.formData);
|
||||
@ -808,27 +970,12 @@
|
||||
}
|
||||
|
||||
let json = recei.ReceiveData(receive, device, pagePath, recArr);
|
||||
this.receivData(json);
|
||||
|
||||
console.log("json=", json)
|
||||
|
||||
let msg = [];
|
||||
if (json.sta_PowerPercent <= 20 && (json.sta_system != 1 || json.sta_system != 3)) {
|
||||
msg.push("设备电量低");
|
||||
}
|
||||
|
||||
let keys = Object.keys(json);
|
||||
|
||||
keys.forEach(key => {
|
||||
if (key in this.formData) {
|
||||
this.formData[key] = json[key];
|
||||
}
|
||||
});
|
||||
|
||||
if (msg.length > 0) {
|
||||
MsgError(msg.join(','), '', these);
|
||||
}
|
||||
|
||||
these.setBleFormData();
|
||||
|
||||
},
|
||||
getDevice: function() {
|
||||
|
||||
@ -118,12 +118,12 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="mode " :class="{active:formData.sta_RadarType=='1'}"
|
||||
v-on:click.stop="showAction">
|
||||
<view class="mode " :class="{active:formData.sta_RadarType!=0}"
|
||||
v-on:click.stop="showAction('BottomMenu')">
|
||||
<view class="leftImg">
|
||||
<image v-show="formData.sta_RadarType=='1'" class="img" src="/static/images/102/redarActive.png"
|
||||
<image v-show="formData.sta_RadarType!=0" class="img" src="/static/images/102/redarActive.png"
|
||||
mode="aspectFit"></image>
|
||||
<image v-show="formData.sta_RadarType!='1'" class="img" src="/static/images/102/redar.png"
|
||||
<image v-show="formData.sta_RadarType==0" class="img" src="/static/images/102/redar.png"
|
||||
mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
@ -146,6 +146,19 @@
|
||||
<text class="smallTxt">{{formData.sta_InfraRed=='1'?'开启':'关闭'}}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="mode "
|
||||
v-on:click.stop="showAction('PictureMenu')">
|
||||
<view class="leftImg">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/open.png"
|
||||
mode="aspectFit"></image>
|
||||
|
||||
</view>
|
||||
<view class="rightTxt">
|
||||
<text class="bigTxt">开机画面</text>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
@ -155,7 +168,7 @@
|
||||
<view class="btnSend fright" v-on:click.stop="sendUsr">发送</view>
|
||||
<view class="clear"></view>
|
||||
<TextToHexV1 class="TextToHex" ref="textToHex" :txts="formData.textLines" :bgColor="'#FFFFFF'"
|
||||
:color="'#000000'" :fontSize="16" />
|
||||
:color="'#000000'" :fontSize="14" />
|
||||
</view>
|
||||
|
||||
<view class="item">
|
||||
@ -183,6 +196,9 @@
|
||||
|
||||
|
||||
<BottomSlideMenuPlus :config="Status.BottomMenu" @btnClick="btnClick" @itemClick="itemClick" @close="closeActionSheet"></BottomSlideMenuPlus>
|
||||
|
||||
<BottomSlideMenuPlus :config="Status.PictureMenu" @btnClick="btnPictureClick" @itemClick="itemPictureClick" @close="closeActionSheet"></BottomSlideMenuPlus>
|
||||
|
||||
<ProParams :id="device.id"></ProParams>
|
||||
<MsgBox ref="msgPop" />
|
||||
<global-loading ref="loading" />
|
||||
@ -192,7 +208,9 @@
|
||||
<script>
|
||||
import usrApi from '@/api/670/HBY670.js';
|
||||
import TextToHexV1 from '@/components/TextToHex/TextToHexV1.vue';
|
||||
import request from '@/utils/request.js';
|
||||
import request, {
|
||||
baseURL
|
||||
} from '@/utils/request.js';
|
||||
import {
|
||||
showLoading,
|
||||
hideLoading,
|
||||
@ -244,6 +262,40 @@
|
||||
},
|
||||
usrToggle: true,
|
||||
bleLinkCnt: 0,
|
||||
PictureMenu:{
|
||||
show: false,
|
||||
showHeader: true,
|
||||
menuItems: [{
|
||||
text: '照片',
|
||||
value: 'img',
|
||||
icon: ''
|
||||
},
|
||||
{
|
||||
text: '视频',
|
||||
value: 'video',
|
||||
icon: ''
|
||||
}
|
||||
],
|
||||
activeIndex: -1,
|
||||
bgColor: '#2a2a2a',
|
||||
itemBgColor: '#3a3a3a',
|
||||
textColor: '#ffffffde',
|
||||
textAlign: 'flex-start',
|
||||
title: '开机画面',
|
||||
showDivider: false,
|
||||
dividerColor: '#00000000',
|
||||
dividerThickness: '0rpx',
|
||||
dividerMargin: '10rpx',
|
||||
itemHeight: '80rpx',
|
||||
type: '',
|
||||
showBtn: true,
|
||||
btnBgColor: "#bbe600",
|
||||
btnText: "确定",
|
||||
btnTextColor: "#232323de",
|
||||
showMask: true,
|
||||
maskBgColor: '#00000066',
|
||||
showClose: false
|
||||
},
|
||||
BottomMenu: {
|
||||
show: false,
|
||||
showHeader: true,
|
||||
@ -340,8 +392,8 @@
|
||||
showConfirm: false
|
||||
},
|
||||
|
||||
permissions: []
|
||||
|
||||
permissions: [],
|
||||
inteval:80
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -512,40 +564,584 @@
|
||||
|
||||
},
|
||||
methods: {
|
||||
showAction(){
|
||||
showAction(type){
|
||||
if(type=='BottomMenu'){
|
||||
this.Status.BottomMenu.show = true;
|
||||
|
||||
this.Status.PictureMenu.show=false;
|
||||
this.Status.BottomMenu.menuItems.find((v,i)=>{
|
||||
if(this.formData.sta_RadarType==v.value){
|
||||
this.Status.BottomMenu.activeIndex=i;
|
||||
return true;
|
||||
}
|
||||
})
|
||||
}) ;
|
||||
}else{
|
||||
this.Status.PictureMenu.show=true;
|
||||
this.Status.BottomMenu.show = false;
|
||||
}
|
||||
|
||||
},
|
||||
btnClick(){
|
||||
this.Status.BottomMenu.show = false;
|
||||
|
||||
let d=this.Status.BottomMenu.menuItems[this.Status.BottomMenu.activeIndex];
|
||||
|
||||
|
||||
|
||||
btnPictureClick(li,i){
|
||||
let f = this.getDevice();
|
||||
if (!f) {
|
||||
this.showBleUnConnect();
|
||||
return;
|
||||
}
|
||||
this.Status.PictureMenu.show = false;
|
||||
|
||||
|
||||
console.log("li=",li)
|
||||
if (li.value == 'img') {
|
||||
//照片
|
||||
these.sendImg();
|
||||
} else {
|
||||
//视频
|
||||
these.checkSendVideo();
|
||||
}
|
||||
},
|
||||
checkSendVideo() {
|
||||
|
||||
if (!this.permissions.includes('3') && this.Status.apiType !== 'listA') {
|
||||
|
||||
MsgError('无操作权限', '确定', these);
|
||||
return;
|
||||
}
|
||||
|
||||
let f = this.getDevice();
|
||||
|
||||
let timeDelayCloseLoading = () => {
|
||||
setTimeout(() => {
|
||||
hideLoading(these);
|
||||
}, 1500);
|
||||
}
|
||||
|
||||
|
||||
let sendVideoPackets = (ReSendNo) => {
|
||||
console.log("开始发送分片数据");
|
||||
return new Promise((resolve, reject) => {
|
||||
if (f) {
|
||||
// 总数据包数
|
||||
var totalPackets = 1536; //36;
|
||||
|
||||
let currentPacket = 1;
|
||||
console.log("发送数据准备中,总共" + totalPackets);
|
||||
if (ReSendNo) {
|
||||
totalPackets = ReSendNo;
|
||||
currentPacket = ReSendNo;
|
||||
}
|
||||
this.totalPackets = totalPackets;
|
||||
// 发送单个数据包
|
||||
const sendNextVideoPacket = () => {
|
||||
// console.log("准备发送一段数据");
|
||||
if (currentPacket > totalPackets) {
|
||||
if (!ReSendNo) {
|
||||
setTimeout(() => {
|
||||
|
||||
ble.sendString(f.deviceId, "transmit complete", f
|
||||
.writeServiceId, f.wirteCharactId, 20)
|
||||
.then(
|
||||
() => {
|
||||
console.log("全部发送完毕")
|
||||
}).catch((ex) => {
|
||||
console.log("出现异常", ex);
|
||||
});
|
||||
}, 500);
|
||||
|
||||
}
|
||||
|
||||
hideLoading(these);
|
||||
showPop({
|
||||
showPop: true,
|
||||
message: "上传成功",
|
||||
iconUrl: "/static/images/common/success.png"
|
||||
}, these);
|
||||
these.videoHexArray = null;
|
||||
resolve();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// 计算当前包的数据
|
||||
let packetSize = 500;
|
||||
|
||||
|
||||
// 创建数据包
|
||||
const startIndex = (currentPacket - 1) * packetSize;
|
||||
const endIndex = Math.min(startIndex + packetSize, these.videoHexArray
|
||||
.length);
|
||||
if (startIndex > endIndex) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
////console.log("111111");
|
||||
const packetData = these.videoHexArray.slice(startIndex, endIndex);
|
||||
|
||||
// 构建数据包
|
||||
////console.log("packetData.length"+packetData.length);
|
||||
const bufferSize = 504; // 头部5字节 + 数据部分
|
||||
const buffer = new ArrayBuffer(bufferSize);
|
||||
const dataView = new DataView(buffer);
|
||||
|
||||
let sortNo = currentPacket.toString(16).padStart(4, '0');
|
||||
|
||||
// 填充头部
|
||||
dataView.setUint8(0, 0x55); // 帧头
|
||||
dataView.setUint8(1, 0x04); // 帧类型:开机画面
|
||||
dataView.setUint8(2, '0x' + sortNo.substring(0, 2)); // 包序号
|
||||
dataView.setUint8(3, '0x' + sortNo.substring(2, 4)); // 包序号
|
||||
|
||||
// dataView.setUint8(4, 0x01);
|
||||
// dataView.setUint8(5, 0xF4);
|
||||
|
||||
for (let i = 0; i < packetData.length; i++) {
|
||||
dataView.setUint8(4 + i, '0x' + packetData[i]);
|
||||
}
|
||||
|
||||
let inteval = 60;
|
||||
|
||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f
|
||||
.wirteCharactId, 10).then(() => {
|
||||
|
||||
updateLoading(these, {
|
||||
text: "正在发送:" + currentPacket + "/" +
|
||||
totalPackets
|
||||
});
|
||||
|
||||
currentPacket++;
|
||||
|
||||
// console.log("发送一段成功,发送下一段");
|
||||
setTimeout(sendNextVideoPacket, inteval);
|
||||
}).catch(err => {
|
||||
console.log("发送失败了", err);
|
||||
if (err.code == '10007') { //遇到这个错误自动重新发送
|
||||
console.log(err.errMsg + ",发送失败了,正在补偿:" +
|
||||
currentPacket);
|
||||
setTimeout(sendNextVideoPacket, 800);
|
||||
} else {
|
||||
|
||||
hideLoading(these);
|
||||
|
||||
showPop({
|
||||
showPop: true,
|
||||
message: err.msg + ",发送失败了",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
buttonText: "确定",
|
||||
iconUrl: "/static/images/common/uploadErr.png"
|
||||
}, these);
|
||||
reject(err);
|
||||
these.videoHexArray = null;
|
||||
return;
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
sendNextVideoPacket();
|
||||
|
||||
|
||||
} else {
|
||||
console.log("Fail.......")
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var sendVideo = (videoPath) => {
|
||||
let uploadVideo = () => {
|
||||
|
||||
these.videoHexArray = [];
|
||||
console.log("开始处理,正在上传");
|
||||
|
||||
showLoading(these, {
|
||||
text: "上传中"
|
||||
});
|
||||
let p1 = new Promise((resolve, reject) => {
|
||||
|
||||
ble.sendString(f.deviceId, "video transmit start", f
|
||||
.writeServiceId, f.wirteCharactId).then(res => {
|
||||
|
||||
setTimeout(() => {
|
||||
console.log("握手成功了");
|
||||
resolve(true);
|
||||
}, 2200)
|
||||
}).catch(ex => {
|
||||
reject(ex);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
let p2 = new Promise((succ, err) => {
|
||||
|
||||
const token = uni.getStorageSync('token');
|
||||
const clientid = uni.getStorageSync('clientID');
|
||||
if (!token) {
|
||||
err({
|
||||
code: 401,
|
||||
msg: "请先登陆后再试"
|
||||
});
|
||||
hideLoading(these);
|
||||
return;
|
||||
}
|
||||
console.log("baseURL=", baseURL);
|
||||
console.log("token", token);
|
||||
console.log("clientID", clientid);
|
||||
uni.uploadFile({
|
||||
// url: 'http://114.55.111.217/video/upload',
|
||||
url: baseURL + "/app/video/upload",
|
||||
filePath: videoPath,
|
||||
name: 'file',
|
||||
header: {
|
||||
"Method": "POST",
|
||||
"Content-Type": "multipart/form-data",
|
||||
"Authorization": 'Bearer ' + token,
|
||||
"clientid": clientid
|
||||
},
|
||||
timeout: 600000,
|
||||
fail: (ex) => {
|
||||
console.log("上传视频失败" + JSON.stringify(ex));
|
||||
|
||||
err(ex);
|
||||
},
|
||||
success: (res) => {
|
||||
|
||||
console.log("上传完成,向蓝牙设备发送");
|
||||
succ(res);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
Promise.all([p1, p2]).then((arr) => {
|
||||
|
||||
if (arr[0].status == 'rejected') {
|
||||
MsgError("设备准备未就绪,请重试",'',these);
|
||||
return;
|
||||
}
|
||||
if(arr[1].status== 'rejected'){
|
||||
MsgError("读取视频失败",'',these);
|
||||
return;
|
||||
}
|
||||
let res = arr[1];
|
||||
// console.log("11111111111111111111111",res);
|
||||
res = JSON.parse(res.data);
|
||||
// console.log("22222222222222222222");
|
||||
if (res.data) {
|
||||
these.videoHexArray = res.data;
|
||||
updateLoading(these, {
|
||||
text: "正在发送:0/1536"
|
||||
});
|
||||
|
||||
|
||||
|
||||
shotVideoClick(res.data);
|
||||
|
||||
|
||||
} else {
|
||||
console.log("服务器未返回正确的数据");
|
||||
|
||||
|
||||
showPop({
|
||||
message: "与服务器连接出现异常,请检查网络设置",
|
||||
iconUrl: "/static/images/common/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
}, these);
|
||||
}
|
||||
|
||||
}).catch((ex) => {
|
||||
console.log("出现异常,", ex)
|
||||
hideLoading(these);
|
||||
showPop({
|
||||
message: "出现异常," + ex.msg,
|
||||
iconUrl: "/static/images/common/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
}, these);
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
let shotVideoClick = () => {
|
||||
console.log("正在开始发送");
|
||||
sendVideoPackets().then(() => {
|
||||
console.log("发送完成");
|
||||
|
||||
}).catch((ex1) => {
|
||||
//console.log("出现了异常", ex1)
|
||||
}).finally(() => {
|
||||
hideLoading(these);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
uploadVideo();
|
||||
|
||||
}
|
||||
|
||||
uni.chooseVideo({
|
||||
sourceType: ['album'],
|
||||
compressed: false, // 关闭视频压缩,确保上传原始文件
|
||||
success: function(res) {
|
||||
console.log("res=", res);
|
||||
let path = res.tempFilePath;
|
||||
// iOS可能返回浮点数,需要转换为整数进行比较
|
||||
let width = Math.round(res.width);
|
||||
let height = Math.round(res.height);
|
||||
let duration = res.duration;
|
||||
|
||||
// 获取平台信息
|
||||
const systemInfo = uni.getSystemInfoSync();
|
||||
const platform = systemInfo.platform;
|
||||
const isIOS = platform === 'ios';
|
||||
|
||||
console.log("平台:", platform, "uni.chooseVideo返回 - 宽度:", width, "高度:", height,
|
||||
"时长:", duration);
|
||||
|
||||
// iOS特殊处理:如果返回的是80*40,很可能是160*80的一半(iOS的bug)
|
||||
if (isIOS && width === 80 && height === 40) {
|
||||
console.log("检测到iOS特殊情况:返回80*40,实际应该是160*80,进行修正");
|
||||
width = 160;
|
||||
height = 80;
|
||||
}
|
||||
|
||||
// 检查分辨率是否符合要求
|
||||
let checkResolution = (w, h) => {
|
||||
// 使用容差比较,允许1像素的误差
|
||||
return Math.abs(w - 160) <= 1 && Math.abs(h - 80) <= 1;
|
||||
};
|
||||
|
||||
let err = [];
|
||||
if (duration < 2) {
|
||||
err.push("视频时长至少2秒");
|
||||
}
|
||||
|
||||
if (!checkResolution(width, height)) {
|
||||
err.push("视频宽高必须是160*80,当前分辨率:" + width + "*" + height);
|
||||
}
|
||||
|
||||
if (err.length > 0) {
|
||||
err = err.join(";");
|
||||
showPop({
|
||||
message: err,
|
||||
iconUrl: "/static/images/common/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
}, these);
|
||||
return;
|
||||
}
|
||||
|
||||
showLoading(these, {
|
||||
text: '正在上传'
|
||||
});
|
||||
setTimeout(() => {
|
||||
sendVideo(path);
|
||||
}, 0);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
sendImg() {
|
||||
if (!this.permissions.includes('3') && this.Status.apiType !== 'listA') {
|
||||
|
||||
MsgError('无操作权限', '确定', these);
|
||||
return;
|
||||
}
|
||||
|
||||
let f = this.getDevice();
|
||||
|
||||
|
||||
var sendImagePackets = function(ReSendNo) {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
// 总数据包数
|
||||
let totalPackets = 52;
|
||||
let currentPacket = 1;
|
||||
|
||||
if (ReSendNo) {
|
||||
totalPackets = ReSendNo;
|
||||
currentPacket = ReSendNo;
|
||||
}
|
||||
|
||||
if (f) {
|
||||
// 发送单个数据包
|
||||
const sendNextPacket = () => {
|
||||
if (currentPacket > totalPackets) {
|
||||
hideLoading(these);
|
||||
these.closeAction();
|
||||
showPop({
|
||||
showPop: true,
|
||||
message: "上传成功",
|
||||
iconUrl: "/static/images/common/success.png",
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
ble.sendString(f.deviceId, "transmit complete", f
|
||||
.writeServiceId, f
|
||||
.wirteCharactId);
|
||||
}, 1000);
|
||||
|
||||
these.rgb565Data = null;
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
// 计算当前包的数据
|
||||
let packetSize = 250;
|
||||
// if (currentPacket <= 51) {
|
||||
// packetSize = 250; // 前51个包每个500字节
|
||||
// } else {
|
||||
// packetSize = 50; // 最后一个包100字节
|
||||
// }
|
||||
|
||||
// 创建数据包
|
||||
const startIndex = (currentPacket - 1) * packetSize;
|
||||
const endIndex = Math.min(startIndex + packetSize, these.rgb565Data
|
||||
.length);
|
||||
if (startIndex > endIndex) {
|
||||
return;
|
||||
}
|
||||
const packetData = these.rgb565Data.slice(startIndex,
|
||||
endIndex);
|
||||
// 构建数据包
|
||||
const bufferSize = 505; // 5 + packetData.length * 2; // 头部5字节 + 数据部分
|
||||
const buffer = new ArrayBuffer(bufferSize);
|
||||
const dataView = new DataView(buffer);
|
||||
|
||||
// 填充头部
|
||||
dataView.setUint8(0, 0x55); // 帧头
|
||||
dataView.setUint8(1, 0x02); // 帧类型:开机画面
|
||||
dataView.setUint8(2, '0x' + currentPacket.toString(16).padStart(2,
|
||||
'0')); // 包序号
|
||||
|
||||
|
||||
dataView.setUint16(3, packetData.length*2,false); // 包t长度
|
||||
|
||||
// 填充数据(每个RGB565值占2字节)
|
||||
for (let i = 0; i < packetData.length; i++) {
|
||||
dataView.setUint16(5 + i * 2, packetData[i], false); // 大端字节序
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//发送数据包
|
||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId,
|
||||
10)
|
||||
.then(() => {
|
||||
|
||||
|
||||
updateLoading(these, {
|
||||
text: "正在发送:" + currentPacket + "/" +
|
||||
totalPackets
|
||||
})
|
||||
currentPacket++;
|
||||
|
||||
setTimeout(sendNextPacket, these.inteval);
|
||||
}).catch(err => {
|
||||
console.log("发送数据包失败了" + JSON.stringify(err));
|
||||
if (err.code == '10007') {
|
||||
setTimeout(sendNextPacket, these.inteval);
|
||||
return;
|
||||
}
|
||||
these.closeAction();
|
||||
showPop({
|
||||
message: err.msg,
|
||||
iconUrl: "/static/images/common/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
});
|
||||
hideLoading(these);
|
||||
these.rgb565Data = null;
|
||||
reject(err);
|
||||
});
|
||||
}
|
||||
|
||||
if (ReSendNo) {
|
||||
sendNextPacket(ReSendNo);
|
||||
return;
|
||||
}
|
||||
// 开始牵手
|
||||
ble.sendString(f.deviceId, "picture transmit start", f.writeServiceId,
|
||||
f.wirteCharactId).then(() => {
|
||||
setTimeout(sendNextPacket, 120);
|
||||
|
||||
}).catch((err) => {
|
||||
console.log("握手没有成功");
|
||||
showPop({
|
||||
message: err.msg,
|
||||
iconUrl: "/static/images/common/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
});
|
||||
hideLoading(these);
|
||||
reject(err);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ['original', 'compressed'],
|
||||
sourceType: ['album','camera'],
|
||||
success: function(res) {
|
||||
uni.navigateTo({
|
||||
url: "/pages/common/ImgCrop/ImgCrop",
|
||||
events: {
|
||||
ImgCutOver: function(data) {
|
||||
|
||||
showLoading(these, {
|
||||
text: "正在发送0/52"
|
||||
});
|
||||
|
||||
|
||||
these.rgb565Data = Common.convertToRGB565(data.piexls);
|
||||
|
||||
setTimeout(function() {
|
||||
sendImagePackets().catch(() => {
|
||||
|
||||
});
|
||||
}, 0)
|
||||
|
||||
}
|
||||
},
|
||||
success(ev) {
|
||||
ev.eventChannel.emit('checkImg', {
|
||||
data: res.tempFiles[0].path
|
||||
})
|
||||
},
|
||||
fail(ex) {
|
||||
console.log("跳转页面失败" + JSON.stringify(ex));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
btnClick(){
|
||||
let f = this.getDevice();
|
||||
if (!f) {
|
||||
this.showBleUnConnect();
|
||||
return;
|
||||
}
|
||||
|
||||
this.Status.BottomMenu.show = false;
|
||||
|
||||
|
||||
let d=this.Status.BottomMenu.menuItems[this.Status.BottomMenu.activeIndex];
|
||||
let bleSend = () => {
|
||||
let json = {ins_RadarType:d.value};
|
||||
|
||||
json = JSON.stringify(json);
|
||||
if (ble) {
|
||||
ble.sendString(f.deviceId, json).then(res => {
|
||||
console.log("send success")
|
||||
console.log("ble send success")
|
||||
this.formData.sta_RadarType = d.value;
|
||||
}).catch(ex => {
|
||||
this.mqSend(json);
|
||||
@ -562,9 +1158,13 @@
|
||||
this.Status.BottomMenu.activeIndex=index;
|
||||
|
||||
|
||||
},
|
||||
itemPictureClick(item,index){
|
||||
this.Status.PictureMenu.activeIndex=index;
|
||||
},
|
||||
closeActionSheet() {
|
||||
this.Status.BottomMenu.show = false;
|
||||
this.Status.PictureMenu.show=false;
|
||||
},
|
||||
sendUsr() {
|
||||
if (!this.permissions.includes('4') && this.Status.apiType !== 'listA') {
|
||||
|
||||
@ -731,7 +731,7 @@
|
||||
dataView.setUint8(4 + i, '0x' + packetData[i]);
|
||||
}
|
||||
|
||||
let inteval = 40;
|
||||
let inteval = 60;
|
||||
|
||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f
|
||||
.wirteCharactId, 10).then(() => {
|
||||
@ -739,7 +739,7 @@
|
||||
updateLoading(these, {
|
||||
text: "正在发送:" + currentPacket + "/" +
|
||||
totalPackets
|
||||
})
|
||||
});
|
||||
|
||||
currentPacket++;
|
||||
|
||||
@ -750,7 +750,7 @@
|
||||
if (err.code == '10007') { //遇到这个错误自动重新发送
|
||||
console.log(err.errMsg + ",发送失败了,正在补偿:" +
|
||||
currentPacket);
|
||||
setTimeout(sendNextVideoPacket, inteval);
|
||||
setTimeout(sendNextVideoPacket, 800);
|
||||
} else {
|
||||
|
||||
hideLoading(these);
|
||||
@ -848,13 +848,12 @@
|
||||
|
||||
Promise.all([p1, p2]).then((arr) => {
|
||||
|
||||
if (arr[0].status == 'rejected') {
|
||||
showPop({
|
||||
message: "设备准备未就绪",
|
||||
iconUrl: "/static/images/common/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
}, these);
|
||||
if (arr[0].status == 'rejected') {
|
||||
MsgError("设备准备未就绪,请重试",'',these);
|
||||
return;
|
||||
}
|
||||
if(arr[1].status== 'rejected'){
|
||||
MsgError("读取视频失败",'',these);
|
||||
return;
|
||||
}
|
||||
let res = arr[1];
|
||||
@ -1333,17 +1332,16 @@
|
||||
];
|
||||
|
||||
let item3 = Object.assign({}, json);
|
||||
item3.textAlign='center';
|
||||
item3.name = 'media';
|
||||
item3.title = '选择媒体';
|
||||
item3.menuItems = [{
|
||||
text: '照片',
|
||||
icon: '/static/images/lightImg/qiang.png',
|
||||
text: '照片',
|
||||
value: 'img',
|
||||
key: 'media'
|
||||
},
|
||||
{
|
||||
text: '动画',
|
||||
icon: '/static/images/lightImg/qiang.png',
|
||||
value: 'flash',
|
||||
key: 'media'
|
||||
}
|
||||
@ -1636,14 +1634,14 @@
|
||||
setTimeout(() => {
|
||||
Promise.allSettled([holdHand('word transmit start', 2200), drawText()]).then(results => {
|
||||
if (results[0].status == 'rejected') {
|
||||
|
||||
MsgError("与蓝牙设备握手失败,请重试",'',these);
|
||||
setTimeout(() => {
|
||||
hideLoading(these)
|
||||
}, 500);
|
||||
return;
|
||||
}
|
||||
if (results[1].status == 'rejected') {
|
||||
|
||||
MsgError("读取文字点阵失败,请重试",'',these);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
<view slot="right">
|
||||
<view class="navbarRight center">
|
||||
<view class="imgContent" :class="{'visibilityHidden':Status.apiType!=item.apiType}"
|
||||
@click.stop="handleRightClick(item,index)" v-for="item,index in Status.navbar.icons">
|
||||
@click.stop="handleRightClick(item,index)" v-for="item,index in Status.navbar.icons">
|
||||
<image class="img" :src="item.src" mode="aspectFit"></image>
|
||||
<view class="baber" v-if="item.math">{{item.math>9?'9+':item.math}}</view>
|
||||
</view>
|
||||
@ -74,8 +74,8 @@
|
||||
|
||||
<view class="slider-container">
|
||||
<slider min="1" max="100" step="1" :disabled="false" :value="formData.liangDu" activeColor="#bbe600"
|
||||
backgroundColor="#00000000" block-size="20" block-color="#ffffffde" @change="sliderChange" @changing="sliderChanging"
|
||||
class="custom-slider" />
|
||||
backgroundColor="#00000000" block-size="20" block-color="#ffffffde" @change="sliderChange"
|
||||
@changing="sliderChanging" class="custom-slider" />
|
||||
|
||||
</view>
|
||||
</view>
|
||||
@ -124,33 +124,33 @@
|
||||
<view class="btnSend fright" v-on:click.stop="sendUsr">发送</view>
|
||||
<view class="clear"></view>
|
||||
<TextToHexV1 class="TextToHex" ref="textToHex" :txts="formData.textLines" :bgColor="'#FFFFFF'"
|
||||
:color="'#000000'" :fontSize="16" />
|
||||
:color="'#000000'" :fontSize="15" />
|
||||
</view>
|
||||
|
||||
<view class="item">
|
||||
<text class="lbl">单位:</text>
|
||||
<input class="value" v-model.trim="formData.textLines[0]" placeholder="请输入单位" maxlength="8"
|
||||
placeholder-class="usrplace" />
|
||||
placeholder-class="usrplace" />
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="lbl">部门:</text>
|
||||
<input class="value" v-model.trim="formData.textLines[1]" placeholder="请输入姓名" maxlength="8"
|
||||
placeholder-class="usrplace" />
|
||||
placeholder-class="usrplace" />
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="lbl">姓名:</text>
|
||||
<input class="value" v-model.trim="formData.textLines[2]" placeholder="请输入职位" maxlength="8"
|
||||
placeholder-class="usrplace" />
|
||||
placeholder-class="usrplace" />
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<ProParams :id="device.id"></ProParams>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- 下方菜单 -->
|
||||
<BottomSlideMenuPlus :config="Status.BottomMenu" @close="closeMenu" @itemClick="handleItemClick"
|
||||
@btnClick="btnClick">
|
||||
@btnClick="btnClick">
|
||||
<view class="addIco">
|
||||
<view class="icoContent center" v-on:click.stop="checkImgUpload()">
|
||||
<image mode="aspectFit" class="img" src="/static/images/6155/DeviceDetail/add.png"></image>
|
||||
@ -180,14 +180,14 @@
|
||||
} from '@/utils/request.js';
|
||||
|
||||
var pagePath = "/pages/6155/BJQ6155";
|
||||
import {
|
||||
MsgSuccess,
|
||||
MsgError,
|
||||
MsgClose,
|
||||
MsgWarning,
|
||||
showPop,
|
||||
MsgInfo
|
||||
} from '@/utils/MsgPops.js'
|
||||
import {
|
||||
MsgSuccess,
|
||||
MsgError,
|
||||
MsgClose,
|
||||
MsgWarning,
|
||||
showPop,
|
||||
MsgInfo
|
||||
} from '@/utils/MsgPops.js'
|
||||
|
||||
var ble = null;
|
||||
var these = null;
|
||||
@ -343,6 +343,7 @@
|
||||
},
|
||||
onLoad: function() {
|
||||
these = this;
|
||||
this.initWatch();
|
||||
recei = BleReceive.getBleReceive();
|
||||
ble = bleTool.getBleTool();
|
||||
|
||||
@ -400,10 +401,10 @@
|
||||
these.formData.bleStatu = 'connecting';
|
||||
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
|
||||
these.formData.bleStatu = true;
|
||||
}).catch(ex => {
|
||||
these.formData.bleStatu = 'err';
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
});;
|
||||
}).catch(ex => {
|
||||
these.formData.bleStatu = 'err';
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
});;
|
||||
these.setBleFormData();
|
||||
these.getDetail();
|
||||
|
||||
@ -423,10 +424,10 @@
|
||||
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
|
||||
console.log("连接成功")
|
||||
these.formData.bleStatu = true;
|
||||
}).catch(ex => {
|
||||
these.formData.bleStatu = 'err';
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
});;
|
||||
}).catch(ex => {
|
||||
these.formData.bleStatu = 'err';
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
});;
|
||||
}
|
||||
},
|
||||
onBackPress(e) {
|
||||
@ -453,6 +454,19 @@
|
||||
|
||||
},
|
||||
methods: {
|
||||
initWatch() {
|
||||
this.$watch('formData.battary', (newVal, oldVal) => {
|
||||
if (newVal <= 20 && this.formData.statu == 0x00) {
|
||||
this.showPop({
|
||||
message: "设备电量低",
|
||||
iconUrl: "/static/images/common/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
bleStatuToggle() {
|
||||
let f = this.getDevice();
|
||||
if (!f) {
|
||||
@ -473,7 +487,7 @@
|
||||
these.formData.bleStatu = true;
|
||||
}).catch(ex => {
|
||||
these.formData.bleStatu = 'err';
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
});
|
||||
return;
|
||||
}
|
||||
@ -635,7 +649,7 @@
|
||||
updateLoading(these, {
|
||||
text: ex.msg
|
||||
});
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
MsgError("连接错误:" + ex.msg, "确定", these);
|
||||
}).finally(() => {
|
||||
setTimeout(() => {
|
||||
hideLoading(these);
|
||||
@ -690,17 +704,10 @@
|
||||
these.$forceUpdate();
|
||||
// console.log("更新后的电量:", these.formData.battary);
|
||||
|
||||
if (this.formData.battary <= 20) {
|
||||
this.showPop({
|
||||
message: "设备电量低",
|
||||
iconUrl: "/static/images/common/uploadErr.png",
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
|
||||
|
||||
showBleUnConnect() {
|
||||
this.showPop({
|
||||
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
|
||||
@ -708,7 +715,7 @@
|
||||
borderColor: "#e034344d",
|
||||
buttonBgColor: "#E03434",
|
||||
buttonText: '去连接',
|
||||
buttonTextColor: '#FFFFFFde',
|
||||
buttonTextColor: '#FFFFFFde',
|
||||
okCallback: function() {
|
||||
// console.log("1111");
|
||||
uni.navigateTo({
|
||||
@ -740,13 +747,13 @@
|
||||
return;
|
||||
}
|
||||
let os = plus.os.name;
|
||||
|
||||
|
||||
// 分包发送图片数据
|
||||
var sendImagePackets = function(ReSendNo) {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
// 总数据包数
|
||||
let totalPackets = os=='Android'?52:200;
|
||||
let totalPackets = os == 'Android' ? 52 : 200;
|
||||
let currentPacket = 1;
|
||||
|
||||
if (ReSendNo) {
|
||||
@ -779,7 +786,7 @@
|
||||
|
||||
// 计算当前包的数据
|
||||
let packetSize = os == 'Android' ? 250 : 64;
|
||||
|
||||
|
||||
|
||||
// 创建数据包
|
||||
let startIndex = (currentPacket - 1) * packetSize;
|
||||
@ -791,7 +798,7 @@
|
||||
let packetData = these.rgb565Data.slice(startIndex,
|
||||
endIndex);
|
||||
// 构建数据包
|
||||
let bufferSize = packetData.length * 2+5; // 头部5字节 + 数据部分
|
||||
let bufferSize = packetData.length * 2 + 5; // 头部5字节 + 数据部分
|
||||
let buffer = new ArrayBuffer(bufferSize);
|
||||
let dataView = new DataView(buffer);
|
||||
|
||||
@ -799,13 +806,13 @@
|
||||
dataView.setUint8(0, os == 'Android' ? 0x55 : 0x56); // 帧头
|
||||
dataView.setUint8(1, 0x02); // 帧类型:开机画面
|
||||
dataView.setUint8(2, currentPacket); // 包序号
|
||||
dataView.setUint16(3, packetData.length*2,false);
|
||||
|
||||
dataView.setUint16(3, packetData.length * 2, false);
|
||||
|
||||
// 填充数据(每个RGB565值占2字节)
|
||||
for (let i = 0; i < packetData.length; i++) {
|
||||
dataView.setUint16(5 + i * 2, packetData[i], false); // 大端字节序
|
||||
}
|
||||
|
||||
|
||||
//发送数据包
|
||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId,
|
||||
10).then(() => {
|
||||
@ -817,7 +824,8 @@
|
||||
})
|
||||
currentPacket++;
|
||||
|
||||
setTimeout(sendNextPacket,os=='Android'? these.inteval:these.inteval/2);
|
||||
setTimeout(sendNextPacket, os == 'Android' ? these
|
||||
.inteval : these.inteval / 2);
|
||||
}).catch(err => {
|
||||
console.log("发送数据包失败了" + JSON.stringify(err));
|
||||
if (err.code == '10007') {
|
||||
@ -865,7 +873,7 @@
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ['original', 'compressed'],
|
||||
sourceType: ['album','camera'],
|
||||
sourceType: ['album', 'camera'],
|
||||
success: function(res) {
|
||||
uni.navigateTo({
|
||||
url: "/pages/common/ImgCrop/ImgCrop",
|
||||
@ -878,9 +886,9 @@
|
||||
console.log("data=", data);
|
||||
these.Status.BottomMenu.show = false;
|
||||
these.rgb565Data = Common.convertToRGB565(data.piexls);
|
||||
console.log("1111111111")
|
||||
console.log("1111111111")
|
||||
setTimeout(function() {
|
||||
console.log("1111111111")
|
||||
console.log("1111111111")
|
||||
sendImagePackets().catch(() => {
|
||||
|
||||
});
|
||||
@ -915,8 +923,8 @@ console.log("1111111111")
|
||||
})
|
||||
return;
|
||||
}
|
||||
let os=plus.os.name;
|
||||
// os='Android';
|
||||
let os = plus.os.name;
|
||||
// os='Android';
|
||||
let f = these.getDevice();
|
||||
|
||||
if (!f) {
|
||||
@ -936,7 +944,7 @@ console.log("1111111111")
|
||||
return new Promise((resolve, reject) => {
|
||||
if (f) {
|
||||
// 总数据包数
|
||||
var totalPackets =os=='Android' ? 1536 : 6000; //36;
|
||||
var totalPackets = os == 'Android' ? 1536 : 6000; //36;
|
||||
|
||||
let currentPacket = 1;
|
||||
console.log("发送数据准备中,总共" + totalPackets);
|
||||
@ -949,30 +957,33 @@ console.log("1111111111")
|
||||
const sendNextVideoPacket = () => {
|
||||
// console.log("准备发送一段数据");
|
||||
if (currentPacket > totalPackets) {
|
||||
updateLoading(these,{text:'发送完毕,正在处理'})
|
||||
updateLoading(these, {
|
||||
text: '发送完毕,正在处理'
|
||||
})
|
||||
if (!ReSendNo) {
|
||||
setTimeout(() => {
|
||||
|
||||
ble.sendString(f.deviceId, "transmit complete", f.writeServiceId, f.wirteCharactId, 20)
|
||||
|
||||
ble.sendString(f.deviceId, "transmit complete", f
|
||||
.writeServiceId, f.wirteCharactId, 20)
|
||||
.then(
|
||||
() => {
|
||||
console.log("全部发送完毕")
|
||||
|
||||
|
||||
hideLoading(these);
|
||||
these.showPop({
|
||||
showPop: true,
|
||||
message: "上传成功",
|
||||
iconUrl: "/static/images/common/success.png"
|
||||
});
|
||||
|
||||
|
||||
}).catch((ex) => {
|
||||
console.log("出现异常", ex);
|
||||
});
|
||||
}, os=='Android'?500:15000);
|
||||
}, os == 'Android' ? 500 : 15000);
|
||||
|
||||
}
|
||||
these.Status.BottomMenu.show = false;
|
||||
|
||||
|
||||
these.videoHexArray = null;
|
||||
resolve();
|
||||
|
||||
@ -980,7 +991,7 @@ console.log("1111111111")
|
||||
}
|
||||
|
||||
// 计算当前包的数据
|
||||
let packetSize =os=='Android'? 500:128;
|
||||
let packetSize = os == 'Android' ? 500 : 128;
|
||||
|
||||
|
||||
// 创建数据包
|
||||
@ -996,28 +1007,29 @@ console.log("1111111111")
|
||||
|
||||
// 构建数据包
|
||||
////console.log("packetData.length"+packetData.length);
|
||||
const bufferSize =packetSize+4; // 头部5字节 + 数据部分
|
||||
const bufferSize = packetSize + 4; // 头部5字节 + 数据部分
|
||||
const buffer = new ArrayBuffer(bufferSize);
|
||||
const dataView = new DataView(buffer);
|
||||
|
||||
|
||||
|
||||
|
||||
// 填充头部
|
||||
dataView.setUint8(0, os=='Android'?0x55:0x56); // 帧头
|
||||
dataView.setUint8(0, os == 'Android' ? 0x55 : 0x56); // 帧头
|
||||
dataView.setUint8(1, 0x04); // 帧类型:开机画面
|
||||
dataView.setUint16(2, currentPacket,false); // 包序号
|
||||
|
||||
dataView.setUint16(2, currentPacket, false); // 包序号
|
||||
|
||||
for (let i = 0; i < packetData.length; i++) {
|
||||
dataView.setUint8(4 + i, parseInt(packetData[i],16));
|
||||
dataView.setUint8(4 + i, parseInt(packetData[i], 16));
|
||||
}
|
||||
|
||||
let inteval = os=='Android'? 100:40;
|
||||
let inteval = os == 'Android' ? 100 : 40;
|
||||
|
||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f
|
||||
.wirteCharactId, 10).then(() => {
|
||||
|
||||
|
||||
updateLoading(these, {
|
||||
text: "正在发送:" +currentPacket+'/'+totalPackets
|
||||
text: "正在发送:" + currentPacket + '/' +
|
||||
totalPackets
|
||||
})
|
||||
|
||||
currentPacket++;
|
||||
@ -1187,7 +1199,7 @@ console.log("1111111111")
|
||||
}).catch((ex1) => {
|
||||
//console.log("出现了异常", ex1)
|
||||
}).finally(() => {
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@ -1753,7 +1765,7 @@ console.log("1111111111")
|
||||
});
|
||||
|
||||
},
|
||||
sliderChanging(evt){
|
||||
sliderChanging(evt) {
|
||||
this.formData.liangDu = evt.detail.value;
|
||||
},
|
||||
sliderChange: function(evt) {
|
||||
@ -1806,8 +1818,8 @@ console.log("1111111111")
|
||||
|
||||
dataView.setUint8(0, 0x55); // 帧头
|
||||
dataView.setUint8(1, 0x07); // 帧类型:亮度调节
|
||||
dataView.setUint8(2, 0x01);
|
||||
dataView.setUint8(3, 0x00);
|
||||
dataView.setUint8(2, 0x01);
|
||||
dataView.setUint8(3, 0x00);
|
||||
dataView.setUint8(4, 0x01); //
|
||||
dataView.setUint8(5, liangDu); // 数据
|
||||
|
||||
@ -2186,7 +2198,7 @@ console.log("1111111111")
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
.slider-container {
|
||||
padding: 0px;
|
||||
|
||||
@ -43,22 +43,32 @@
|
||||
<!-- 设备基本信息 -->
|
||||
<view class="info-card">
|
||||
<view class="info-row">
|
||||
<text class="info-label">IMEI号</text>
|
||||
<text class="info-label">IMEI</text>
|
||||
<text class="info-value status-running">{{ deviceInfo.deviceImei }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">MAC</text>
|
||||
<text class="info-value status-running">{{ itemInfo.deviceMac }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">设备状态</text>
|
||||
<text class="info-value status-running">
|
||||
{{ deviceInfo.onlineStatus === 0 ? '离线' : deviceInfo.onlineStatus === 2 ? '故障' : '在线' }}
|
||||
</text>
|
||||
</view>
|
||||
<view class="info-row" v-if="itemInfo.deviceMac" @click="bleStatuToggle">
|
||||
<text class="info-label">蓝牙状态</text>
|
||||
<text class="info-value status-running" :class="formData.bleStatu?'green':'red'">
|
||||
{{getbleStatu}}
|
||||
<view class="info-row" >
|
||||
<text class="info-label">蓝牙名称</text>
|
||||
<text class="info-value status-running" >
|
||||
{{deviceInfo.bluetoothName}}
|
||||
</text>
|
||||
</view>
|
||||
<view class="info-row" v-if="itemInfo.deviceMac" @click="bleStatuToggle">
|
||||
<view class="info-row" @click="bleStatuToggle">
|
||||
<text class="info-label">蓝牙状态</text>
|
||||
<text class="info-value status-running" :class="getbleStatu.cls">
|
||||
{{getbleStatu.txt}}
|
||||
</text>
|
||||
</view>
|
||||
<view class="info-row" @click="bleStatuToggle">
|
||||
<text class="info-label">充电状态</text>
|
||||
<text class="info-value status-running">
|
||||
{{deviceInfo.chargeState != 0?'充电中':'未充电'}}
|
||||
@ -433,24 +443,36 @@
|
||||
return this.modeType === 'main' ? '灯光模式' : '激光模式';
|
||||
},
|
||||
getbleStatu() {
|
||||
|
||||
let txt="未连接"
|
||||
let cls="";
|
||||
if (this.formData.bleStatu === true) {
|
||||
return '已连接';
|
||||
txt= '已连接';
|
||||
cls="green";
|
||||
}
|
||||
if (this.formData.bleStatu === 'connecting') {
|
||||
return '连接中';
|
||||
txt= '连接中';
|
||||
}
|
||||
if (this.formData.bleStatu === 'dicconnect') {
|
||||
return '正在断开';
|
||||
txt= '正在断开';
|
||||
}
|
||||
if (this.formData.bleStatu === 'err') {
|
||||
return '连接异常';
|
||||
txt= '连接异常';
|
||||
cls="red"
|
||||
}
|
||||
return '未连接';
|
||||
return {txt:txt,cls:cls}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
initWatch(){
|
||||
this.$watch("deviceInfo.batteryPercentage",(newVal,oldVal)=>{
|
||||
if (this.deviceInfo.batteryPercentage < 20 &&
|
||||
this.deviceInfo.chargeState == 0) {
|
||||
this.popupType = 'bettery';
|
||||
this.popupMessage = '请及时充电';
|
||||
this.showPopupFlag = true;
|
||||
}
|
||||
});
|
||||
},
|
||||
onReceive(deviceState, parsedMessage) { //蓝牙/Mq通用消息处理
|
||||
switch (deviceState[0]) {
|
||||
// 1设备切换灯光实时返回
|
||||
@ -482,12 +504,7 @@
|
||||
this.deviceInfo.batteryRemainingTime = deviceState[5]; //第6位200代表电池剩余续航时间200分钟
|
||||
}
|
||||
setTimeout(() => {
|
||||
if (this.deviceInfo.batteryPercentage < 20 &&
|
||||
this.deviceInfo.chargeState == 0) {
|
||||
this.popupType = 'bettery';
|
||||
this.popupMessage = '请及时充电';
|
||||
this.showPopupFlag = true;
|
||||
}
|
||||
|
||||
if (this.apiType === 'listA') {
|
||||
this.fetchDeviceDetail(data.data.id)
|
||||
} else {
|
||||
@ -2014,7 +2031,7 @@
|
||||
},
|
||||
onLoad(options) {
|
||||
these = this;
|
||||
|
||||
this.initWatch();
|
||||
rec = BleReceive.getBleReceive();
|
||||
const eventChannel = this.getOpenerEventChannel();
|
||||
// 监听 'detailData' 事件,获取传过来的数据
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
{{Statu.boundRemark}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="btnLink" @click="Link()">
|
||||
<view class="btnLink" @click="Bind()">
|
||||
绑定
|
||||
</view>
|
||||
|
||||
@ -71,7 +71,10 @@
|
||||
"communicationMode": "",
|
||||
"imei": ""
|
||||
},
|
||||
serverDevice: null
|
||||
serverDevice: null,
|
||||
groupid:null,
|
||||
typeList:[],
|
||||
uploadStatu:null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -86,7 +89,6 @@
|
||||
}
|
||||
},
|
||||
deviceStatu: function() {
|
||||
debugger;
|
||||
if (!this.device.name && !this.device.macAddress) {
|
||||
return "";
|
||||
}
|
||||
@ -127,7 +129,8 @@
|
||||
console.log("返回取消订阅");
|
||||
clearInterval(inteval);
|
||||
ble.removeAllCallback(pagePath);
|
||||
|
||||
clearTimeout(this.Statu.timeInteval);
|
||||
this.uploadStatu=null;
|
||||
if(!this.Statu.isBind && these.device.deviceId){
|
||||
ble.disconnectDevice(these.device.deviceId).catch(ex=>{
|
||||
console.error("无法断开蓝牙连接");
|
||||
@ -137,6 +140,8 @@
|
||||
|
||||
onLoad(option) {
|
||||
these = this;
|
||||
this.groupid=new Date().getTime()+"";
|
||||
|
||||
ble = bleTool.getBleTool();
|
||||
|
||||
ble.addStateBreakCallback(res => {
|
||||
@ -258,6 +263,108 @@
|
||||
|
||||
},
|
||||
methods: {
|
||||
getDevList() {
|
||||
return new Promise((resolve,reject)=>{
|
||||
let arr = [
|
||||
|
||||
];
|
||||
request({
|
||||
url: '/app/xinghan/device/typeAll',
|
||||
method: 'get'
|
||||
}).then(res => {
|
||||
if (res && res.code == 200) {
|
||||
console.log("获取到类型", res.data);
|
||||
arr = res.data;
|
||||
this.typeList = arr;
|
||||
resolve(arr);
|
||||
return;
|
||||
}
|
||||
reject();
|
||||
|
||||
}).catch(ex => {
|
||||
console.error("获取设备类型列表失败",ex);
|
||||
reject();
|
||||
})
|
||||
});
|
||||
|
||||
},
|
||||
uploadItem() {
|
||||
if(this.uploadStatu!==null){
|
||||
console.error("执行过上传,不再执行");
|
||||
return;
|
||||
}
|
||||
|
||||
this.uploadStatu="start";
|
||||
console.log("开始上传设备");
|
||||
|
||||
let type=this.device.name.toLowerCase();
|
||||
if(type.indexOf("bjq6155-")>-1){//6155特别处理
|
||||
type="xh6155"
|
||||
}
|
||||
if(type.indexOf("bjq6155-")>-1){//6155特别处理
|
||||
type="xh6155"
|
||||
}
|
||||
if(type.indexOf("bjq6075-")>-1){//6075j特别处理
|
||||
bype='bjq6075j';
|
||||
}
|
||||
type=type.replace(/-/g,'');
|
||||
let upload=()=>{
|
||||
let f=this.typeList.find((v,i)=>{
|
||||
if(type.indexOf(v.typeName.replace(/-/g,'').toLowerCase())>-1){
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
if(!f){
|
||||
this.uploadStatu="type is valid";
|
||||
console.error("找不到此类型名称",type);
|
||||
console.error("tpelist=",this.typeList);
|
||||
return;
|
||||
}
|
||||
let json = {
|
||||
"deviceType": f.id,
|
||||
"deviceName": this.device.name,
|
||||
"deviceMac": this.device.macAddress,
|
||||
"bluetoothName": this.device.name,
|
||||
"deviceImei":this.device.imei?this.device.imei:'',
|
||||
"remark": "com.chxhyc.cn auto upload"
|
||||
}
|
||||
request({
|
||||
url: '/app/xinghan/device/add',
|
||||
method: 'post',
|
||||
data: json
|
||||
}).then(res => {
|
||||
if (res && res.code == 200) {
|
||||
this.uploadStatu="success";
|
||||
console.log("上传成功",res);
|
||||
} else {
|
||||
this.uploadStatu="upload error";
|
||||
console.error("上传失败,",res);
|
||||
}
|
||||
}).catch(ex => {
|
||||
this.uploadStatu="upload error";
|
||||
console.error("上传失败,",ex);
|
||||
});
|
||||
}
|
||||
|
||||
let exec = () => {
|
||||
|
||||
if(this.typeList.length==0){
|
||||
this.getDevList().then(results=>{
|
||||
upload();
|
||||
}).catch(ex=>{
|
||||
this.uploadStatu="get types error";
|
||||
console.error("获取类型失败,",ex);
|
||||
});
|
||||
}else{
|
||||
upload();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
setTimeout(exec, 10)
|
||||
},
|
||||
reLinkdevice() {
|
||||
ble.LinkBlue(these.device.deviceId).then(res => {
|
||||
updateLoading(these, {
|
||||
@ -320,6 +427,7 @@
|
||||
clearInterval(inteval);
|
||||
} else {
|
||||
deviceInvalid();
|
||||
this.uploadItem();
|
||||
}
|
||||
} else {
|
||||
this.serverDevice =null;
|
||||
@ -337,7 +445,7 @@
|
||||
}, 500);
|
||||
|
||||
},
|
||||
Link() {
|
||||
Bind() {
|
||||
// 调用绑定设备接口
|
||||
|
||||
// let f = ble.data.LinkedList.find((v) => {
|
||||
|
||||
@ -727,7 +727,7 @@
|
||||
});
|
||||
|
||||
let index = 1;
|
||||
let total = 5;
|
||||
let total = 1;
|
||||
|
||||
let linkCallback = (res) => {
|
||||
console.log("连接成功", these.device);
|
||||
|
||||
@ -45,12 +45,17 @@
|
||||
|
||||
|
||||
</view>
|
||||
<view class="tab">
|
||||
<view class="center tabItem" @click="Status.tabIndex=0" :class="{'active':Status.tabIndex==0}">未入库(<text class="mathIcon">{{UnJoin.length}}</text>)</view>
|
||||
<view class="center tabItem" @click="Status.tabIndex=1" :class="{'active':Status.tabIndex==1}">已入库(<text class="mathIcon">{{joined.length}}</text>)</view>
|
||||
<view class="center tabItem" @click="Status.tabIndex=2" :class="{'active':Status.tabIndex==2}">全部(<text class="mathIcon">{{SearchEquips.length}}</text>)</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="mainContent">
|
||||
<view class="p100">
|
||||
|
||||
<view class="list searchList">
|
||||
<view class="item" v-on:click="Link(item,index)" v-for="item, index in SearchEquips"
|
||||
<view class="item" v-on:click="Link(item,index)" v-for="item, index in list"
|
||||
v-show="!item['linkStatu']"
|
||||
:class="{'displayNone':item.name.toLowerCase().indexOf(search.toLowerCase())===-1}">
|
||||
<view class="leftImg ">
|
||||
@ -152,7 +157,8 @@
|
||||
title: '添加设备',
|
||||
showBack: true,
|
||||
height: 90
|
||||
}
|
||||
},
|
||||
tabIndex:0
|
||||
},
|
||||
search: '',
|
||||
groupid: '',
|
||||
@ -168,12 +174,35 @@
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
list(){
|
||||
if(this.Status.tabIndex==0){
|
||||
return this.UnJoin;
|
||||
}
|
||||
if(this.Status.tabIndex==1){
|
||||
return this.joined;
|
||||
}
|
||||
|
||||
return this.SearchEquips;
|
||||
},
|
||||
SearchEquips: function() {
|
||||
let f = this.EquipMents.filter(v => {
|
||||
return v.name.toLowerCase().indexOf(this.search.toLowerCase()) > -1
|
||||
});
|
||||
return f;
|
||||
}
|
||||
},
|
||||
joined(){
|
||||
let f=this.EquipMents.filter(v => {
|
||||
return v.name.toLowerCase().indexOf(this.search.toLowerCase()) > -1 && v.isUpload;
|
||||
});
|
||||
return f;
|
||||
},
|
||||
UnJoin(){
|
||||
let f=this.EquipMents.filter(v => {
|
||||
return v.name.toLowerCase().indexOf(this.search.toLowerCase()) > -1 && !v.isUpload;
|
||||
});
|
||||
return f;
|
||||
},
|
||||
|
||||
},
|
||||
onHide: function() {
|
||||
ble.StopSearch();
|
||||
@ -427,7 +456,7 @@
|
||||
|
||||
if (!f) {
|
||||
arr[i].remark = '正在校验...';
|
||||
these.EquipMents.push(arr[i]);
|
||||
these.EquipMents.unshift(arr[i]);
|
||||
|
||||
these.getDevice(arr[i]);
|
||||
|
||||
@ -482,18 +511,19 @@
|
||||
|
||||
|
||||
ble.addStateBreakCallback(() => {
|
||||
|
||||
MsgError('蓝牙不可用','确定',these);
|
||||
|
||||
MsgError('蓝牙不可用','',these);
|
||||
|
||||
these.EquipMents=[];
|
||||
these.EquipMents.filter((v, i) => {
|
||||
these.$set(these.EquipMents[i], 'link', false);
|
||||
});
|
||||
}, pagePath);
|
||||
ble.addStateRecoveryCallback(() => {
|
||||
|
||||
|
||||
these.ReSearch();
|
||||
MsgSuccess('蓝牙恢复可用','',these,()=>{
|
||||
MsgSuccess('蓝牙恢复可用','确定',these,()=>{
|
||||
MsgClear(these);
|
||||
})
|
||||
});
|
||||
},
|
||||
pagePath);
|
||||
|
||||
@ -553,11 +583,10 @@
|
||||
|
||||
|
||||
|
||||
|
||||
// #ifdef APP|APP-PLUS
|
||||
setTimeout(()=>{
|
||||
debugger;
|
||||
MsgInfo("如需要在PC上查看此数据,请复制链接后通过微信发送到PC,在PC端打开,然后点右上角扫码授权","复制链接",these,true,()=>{
|
||||
console.log("执行复制");
|
||||
console.log("开始访问剪切板");
|
||||
uni.setClipboardData({
|
||||
data:'https://static-mp-5b7c35fc-f6fe-4100-a2e1-3669e4d4bfc9.next.bspapp.com/AppTools/views/index.html',
|
||||
success(){
|
||||
@ -565,25 +594,19 @@
|
||||
title:'已复制链接'
|
||||
});
|
||||
|
||||
// #ifdef APP
|
||||
|
||||
plus.runtime.openURL('weixin://', (err) => {
|
||||
MsgError("打开微信失败,请手动打开微信,发送至'文件传输助手'");
|
||||
});
|
||||
// #endif
|
||||
|
||||
// #ifndef APP
|
||||
MsgInfo("已复制链接,请打开浏览器查看","",these);
|
||||
setTimeout(()=>{
|
||||
MsgClear(these);
|
||||
},1200)
|
||||
// #endif
|
||||
},
|
||||
fail(ex){
|
||||
console.error("无法复制",ex)
|
||||
fail(ex) {
|
||||
console.error("ex=",ex);
|
||||
}
|
||||
});
|
||||
});
|
||||
},500);
|
||||
// #endif
|
||||
|
||||
},
|
||||
|
||||
onShow: function() {
|
||||
@ -812,6 +835,7 @@
|
||||
|
||||
let json = getUrlParams(res.result);
|
||||
if (!json.key) {
|
||||
|
||||
|
||||
MsgError('无效的二维码','',these);
|
||||
return;
|
||||
@ -892,11 +916,11 @@
|
||||
ble.disconnectDevice().finally(dis => {
|
||||
|
||||
ble.StopSearch().finally(res => {
|
||||
|
||||
setTimeout(()=>{
|
||||
this.EquipMents = [];
|
||||
|
||||
this.EquipMents = [];
|
||||
this.PairEquip = [];
|
||||
ble.StartSearch().then(result => {
|
||||
setTimeout(()=>{
|
||||
ble.StartSearch().then(result => {
|
||||
|
||||
}).catch(err => {
|
||||
console.error("err=", err);
|
||||
@ -904,7 +928,7 @@
|
||||
}).finally(()=>{
|
||||
hideLoading(these);
|
||||
});
|
||||
},200);
|
||||
},600)
|
||||
|
||||
}).catch(ex => {
|
||||
console.error("ex=", ex);
|
||||
@ -993,7 +1017,7 @@
|
||||
});
|
||||
|
||||
let index = 1;
|
||||
let total = 5;
|
||||
let total = 1;
|
||||
|
||||
let linkCallback = (res) => {
|
||||
let c = these.PairEquip.find(function(v) {
|
||||
@ -1029,14 +1053,11 @@
|
||||
return false;
|
||||
});
|
||||
|
||||
ble.StopSearch();
|
||||
|
||||
resolve(res);
|
||||
}).catch((ex) => {
|
||||
if (index == total) {
|
||||
console.log("连接了N次都没连上");
|
||||
updateLoading(this, {
|
||||
text: ex.msg
|
||||
});
|
||||
reject(ex);
|
||||
return;
|
||||
}
|
||||
@ -1058,8 +1079,8 @@
|
||||
these.sendEquipToMq();
|
||||
}).catch(ex => {
|
||||
console.log("ex=", ex)
|
||||
|
||||
MsgError("连接失败:" + ex.msg,'',these);
|
||||
|
||||
MsgError("连接失败"+ex.code + ex.msg,'',these);
|
||||
hideLoading(these);
|
||||
});
|
||||
}
|
||||
@ -1076,6 +1097,22 @@
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.tabItem.active{
|
||||
border-bottom:2rpx solid #BBE600;
|
||||
color:#BBE600;
|
||||
}
|
||||
.mathIcon{
|
||||
color: #BBE600;
|
||||
}
|
||||
.tab{
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
align-content: center;
|
||||
justify-content: space-evenly;
|
||||
height: 60rpx;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
.noLink {
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
@ -1228,12 +1265,7 @@
|
||||
min-height: 120rpx;
|
||||
}
|
||||
|
||||
.searchList {
|
||||
width: 100%;
|
||||
height: calc(100% - 186rpx);
|
||||
overflow-y: scroll;
|
||||
margin-top: 120rpx;
|
||||
}
|
||||
|
||||
|
||||
.list .item {
|
||||
width: 100%;
|
||||
@ -1447,7 +1479,7 @@
|
||||
.topStatric {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
padding: 30rpx;
|
||||
padding:0rpx 30rpx;
|
||||
position: fixed;
|
||||
top: 0rpx;
|
||||
z-index: 99;
|
||||
@ -1463,9 +1495,15 @@
|
||||
|
||||
.mainContent {
|
||||
|
||||
margin-top: 160rpx;
|
||||
margin-top: 280rpx;
|
||||
}
|
||||
|
||||
.searchList {
|
||||
width: 100%;
|
||||
height: calc(100% - 186rpx);
|
||||
overflow-y: scroll;
|
||||
margin-top: 90rpx;
|
||||
}
|
||||
|
||||
/* #endif */
|
||||
|
||||
@ -1476,9 +1514,15 @@
|
||||
}
|
||||
|
||||
.topStatric {
|
||||
top: 90rpx
|
||||
top: 130rpx
|
||||
}
|
||||
|
||||
.searchList {
|
||||
width: 100%;
|
||||
height: calc(100% - 186rpx);
|
||||
overflow-y: scroll;
|
||||
margin-top: 150rpx;
|
||||
}
|
||||
/* #endif */
|
||||
|
||||
|
||||
|
||||
@ -27,10 +27,11 @@
|
||||
<mescroll-uni class="device-list" @init="mescrollInit" @down="downCallback" @up="upCallback" :up="upOption"
|
||||
:down="downOption" :fixed="false" :style="{ height: mescrollHeight + 'px' }">
|
||||
<view v-if="deviceList.length>0">
|
||||
<uni-swipe-action ref="swipeAction" >
|
||||
<uni-swipe-action ref="swipeAction">
|
||||
<block v-for="(item, index) in deviceList" :key="index" :ref="'swipeItem_' + index">
|
||||
<uni-swipe-action-item :right-options="Options" :show="item.showOption"
|
||||
@click="handleSwipeClick($event, item, index)" class="device-card"
|
||||
:class="item.active?'active':''"
|
||||
:style="{ border: item.communicationMode==0 && item.onlineStatus==1 && item.alarmStatus==1 ? '1px solid rgba(224, 52, 52, 1)' : 'none' }">
|
||||
<view @click.stop="handleFile(item,index)">
|
||||
<view class="device-header">
|
||||
@ -62,7 +63,8 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<image @click.stop="swipeToggle(item,index)" src="/static/images/common/cires.png" class="circle" mode="aspectFit"></image>
|
||||
<image @click.stop="swipeToggle(item,index)" src="/static/images/common/cires.png"
|
||||
class="circle" mode="aspectFit"></image>
|
||||
</uni-swipe-action-item>
|
||||
</block>
|
||||
</uni-swipe-action>
|
||||
@ -136,8 +138,8 @@
|
||||
</view>
|
||||
<!-- 蒙板、用于点击任意位置关闭悬浮的菜单 -->
|
||||
<view class="mask" v-show="showTooltip||showshare" @click.stop="closePopMenu"></view>
|
||||
|
||||
|
||||
|
||||
|
||||
<MsgBox ref="msgPop" />
|
||||
</view>
|
||||
</template>
|
||||
@ -242,8 +244,8 @@
|
||||
isLock: false,
|
||||
empty: {
|
||||
tip: '暂无数据',
|
||||
hideScroll: false,
|
||||
icon: '/static/images/common/empty.png'
|
||||
hideScroll: false,
|
||||
icon: '/static/images/common/empty.png'
|
||||
},
|
||||
textNoMore: '没有更多数据了'
|
||||
},
|
||||
@ -315,7 +317,7 @@
|
||||
|
||||
},
|
||||
bleBreak(res) {
|
||||
// console.error("蓝牙断开连接", res);
|
||||
console.error("蓝牙断开连接", res);
|
||||
if (res.deviceId) {
|
||||
this.updateBleStatu(res.deviceId);
|
||||
}
|
||||
@ -698,37 +700,44 @@
|
||||
}
|
||||
})
|
||||
},
|
||||
swipeToggle(item,index){
|
||||
if(!item.showOption || item.showOption=='none'){
|
||||
this.$set(this.deviceList[index],'showOption','right');
|
||||
swipeToggle(item, index) {
|
||||
if (!item.showOption || item.showOption == 'none') {
|
||||
this.$set(this.deviceList[index], 'showOption', 'right');
|
||||
return;
|
||||
}
|
||||
this.$set(this.deviceList[index],'showOption','none');
|
||||
this.$set(this.deviceList[index], 'showOption', 'none');
|
||||
},
|
||||
// 列表跳转
|
||||
handleFile(item,index) {
|
||||
if(item.showOption=='right'){
|
||||
this.$set(this.deviceList[index],'showOption','none');
|
||||
handleFile(item, index) {
|
||||
if (item.showOption == 'right') {
|
||||
this.$set(this.deviceList[index], 'showOption', 'none');
|
||||
return;
|
||||
}
|
||||
let url = item.detailPageUrl;
|
||||
uni.navigateTo({
|
||||
url: url,
|
||||
events: {
|
||||
ack: function(data) {}
|
||||
},
|
||||
success: (res) => {
|
||||
// 页面跳转成功后的回调函数
|
||||
res.eventChannel.emit('detailData', {
|
||||
data: item,
|
||||
deviceType: this.tabs[this.activeTab].id || '',
|
||||
apiType: 'listA' //标识,根据这个参数,区分普通详情,分享跳转详情,查不一样的权限信息
|
||||
});
|
||||
},
|
||||
fail(ex) {
|
||||
console.log("ex=", ex);
|
||||
}
|
||||
})
|
||||
|
||||
this.$set(this.deviceList[index], 'active', true);
|
||||
setTimeout(() => {
|
||||
this.$set(this.deviceList[index], 'active', false);
|
||||
let url = item.detailPageUrl;
|
||||
uni.navigateTo({
|
||||
url: url,
|
||||
events: {
|
||||
ack: function(data) {}
|
||||
},
|
||||
success: (res) => {
|
||||
// 页面跳转成功后的回调函数
|
||||
res.eventChannel.emit('detailData', {
|
||||
data: item,
|
||||
deviceType: this.tabs[this.activeTab].id || '',
|
||||
apiType: 'listA' //标识,根据这个参数,区分普通详情,分享跳转详情,查不一样的权限信息
|
||||
});
|
||||
},
|
||||
fail(ex) {
|
||||
console.log("ex=", ex);
|
||||
}
|
||||
});
|
||||
}, 100);
|
||||
|
||||
|
||||
},
|
||||
|
||||
updateDeviceStatus(data) {
|
||||
@ -768,7 +777,6 @@
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
|
||||
// console.error("首页加载");
|
||||
this.getTab()
|
||||
this.downCallback();
|
||||
@ -785,7 +793,7 @@
|
||||
this.downCallback();
|
||||
});
|
||||
ble = bleTool.getBleTool();
|
||||
console.log("this=",this);
|
||||
console.log("this=", this);
|
||||
recei = BleReceive.getBleReceive(this);
|
||||
//蓝牙连接成功的回调
|
||||
ble.addRecoveryCallback((res) => {
|
||||
@ -795,7 +803,7 @@
|
||||
|
||||
//蓝牙断开连接的回调
|
||||
ble.addDisposeCallback((res) => {
|
||||
// console.log("蓝牙断开连接的回调");
|
||||
console.log("蓝牙断开连接的回调");
|
||||
this.bleBreak(res);
|
||||
}, pagePath);
|
||||
|
||||
@ -813,8 +821,8 @@
|
||||
|
||||
//接收到消息的回调
|
||||
ble.addReceiveCallback((receive, device, path, recArr) => {
|
||||
// console.error("首页收到消息了");
|
||||
let json=recei.ReceiveData(receive, device, path, recArr);
|
||||
// console.error("首页收到消息了");
|
||||
let json = recei.ReceiveData(receive, device, path, recArr);
|
||||
// console.error("消息内容",json);
|
||||
this.updateBleStatu();
|
||||
}, pagePath);
|
||||
@ -888,22 +896,23 @@
|
||||
text-align: center;
|
||||
/* 文字居中 */
|
||||
/* 设置最小宽度 */
|
||||
|
||||
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.tab-item.active {
|
||||
color: #bbe600;
|
||||
|
||||
|
||||
height: 60rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
.tab-item.active::before{
|
||||
|
||||
.tab-item.active::before {
|
||||
content: "";
|
||||
background-color: #bbe600;
|
||||
background-color: #bbe600;
|
||||
position: absolute;
|
||||
top: 90%;
|
||||
left:35%;
|
||||
left: 35%;
|
||||
width: 30%;
|
||||
height: 6rpx;
|
||||
border-radius: 6rpx;
|
||||
@ -957,6 +966,9 @@
|
||||
box-sizing: border-box;
|
||||
position: relative;
|
||||
}
|
||||
.device-card.active{
|
||||
background-color: #2a2a2a !important;
|
||||
}
|
||||
|
||||
|
||||
.device-header {
|
||||
@ -1160,23 +1172,24 @@
|
||||
}
|
||||
|
||||
|
||||
.cancelBtn{
|
||||
|
||||
|
||||
.cancelBtn {
|
||||
|
||||
|
||||
text-align: center;
|
||||
width: 170rpx !important;
|
||||
background-color: #00000000;
|
||||
}
|
||||
|
||||
.agreement-popupC .cancelBtn{
|
||||
border:1rpx solid #E03434;
|
||||
color:#E03434;
|
||||
|
||||
.agreement-popupC .cancelBtn {
|
||||
border: 1rpx solid #E03434;
|
||||
color: #E03434;
|
||||
}
|
||||
|
||||
.agreement-popupD .cancelBtn{
|
||||
|
||||
.agreement-popupD .cancelBtn {
|
||||
border: 1rpx solid rgba(255, 255, 255, 0.6);
|
||||
color:rgba(255, 255, 255, 0.6);
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
}
|
||||
|
||||
.agreement-popupD {
|
||||
width: 75%;
|
||||
background-color: rgb(42, 42, 42);
|
||||
|
||||
280
pages/common/map/index.nvue
Normal file
280
pages/common/map/index.nvue
Normal file
@ -0,0 +1,280 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<map class="map" :latitude="latitude" :longitude="longitude" :markers="covers" @markertap="onMarkerTap"
|
||||
:scale="16"></map>
|
||||
|
||||
<!-- 加载提示 -->
|
||||
<view v-if="loading" class="loading-mask">
|
||||
<view class="loading-content">加载中...</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Common from "@/utils/Common.js";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
latitude: 39.909,
|
||||
longitude: 116.39742,
|
||||
covers: [],
|
||||
loading: true,
|
||||
markerData: [],
|
||||
clickMarker: {
|
||||
"deviceId": "",
|
||||
"deviceName": "",
|
||||
"deviceImei": "",
|
||||
"deviceMac": "",
|
||||
"communicationMode": null,
|
||||
"devicePic": "",
|
||||
"typeName": "",
|
||||
"bluetoothName": "",
|
||||
"deviceStatus": 1,
|
||||
"personnelInfo": null,
|
||||
"sendMsg": null,
|
||||
"mainLightMode": null,
|
||||
"laserLightMode": "",
|
||||
"batteryPercentage": "",
|
||||
"chargeState": "0",
|
||||
"batteryRemainingTime": "0",
|
||||
"onlineStatus": 0,
|
||||
"longitude": "",
|
||||
"latitude": "",
|
||||
"address": "",
|
||||
"alarmStatus": null,
|
||||
"lightBrightness": null
|
||||
},
|
||||
Status: {
|
||||
BottomMenu: {
|
||||
show: false,
|
||||
showHeader: true,
|
||||
menuItems: [{
|
||||
text: '高德地图',
|
||||
value: 'amap',
|
||||
icon: ''
|
||||
},
|
||||
{
|
||||
text: '百度地图',
|
||||
value: 'baidumap',
|
||||
icon: ''
|
||||
}
|
||||
],
|
||||
activeIndex: -1,
|
||||
bgColor: '#2a2a2a',
|
||||
itemBgColor: '#3a3a3a',
|
||||
textColor: '#ffffffde',
|
||||
textAlign: 'flex-start',
|
||||
title: '选择导航',
|
||||
showDivider: false,
|
||||
dividerColor: '#00000000',
|
||||
dividerThickness: '0rpx',
|
||||
dividerMargin: '10rpx',
|
||||
itemHeight: '80rpx',
|
||||
type: '',
|
||||
showBtn: false,
|
||||
btnBgColor: "#bbe600",
|
||||
btnText: "确定",
|
||||
btnTextColor: "#232323de",
|
||||
showMask: true,
|
||||
maskBgColor: '#00000066',
|
||||
showClose: false
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
const eventChannel = this.getOpenerEventChannel();
|
||||
eventChannel.on('Map', (receivedData) => {
|
||||
console.log("地图页收到数据",receivedData);
|
||||
this.loading = true;
|
||||
this.covers = [];
|
||||
const dataContent = receivedData.data;
|
||||
|
||||
if (Array.isArray(dataContent)) {
|
||||
const validDevices = dataContent.filter(device =>
|
||||
device.latitude && device.longitude &&
|
||||
device.latitude !== '' && device.longitude !== ''
|
||||
);
|
||||
this.markerData = validDevices;
|
||||
if (validDevices.length > 0) {
|
||||
this.processMultipleMarkers(validDevices);
|
||||
} else {
|
||||
console.log('无有效经纬度');
|
||||
this.loading = false;
|
||||
}
|
||||
} else if (typeof dataContent === 'object' && dataContent !== null) {
|
||||
if (this.validateMarker(dataContent)) {
|
||||
this.markerData = [dataContent];
|
||||
this.processSingleMarker(dataContent);
|
||||
} else {
|
||||
console.log('经纬度无效');
|
||||
this.loading = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
showAction() {
|
||||
|
||||
let gd=plus.runtime.isApplicationExist({
|
||||
pname: 'com.autonavi.minimap', // 安卓高德包名
|
||||
action: 'iosamap://' // iOS高德 Scheme
|
||||
});
|
||||
|
||||
let bd= plus.runtime.isApplicationExist({
|
||||
pname: 'com.baidu.BaiduMap', // 安卓百度包名
|
||||
action: 'baidumap://' // iOS百度 Scheme
|
||||
});
|
||||
let list=[];
|
||||
let gdStr='高德地图';
|
||||
let bdStr='百度地图';
|
||||
console.log("gd=",gd);
|
||||
console.log("bd=",bd);
|
||||
list=[gdStr,bdStr];
|
||||
uni.showActionSheet({
|
||||
title: '选择地图',
|
||||
|
||||
itemList:list ,
|
||||
success: (res)=> {
|
||||
let mapType = 'amap';
|
||||
if (res.tapIndex == 1) {
|
||||
mapType = 'baiduMap';
|
||||
if(!bd){
|
||||
uni.showToast({
|
||||
icon:"error",
|
||||
title:'未安装'+bdStr
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(res.tapIndex==0 && !gd) {
|
||||
uni.showToast({
|
||||
icon:"error",
|
||||
title:'未安装'+gdStr
|
||||
})
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
let marker = this.clickMarker;
|
||||
Common.MapNavi(marker.longitude, marker.latitude, marker.address, mapType).catch(
|
||||
ex => {
|
||||
uni.showToast({
|
||||
icon: "error",
|
||||
title: '无法打开地图'
|
||||
});
|
||||
});
|
||||
|
||||
},
|
||||
})
|
||||
|
||||
},
|
||||
|
||||
navigatMap(e) {
|
||||
console.log("点位被点击,", e);
|
||||
},
|
||||
processSingleMarker(marker) {
|
||||
const lat = parseFloat(marker.latitude);
|
||||
const lng = parseFloat(marker.longitude);
|
||||
this.latitude = lat;
|
||||
this.longitude = lng;
|
||||
|
||||
this.covers = [{
|
||||
id: marker.id+"",
|
||||
latitude: lat,
|
||||
longitude: lng,
|
||||
iconPath: '/static/images/common/mapLocation.png',
|
||||
width: 30,
|
||||
height: 50,
|
||||
anchor: {
|
||||
x: 0.5,
|
||||
y: 0.5
|
||||
},
|
||||
callout: {
|
||||
content: marker.deviceName
|
||||
}
|
||||
}];
|
||||
|
||||
console.log("covers=",this.covers);
|
||||
this.loading = false;
|
||||
},
|
||||
|
||||
processMultipleMarkers(markers) {
|
||||
const first = markers[0];
|
||||
this.latitude = parseFloat(first.latitude);
|
||||
this.longitude = parseFloat(first.longitude);
|
||||
|
||||
this.covers = markers.map((marker, index) => ({
|
||||
id: marker.id+"",
|
||||
latitude: parseFloat(marker.latitude),
|
||||
longitude: parseFloat(marker.longitude),
|
||||
iconPath: '/static/images/common/mapLocation.png',
|
||||
width: 30,
|
||||
height: 50,
|
||||
anchor: {
|
||||
x: 0.5,
|
||||
y: 0.5
|
||||
},
|
||||
callout: {
|
||||
content: marker.deviceName
|
||||
}
|
||||
}));
|
||||
this.loading = false;
|
||||
},
|
||||
|
||||
validateMarker(marker) {
|
||||
const lat = parseFloat(marker.latitude);
|
||||
const lng = parseFloat(marker.longitude);
|
||||
return !isNaN(lat) && !isNaN(lng);
|
||||
},
|
||||
|
||||
onMarkerTap(e) {
|
||||
console.log('点击了标记', e);
|
||||
let marker = this.markerData.find(item => {
|
||||
return item.id == e.detail.markerId
|
||||
});
|
||||
console.log('点击了标记', marker);
|
||||
if (marker) {
|
||||
this.clickMarker = marker;
|
||||
this.showAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
/* nvue 全屏必须这样写 */
|
||||
.container {
|
||||
flex: 1;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.map {
|
||||
width: 750rpx;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.loading-mask {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
.loading-content {
|
||||
color: #fff;
|
||||
font-size: 28rpx;
|
||||
padding: 20rpx 30rpx;
|
||||
background-color: rgba(0, 0, 0, 0.7);
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
</style>
|
||||
@ -79,16 +79,17 @@ export default {
|
||||
this.latitude = lat;
|
||||
this.longitude = lng;
|
||||
// 创建标记点
|
||||
console.log("devicePic=",marker)
|
||||
this.covers = [{
|
||||
id: marker.deviceImei, // 适配deviceId字段
|
||||
latitude: lat,
|
||||
longitude: lng,
|
||||
iconPath: marker.devicePic || '/static/images/common/mapLocation.png',
|
||||
width: 40,
|
||||
height: 40,
|
||||
iconPath: '/static/images/common/mapLocation.png',
|
||||
width: 60,
|
||||
height: 60,
|
||||
anchor: {x: 0.5, y: 0.5}, // 锚点在中心
|
||||
callout: {
|
||||
content: `ID: ${marker.deviceImei}`
|
||||
content: `${marker.deviceName}`
|
||||
}
|
||||
}];
|
||||
|
||||
@ -102,17 +103,18 @@ export default {
|
||||
this.latitude = parseFloat(firstMarker.latitude);
|
||||
this.longitude = parseFloat(firstMarker.longitude);
|
||||
|
||||
console.log("devicePic=",marker.devicePic)
|
||||
// 转换所有有效标记点
|
||||
this.covers = markers.map((marker, index) => ({
|
||||
id: marker.deviceId || marker.id || marker.deviceImei || index + 1,
|
||||
latitude: parseFloat(marker.latitude),
|
||||
longitude: parseFloat(marker.longitude),
|
||||
iconPath: marker.devicePic || '/static/images/common/device.png',
|
||||
width: 40,
|
||||
height: 40,
|
||||
iconPath: '/static/images/common/mapLocation.png',
|
||||
width: 60,
|
||||
height: 60,
|
||||
anchor: {x: 0.5, y: 0.5},
|
||||
callout: {
|
||||
content: `ID: ${marker.deviceImei}`,
|
||||
content: `${marker.deviceName}`,
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
<!-- 编辑弹窗 -->
|
||||
<MsgBox ref="editPop">
|
||||
<view>
|
||||
修改紧急联系人
|
||||
编辑紧急联系人
|
||||
</view>
|
||||
<view class="w60">
|
||||
|
||||
|
||||
@ -151,7 +151,9 @@
|
||||
uni.reLaunch({
|
||||
url: '/pages/common/login/index'
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
|
||||
},
|
||||
// 退出登录
|
||||
|
||||
@ -768,8 +768,9 @@ class BleHelper {
|
||||
} catch (convertException) {
|
||||
if (str && (str.trim().startsWith('{') || str.trim().startsWith('['))) {
|
||||
console.error("JSON解析失败(可能是格式错误的数据)", convertException);
|
||||
console.error("错误的数据", str);
|
||||
|
||||
}
|
||||
console.error("错误的数据", str);
|
||||
}
|
||||
|
||||
if (isUpdate) {
|
||||
@ -790,7 +791,7 @@ class BleHelper {
|
||||
str: str,
|
||||
hexs: hexs
|
||||
};
|
||||
// console.log("监听到特征值:", recData);
|
||||
console.log("监听到特征值:", recData);
|
||||
if (this.cfg.receivDataCallback) {
|
||||
|
||||
if (this.cfg.receivDataCallback.length > 0) {
|
||||
|
||||
165
utils/Common.js
165
utils/Common.js
@ -491,71 +491,85 @@ export default {
|
||||
return result;
|
||||
},
|
||||
formatTime(value, unit = 'minute') {
|
||||
// 边界处理:空值、0或负数
|
||||
if (!value || value <= 0) return '0秒';
|
||||
|
||||
// 将所有单位统一转换为分钟和总秒数
|
||||
let minutes;
|
||||
let totalSeconds;
|
||||
|
||||
switch (unit) {
|
||||
case 'second': // 秒
|
||||
minutes = value / 60;
|
||||
totalSeconds = value;
|
||||
break;
|
||||
case 'minute': // 分钟(默认)
|
||||
minutes = value;
|
||||
totalSeconds = value * 60;
|
||||
break;
|
||||
case 'hour': // 小时
|
||||
minutes = value * 60;
|
||||
totalSeconds = value * 3600;
|
||||
break;
|
||||
case 'day': // 天
|
||||
minutes = value * 24 * 60;
|
||||
totalSeconds = value * 86400;
|
||||
break;
|
||||
default:
|
||||
minutes = value;
|
||||
totalSeconds = value * 60;
|
||||
}
|
||||
|
||||
// 定义时间单位(分钟)
|
||||
const units = [
|
||||
{ label: '年', minutes: 365 * 24 * 60 },
|
||||
{ label: '月', minutes: 30 * 24 * 60 }, // 按30天简化计算
|
||||
{ label: '天', minutes: 24 * 60 },
|
||||
{ label: '小时', minutes: 60 },
|
||||
{ label: '分', minutes: 1 }
|
||||
];
|
||||
|
||||
let remaining = minutes;
|
||||
const parts = [];
|
||||
|
||||
for (const unitObj of units) {
|
||||
const val = Math.floor(remaining / unitObj.minutes);
|
||||
if (val > 0) {
|
||||
parts.push(`${val}${unitObj.label}`);
|
||||
remaining %= unitObj.minutes;
|
||||
}
|
||||
}
|
||||
|
||||
// 处理剩余的秒数(remaining 现在是小于1分钟的分钟数)
|
||||
if (remaining > 0) {
|
||||
const seconds = Math.round(remaining * 60);
|
||||
if (seconds > 0) {
|
||||
parts.push(`${seconds}秒`);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果没有任何部分,返回总秒数
|
||||
if (parts.length === 0) {
|
||||
return `${Math.floor(totalSeconds)}秒`;
|
||||
}
|
||||
|
||||
return parts.join('');
|
||||
// 边界处理:空值、0或负数
|
||||
if (!value || value <= 0) return '0秒';
|
||||
|
||||
// 将所有单位统一转换为分钟和总秒数
|
||||
let minutes;
|
||||
let totalSeconds;
|
||||
|
||||
switch (unit) {
|
||||
case 'second': // 秒
|
||||
minutes = value / 60;
|
||||
totalSeconds = value;
|
||||
break;
|
||||
case 'minute': // 分钟(默认)
|
||||
minutes = value;
|
||||
totalSeconds = value * 60;
|
||||
break;
|
||||
case 'hour': // 小时
|
||||
minutes = value * 60;
|
||||
totalSeconds = value * 3600;
|
||||
break;
|
||||
case 'day': // 天
|
||||
minutes = value * 24 * 60;
|
||||
totalSeconds = value * 86400;
|
||||
break;
|
||||
default:
|
||||
minutes = value;
|
||||
totalSeconds = value * 60;
|
||||
}
|
||||
|
||||
// 定义时间单位(分钟)
|
||||
const units = [{
|
||||
label: '年',
|
||||
minutes: 365 * 24 * 60
|
||||
},
|
||||
{
|
||||
label: '月',
|
||||
minutes: 30 * 24 * 60
|
||||
}, // 按30天简化计算
|
||||
{
|
||||
label: '天',
|
||||
minutes: 24 * 60
|
||||
},
|
||||
{
|
||||
label: '小时',
|
||||
minutes: 60
|
||||
},
|
||||
{
|
||||
label: '分',
|
||||
minutes: 1
|
||||
}
|
||||
];
|
||||
|
||||
let remaining = minutes;
|
||||
const parts = [];
|
||||
|
||||
for (const unitObj of units) {
|
||||
const val = Math.floor(remaining / unitObj.minutes);
|
||||
if (val > 0) {
|
||||
parts.push(`${val}${unitObj.label}`);
|
||||
remaining %= unitObj.minutes;
|
||||
}
|
||||
}
|
||||
|
||||
// 处理剩余的秒数(remaining 现在是小于1分钟的分钟数)
|
||||
if (remaining > 0) {
|
||||
const seconds = Math.round(remaining * 60);
|
||||
if (seconds > 0) {
|
||||
parts.push(`${seconds}秒`);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果没有任何部分,返回总秒数
|
||||
if (parts.length === 0) {
|
||||
return `${Math.floor(totalSeconds)}秒`;
|
||||
}
|
||||
|
||||
return parts.join('');
|
||||
},
|
||||
regeo(lon, lat) {
|
||||
regeo(lon, lat) { //逆地理,将坐标解析出地址
|
||||
return new Promise((resolve, reject) => {
|
||||
let url =
|
||||
'https://restapi.amap.com/v3/geocode/regeo?key=ca3af8a20d628897020893892bda5ae4&location=' +
|
||||
@ -579,6 +593,29 @@ export default {
|
||||
});
|
||||
});
|
||||
|
||||
},
|
||||
MapNavi(lon, lat, name, mapType) {//打开地图路线规划页面
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!lon || !lat) {
|
||||
reject("经纬度不能为空");
|
||||
return;
|
||||
}
|
||||
|
||||
let url = "";
|
||||
if (!mapType || mapType == 'amap') {
|
||||
let amapScheme = uni.getSystemInfoSync().platform === 'ios' ? 'iosamap://' : 'androidamap://';
|
||||
url = `${amapScheme}route/plan?sourceApplication=myapp&dlat=${lat}&dlon=${lon}&dname=${name}&dev=0&t=0`;
|
||||
} else {
|
||||
url =`baidumap://map/direction?destination=latlng:${lat},${lon}|name:${name}&coord_type=gcj02&src=myapp`
|
||||
}
|
||||
|
||||
plus.runtime.openURL(url, (ex) => {
|
||||
console.error("ex=",ex);
|
||||
reject("无法打开地图软件"+url);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
import config from '../config/index.js';
|
||||
export const env = 'development'; //production development //开发of线上 改这里就行
|
||||
export const env = 'production'; //production development //开发of线上 改这里就行
|
||||
const BASE = config[env];
|
||||
const request = (options) => {
|
||||
// console.log("options" + JSON.stringify(options), BASE.BASE_URL)
|
||||
|
||||
Reference in New Issue
Block a user