1
0
forked from dyf/APP

常规小优化

This commit is contained in:
liub
2026-04-22 08:29:06 +08:00
parent 01ff9c7a05
commit 1f88de4710
22 changed files with 1682 additions and 392 deletions

17
App.vue
View File

@ -103,6 +103,14 @@
if (appid !== 'HBuilder') { if (appid !== 'HBuilder') {
upgrade.checkAndUpdateWgt(); upgrade.checkAndUpdateWgt();
} }
uni.setKeepScreenOn({
keepScreenOn:true
}).then(res=>{
console.log("已设置屏幕常亮");
}).catch(ex=>{
console.error("设置屏幕常亮失败,ex=",ex)
})
// #endif // #endif
@ -110,6 +118,15 @@
onHide: function() { onHide: function() {
console.log('App Hide'); console.log('App Hide');
// #ifdef APP|APP-PLUS // #ifdef APP|APP-PLUS
uni.setKeepScreenOn({
keepScreenOn:false
}).then(res=>{
console.log("已关闭屏幕常亮");
}).catch(ex=>{
console.error("设置屏幕常亮失败,ex=",ex)
})
// 上传中不主动断开:语音上传进行中则不断开蓝牙 // 上传中不主动断开:语音上传进行中则不断开蓝牙
let ble = bleTool.getBleTool(); let ble = bleTool.getBleTool();
if (ble && ble.isVoiceUploading && ble.isVoiceUploading()) { if (ble && ble.isVoiceUploading && ble.isVoiceUploading()) {

View File

@ -33,7 +33,7 @@
<image v-if="item.icon" :src="item.icon" mode="aspectFit"></image> <image v-if="item.icon" :src="item.icon" mode="aspectFit"></image>
</view> </view>
<text class="itemTxt">{{ item.text }}</text> <text class="itemTxt" :class="(config.textAlign=='flex-start'&&!item.icon)?'txtIndent':''">{{ item.text }}</text>
</view> </view>
@ -139,8 +139,8 @@
</script> </script>
<style> <style>
.itemTxt{ .txtIndent{
text-indent: 20rpx; text-indent: 30rpx;
} }
.message-popup { .message-popup {
position: relative; position: relative;

View File

@ -14,7 +14,13 @@
<view v-if="!visiblePrompt"> <view v-if="!visiblePrompt">
<image v-if="iconUrl" :src="iconUrl" mode="aspectFit" class="popup-icon" <image v-if="iconUrl" :src="iconUrl" mode="aspectFit" class="popup-icon"
:style="{ tintColor: textColor || getTypeStyle('textColor') }"></image> :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'"> <view class="popup-message" :class="showSlot?'':'displayNone'">
<slot></slot> <slot></slot>
</view> </view>
@ -83,7 +89,7 @@
buttonTextColor: String, buttonTextColor: String,
iconUrl: String, iconUrl: String,
message: { message: {
type: String, type: String|Array,
default: '' default: ''
}, },
buttonText: { buttonText: {

View File

@ -141,27 +141,35 @@
borderColor: "#e034344d", borderColor: "#e034344d",
buttonBgColor: "#E03434", buttonBgColor: "#E03434",
bgColor:'#383934cc', bgColor:'#383934cc',
buttonTextColor:'#FFFFFFde' buttonTextColor:'#FFFFFFde',
showCancel:true,
buttonCancelText:'取消'
}, },
succ: { succ: {
icoUrl: '/static/images/common/success.png', icoUrl: '/static/images/common/success.png',
borderColor: "#BBE6004d", borderColor: "#BBE6004d",
buttonBgColor: "#BBE600", buttonBgColor: "#BBE600",
buttonTextColor:'#232323de', buttonTextColor:'#232323de',
bgColor:'#383934cc' bgColor:'#383934cc',
showCancel:true,
buttonCancelText:'取消'
}, },
warn: { warn: {
icoUrl: '/static/images/common/warning.png', icoUrl: '/static/images/common/warning.png',
borderColor: "#FFC84E4d", borderColor: "#FFC84E4d",
buttonBgColor: "#FFC84E", buttonBgColor: "#FFC84E",
buttonTextColor:'#FFFFFFde', buttonTextColor:'#FFFFFFde',
bgColor:'#383934cc' bgColor:'#383934cc',
showCancel:true,
buttonCancelText:'取消'
}, },
info:{ info:{
borderColor: "#BBE6004d", borderColor: "#BBE6004d",
buttonBgColor: "#BBE600", buttonBgColor: "#BBE600",
bgColor:'#383934cc', bgColor:'#383934cc',
buttonTextColor:'#232323de' buttonTextColor:'#232323de',
showCancel:true,
buttonCancelText:'取消'
}, },
prompt:{ prompt:{

View File

@ -2,7 +2,7 @@
"name" : "星汉物联", "name" : "星汉物联",
"appid" : "__UNI__A21EF43", "appid" : "__UNI__A21EF43",
"description" : "设备管控", "description" : "设备管控",
"versionName" : "1.0.25", "versionName" : "1.0.27",
"versionCode" : 101, "versionCode" : 101,
"transformPx" : false, "transformPx" : false,
/* 5+App */ /* 5+App */
@ -79,7 +79,8 @@
"NSMicrophoneUsageDescription" : "App需要您的同意访问麦克风,用于上传语音包" "NSMicrophoneUsageDescription" : "App需要您的同意访问麦克风,用于上传语音包"
}, },
"idfa" : false, "idfa" : false,
"urltypes" : "" "urltypes" : "",
"urlschemewhitelist" : ""
}, },
/* SDK */ /* SDK */
"sdkConfigs" : { "sdkConfigs" : {
@ -100,23 +101,19 @@
}, },
"push" : { "push" : {
"unipush" : { "unipush" : {
"version" : "2",
"offline" : true, "offline" : true,
"hms" : {}, "hms" : {},
"oppo" : {}, "oppo" : {},
"vivo" : {}, "vivo" : {},
"mi" : {}, "mi" : {},
"meizu" : {},
"honor" : {}, "honor" : {},
"version" : "2",
"icons" : { "icons" : {
"small" : { "small" : {
"ldpi" : "unpackage/res/icons/18x18.png", "hdpi" : "unpackage/res/icons/36x36.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"
} }
}, }
"meizu" : {}
} }
} }
}, },

View File

@ -169,6 +169,7 @@
"path": "pages/common/map/index", "path": "pages/common/map/index",
"style": { "style": {
"navigationBarTitleText": "地图" "navigationBarTitleText": "地图"
} }
}, },
{ {

View File

@ -65,7 +65,8 @@
</view> </view>
</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>{{ShakeBit}}</view>
</view> </view>
@ -135,6 +136,8 @@
<ProParams :id="device.id"></ProParams> <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" /> <global-loading ref="loading" />
@ -188,7 +191,7 @@
pageHide: false, pageHide: false,
usrToggle: false, usrToggle: false
}, },
formData: { formData: {
img: '/static/images/common/HBY018A.png', img: '/static/images/common/HBY018A.png',
@ -201,6 +204,7 @@
sta_ShakeBit: 0, //报警状态 sta_ShakeBit: 0, //报警状态
sta_system: '', //0关机 1关机充电 2开机未充电 3开机充电 sta_system: '', //0关机 1关机充电 2开机未充电 3开机充电
bleStatu: '', bleStatu: '',
}, },
dic: { dic: {
sta_Side_Light: [ sta_Side_Light: [
@ -235,7 +239,8 @@
sta_charge: { sta_charge: {
"0": '未充电', "0": '未充电',
"1": '充电中' "1": '充电中'
} },
actionSheets: []
}, },
device: { device: {
@ -251,8 +256,8 @@
bindingTime: "", bindingTime: "",
onlineStatus: 0, onlineStatus: 0,
battery: "0", battery: "0",
latitude: '30.495455', latitude: '',
longitude: '114.409500', longitude: '',
alarmStatus: null, alarmStatus: null,
detailPageUrl: "/pages/018A/HBY018A", detailPageUrl: "/pages/018A/HBY018A",
showConfirm: false, showConfirm: false,
@ -281,8 +286,8 @@
ble.addDisposeCallback(this.deviceDispose, pagePath); ble.addDisposeCallback(this.deviceDispose, pagePath);
ble.addRecoveryCallback(this.deviceRecovry, pagePath); ble.addRecoveryCallback(this.deviceRecovry, pagePath);
this.initWatch();
this.initActionData();
let eventChannel = this.getOpenerEventChannel(); let eventChannel = this.getOpenerEventChannel();
@ -306,6 +311,9 @@
these.formData[key] = form[key]; 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.blename = f.name ? f.name : "Unname";
these.formData.deviceName = device.deviceName; these.formData.deviceName = device.deviceName;
@ -322,7 +330,7 @@
these.setBleFormData(); these.setBleFormData();
this.initWatch();
}); });
}, },
@ -365,7 +373,6 @@
let dic = { let dic = {
"1": "设备SOS求救中", "1": "设备SOS求救中",
"2": "设备静止报警中", "2": "设备静止报警中",
"6": "设备遇水报警中"
}; };
let keys = Object.keys(dic); let keys = Object.keys(dic);
let f = keys.find(key => { let f = keys.find(key => {
@ -382,23 +389,157 @@
}, },
methods: { 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() { getDeviceDetail() {
api.getDetail(this.device.id).then(res => { api.getDetail(this.device.id).then(res => {
if (res && res.code == 200) { if (res && res.code == 200) {
let data = res.data; let data = res.data;
let keys = Object.keys(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++) { for (let i = 0; i < keys.length; i++) {
let key = keys[i]; let key = keys[i];
let dk=dKeys.find(k=>{ let dk = dKeys.find(k => {
return key.toLowerCase()==k.toLowerCase(); return key.toLowerCase() == k.toLowerCase();
}); });
if(dk){ if (dk) {
this.$set(this.device,dk,data[key]); this.$set(this.device, dk, data[key]);
}else{ } else {
this.$set(this.device,key,data[key]); 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) { routePlan() {
this.reGeo(); if (this.formData.sta_ShakeBit == 2) {
} MsgError(["设备静止报警中!", "请注意接听设备来电和短信!"], "位置导航", these, () => {
}); these.showAction('map');
});
}
}, },
reGeo() { reGeo() {
console.log("经纬度发生变化,执行逆地理") console.log("经纬度发生变化,执行逆地理")
@ -470,11 +611,13 @@
this.device.longitude = lnglat[0]; this.device.longitude = lnglat[0];
this.device.latitude = lnglat[1]; this.device.latitude = lnglat[1];
Common.regeo(lnglat[0], lnglat[1]).then(res => { Common.regeo(lnglat[0], lnglat[1]).then(res => {
this.formData.address = res.regeocode.formatted_address this.formData.address = res.regeocode.formatted_address
}).catch(ex => { }).catch(ex => {
console.error("逆地理失败了") console.error("逆地理失败了")
}) }).finally(this.routePlan);
}).catch(err => { }).catch(err => {
console.error("坐标转换失败了"); console.error("坐标转换失败了");
}); });
@ -493,13 +636,13 @@
success(res) { success(res) {
res.eventChannel.emit('device', these.device); res.eventChannel.emit('device', these.device);
}, },
events:{ events: {
linkManOver:(data)=>{ linkManOver: (data) => {
this.device.contact1Phone=data[0]; this.device.contact1Phone = data[0];
this.device.contact2Phone=data[1]; this.device.contact2Phone = data[1];
}, },
MsgOver:(data)=>{ MsgOver: (data) => {
this.device.sosSmsMsg=data; this.device.sosSmsMsg = data;
} }
} }
}); });
@ -622,23 +765,28 @@
MsgError("获取设备位置异常", '', these); MsgError("获取设备位置异常", '', these);
return; return;
} }
let promise = lnglatConvert.wgs84_to_gcj02(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 => { // 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]; console.log("device=",this.device);
this.detailData.latitude = lnglat[1]; uni.navigateTo({
uni.navigateTo({ url: '/pages/common/map/index',
url: '/pages/common/map/index', events: {
events: { ack: function(data) {}
ack: function(data) {} },
}, success: (res) => {
success: (res) => { res.eventChannel.emit('Map', {
res.eventChannel.emit('Map', { data: this.device
data: this.detailData });
}); },
} fail(ex) {
}) console.error("跳转失败", ex);
}); }
})
// });
}, },
LighSetting(item, index) { LighSetting(item, index) {
@ -717,6 +865,20 @@
}, these, false); }, 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) { deviceRecovry(res) {
console.log("蓝牙连接成功", these.formData); console.log("蓝牙连接成功", these.formData);
@ -808,27 +970,12 @@
} }
let json = recei.ReceiveData(receive, device, pagePath, recArr); 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() { getDevice: function() {

View File

@ -118,12 +118,12 @@
</view> </view>
</view> </view>
<view class="mode " :class="{active:formData.sta_RadarType=='1'}" <view class="mode " :class="{active:formData.sta_RadarType!=0}"
v-on:click.stop="showAction"> v-on:click.stop="showAction('BottomMenu')">
<view class="leftImg"> <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> 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> mode="aspectFit"></image>
</view> </view>
<view class="rightTxt"> <view class="rightTxt">
@ -146,6 +146,19 @@
<text class="smallTxt">{{formData.sta_InfraRed=='1'?'开启':'关闭'}}</text> <text class="smallTxt">{{formData.sta_InfraRed=='1'?'开启':'关闭'}}</text>
</view> </view>
</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> </view>
@ -155,7 +168,7 @@
<view class="btnSend fright" v-on:click.stop="sendUsr">发送</view> <view class="btnSend fright" v-on:click.stop="sendUsr">发送</view>
<view class="clear"></view> <view class="clear"></view>
<TextToHexV1 class="TextToHex" ref="textToHex" :txts="formData.textLines" :bgColor="'#FFFFFF'" <TextToHexV1 class="TextToHex" ref="textToHex" :txts="formData.textLines" :bgColor="'#FFFFFF'"
:color="'#000000'" :fontSize="16" /> :color="'#000000'" :fontSize="14" />
</view> </view>
<view class="item"> <view class="item">
@ -183,6 +196,9 @@
<BottomSlideMenuPlus :config="Status.BottomMenu" @btnClick="btnClick" @itemClick="itemClick" @close="closeActionSheet"></BottomSlideMenuPlus> <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> <ProParams :id="device.id"></ProParams>
<MsgBox ref="msgPop" /> <MsgBox ref="msgPop" />
<global-loading ref="loading" /> <global-loading ref="loading" />
@ -192,7 +208,9 @@
<script> <script>
import usrApi from '@/api/670/HBY670.js'; import usrApi from '@/api/670/HBY670.js';
import TextToHexV1 from '@/components/TextToHex/TextToHexV1.vue'; import TextToHexV1 from '@/components/TextToHex/TextToHexV1.vue';
import request from '@/utils/request.js'; import request, {
baseURL
} from '@/utils/request.js';
import { import {
showLoading, showLoading,
hideLoading, hideLoading,
@ -244,6 +262,40 @@
}, },
usrToggle: true, usrToggle: true,
bleLinkCnt: 0, 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: { BottomMenu: {
show: false, show: false,
showHeader: true, showHeader: true,
@ -340,8 +392,8 @@
showConfirm: false showConfirm: false
}, },
permissions: [] permissions: [],
inteval:80
} }
}, },
computed: { computed: {
@ -512,40 +564,584 @@
}, },
methods: { methods: {
showAction(){ showAction(type){
if(type=='BottomMenu'){
this.Status.BottomMenu.show = true; this.Status.BottomMenu.show = true;
this.Status.PictureMenu.show=false;
this.Status.BottomMenu.menuItems.find((v,i)=>{ this.Status.BottomMenu.menuItems.find((v,i)=>{
if(this.formData.sta_RadarType==v.value){ if(this.formData.sta_RadarType==v.value){
this.Status.BottomMenu.activeIndex=i; this.Status.BottomMenu.activeIndex=i;
return true; return true;
} }
}) }) ;
}else{
this.Status.PictureMenu.show=true;
this.Status.BottomMenu.show = false;
}
}, },
btnClick(){ btnPictureClick(li,i){
this.Status.BottomMenu.show = false;
let d=this.Status.BottomMenu.menuItems[this.Status.BottomMenu.activeIndex];
let f = this.getDevice(); 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) { if (!f) {
this.showBleUnConnect(); this.showBleUnConnect();
return; return;
} }
this.Status.BottomMenu.show = false;
let d=this.Status.BottomMenu.menuItems[this.Status.BottomMenu.activeIndex];
let bleSend = () => { let bleSend = () => {
let json = {ins_RadarType:d.value}; let json = {ins_RadarType:d.value};
json = JSON.stringify(json); json = JSON.stringify(json);
if (ble) { if (ble) {
ble.sendString(f.deviceId, json).then(res => { ble.sendString(f.deviceId, json).then(res => {
console.log("send success") console.log("ble send success")
this.formData.sta_RadarType = d.value; this.formData.sta_RadarType = d.value;
}).catch(ex => { }).catch(ex => {
this.mqSend(json); this.mqSend(json);
@ -562,9 +1158,13 @@
this.Status.BottomMenu.activeIndex=index; this.Status.BottomMenu.activeIndex=index;
},
itemPictureClick(item,index){
this.Status.PictureMenu.activeIndex=index;
}, },
closeActionSheet() { closeActionSheet() {
this.Status.BottomMenu.show = false; this.Status.BottomMenu.show = false;
this.Status.PictureMenu.show=false;
}, },
sendUsr() { sendUsr() {
if (!this.permissions.includes('4') && this.Status.apiType !== 'listA') { if (!this.permissions.includes('4') && this.Status.apiType !== 'listA') {

View File

@ -731,7 +731,7 @@
dataView.setUint8(4 + i, '0x' + packetData[i]); dataView.setUint8(4 + i, '0x' + packetData[i]);
} }
let inteval = 40; let inteval = 60;
ble.sendData(f.deviceId, buffer, f.writeServiceId, f ble.sendData(f.deviceId, buffer, f.writeServiceId, f
.wirteCharactId, 10).then(() => { .wirteCharactId, 10).then(() => {
@ -739,7 +739,7 @@
updateLoading(these, { updateLoading(these, {
text: "正在发送:" + currentPacket + "/" + text: "正在发送:" + currentPacket + "/" +
totalPackets totalPackets
}) });
currentPacket++; currentPacket++;
@ -750,7 +750,7 @@
if (err.code == '10007') { //遇到这个错误自动重新发送 if (err.code == '10007') { //遇到这个错误自动重新发送
console.log(err.errMsg + ",发送失败了,正在补偿:" + console.log(err.errMsg + ",发送失败了,正在补偿:" +
currentPacket); currentPacket);
setTimeout(sendNextVideoPacket, inteval); setTimeout(sendNextVideoPacket, 800);
} else { } else {
hideLoading(these); hideLoading(these);
@ -848,13 +848,12 @@
Promise.all([p1, p2]).then((arr) => { Promise.all([p1, p2]).then((arr) => {
if (arr[0].status == 'rejected') { if (arr[0].status == 'rejected') {
showPop({ MsgError("设备准备未就绪,请重试",'',these);
message: "设备准备未就绪", return;
iconUrl: "/static/images/common/uploadErr.png", }
borderColor: "#e034344d", if(arr[1].status== 'rejected'){
buttonBgColor: "#E03434", MsgError("读取视频失败",'',these);
}, these);
return; return;
} }
let res = arr[1]; let res = arr[1];
@ -1333,17 +1332,16 @@
]; ];
let item3 = Object.assign({}, json); let item3 = Object.assign({}, json);
item3.textAlign='center';
item3.name = 'media'; item3.name = 'media';
item3.title = '选择媒体'; item3.title = '选择媒体';
item3.menuItems = [{ item3.menuItems = [{
text: '照片', text: '照片',
icon: '/static/images/lightImg/qiang.png',
value: 'img', value: 'img',
key: 'media' key: 'media'
}, },
{ {
text: '动画', text: '动画',
icon: '/static/images/lightImg/qiang.png',
value: 'flash', value: 'flash',
key: 'media' key: 'media'
} }
@ -1636,14 +1634,14 @@
setTimeout(() => { setTimeout(() => {
Promise.allSettled([holdHand('word transmit start', 2200), drawText()]).then(results => { Promise.allSettled([holdHand('word transmit start', 2200), drawText()]).then(results => {
if (results[0].status == 'rejected') { if (results[0].status == 'rejected') {
MsgError("与蓝牙设备握手失败,请重试",'',these);
setTimeout(() => { setTimeout(() => {
hideLoading(these) hideLoading(these)
}, 500); }, 500);
return; return;
} }
if (results[1].status == 'rejected') { if (results[1].status == 'rejected') {
MsgError("读取文字点阵失败,请重试",'',these);
return; return;
} }

View File

@ -10,7 +10,7 @@
<view slot="right"> <view slot="right">
<view class="navbarRight center"> <view class="navbarRight center">
<view class="imgContent" :class="{'visibilityHidden':Status.apiType!=item.apiType}" <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> <image class="img" :src="item.src" mode="aspectFit"></image>
<view class="baber" v-if="item.math">{{item.math>9?'9+':item.math}}</view> <view class="baber" v-if="item.math">{{item.math>9?'9+':item.math}}</view>
</view> </view>
@ -74,8 +74,8 @@
<view class="slider-container"> <view class="slider-container">
<slider min="1" max="100" step="1" :disabled="false" :value="formData.liangDu" activeColor="#bbe600" <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" backgroundColor="#00000000" block-size="20" block-color="#ffffffde" @change="sliderChange"
class="custom-slider" /> @changing="sliderChanging" class="custom-slider" />
</view> </view>
</view> </view>
@ -124,33 +124,33 @@
<view class="btnSend fright" v-on:click.stop="sendUsr">发送</view> <view class="btnSend fright" v-on:click.stop="sendUsr">发送</view>
<view class="clear"></view> <view class="clear"></view>
<TextToHexV1 class="TextToHex" ref="textToHex" :txts="formData.textLines" :bgColor="'#FFFFFF'" <TextToHexV1 class="TextToHex" ref="textToHex" :txts="formData.textLines" :bgColor="'#FFFFFF'"
:color="'#000000'" :fontSize="16" /> :color="'#000000'" :fontSize="15" />
</view> </view>
<view class="item"> <view class="item">
<text class="lbl">单位</text> <text class="lbl">单位</text>
<input class="value" v-model.trim="formData.textLines[0]" placeholder="请输入单位" maxlength="8" <input class="value" v-model.trim="formData.textLines[0]" placeholder="请输入单位" maxlength="8"
placeholder-class="usrplace" /> placeholder-class="usrplace" />
</view> </view>
<view class="item"> <view class="item">
<text class="lbl">部门</text> <text class="lbl">部门</text>
<input class="value" v-model.trim="formData.textLines[1]" placeholder="请输入姓名" maxlength="8" <input class="value" v-model.trim="formData.textLines[1]" placeholder="请输入姓名" maxlength="8"
placeholder-class="usrplace" /> placeholder-class="usrplace" />
</view> </view>
<view class="item"> <view class="item">
<text class="lbl">姓名</text> <text class="lbl">姓名</text>
<input class="value" v-model.trim="formData.textLines[2]" placeholder="请输入职位" maxlength="8" <input class="value" v-model.trim="formData.textLines[2]" placeholder="请输入职位" maxlength="8"
placeholder-class="usrplace" /> placeholder-class="usrplace" />
</view> </view>
</view> </view>
<ProParams :id="device.id"></ProParams> <ProParams :id="device.id"></ProParams>
<!-- 下方菜单 --> <!-- 下方菜单 -->
<BottomSlideMenuPlus :config="Status.BottomMenu" @close="closeMenu" @itemClick="handleItemClick" <BottomSlideMenuPlus :config="Status.BottomMenu" @close="closeMenu" @itemClick="handleItemClick"
@btnClick="btnClick"> @btnClick="btnClick">
<view class="addIco"> <view class="addIco">
<view class="icoContent center" v-on:click.stop="checkImgUpload()"> <view class="icoContent center" v-on:click.stop="checkImgUpload()">
<image mode="aspectFit" class="img" src="/static/images/6155/DeviceDetail/add.png"></image> <image mode="aspectFit" class="img" src="/static/images/6155/DeviceDetail/add.png"></image>
@ -180,14 +180,14 @@
} from '@/utils/request.js'; } from '@/utils/request.js';
var pagePath = "/pages/6155/BJQ6155"; var pagePath = "/pages/6155/BJQ6155";
import { import {
MsgSuccess, MsgSuccess,
MsgError, MsgError,
MsgClose, MsgClose,
MsgWarning, MsgWarning,
showPop, showPop,
MsgInfo MsgInfo
} from '@/utils/MsgPops.js' } from '@/utils/MsgPops.js'
var ble = null; var ble = null;
var these = null; var these = null;
@ -343,6 +343,7 @@
}, },
onLoad: function() { onLoad: function() {
these = this; these = this;
this.initWatch();
recei = BleReceive.getBleReceive(); recei = BleReceive.getBleReceive();
ble = bleTool.getBleTool(); ble = bleTool.getBleTool();
@ -400,10 +401,10 @@
these.formData.bleStatu = 'connecting'; these.formData.bleStatu = 'connecting';
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => { ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
these.formData.bleStatu = true; these.formData.bleStatu = true;
}).catch(ex => { }).catch(ex => {
these.formData.bleStatu = 'err'; these.formData.bleStatu = 'err';
MsgError("连接错误:" + ex.msg, "确定", these); MsgError("连接错误:" + ex.msg, "确定", these);
});; });;
these.setBleFormData(); these.setBleFormData();
these.getDetail(); these.getDetail();
@ -423,10 +424,10 @@
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => { ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
console.log("连接成功") console.log("连接成功")
these.formData.bleStatu = true; these.formData.bleStatu = true;
}).catch(ex => { }).catch(ex => {
these.formData.bleStatu = 'err'; these.formData.bleStatu = 'err';
MsgError("连接错误:" + ex.msg, "确定", these); MsgError("连接错误:" + ex.msg, "确定", these);
});; });;
} }
}, },
onBackPress(e) { onBackPress(e) {
@ -453,6 +454,19 @@
}, },
methods: { 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() { bleStatuToggle() {
let f = this.getDevice(); let f = this.getDevice();
if (!f) { if (!f) {
@ -473,7 +487,7 @@
these.formData.bleStatu = true; these.formData.bleStatu = true;
}).catch(ex => { }).catch(ex => {
these.formData.bleStatu = 'err'; these.formData.bleStatu = 'err';
MsgError("连接错误:" + ex.msg, "确定", these); MsgError("连接错误:" + ex.msg, "确定", these);
}); });
return; return;
} }
@ -635,7 +649,7 @@
updateLoading(these, { updateLoading(these, {
text: ex.msg text: ex.msg
}); });
MsgError("连接错误:" + ex.msg, "确定", these); MsgError("连接错误:" + ex.msg, "确定", these);
}).finally(() => { }).finally(() => {
setTimeout(() => { setTimeout(() => {
hideLoading(these); hideLoading(these);
@ -690,17 +704,10 @@
these.$forceUpdate(); these.$forceUpdate();
// console.log("更新后的电量:", these.formData.battary); // console.log("更新后的电量:", these.formData.battary);
if (this.formData.battary <= 20) {
this.showPop({
message: "设备电量低",
iconUrl: "/static/images/common/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
});
}
}, },
showBleUnConnect() { showBleUnConnect() {
this.showPop({ this.showPop({
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备", message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
@ -708,7 +715,7 @@
borderColor: "#e034344d", borderColor: "#e034344d",
buttonBgColor: "#E03434", buttonBgColor: "#E03434",
buttonText: '去连接', buttonText: '去连接',
buttonTextColor: '#FFFFFFde', buttonTextColor: '#FFFFFFde',
okCallback: function() { okCallback: function() {
// console.log("1111"); // console.log("1111");
uni.navigateTo({ uni.navigateTo({
@ -740,13 +747,13 @@
return; return;
} }
let os = plus.os.name; let os = plus.os.name;
// 分包发送图片数据 // 分包发送图片数据
var sendImagePackets = function(ReSendNo) { var sendImagePackets = function(ReSendNo) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
// 总数据包数 // 总数据包数
let totalPackets = os=='Android'?52:200; let totalPackets = os == 'Android' ? 52 : 200;
let currentPacket = 1; let currentPacket = 1;
if (ReSendNo) { if (ReSendNo) {
@ -779,7 +786,7 @@
// 计算当前包的数据 // 计算当前包的数据
let packetSize = os == 'Android' ? 250 : 64; let packetSize = os == 'Android' ? 250 : 64;
// 创建数据包 // 创建数据包
let startIndex = (currentPacket - 1) * packetSize; let startIndex = (currentPacket - 1) * packetSize;
@ -791,7 +798,7 @@
let packetData = these.rgb565Data.slice(startIndex, let packetData = these.rgb565Data.slice(startIndex,
endIndex); endIndex);
// 构建数据包 // 构建数据包
let bufferSize = packetData.length * 2+5; // 头部5字节 + 数据部分 let bufferSize = packetData.length * 2 + 5; // 头部5字节 + 数据部分
let buffer = new ArrayBuffer(bufferSize); let buffer = new ArrayBuffer(bufferSize);
let dataView = new DataView(buffer); let dataView = new DataView(buffer);
@ -799,13 +806,13 @@
dataView.setUint8(0, os == 'Android' ? 0x55 : 0x56); // 帧头 dataView.setUint8(0, os == 'Android' ? 0x55 : 0x56); // 帧头
dataView.setUint8(1, 0x02); // 帧类型:开机画面 dataView.setUint8(1, 0x02); // 帧类型:开机画面
dataView.setUint8(2, currentPacket); // 包序号 dataView.setUint8(2, currentPacket); // 包序号
dataView.setUint16(3, packetData.length*2,false); dataView.setUint16(3, packetData.length * 2, false);
// 填充数据每个RGB565值占2字节 // 填充数据每个RGB565值占2字节
for (let i = 0; i < packetData.length; i++) { for (let i = 0; i < packetData.length; i++) {
dataView.setUint16(5 + i * 2, packetData[i], false); // 大端字节序 dataView.setUint16(5 + i * 2, packetData[i], false); // 大端字节序
} }
//发送数据包 //发送数据包
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId,
10).then(() => { 10).then(() => {
@ -817,7 +824,8 @@
}) })
currentPacket++; currentPacket++;
setTimeout(sendNextPacket,os=='Android'? these.inteval:these.inteval/2); setTimeout(sendNextPacket, os == 'Android' ? these
.inteval : these.inteval / 2);
}).catch(err => { }).catch(err => {
console.log("发送数据包失败了" + JSON.stringify(err)); console.log("发送数据包失败了" + JSON.stringify(err));
if (err.code == '10007') { if (err.code == '10007') {
@ -865,7 +873,7 @@
uni.chooseImage({ uni.chooseImage({
count: 1, count: 1,
sizeType: ['original', 'compressed'], sizeType: ['original', 'compressed'],
sourceType: ['album','camera'], sourceType: ['album', 'camera'],
success: function(res) { success: function(res) {
uni.navigateTo({ uni.navigateTo({
url: "/pages/common/ImgCrop/ImgCrop", url: "/pages/common/ImgCrop/ImgCrop",
@ -878,9 +886,9 @@
console.log("data=", data); console.log("data=", data);
these.Status.BottomMenu.show = false; these.Status.BottomMenu.show = false;
these.rgb565Data = Common.convertToRGB565(data.piexls); these.rgb565Data = Common.convertToRGB565(data.piexls);
console.log("1111111111") console.log("1111111111")
setTimeout(function() { setTimeout(function() {
console.log("1111111111") console.log("1111111111")
sendImagePackets().catch(() => { sendImagePackets().catch(() => {
}); });
@ -915,8 +923,8 @@ console.log("1111111111")
}) })
return; return;
} }
let os=plus.os.name; let os = plus.os.name;
// os='Android'; // os='Android';
let f = these.getDevice(); let f = these.getDevice();
if (!f) { if (!f) {
@ -936,7 +944,7 @@ console.log("1111111111")
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (f) { if (f) {
// 总数据包数 // 总数据包数
var totalPackets =os=='Android' ? 1536 : 6000; //36; var totalPackets = os == 'Android' ? 1536 : 6000; //36;
let currentPacket = 1; let currentPacket = 1;
console.log("发送数据准备中,总共" + totalPackets); console.log("发送数据准备中,总共" + totalPackets);
@ -949,30 +957,33 @@ console.log("1111111111")
const sendNextVideoPacket = () => { const sendNextVideoPacket = () => {
// console.log("准备发送一段数据"); // console.log("准备发送一段数据");
if (currentPacket > totalPackets) { if (currentPacket > totalPackets) {
updateLoading(these,{text:'发送完毕,正在处理'}) updateLoading(these, {
text: '发送完毕,正在处理'
})
if (!ReSendNo) { if (!ReSendNo) {
setTimeout(() => { setTimeout(() => {
ble.sendString(f.deviceId, "transmit complete", f.writeServiceId, f.wirteCharactId, 20) ble.sendString(f.deviceId, "transmit complete", f
.writeServiceId, f.wirteCharactId, 20)
.then( .then(
() => { () => {
console.log("全部发送完毕") console.log("全部发送完毕")
hideLoading(these); hideLoading(these);
these.showPop({ these.showPop({
showPop: true, showPop: true,
message: "上传成功", message: "上传成功",
iconUrl: "/static/images/common/success.png" iconUrl: "/static/images/common/success.png"
}); });
}).catch((ex) => { }).catch((ex) => {
console.log("出现异常", ex); console.log("出现异常", ex);
}); });
}, os=='Android'?500:15000); }, os == 'Android' ? 500 : 15000);
} }
these.Status.BottomMenu.show = false; these.Status.BottomMenu.show = false;
these.videoHexArray = null; these.videoHexArray = null;
resolve(); 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); ////console.log("packetData.length"+packetData.length);
const bufferSize =packetSize+4; // 头部5字节 + 数据部分 const bufferSize = packetSize + 4; // 头部5字节 + 数据部分
const buffer = new ArrayBuffer(bufferSize); const buffer = new ArrayBuffer(bufferSize);
const dataView = new DataView(buffer); const dataView = new DataView(buffer);
// 填充头部 // 填充头部
dataView.setUint8(0, os=='Android'?0x55:0x56); // 帧头 dataView.setUint8(0, os == 'Android' ? 0x55 : 0x56); // 帧头
dataView.setUint8(1, 0x04); // 帧类型:开机画面 dataView.setUint8(1, 0x04); // 帧类型:开机画面
dataView.setUint16(2, currentPacket,false); // 包序号 dataView.setUint16(2, currentPacket, false); // 包序号
for (let i = 0; i < packetData.length; i++) { 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 ble.sendData(f.deviceId, buffer, f.writeServiceId, f
.wirteCharactId, 10).then(() => { .wirteCharactId, 10).then(() => {
updateLoading(these, { updateLoading(these, {
text: "正在发送:" +currentPacket+'/'+totalPackets text: "正在发送:" + currentPacket + '/' +
totalPackets
}) })
currentPacket++; currentPacket++;
@ -1187,7 +1199,7 @@ console.log("1111111111")
}).catch((ex1) => { }).catch((ex1) => {
//console.log("出现了异常", ex1) //console.log("出现了异常", ex1)
}).finally(() => { }).finally(() => {
}); });
} }
@ -1753,7 +1765,7 @@ console.log("1111111111")
}); });
}, },
sliderChanging(evt){ sliderChanging(evt) {
this.formData.liangDu = evt.detail.value; this.formData.liangDu = evt.detail.value;
}, },
sliderChange: function(evt) { sliderChange: function(evt) {
@ -1806,8 +1818,8 @@ console.log("1111111111")
dataView.setUint8(0, 0x55); // 帧头 dataView.setUint8(0, 0x55); // 帧头
dataView.setUint8(1, 0x07); // 帧类型:亮度调节 dataView.setUint8(1, 0x07); // 帧类型:亮度调节
dataView.setUint8(2, 0x01); dataView.setUint8(2, 0x01);
dataView.setUint8(3, 0x00); dataView.setUint8(3, 0x00);
dataView.setUint8(4, 0x01); // dataView.setUint8(4, 0x01); //
dataView.setUint8(5, liangDu); // 数据 dataView.setUint8(5, liangDu); // 数据
@ -2186,7 +2198,7 @@ console.log("1111111111")
text-align: left; text-align: left;
} }
.slider-container { .slider-container {
padding: 0px; padding: 0px;

View File

@ -43,22 +43,32 @@
<!-- 设备基本信息 --> <!-- 设备基本信息 -->
<view class="info-card"> <view class="info-card">
<view class="info-row"> <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> <text class="info-value status-running">{{ deviceInfo.deviceImei }}</text>
</view> </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"> <view class="info-row">
<text class="info-label">设备状态</text> <text class="info-label">设备状态</text>
<text class="info-value status-running"> <text class="info-value status-running">
{{ deviceInfo.onlineStatus === 0 ? '离线' : deviceInfo.onlineStatus === 2 ? '故障' : '在线' }} {{ deviceInfo.onlineStatus === 0 ? '离线' : deviceInfo.onlineStatus === 2 ? '故障' : '在线' }}
</text> </text>
</view> </view>
<view class="info-row" v-if="itemInfo.deviceMac" @click="bleStatuToggle"> <view class="info-row" >
<text class="info-label">蓝牙状态</text> <text class="info-label">蓝牙名称</text>
<text class="info-value status-running" :class="formData.bleStatu?'green':'red'"> <text class="info-value status-running" >
{{getbleStatu}} {{deviceInfo.bluetoothName}}
</text> </text>
</view> </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-label">充电状态</text>
<text class="info-value status-running"> <text class="info-value status-running">
{{deviceInfo.chargeState != 0?'充电中':'未充电'}} {{deviceInfo.chargeState != 0?'充电中':'未充电'}}
@ -433,24 +443,36 @@
return this.modeType === 'main' ? '灯光模式' : '激光模式'; return this.modeType === 'main' ? '灯光模式' : '激光模式';
}, },
getbleStatu() { getbleStatu() {
let txt="未连接"
let cls="";
if (this.formData.bleStatu === true) { if (this.formData.bleStatu === true) {
return '已连接'; txt= '已连接';
cls="green";
} }
if (this.formData.bleStatu === 'connecting') { if (this.formData.bleStatu === 'connecting') {
return '连接中'; txt= '连接中';
} }
if (this.formData.bleStatu === 'dicconnect') { if (this.formData.bleStatu === 'dicconnect') {
return '正在断开'; txt= '正在断开';
} }
if (this.formData.bleStatu === 'err') { if (this.formData.bleStatu === 'err') {
return '连接异常'; txt= '连接异常';
cls="red"
} }
return '未连接'; return {txt:txt,cls:cls}
} }
}, },
methods: { 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通用消息处理 onReceive(deviceState, parsedMessage) { //蓝牙/Mq通用消息处理
switch (deviceState[0]) { switch (deviceState[0]) {
// 1设备切换灯光实时返回 // 1设备切换灯光实时返回
@ -482,12 +504,7 @@
this.deviceInfo.batteryRemainingTime = deviceState[5]; //第6位200代表电池剩余续航时间200分钟 this.deviceInfo.batteryRemainingTime = deviceState[5]; //第6位200代表电池剩余续航时间200分钟
} }
setTimeout(() => { setTimeout(() => {
if (this.deviceInfo.batteryPercentage < 20 &&
this.deviceInfo.chargeState == 0) {
this.popupType = 'bettery';
this.popupMessage = '请及时充电';
this.showPopupFlag = true;
}
if (this.apiType === 'listA') { if (this.apiType === 'listA') {
this.fetchDeviceDetail(data.data.id) this.fetchDeviceDetail(data.data.id)
} else { } else {
@ -2014,7 +2031,7 @@
}, },
onLoad(options) { onLoad(options) {
these = this; these = this;
this.initWatch();
rec = BleReceive.getBleReceive(); rec = BleReceive.getBleReceive();
const eventChannel = this.getOpenerEventChannel(); const eventChannel = this.getOpenerEventChannel();
// 监听 'detailData' 事件,获取传过来的数据 // 监听 'detailData' 事件,获取传过来的数据

View File

@ -24,7 +24,7 @@
{{Statu.boundRemark}} {{Statu.boundRemark}}
</view> </view>
</view> </view>
<view class="btnLink" @click="Link()"> <view class="btnLink" @click="Bind()">
绑定 绑定
</view> </view>
@ -71,7 +71,10 @@
"communicationMode": "", "communicationMode": "",
"imei": "" "imei": ""
}, },
serverDevice: null serverDevice: null,
groupid:null,
typeList:[],
uploadStatu:null
} }
}, },
computed: { computed: {
@ -86,7 +89,6 @@
} }
}, },
deviceStatu: function() { deviceStatu: function() {
debugger;
if (!this.device.name && !this.device.macAddress) { if (!this.device.name && !this.device.macAddress) {
return ""; return "";
} }
@ -127,7 +129,8 @@
console.log("返回取消订阅"); console.log("返回取消订阅");
clearInterval(inteval); clearInterval(inteval);
ble.removeAllCallback(pagePath); ble.removeAllCallback(pagePath);
clearTimeout(this.Statu.timeInteval);
this.uploadStatu=null;
if(!this.Statu.isBind && these.device.deviceId){ if(!this.Statu.isBind && these.device.deviceId){
ble.disconnectDevice(these.device.deviceId).catch(ex=>{ ble.disconnectDevice(these.device.deviceId).catch(ex=>{
console.error("无法断开蓝牙连接"); console.error("无法断开蓝牙连接");
@ -137,6 +140,8 @@
onLoad(option) { onLoad(option) {
these = this; these = this;
this.groupid=new Date().getTime()+"";
ble = bleTool.getBleTool(); ble = bleTool.getBleTool();
ble.addStateBreakCallback(res => { ble.addStateBreakCallback(res => {
@ -258,6 +263,108 @@
}, },
methods: { 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() { reLinkdevice() {
ble.LinkBlue(these.device.deviceId).then(res => { ble.LinkBlue(these.device.deviceId).then(res => {
updateLoading(these, { updateLoading(these, {
@ -320,6 +427,7 @@
clearInterval(inteval); clearInterval(inteval);
} else { } else {
deviceInvalid(); deviceInvalid();
this.uploadItem();
} }
} else { } else {
this.serverDevice =null; this.serverDevice =null;
@ -337,7 +445,7 @@
}, 500); }, 500);
}, },
Link() { Bind() {
// 调用绑定设备接口 // 调用绑定设备接口
// let f = ble.data.LinkedList.find((v) => { // let f = ble.data.LinkedList.find((v) => {

View File

@ -727,7 +727,7 @@
}); });
let index = 1; let index = 1;
let total = 5; let total = 1;
let linkCallback = (res) => { let linkCallback = (res) => {
console.log("连接成功", these.device); console.log("连接成功", these.device);

View File

@ -45,12 +45,17 @@
</view> </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>
<view class="mainContent"> <view class="mainContent">
<view class="p100"> <view class="p100">
<view class="list searchList"> <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']" v-show="!item['linkStatu']"
:class="{'displayNone':item.name.toLowerCase().indexOf(search.toLowerCase())===-1}"> :class="{'displayNone':item.name.toLowerCase().indexOf(search.toLowerCase())===-1}">
<view class="leftImg "> <view class="leftImg ">
@ -152,7 +157,8 @@
title: '添加设备', title: '添加设备',
showBack: true, showBack: true,
height: 90 height: 90
} },
tabIndex:0
}, },
search: '', search: '',
groupid: '', groupid: '',
@ -168,12 +174,35 @@
} }
}, },
computed: { computed: {
list(){
if(this.Status.tabIndex==0){
return this.UnJoin;
}
if(this.Status.tabIndex==1){
return this.joined;
}
return this.SearchEquips;
},
SearchEquips: function() { SearchEquips: function() {
let f = this.EquipMents.filter(v => { let f = this.EquipMents.filter(v => {
return v.name.toLowerCase().indexOf(this.search.toLowerCase()) > -1 return v.name.toLowerCase().indexOf(this.search.toLowerCase()) > -1
}); });
return f; 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() { onHide: function() {
ble.StopSearch(); ble.StopSearch();
@ -427,7 +456,7 @@
if (!f) { if (!f) {
arr[i].remark = '正在校验...'; arr[i].remark = '正在校验...';
these.EquipMents.push(arr[i]); these.EquipMents.unshift(arr[i]);
these.getDevice(arr[i]); these.getDevice(arr[i]);
@ -482,18 +511,19 @@
ble.addStateBreakCallback(() => { ble.addStateBreakCallback(() => {
MsgError('蓝牙不可用','确定',these);
MsgError('蓝牙不可用','',these);
these.EquipMents=[]; these.EquipMents.filter((v, i) => {
these.$set(these.EquipMents[i], 'link', false);
});
}, pagePath); }, pagePath);
ble.addStateRecoveryCallback(() => { ble.addStateRecoveryCallback(() => {
these.ReSearch(); these.ReSearch();
MsgSuccess('蓝牙恢复可用','',these,()=>{ MsgSuccess('蓝牙恢复可用','确定',these,()=>{
MsgClear(these); MsgClear(these);
}) });
}, },
pagePath); pagePath);
@ -553,11 +583,10 @@
// #ifdef APP|APP-PLUS
setTimeout(()=>{ setTimeout(()=>{
debugger;
MsgInfo("如需要在PC上查看此数据,请复制链接后通过微信发送到PC,在PC端打开然后点右上角扫码授权","复制链接",these,true,()=>{ MsgInfo("如需要在PC上查看此数据,请复制链接后通过微信发送到PC,在PC端打开然后点右上角扫码授权","复制链接",these,true,()=>{
console.log("执行复制"); console.log("开始访问剪切板");
uni.setClipboardData({ uni.setClipboardData({
data:'https://static-mp-5b7c35fc-f6fe-4100-a2e1-3669e4d4bfc9.next.bspapp.com/AppTools/views/index.html', data:'https://static-mp-5b7c35fc-f6fe-4100-a2e1-3669e4d4bfc9.next.bspapp.com/AppTools/views/index.html',
success(){ success(){
@ -565,25 +594,19 @@
title:'已复制链接' title:'已复制链接'
}); });
// #ifdef APP
plus.runtime.openURL('weixin://', (err) => { plus.runtime.openURL('weixin://', (err) => {
MsgError("打开微信失败,请手动打开微信,发送至'文件传输助手'"); MsgError("打开微信失败,请手动打开微信,发送至'文件传输助手'");
}); });
// #endif
// #ifndef APP
MsgInfo("已复制链接,请打开浏览器查看","",these);
setTimeout(()=>{
MsgClear(these);
},1200)
// #endif
}, },
fail(ex){ fail(ex) {
console.error("无法复制",ex) console.error("ex=",ex);
} }
}); });
}); });
},500); },500);
// #endif
}, },
onShow: function() { onShow: function() {
@ -812,6 +835,7 @@
let json = getUrlParams(res.result); let json = getUrlParams(res.result);
if (!json.key) { if (!json.key) {
MsgError('无效的二维码','',these); MsgError('无效的二维码','',these);
return; return;
@ -892,11 +916,11 @@
ble.disconnectDevice().finally(dis => { ble.disconnectDevice().finally(dis => {
ble.StopSearch().finally(res => { ble.StopSearch().finally(res => {
setTimeout(()=>{ this.EquipMents = [];
this.EquipMents = [];
this.PairEquip = []; this.PairEquip = [];
ble.StartSearch().then(result => { setTimeout(()=>{
ble.StartSearch().then(result => {
}).catch(err => { }).catch(err => {
console.error("err=", err); console.error("err=", err);
@ -904,7 +928,7 @@
}).finally(()=>{ }).finally(()=>{
hideLoading(these); hideLoading(these);
}); });
},200); },600)
}).catch(ex => { }).catch(ex => {
console.error("ex=", ex); console.error("ex=", ex);
@ -993,7 +1017,7 @@
}); });
let index = 1; let index = 1;
let total = 5; let total = 1;
let linkCallback = (res) => { let linkCallback = (res) => {
let c = these.PairEquip.find(function(v) { let c = these.PairEquip.find(function(v) {
@ -1029,14 +1053,11 @@
return false; return false;
}); });
ble.StopSearch();
resolve(res); resolve(res);
}).catch((ex) => { }).catch((ex) => {
if (index == total) { if (index == total) {
console.log("连接了N次都没连上"); console.log("连接了N次都没连上");
updateLoading(this, {
text: ex.msg
});
reject(ex); reject(ex);
return; return;
} }
@ -1058,8 +1079,8 @@
these.sendEquipToMq(); these.sendEquipToMq();
}).catch(ex => { }).catch(ex => {
console.log("ex=", ex) console.log("ex=", ex)
MsgError("连接失败:" + ex.msg,'',these); MsgError("连接失败"+ex.code + ex.msg,'',these);
hideLoading(these); hideLoading(these);
}); });
} }
@ -1076,6 +1097,22 @@
</script> </script>
<style> <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 { .noLink {
text-align: center; text-align: center;
width: 100%; width: 100%;
@ -1228,12 +1265,7 @@
min-height: 120rpx; min-height: 120rpx;
} }
.searchList {
width: 100%;
height: calc(100% - 186rpx);
overflow-y: scroll;
margin-top: 120rpx;
}
.list .item { .list .item {
width: 100%; width: 100%;
@ -1447,7 +1479,7 @@
.topStatric { .topStatric {
width: 100%; width: 100%;
box-sizing: border-box; box-sizing: border-box;
padding: 30rpx; padding:0rpx 30rpx;
position: fixed; position: fixed;
top: 0rpx; top: 0rpx;
z-index: 99; z-index: 99;
@ -1463,9 +1495,15 @@
.mainContent { .mainContent {
margin-top: 160rpx; margin-top: 280rpx;
} }
.searchList {
width: 100%;
height: calc(100% - 186rpx);
overflow-y: scroll;
margin-top: 90rpx;
}
/* #endif */ /* #endif */
@ -1476,9 +1514,15 @@
} }
.topStatric { .topStatric {
top: 90rpx top: 130rpx
} }
.searchList {
width: 100%;
height: calc(100% - 186rpx);
overflow-y: scroll;
margin-top: 150rpx;
}
/* #endif */ /* #endif */

View File

@ -27,10 +27,11 @@
<mescroll-uni class="device-list" @init="mescrollInit" @down="downCallback" @up="upCallback" :up="upOption" <mescroll-uni class="device-list" @init="mescrollInit" @down="downCallback" @up="upCallback" :up="upOption"
:down="downOption" :fixed="false" :style="{ height: mescrollHeight + 'px' }"> :down="downOption" :fixed="false" :style="{ height: mescrollHeight + 'px' }">
<view v-if="deviceList.length>0"> <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"> <block v-for="(item, index) in deviceList" :key="index" :ref="'swipeItem_' + index">
<uni-swipe-action-item :right-options="Options" :show="item.showOption" <uni-swipe-action-item :right-options="Options" :show="item.showOption"
@click="handleSwipeClick($event, item, index)" class="device-card" @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' }"> :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 @click.stop="handleFile(item,index)">
<view class="device-header"> <view class="device-header">
@ -62,7 +63,8 @@
</view> </view>
</view> </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> </uni-swipe-action-item>
</block> </block>
</uni-swipe-action> </uni-swipe-action>
@ -136,8 +138,8 @@
</view> </view>
<!-- 蒙板用于点击任意位置关闭悬浮的菜单 --> <!-- 蒙板用于点击任意位置关闭悬浮的菜单 -->
<view class="mask" v-show="showTooltip||showshare" @click.stop="closePopMenu"></view> <view class="mask" v-show="showTooltip||showshare" @click.stop="closePopMenu"></view>
<MsgBox ref="msgPop" /> <MsgBox ref="msgPop" />
</view> </view>
</template> </template>
@ -242,8 +244,8 @@
isLock: false, isLock: false,
empty: { empty: {
tip: '暂无数据', tip: '暂无数据',
hideScroll: false, hideScroll: false,
icon: '/static/images/common/empty.png' icon: '/static/images/common/empty.png'
}, },
textNoMore: '没有更多数据了' textNoMore: '没有更多数据了'
}, },
@ -315,7 +317,7 @@
}, },
bleBreak(res) { bleBreak(res) {
// console.error("蓝牙断开连接", res); console.error("蓝牙断开连接", res);
if (res.deviceId) { if (res.deviceId) {
this.updateBleStatu(res.deviceId); this.updateBleStatu(res.deviceId);
} }
@ -698,37 +700,44 @@
} }
}) })
}, },
swipeToggle(item,index){ swipeToggle(item, index) {
if(!item.showOption || item.showOption=='none'){ if (!item.showOption || item.showOption == 'none') {
this.$set(this.deviceList[index],'showOption','right'); this.$set(this.deviceList[index], 'showOption', 'right');
return; return;
} }
this.$set(this.deviceList[index],'showOption','none'); this.$set(this.deviceList[index], 'showOption', 'none');
}, },
// 列表跳转 // 列表跳转
handleFile(item,index) { handleFile(item, index) {
if(item.showOption=='right'){ if (item.showOption == 'right') {
this.$set(this.deviceList[index],'showOption','none'); this.$set(this.deviceList[index], 'showOption', 'none');
return; return;
} }
let url = item.detailPageUrl;
uni.navigateTo({ this.$set(this.deviceList[index], 'active', true);
url: url, setTimeout(() => {
events: { this.$set(this.deviceList[index], 'active', false);
ack: function(data) {} let url = item.detailPageUrl;
}, uni.navigateTo({
success: (res) => { url: url,
// 页面跳转成功后的回调函数 events: {
res.eventChannel.emit('detailData', { ack: function(data) {}
data: item, },
deviceType: this.tabs[this.activeTab].id || '', success: (res) => {
apiType: 'listA' //标识,根据这个参数,区分普通详情,分享跳转详情,查不一样的权限信息 // 页面跳转成功后的回调函数
}); res.eventChannel.emit('detailData', {
}, data: item,
fail(ex) { deviceType: this.tabs[this.activeTab].id || '',
console.log("ex=", ex); apiType: 'listA' //标识,根据这个参数,区分普通详情,分享跳转详情,查不一样的权限信息
} });
}) },
fail(ex) {
console.log("ex=", ex);
}
});
}, 100);
}, },
updateDeviceStatus(data) { updateDeviceStatus(data) {
@ -768,7 +777,6 @@
} }
}, },
onLoad() { onLoad() {
// console.error("首页加载"); // console.error("首页加载");
this.getTab() this.getTab()
this.downCallback(); this.downCallback();
@ -785,7 +793,7 @@
this.downCallback(); this.downCallback();
}); });
ble = bleTool.getBleTool(); ble = bleTool.getBleTool();
console.log("this=",this); console.log("this=", this);
recei = BleReceive.getBleReceive(this); recei = BleReceive.getBleReceive(this);
//蓝牙连接成功的回调 //蓝牙连接成功的回调
ble.addRecoveryCallback((res) => { ble.addRecoveryCallback((res) => {
@ -795,7 +803,7 @@
//蓝牙断开连接的回调 //蓝牙断开连接的回调
ble.addDisposeCallback((res) => { ble.addDisposeCallback((res) => {
// console.log("蓝牙断开连接的回调"); console.log("蓝牙断开连接的回调");
this.bleBreak(res); this.bleBreak(res);
}, pagePath); }, pagePath);
@ -813,8 +821,8 @@
//接收到消息的回调 //接收到消息的回调
ble.addReceiveCallback((receive, device, path, recArr) => { ble.addReceiveCallback((receive, device, path, recArr) => {
// console.error("首页收到消息了"); // console.error("首页收到消息了");
let json=recei.ReceiveData(receive, device, path, recArr); let json = recei.ReceiveData(receive, device, path, recArr);
// console.error("消息内容",json); // console.error("消息内容",json);
this.updateBleStatu(); this.updateBleStatu();
}, pagePath); }, pagePath);
@ -888,22 +896,23 @@
text-align: center; text-align: center;
/* 文字居中 */ /* 文字居中 */
/* 设置最小宽度 */ /* 设置最小宽度 */
position: relative; position: relative;
} }
.tab-item.active { .tab-item.active {
color: #bbe600; color: #bbe600;
height: 60rpx; height: 60rpx;
font-weight: bold; font-weight: bold;
} }
.tab-item.active::before{
.tab-item.active::before {
content: ""; content: "";
background-color: #bbe600; background-color: #bbe600;
position: absolute; position: absolute;
top: 90%; top: 90%;
left:35%; left: 35%;
width: 30%; width: 30%;
height: 6rpx; height: 6rpx;
border-radius: 6rpx; border-radius: 6rpx;
@ -957,6 +966,9 @@
box-sizing: border-box; box-sizing: border-box;
position: relative; position: relative;
} }
.device-card.active{
background-color: #2a2a2a !important;
}
.device-header { .device-header {
@ -1160,23 +1172,24 @@
} }
.cancelBtn{ .cancelBtn {
text-align: center; text-align: center;
width: 170rpx !important; width: 170rpx !important;
background-color: #00000000; background-color: #00000000;
} }
.agreement-popupC .cancelBtn{ .agreement-popupC .cancelBtn {
border:1rpx solid #E03434; border: 1rpx solid #E03434;
color:#E03434; color: #E03434;
} }
.agreement-popupD .cancelBtn{ .agreement-popupD .cancelBtn {
border: 1rpx solid rgba(255, 255, 255, 0.6); 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 { .agreement-popupD {
width: 75%; width: 75%;
background-color: rgb(42, 42, 42); background-color: rgb(42, 42, 42);

280
pages/common/map/index.nvue Normal file
View 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>

View File

@ -79,16 +79,17 @@ export default {
this.latitude = lat; this.latitude = lat;
this.longitude = lng; this.longitude = lng;
// 创建标记点 // 创建标记点
console.log("devicePic=",marker)
this.covers = [{ this.covers = [{
id: marker.deviceImei, // 适配deviceId字段 id: marker.deviceImei, // 适配deviceId字段
latitude: lat, latitude: lat,
longitude: lng, longitude: lng,
iconPath: marker.devicePic || '/static/images/common/mapLocation.png', iconPath: '/static/images/common/mapLocation.png',
width: 40, width: 60,
height: 40, height: 60,
anchor: {x: 0.5, y: 0.5}, // 锚点在中心 anchor: {x: 0.5, y: 0.5}, // 锚点在中心
callout: { callout: {
content: `ID: ${marker.deviceImei}` content: `${marker.deviceName}`
} }
}]; }];
@ -102,17 +103,18 @@ export default {
this.latitude = parseFloat(firstMarker.latitude); this.latitude = parseFloat(firstMarker.latitude);
this.longitude = parseFloat(firstMarker.longitude); this.longitude = parseFloat(firstMarker.longitude);
console.log("devicePic=",marker.devicePic)
// 转换所有有效标记点 // 转换所有有效标记点
this.covers = markers.map((marker, index) => ({ this.covers = markers.map((marker, index) => ({
id: marker.deviceId || marker.id || marker.deviceImei || index + 1, id: marker.deviceId || marker.id || marker.deviceImei || index + 1,
latitude: parseFloat(marker.latitude), latitude: parseFloat(marker.latitude),
longitude: parseFloat(marker.longitude), longitude: parseFloat(marker.longitude),
iconPath: marker.devicePic || '/static/images/common/device.png', iconPath: '/static/images/common/mapLocation.png',
width: 40, width: 60,
height: 40, height: 60,
anchor: {x: 0.5, y: 0.5}, anchor: {x: 0.5, y: 0.5},
callout: { callout: {
content: `ID: ${marker.deviceImei}`, content: `${marker.deviceName}`,
} }
})); }));

View File

@ -20,7 +20,7 @@
<!-- 编辑弹窗 --> <!-- 编辑弹窗 -->
<MsgBox ref="editPop"> <MsgBox ref="editPop">
<view> <view>
修改紧急联系人 编辑紧急联系人
</view> </view>
<view class="w60"> <view class="w60">

View File

@ -151,7 +151,9 @@
uni.reLaunch({ uni.reLaunch({
url: '/pages/common/login/index' url: '/pages/common/login/index'
}); });
}) });
}, },
// 退出登录 // 退出登录

View File

@ -768,8 +768,9 @@ class BleHelper {
} catch (convertException) { } catch (convertException) {
if (str && (str.trim().startsWith('{') || str.trim().startsWith('['))) { if (str && (str.trim().startsWith('{') || str.trim().startsWith('['))) {
console.error("JSON解析失败可能是格式错误的数据", convertException); console.error("JSON解析失败可能是格式错误的数据", convertException);
console.error("错误的数据", str);
} }
console.error("错误的数据", str);
} }
if (isUpdate) { if (isUpdate) {
@ -790,7 +791,7 @@ class BleHelper {
str: str, str: str,
hexs: hexs hexs: hexs
}; };
// console.log("监听到特征值:", recData); console.log("监听到特征值:", recData);
if (this.cfg.receivDataCallback) { if (this.cfg.receivDataCallback) {
if (this.cfg.receivDataCallback.length > 0) { if (this.cfg.receivDataCallback.length > 0) {

View File

@ -491,71 +491,85 @@ export default {
return result; return result;
}, },
formatTime(value, unit = 'minute') { formatTime(value, unit = 'minute') {
// 边界处理空值、0或负数 // 边界处理空值、0或负数
if (!value || value <= 0) return '0秒'; if (!value || value <= 0) return '0秒';
// 将所有单位统一转换为分钟和总秒数 // 将所有单位统一转换为分钟和总秒数
let minutes; let minutes;
let totalSeconds; let totalSeconds;
switch (unit) { switch (unit) {
case 'second': // 秒 case 'second': // 秒
minutes = value / 60; minutes = value / 60;
totalSeconds = value; totalSeconds = value;
break; break;
case 'minute': // 分钟(默认) case 'minute': // 分钟(默认)
minutes = value; minutes = value;
totalSeconds = value * 60; totalSeconds = value * 60;
break; break;
case 'hour': // 小时 case 'hour': // 小时
minutes = value * 60; minutes = value * 60;
totalSeconds = value * 3600; totalSeconds = value * 3600;
break; break;
case 'day': // 天 case 'day': // 天
minutes = value * 24 * 60; minutes = value * 24 * 60;
totalSeconds = value * 86400; totalSeconds = value * 86400;
break; break;
default: default:
minutes = value; minutes = value;
totalSeconds = value * 60; totalSeconds = value * 60;
} }
// 定义时间单位(分钟) // 定义时间单位(分钟)
const units = [ const units = [{
{ label: '年', minutes: 365 * 24 * 60 }, label: '年',
{ label: '月', minutes: 30 * 24 * 60 }, // 按30天简化计算 minutes: 365 * 24 * 60
{ label: '天', minutes: 24 * 60 }, },
{ label: '小时', minutes: 60 }, {
{ label: '', minutes: 1 } label: '',
]; minutes: 30 * 24 * 60
}, // 按30天简化计算
let remaining = minutes; {
const parts = []; label: '天',
minutes: 24 * 60
for (const unitObj of units) { },
const val = Math.floor(remaining / unitObj.minutes); {
if (val > 0) { label: '小时',
parts.push(`${val}${unitObj.label}`); minutes: 60
remaining %= unitObj.minutes; },
} {
} label: '分',
minutes: 1
// 处理剩余的秒数remaining 现在是小于1分钟的分钟数 }
if (remaining > 0) { ];
const seconds = Math.round(remaining * 60);
if (seconds > 0) { let remaining = minutes;
parts.push(`${seconds}`); const parts = [];
}
} for (const unitObj of units) {
const val = Math.floor(remaining / unitObj.minutes);
// 如果没有任何部分,返回总秒数 if (val > 0) {
if (parts.length === 0) { parts.push(`${val}${unitObj.label}`);
return `${Math.floor(totalSeconds)}`; remaining %= unitObj.minutes;
} }
}
return parts.join('');
// 处理剩余的秒数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) => { return new Promise((resolve, reject) => {
let url = let url =
'https://restapi.amap.com/v3/geocode/regeo?key=ca3af8a20d628897020893892bda5ae4&location=' + '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);
});
});
} }
} }

View File

@ -1,5 +1,5 @@
import config from '../config/index.js'; 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 BASE = config[env];
const request = (options) => { const request = (options) => {
// console.log("options" + JSON.stringify(options), BASE.BASE_URL) // console.log("options" + JSON.stringify(options), BASE.BASE_URL)