1
0
forked from dyf/APP
This commit is contained in:
fengerli
2026-01-30 13:29:15 +08:00
53 changed files with 8008 additions and 2154 deletions

View File

@ -53,6 +53,9 @@
}, },
onHide: function() { onHide: function() {
console.log('App Hide'); console.log('App Hide');
},
onError(ex) {
console.error("出现了未知的异常",ex);
} }
} }
</script> </script>

View File

@ -17,6 +17,13 @@ export function deviceTypeList(params) {
}) })
} }
export function typeAll(){
return request({
url: '/app/xinghan/device/typeAll',
method: 'get'
});
}
// 删除设备列表接口 // 删除设备列表接口
export function deviceUnbind(id) { export function deviceUnbind(id) {
return request({ return request({

View File

@ -229,12 +229,12 @@
let linePixls = []; let linePixls = [];
let item = this.validTxts[i]; let item = this.validTxts[i];
console.log("item=",item);
for (var j = 0; j < item.length; j++) { for (var j = 0; j < item.length; j++) {
let result = await drawTxt(item[j]); let result = await drawTxt(item[j]);
linePixls.push(convertCharToMatrix(result.pixelData)); linePixls.push(convertCharToMatrix(result.pixelData));
} }
console.log("hexs=",linePixls.join(",")); // console.log("hexs=",linePixls.join(","));
arr.push(linePixls); arr.push(linePixls);
} }

View File

@ -2,7 +2,7 @@
const config = { const config = {
// 开发环境 // 开发环境
development: { development: {
BASE_URL: 'http://139.224.253.23:8000', BASE_URL: 'http://192.168.110.57:8000',//http://139.224.253.23:8000
API_PREFIX: '', API_PREFIX: '',
// MQTT 配置 // MQTT 配置
MQTT_HOST: 'www.cnxhyc.com', MQTT_HOST: 'www.cnxhyc.com',

View File

@ -6,13 +6,13 @@ import uView from 'vk-uview-ui';
// #ifndef VUE3 // #ifndef VUE3
import Vue from 'vue' import Vue from 'vue'
import store from './store/store';
import './uni.promisify.adaptor' import './uni.promisify.adaptor'
Vue.config.productionTip = false Vue.config.productionTip = false
App.mpType = 'app' App.mpType = 'app'
const app = new Vue({ const app = new Vue({
store,
...App ...App
}) })
Vue.use(uView) Vue.use(uView)

View File

@ -2,7 +2,7 @@
"name" : "星汉物联", "name" : "星汉物联",
"appid" : "__UNI__A21EF43", "appid" : "__UNI__A21EF43",
"description" : "设备管控", "description" : "设备管控",
"versionName" : "1.0.8", "versionName" : "1.0.12",
"versionCode" : "100", "versionCode" : "100",
"transformPx" : false, "transformPx" : false,
/* 5+App */ /* 5+App */
@ -99,23 +99,7 @@
}, },
"push" : { "push" : {
"unipush" : { "unipush" : {
"version" : "2", "offline" : false
"offline" : true,
"hms" : {},
"oppo" : {},
"vivo" : {},
"mi" : {},
"meizu" : {},
"honor" : {},
"icons" : {
"small" : {
"xxhdpi" : "unpackage/res/icons/72x72.png",
"xhdpi" : "unpackage/res/icons/48x48.png",
"hdpi" : "unpackage/res/icons/36x36.png",
"mdpi" : "unpackage/res/icons/24x24.png",
"ldpi" : "unpackage/res/icons/18x18.png"
}
}
} }
} }
}, },

View File

@ -2,7 +2,7 @@
"dependencies": { "dependencies": {
"axios": "^1.9.0", "axios": "^1.9.0",
"blueimp-md5": "^2.19.0", "blueimp-md5": "^2.19.0",
"paho-mqtt": "^1.1.0", "paho-mqtt": "^1.1.0",
"vk-uview-ui": "^1.5.2" "vk-uview-ui": "^1.5.2"
} }
} }

View File

@ -339,6 +339,7 @@
"path" : "pages/102/HBY102", "path" : "pages/102/HBY102",
"style" : "style" :
{ {
"navigationStyle": "custom",
"navigationBarTitleText" : "HBY102" "navigationBarTitleText" : "HBY102"
} }
}, },
@ -362,6 +363,27 @@
{ {
"navigationBarTitleText" : "HBY018A" "navigationBarTitleText" : "HBY018A"
} }
},
{
"path" : "pages/6107/BJQ6107",
"style" :
{
"navigationBarTitleText" : "BJQ6107"
}
},
{
"path" : "pages/6155/BJQ6155",
"style" :
{
"navigationBarTitleText" : "BJQ6155"
}
},
{
"path" : "pages/102/HBY102_History",
"style" :
{
"navigationStyle": "custom"
}
} }

View File

@ -255,10 +255,7 @@
hideLoading, hideLoading,
updateLoading updateLoading
} from '@/utils/loading.js' } from '@/utils/loading.js'
import { import request, { baseURL } from '@/utils/request.js';
request,
baseURL
} from '../../utils/request';
import Common from '@/utils/Common.js' import Common from '@/utils/Common.js'
const pagePath = "/pages/100/HBY100"; const pagePath = "/pages/100/HBY100";

View File

@ -1,5 +1,26 @@
<template> <template>
<view class="content contentBg"> <view class="content contentBg">
<uni-nav-bar class="nvbar" leftIcon="left" @clickLeft="navigatorBack">
<view slot="left">
<uni-icons type="back" size="23" color="#FFFFFF"></uni-icons>
</view>
<view slot="default" class="center uninavebartext">
{{Status.navbar.title}}
</view>
<view slot="right">
<view class="navbarRight center">
<view class="imgContent" @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>
</view>
</view>
</uni-nav-bar>
<view class="eq"> <view class="eq">
<view class="leftImg" @click.stop="previewImg(device.devicePic?device.devicePic:formData.img)"> <view class="leftImg" @click.stop="previewImg(device.devicePic?device.devicePic:formData.img)">
<image class="img" :src="device.devicePic?device.devicePic:formData.img" mode="aspectFit"></image> <image class="img" :src="device.devicePic?device.devicePic:formData.img" mode="aspectFit"></image>
@ -16,7 +37,8 @@
<view class="row"> <view class="row">
<image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image> <image class="img" src="/static/images/6155/DeviceDetail/time.png" mode="aspectFit"></image>
<view class="txt"> <view class="txt">
<view class="bigTxt">{{formData.sta_charge?dic.sta_charge[formData.sta_charge+'']:"未充电" }}</view> <view class="bigTxt">{{formData.sta_charge?dic.sta_charge[formData.sta_charge+'']:"未充电" }}
</view>
<view class="smallTxt">设备状态</view> <view class="smallTxt">设备状态</view>
</view> </view>
</view> </view>
@ -46,7 +68,7 @@
</view> --> </view> -->
</view> </view>
<view class="warnnig" v-for="item,index in warnDevices"> <view class="warnnig" v-for="item,index in warnDevices">
<view>闯入报警</view> <view>闯入报警</view>
<view> <view>
{{item.name}} {{item.name}}
@ -161,9 +183,9 @@
<global-loading ref="loading" /> <global-loading ref="loading" />
<BottomSlideMenuPlus :config="Status.BottomMenu" @itemClick="btnClick" @close="closeActionSheet"> <BottomSlideMenuPlus :config="Status.BottomMenu" @itemClick="btnClick" @close="closeActionSheet">
</BottomSlideMenuPlus> </BottomSlideMenuPlus>
</view> </view>
</template> </template>
@ -223,30 +245,30 @@
show: false, show: false,
showHeader: true, showHeader: true,
menuItems: [{ menuItems: [{
text: '2M', text: '2M',
value:'status_2M', value: 'status_2M',
icon: '' icon: ''
}, },
{ {
text: '4M', text: '4M',
value:'status_4M', value: 'status_4M',
icon: '' icon: ''
}, },
{ {
text: '7M', text: '7M',
value:'status_7M', value: 'status_7M',
icon: '' icon: ''
}, },
{ {
text: '10M', text: '10M',
value:'status_10M', value: 'status_10M',
icon: '' icon: ''
}, },
{ {
text: '关闭', text: '关闭',
value:'status_off', value: 'status_off',
icon: '' icon: ''
} }
], ],
activeIndex: -1, activeIndex: -1,
bgColor: '#2a2a2a', bgColor: '#2a2a2a',
@ -269,6 +291,21 @@
showClose: false showClose: false
}, },
usrToggle: false, usrToggle: false,
navbar: {
icons: [{
src: '/static/images/common/history.png',
callback: this.gotoHistory,
math: 0
},
{
src: '/static/images/common/shape.png',
callback: this.gotoShare
}
],
title: 'HBY102'
},
apiType: ''
}, },
formData: { formData: {
img: '/static/images/common/HBY102.png', img: '/static/images/common/HBY102.png',
@ -281,13 +318,13 @@
statu: '', statu: '',
sta_address: '', sta_address: '',
bleStatu: false, bleStatu: false,
sta_charge:'', sta_charge: '',
sta_LedType: '', sta_LedType: '',
sta_RadarType: '', sta_RadarType: '',
sta_Online: '', sta_Online: '',
warnTime: '', warnTime: '',
sta_sosadd: "", sta_sosadd: "",
sta_sosName:'', sta_sosName: '',
sta_IntrusTime: '' sta_IntrusTime: ''
}, },
@ -300,7 +337,8 @@
show: true, show: true,
img: '/static/images/100/light.png', img: '/static/images/100/light.png',
activeImg: '/static/images/100/lightActive.png', activeImg: '/static/images/100/lightActive.png',
group: 'sta_LedType' group: 'sta_LedType',
permission: '1'
}, },
{ {
key: 'led_low_flash', key: 'led_low_flash',
@ -308,7 +346,8 @@
show: true, show: true,
img: '/static/images/102/lowFlash.png', img: '/static/images/102/lowFlash.png',
activeImg: '/static/images/102/lowFlashActive.png', activeImg: '/static/images/102/lowFlashActive.png',
group: 'sta_LedType' group: 'sta_LedType',
permission: '1'
}, },
{ {
key: 'led_steady', key: 'led_steady',
@ -316,7 +355,8 @@
show: true, show: true,
img: '/static/images/102/liting.png', img: '/static/images/102/liting.png',
activeImg: '/static/images/102/litingActive.png', activeImg: '/static/images/102/litingActive.png',
group: 'sta_LedType' group: 'sta_LedType',
permission: '1'
}, },
{ {
key: 'status_on', key: 'status_on',
@ -324,7 +364,8 @@
show: true, show: true,
img: '/static/images/102/redar.png', img: '/static/images/102/redar.png',
activeImg: '/static/images/102/redarActive.png', activeImg: '/static/images/102/redarActive.png',
group: 'sta_RadarType' group: 'sta_RadarType',
permission: '48'
}, },
{ {
key: 'E49_on', key: 'E49_on',
@ -332,7 +373,8 @@
show: true, show: true,
img: '/static/images/102/line.png', img: '/static/images/102/line.png',
activeImg: '/static/images/102/lineActive.png', activeImg: '/static/images/102/lineActive.png',
group: 'sta_Online' group: 'sta_Online',
permission: '49'
}, },
{ {
key: 'led_off', key: 'led_off',
@ -377,7 +419,8 @@
showConfirm: false showConfirm: false
}, },
groupDevices: [], groupDevices: [],
warnDevices:[] warnDevices: [],
permissions: []
} }
}, },
@ -404,9 +447,20 @@
eventChannel.on('detailData', function(data) { eventChannel.on('detailData', function(data) {
// console.log("收到父页面的参数:" + JSON.stringify(data)); console.log("收到父页面的参数:" + JSON.stringify(data));
var device = data.data; var device = data.data;
these.Status.apiType = data.apiType;
if (data.apiType !== 'listA') {
Common.getdeviceShareId(data.data.id).then(res => {
if (res.code == 200) {
if (res.data.permission) {
these.permissions = res.data.permission.split(',');
}
}
});
}
these.device = device; these.device = device;
these.getWarns();
let f = ble.data.LinkedList.find((v) => { let f = ble.data.LinkedList.find((v) => {
if (v.macAddress == device.deviceMac) { if (v.macAddress == device.deviceMac) {
// console.log("找到设备了", v); // console.log("找到设备了", v);
@ -452,34 +506,181 @@
}, },
onShow() { onShow() {
this.Status.pageHide = false; this.Status.pageHide = false;
this.getLinkedCnt();
}, },
computed: { computed: {
Distance:function(){ Distance: function() {
let f=this.Status.BottomMenu.menuItems.find((item,index)=>{ let f = this.Status.BottomMenu.menuItems.find((item, index) => {
return item.value===this.formData.sta_RadarType; return item.value === this.formData.sta_RadarType;
}); });
if(f){ if (f) {
return f.text; return f.text;
} }
return '关闭'; return '关闭';
}, },
activeIndex:function(){ activeIndex: function() {
let active=4; let active = 4;
let f=this.Status.BottomMenu.menuItems.find((item,index)=>{ let f = this.Status.BottomMenu.menuItems.find((item, index) => {
if(item.value===this.formData.sta_RadarType){ if (item.value === this.formData.sta_RadarType) {
active=index; active = index;
} }
}); });
return active; return active;
} }
}, },
methods: { methods: {
getLinkedCnt() {//获取在线设备的数量
let f = this.getDevice();
// #ifdef APP-PLUS
if (!f) {
return;
}
// #endif
// #ifdef H5
f = {
deviceId: '12345'
}
// #endif
if (ble) {
let buffer = {
ins_Quantity: "query"
};
ble.sendString(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 30).then(res=>{
setTimeout(()=>{
this.getWarns();
},1500);
}).catch(()=>{
this.getWarns();
})
}
},
getWarns() {
return new Promise((resolve, reject) => {
if (!these.device.id) {
return;
}
let warnKey = "102_" + these.device.id + "_warning";
let linkKey = "102_" + these.device.id + "_linked";
let p1 = new Promise((succ, err) => {
uni.getStorage({
key: warnKey,
success(res) {
let data = res.data;
let fs = data.filter(v => {
return !v.read
});
succ(fs);
},
fail(ex) {
err(null);
}
});
});
let p2 = new Promise((succ, err) => {
uni.getStorage({
key: linkKey,
success(res) {
console.error("获取到联机数据",res);
let data = res.data;
let fs = data.filter(v => {
return !v.read
});
console.error("未读联机数据",fs);
succ(fs);
},
fail(ex) {
err(null);
}
});
});
Promise.allSettled([p1, p2]).then(results => {
let fs = [];
if (results[0].status == 'fulfilled') {
fs=fs.concat(results[0].value);
}
if (results[1].status == 'fulfilled') {
fs=fs.concat(results[1].value);
}
console.error("获取到未读消息",fs);
these.$set(these.Status.navbar.icons[0], "math", fs.length);
});
});
},
gotoHistory(item, s) {
uni.navigateTo({
url: '/pages/102/HBY102_History',
success: (res) => {
res.eventChannel.emit('detailData', {
data: these.device
});
}
});
},
gotoShare(item, s) {
uni.navigateTo({
url: '/pages/common/share/index',
events: {
ack: function(data) {}
},
success: (res) => {
let json = {
persissonType: '102'
};
Object.assign(json, this.device);
res.eventChannel.emit('share', {
data: json
});
}
})
},
handleRightClick(item, s) {
if (item && item.callback) {
item.callback(item, s);
} else {
uni.showModal({
content: '敬请期待'
})
}
},
navigatorBack() {
uni.navigateBack();
},
actionSett(item, index) { actionSett(item, index) {
if (!this.permissions.includes(item.permission) && this.Status.apiType !== 'listA') {
this.showPop({
message: '无操作权限',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
okCallback: null,
buttonText: "确定"
})
return;
}
if (item.group == 'sta_LedType') { if (item.group == 'sta_LedType') {
this.sosSetting(item, index); this.sosSetting(item, index);
return; return;
@ -488,7 +689,7 @@
if (item.group == 'sta_RadarType') { if (item.group == 'sta_RadarType') {
// this.toggleRedar(item, index); // this.toggleRedar(item, index);
this.showRedarSetting(item,index); this.showRedarSetting(item, index);
return; return;
} }
@ -555,24 +756,24 @@
}, },
showRedarSetting(){ showRedarSetting() {
this.Status.BottomMenu.show=true; this.Status.BottomMenu.show = true;
this.Status.BottomMenu.showBtn=false; this.Status.BottomMenu.showBtn = false;
this.Status.BottomMenu.title="感应距离设置"; this.Status.BottomMenu.title = "感应距离设置";
this.Status.BottomMenu.textAlign="center"; this.Status.BottomMenu.textAlign = "center";
this.Status.BottomMenu.showMask=true; this.Status.BottomMenu.showMask = true;
this.Status.BottomMenu.activeIndex=this.activeIndex; this.Status.BottomMenu.activeIndex = this.activeIndex;
}, },
btnClick(item,index){ btnClick(item, index) {
this.Status.BottomMenu.show=false; this.Status.BottomMenu.show = false;
console.log("选中的项:"+index+",值:"+JSON.stringify(item)); console.log("选中的项:" + index + ",值:" + JSON.stringify(item));
this.toggleRedar(item,index); this.toggleRedar(item, index);
}, },
closeActionSheet(){ closeActionSheet() {
this.Status.BottomMenu.show=false; this.Status.BottomMenu.show = false;
}, },
toggleRedar(item, index) { //雷达启停 toggleRedar(item, index) { //雷达启停
let f = this.getDevice(); let f = this.getDevice();
@ -601,7 +802,7 @@
.then(res => { .then(res => {
debugger; debugger;
this.formData.sta_RadarType = val; this.formData.sta_RadarType = val;
this.Status.BottomMenu.activeIndex=index; this.Status.BottomMenu.activeIndex = index;
these.setBleFormData(); these.setBleFormData();
resolve(); resolve();
}) })
@ -642,6 +843,19 @@
sosSetting(item, isOk) { sosSetting(item, isOk) {
if (!this.permissions.includes('46') && this.Status.apiType !== 'listA') {
this.showPop({
message: '无操作权限',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
borderColor: "#e034344d",
buttonBgColor: "#E03434",
okCallback: null,
buttonText: "确定"
})
return;
}
if (item.key == 'led_alarm' && this.formData.sta_LedType == 'led_alarm') { if (item.key == 'led_alarm' && this.formData.sta_LedType == 'led_alarm') {
return; return;
} }
@ -817,59 +1031,66 @@
let json = recei.ReceiveData(receive, device, pagePath, recArr); let json = recei.ReceiveData(receive, device, pagePath, recArr);
console.log("json=", json) console.log("json=", json)
setTimeout(()=>{
this.getWarns();
},500);
let active = -1;
let active=-1; let f = this.Status.BottomMenu.menuItems.find((item, index) => {
let f=this.Status.BottomMenu.menuItems.find((item,index)=>{
if (item.value === json.sta_RadarType) {
if(item.value===json.sta_RadarType){ active = index;
active=index;
} }
}); });
this.Status.BottomMenu.activeIndex=active; this.Status.BottomMenu.activeIndex = active;
let msg = []; let msg = [];
if (json.sta_PowerPercent <= 20 && (json.sta_charge===0 || json.sta_charge==='0')) { if (json.sta_PowerPercent <= 20 && (json.sta_charge === 0 || json.sta_charge === '0')) {
msg.push("设备电量低"); msg.push("设备电量低");
} }
if(json.sta_sosadd_off){//某个设备解除报警 if (json.sta_sosadd_off) { //某个设备解除报警
this.warnDevices.filter((d,index)=>{ this.warnDevices.filter((d, index) => {
if(d.mac===json.sta_sosadd_off){ if (d.mac === json.sta_sosadd_off) {
this.warnDevices.splice(index,1); this.warnDevices.splice(index, 1);
} }
}); });
} }
let keys = Object.keys(json); let keys = Object.keys(json);
keys.forEach(key => { keys.forEach(key => {
if (key in this.formData) { if (key in this.formData) {
// console.log("key=",key+",value=",json[key]); // console.log("key=",key+",value=",json[key]);
this.formData[key] = json[key]; this.formData[key] = json[key];
} }
}); });
if (json.sta_sosadd) {//某个设备闯入报警
console.log("查询设备中",json.sta_sosadd); if (json.sta_sosadd) { //某个设备闯入报警
console.log("查询设备中", json.sta_sosadd);
this.searchDevice(json.sta_sosadd).catch(ex => {}).then(dev => { this.searchDevice(json.sta_sosadd).catch(ex => {}).then(dev => {
console.log("dev=", dev); console.log("dev=", dev);
let d=this.warnDevices.find(v=>{return v.mac===json.sta_sosadd}); let d = this.warnDevices.find(v => {
let deviceName=""; return v.mac === json.sta_sosadd
});
let deviceName = "";
if (dev) { if (dev) {
// this.formData.sta_sosName=dev.deviceName; // this.formData.sta_sosName=dev.deviceName;
msg.push('"' + dev.deviceName + '"闯入报警中'); msg.push('"' + dev.deviceName + '"闯入报警中');
deviceName=dev.deviceName; deviceName = dev.deviceName;
} else { } else {
msg.push('闯入报警中'); msg.push('闯入报警中');
// this.formData.sta_sosName=""; // this.formData.sta_sosName="";
} }
if(!d){ if (!d) {
this.warnDevices.push({mac:json.sta_sosadd,name:deviceName}); this.warnDevices.push({
mac: json.sta_sosadd,
name: deviceName
});
} }
this.showMsg(msg.join(',')); this.showMsg(msg.join(','));
}); });
@ -898,7 +1119,7 @@
}, },
getWarDevice(macStr) { getWarDevice(macStr) {
console.log("macStr=",macStr); console.log("macStr=", macStr);
if (macStr) { if (macStr) {
if (!macStr.includes(':')) { if (!macStr.includes(':')) {
@ -1158,6 +1379,11 @@
</script> </script>
<style> <style>
.uninavebartext {
width: 100%;
font-size: 32rpx;
}
.content { .content {
padding: 30rpx; padding: 30rpx;
box-sizing: border-box; box-sizing: border-box;
@ -1919,4 +2145,65 @@
letter-spacing: 0.07px; letter-spacing: 0.07px;
} }
.navbarRight {
width: 60px;
height: 100%;
}
.navbarRight .imgContent {
width: 36rpx;
height: 36rpx;
position: relative;
}
.navbarRight .imgContent:first-child {
margin-right: 36rpx;
width: 38rpx !important;
height: 38rpx !important;
margin-top: -2rpx;
}
.navbarRight .imgContent .baber {
position: absolute;
z-index: 100;
width: 30rpx;
height: 30rpx;
line-height: 30rpx;
right: -15rpx;
top: -15rpx;
border-radius: 50%;
background: #f12828;
color: #ffffff;
font-family: 'PingFang SC';
font-style: Regular;
font-size: 20rpx;
font-weight: 400;
text-align: center;
overflow: hidden;
white-space: nowrap;
}
.navbarRight .imgContent .img {
width: 100%;
height: 100%;
box-sizing: border-box;
position: relative;
}
.navbarRight .imgContent .img:last-child {
padding: 1rpx;
}
.nvbar {
top: 0px;
}
/deep/ .uni-navbar--fixed {
top: 0px;
}
</style> </style>

1327
pages/102/HBY102_History.vue Normal file

File diff suppressed because it is too large Load Diff

View File

@ -228,7 +228,7 @@
:key="index" :key="index"
> >
<checkbox <checkbox
v-model="selectedSoundFiles"
:value="file" :value="file"
@change="handleSoundFileSelect" @change="handleSoundFileSelect"
/> />
@ -356,9 +356,7 @@
laserModeSettings, //激光模式设置 laserModeSettings, //激光模式设置
mapReverseGeocoding //地图逆解析 mapReverseGeocoding //地图逆解析
} from '@/api/6170/deviceControl.js' } from '@/api/6170/deviceControl.js'
import {
getDeviceId
} from '../../store/BLETools';
import { import {
baseURL, baseURL,
getToken, getToken,

View File

@ -107,7 +107,7 @@
<view class="lampMode"> <view class="lampMode">
<view class="colorContent"> <view class="colorContent">
<view v-for="item,index in dic.groups" class="item" <view v-for="item,index in formData.groups" class="item"
:class="{active:item.id==formData.sta_GroupType,marginNoLeft:index%3===0}" :class="{active:item.id==formData.sta_GroupType,marginNoLeft:index%3===0}"
@click.stop="groupSetting(item,index)"> @click.stop="groupSetting(item,index)">
@ -125,15 +125,15 @@
<view class="lamp noPadding"> <view class="lamp noPadding">
<view class="title">箭头模式</view> <view class="title">箭头模式</view>
<view class="smlltitle"> <view class="smlltitle">
箭头朝向 朝向/颜色
</view> </view>
</view> </view>
<view class="arrowContent marginTop10"> <view class="arrowContent marginTop10">
<view class="modeSetting"> <view class="modeSetting">
<view class="arrow" @click.stop="ArrowSet('red_front')" <view class="arrow" @click.stop="ArrowModeSet('right_off')"
:class="formData.sta_ArrowType=='red_front'?'active':''"> :class="formData.sta_ArrowMode=='right_off'?'active':''">
<view class="outCircle"> <view class="outCircle">
<view class="item"> <view class="item">
<image class="img nomal" src="/static/images/4877/arrow.png" mode="aspectFit"></image> <image class="img nomal" src="/static/images/4877/arrow.png" mode="aspectFit"></image>
@ -141,10 +141,10 @@
</image> </image>
</view> </view>
</view> </view>
<view class="text">红色朝前</view> <view class="text">朝左</view>
</view> </view>
<view class="arrow" @click.stop="ArrowSet('green_back')" <view class="arrow" @click.stop="ArrowModeSet('right_on')"
:class="formData.sta_ArrowType=='green_back'?'active':''"> :class="formData.sta_ArrowMode=='right_on'?'active':''">
<view class="outCircle"> <view class="outCircle">
<view class="item"> <view class="item">
<image class="img nomal translate" src="/static/images/4877/arrow.png" mode="aspectFit"> <image class="img nomal translate" src="/static/images/4877/arrow.png" mode="aspectFit">
@ -153,10 +153,37 @@
mode="aspectFit"></image> mode="aspectFit"></image>
</view> </view>
</view> </view>
<view class="text">绿色朝后</view> <view class="text">朝右</view>
</view> </view>
</view> </view>
<view class="line"></view>
<view class="modeSetting">
<view class="arrow" @click.stop="ArrowSet('red_front')"
:class="formData.sta_ArrowType=='red_front'?'redactive':''">
<view class="outCircle">
<view class="item">
<view class="text">红色</view>
</view>
</view>
</view>
<view class="arrow" @click.stop="ArrowSet('green_back')"
:class="formData.sta_ArrowType=='green_back'?'greenactive':''">
<view class="outCircle">
<view class="item">
<view class="text">绿色</view>
</view>
</view>
</view>
</view>
</view> </view>
<view class="lamp noPadding"> <view class="lamp noPadding">
@ -248,14 +275,11 @@
hideLoading, hideLoading,
updateLoading updateLoading
} from '@/utils/loading.js' } from '@/utils/loading.js'
import { import request, { baseURL } from '@/utils/request.js';
request,
baseURL
} from '../../utils/request';
import { import {
colors as groupColors colors as groupColors
} from '@/api/4877/BJQ4877.js'; } from '@/api/4877/BJQ4877.js';
import MqTool from '@/utils/MqHelper.js' import MqTool from '@/utils/MqHelper.js'
const pagePath = "/pages/4877/BJQ4877"; const pagePath = "/pages/4877/BJQ4877";
@ -265,7 +289,7 @@
var recei = null; var recei = null;
var interval = null; var interval = null;
var slidTime = null; var slidTime = null;
var mq=null; var mq = null;
export default { export default {
data() { data() {
return { return {
@ -346,7 +370,11 @@
sta_GroupType: -1, //配组 sta_GroupType: -1, //配组
sta_ArrowType: '', //箭头方向 sta_ArrowType: '', //箭头方向
warnTime: 0, warnTime: 0,
sta_Channel: 80 sta_Channel: 31,
sta_ArrowMode:'',
groups: [
]
}, },
dic: { dic: {
SOS: [{ SOS: [{
@ -361,10 +389,8 @@
img: '/static/images/4877/fan.png', img: '/static/images/4877/fan.png',
activeImg: '/static/images/4877/fanActive.png' activeImg: '/static/images/4877/fanActive.png'
} }
],
groups: [
] ]
}, },
device: { device: {
id: "", id: "",
@ -391,19 +417,19 @@
onUnload() { onUnload() {
console.log("页面卸载,释放资源"); console.log("页面卸载,释放资源");
ble.removeAllCallback(pagePath); ble.removeAllCallback(pagePath);
if(mq){ if (mq) {
mq.unSubscribes(); mq.unSubscribes();
mq.disconnect(); mq.disconnect();
} }
ble=null; ble = null;
mq=null; mq = null;
clearInterval(interval); clearInterval(interval);
}, },
onLoad: function() { onLoad: function() {
these = this; these = this;
recei = BleReceive.getBleReceive(); recei = BleReceive.getBleReceive();
ble = BleTool.getBleTool(); ble = BleTool.getBleTool();
mq=MqTool.getMqTool(); mq = MqTool.getMqTool();
this.dic.gropus = []; this.dic.gropus = [];
@ -433,19 +459,28 @@
return false; return false;
}); });
these.dic.groups = groups; these.formData.groups = groups;
} }
var device = data.data; var device = data.data;
these.device = device; these.device = device;
let arr=[{topic:'C/4877_Groups_'+these.device.id,callback:these.getCheckedColors}]; let arr = [{
mq.init().then(res=>{ topic: 'C/4877_Groups_' + these.device.id,
mq.subscribes(arr).catch(ex=>{ callback: these.getCheckedColors
console.error("ex=",ex); }
// ,
// {
// topic: 'C/4877_Channel_' + these.device.id,
// callback: these.getChannel
// }
];
mq.init().then(res => {
mq.subscribes(arr).catch(ex => {
console.error("ex=", ex);
}); });
}) })
let f = ble.data.LinkedList.find((v) => { let f = ble.data.LinkedList.find((v) => {
if (v.macAddress == device.deviceMac) { if (v.macAddress == device.deviceMac) {
// console.log("找到设备了", v); // console.log("找到设备了", v);
@ -474,8 +509,8 @@
these.formData.bleStatu = false; these.formData.bleStatu = false;
these.formData.deviceId = f.deviceId; these.formData.deviceId = f.deviceId;
these.formData.warnTime=null; these.formData.warnTime = null;
these.formData.sta_SOSType='sos_off'; these.formData.sta_SOSType = 'sos_off';
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;
}); });
@ -496,38 +531,53 @@
}, },
methods: { methods: {
getCheckedColors(rec){ getChannel(rec) {
console.error("收到MQ消息:",rec); console.error("收到MQ信道保留消息:", rec);
try{ try {
let str=rec.receive.payloadString; let str = rec.receive.payloadString;
let arr=JSON.parse(str); let json = JSON.parse(str);
if('ins_channel' in json){
this.formData.sta_Channel=json.ins_channel;
let groups = groupColors.filter((v,index) => { these.setBleFormData();
if(arr[index]===1){ }
return true;
} } catch (err) {
return false;
});
these.dic.groups = groups;
let checks = groups.map(item => {
return item.id
});
uni.setStorage({
key: "4877CheckColor_" + this.device.id,
data: checks
});
}catch(err){
} }
},
getCheckedColors(rec) {
console.error("收到MQ消息:", rec);
try {
let str = rec.receive.payloadString;
let arr = JSON.parse(str);
let groups = groupColors.filter((v, index) => {
if (arr[index] === 1) {
return true;
}
return false;
});
these.formData.groups = groups;
console.error("groups=",these.formData.groups);
let checks = groups.map(item => {
return item.id
});
uni.setStorage({
key: "4877CheckColor_" + this.device.id,
data: checks
});
} catch (err) {
}
}, },
ShowChannelEdit() { ShowChannelEdit() {
this.Status.ShowEditChannel = true; this.Status.ShowEditChannel = true;
@ -547,15 +597,15 @@
promptTitle: '', promptTitle: '',
modelValue: '', modelValue: '',
visibleClose: false, visibleClose: false,
okCallback: ()=>{ okCallback: () => {
this.onChannelChanging(); this.onChannelChanging();
this.Status.ShowEditChannel=false; this.Status.ShowEditChannel = false;
}, },
showSlot: true, showSlot: true,
buttonCancelText: '取消', buttonCancelText: '取消',
showCancel: true, showCancel: true,
cancelCallback:()=>{ cancelCallback: () => {
this.Status.ShowEditChannel=false; this.Status.ShowEditChannel = false;
} }
}); });
}, },
@ -566,7 +616,7 @@
return; return;
} }
let f = this.getDevice(); let f = this.getDevice();
if (!f) { if (!f) {
this.showBleUnConnect(); this.showBleUnConnect();
return; return;
@ -580,6 +630,14 @@
json = JSON.stringify(json); json = JSON.stringify(json);
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => { ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
console.log("发送成功"); console.log("发送成功");
// mq.sendData('C/4877_Channel_' + these.device.id, JSON.stringify(json), true).then(
// res => {
// console.log("发送成功,", res)
// }).catch(err => {
// console.error("err=", err);
// });
this.setBleFormData(); this.setBleFormData();
}).catch(ex => { }).catch(ex => {
this.showMsg(ex.msg); this.showMsg(ex.msg);
@ -587,6 +645,31 @@
}, 200) }, 200)
},
ArrowModeSet(val) {
if (this.formData.sta_SOSType === 'sos') {
this.showMsg("设备强制报警中,请先关闭报警")
return;
}
let f = this.getDevice();
if (!f) {
this.showBleUnConnect();
return;
}
if (this.formData.sta_ArrowMode === val) {
return;
}
var json = {
ins_right_side: val
}
json = JSON.stringify(json);
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
this.formData.sta_ArrowMode = val;
}).catch(ex => {
this.showMsg(ex.msg);
});
}, },
ArrowSet(val) { ArrowSet(val) {
if (this.formData.sta_SOSType === 'sos') { if (this.formData.sta_SOSType === 'sos') {
@ -631,7 +714,7 @@
return false; return false;
}); });
these.dic.groups = arr; these.formData.groups = arr;
these.CheckGroupOver(data.allFlag); these.CheckGroupOver(data.allFlag);
} }
}, },
@ -648,17 +731,17 @@
return; return;
} }
mq.sendData('C/4877_Groups_'+these.device.id,JSON.stringify(arr),true).then(res=>{ mq.sendData('C/4877_Groups_' + these.device.id, JSON.stringify(arr), true).then(res => {
console.log("发送成功,",res) console.log("发送成功,", res)
}).catch(err=>{ }).catch(err => {
console.error("err=",err); console.error("err=", err);
}); });
var json = { var json = {
ins_GroupType: arr ins_GroupType: arr
} }
json = JSON.stringify(json); json = JSON.stringify(json);
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => { ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
this.setBleFormData();
}).catch(ex => { }).catch(ex => {
this.showMsg(ex.msg); this.showMsg(ex.msg);
}); });
@ -672,11 +755,11 @@
// borderColor: "#e034344d", // borderColor: "#e034344d",
// buttonBgColor: "#E03434", // buttonBgColor: "#E03434",
// okCallback: () => { // okCallback: () => {
clearInterval(interval); clearInterval(interval);
this.sosSetting({ this.sosSetting({
val: val val: val
}); });
// }, // },
// buttonText: "解除", // buttonText: "解除",
// showCancel: true, // showCancel: true,
@ -715,21 +798,21 @@
} }
groupSet(); groupSet();
}, },
SOSEvt(){ SOSEvt() {
if (this.formData.sta_SOSType == 'sos') { if (this.formData.sta_SOSType == 'sos') {
this.formData.sta_ArrowType='arrow_off'; this.formData.sta_ArrowType = 'arrow_off';
this.formData.warnTime = 0; this.formData.warnTime = 0;
clearInterval(interval); clearInterval(interval);
interval = setInterval(() => { interval = setInterval(() => {
this.formData.warnTime += 1; this.formData.warnTime += 1;
}, 1000) }, 1000)
}else{ } else {
clearInterval(interval); clearInterval(interval);
interval=null; interval = null;
this.formData.warnTime = 0; this.formData.warnTime = 0;
} }
}, },
sosSetting(item, index) { sosSetting(item, index) {
let f = this.getDevice(); let f = this.getDevice();
@ -750,7 +833,7 @@
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => { ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
this.formData.sta_GroupType = -1; this.formData.sta_GroupType = -1;
this.formData.sta_SOSType = json.ins_SOSType this.formData.sta_SOSType = json.ins_SOSType
these.SOSEvt(); these.SOSEvt();
}) })
@ -759,9 +842,9 @@
}); });
} }
let confirmTask=()=>{ let confirmTask = () => {
this.showPop({ this.showPop({
message: '确定' + (this.formData.sta_SOSType === 'sos' ? '关闭' : '开启') + '声光报警模式?', message: '确定' + (this.formData.sta_SOSType === 'sos' ? '关闭' : '开启') + '声光报警模式?',
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png", iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
@ -777,14 +860,14 @@
confirmTask(); confirmTask();
} else if (item.val === 'sos_off') { } else if (item.val === 'sos_off') {
if(this.formData.sta_SOSType === 'sos'){ if (this.formData.sta_SOSType === 'sos') {
confirmTask(); confirmTask();
}else{ } else {
task(); task();
} }
} else { } else {
if (this.formData.sta_SOSType === 'sos') { if (this.formData.sta_SOSType === 'sos') {
@ -922,14 +1005,14 @@
this.formData[key] = data[key]; this.formData[key] = data[key];
} }
}); });
let msg = []; let msg = [];
if (data.sta_SOSType == 'sos') { if (data.sta_SOSType == 'sos') {
msg.push("设备声光报警中"); msg.push("设备声光报警中");
} }
if('sta_SOSType' in data){ if ('sta_SOSType' in data) {
these.SOSEvt(); these.SOSEvt();
} }
if (data.sta_PowerPercent <= 20) { if (data.sta_PowerPercent <= 20) {
@ -1566,7 +1649,7 @@
border-radius: 16rpx; border-radius: 16rpx;
background: rgba(26, 26, 26, 1); background: rgba(26, 26, 26, 1);
width: 100%; width: 100%;
padding: 10rpx 0rpx; padding: 20rpx 0rpx;
} }
.modeSetting { .modeSetting {
@ -1600,7 +1683,22 @@
letter-spacing: 0.14rpx; letter-spacing: 0.14rpx;
} }
.modeSetting .arrow .outCircle .text {
margin-top:0rpx !important;
}
.arrowContent .line {
width:calc(100% - 60rpx);
height: 0rpx;
border-bottom:1px solid #ffffff30;
margin: 30rpx ;
}
.modeSetting .arrow .outCircle { .modeSetting .arrow .outCircle {
width: 120rpx; width: 120rpx;
height: 120rpx; height: 120rpx;
@ -1632,6 +1730,8 @@
align-items: center; align-items: center;
} }
.modeSetting .arrow.active .outCircle { .modeSetting .arrow.active .outCircle {
border: 4rpx solid rgba(174, 214, 0, 1); border: 4rpx solid rgba(174, 214, 0, 1);
padding: 4rpx; padding: 4rpx;
@ -1642,6 +1742,35 @@
border-radius: 50%; border-radius: 50%;
} }
.modeSetting .arrow.redactive .outCircle {
border: 4rpx solid #EC2A2A;
padding: 4rpx;
}
.modeSetting .arrow.redactive .item {
background: #EC2A2A;
border-radius: 50%;
}
.modeSetting .arrow.greenactive .outCircle {
border: 4rpx solid #00BD00;
padding: 4rpx;
}
.modeSetting .arrow.greenactive .item {
background: #00BD00;
border-radius: 50%;
}
.modeSetting .arrow.redactive .item .text,
.modeSetting .arrow.greenactive .item .text{
color:#FFFFFFde !important;
}
.modeSetting .item .img { .modeSetting .item .img {
width: 52rpx; width: 52rpx;

View File

@ -240,10 +240,7 @@
hideLoading, hideLoading,
updateLoading updateLoading
} from '@/utils/loading.js' } from '@/utils/loading.js'
import { import request, { baseURL } from '@/utils/request.js';
request,
baseURL
} from '../../utils/request';
import usrApi from '@/api/670/HBY670.js' import usrApi from '@/api/670/HBY670.js'
const pagePath = "/pages/4877/BJQ4877"; const pagePath = "/pages/4877/BJQ4877";

1968
pages/6107/BJQ6107.vue Normal file

File diff suppressed because it is too large Load Diff

2166
pages/6155/BJQ6155.vue Normal file

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@
<qf-image-cropper :src="src" :showAngle="false" :width="cropWidth" :height="cropHeight" fileType="jpg" <qf-image-cropper :src="src" :showAngle="false" :width="cropWidth" :height="cropHeight" fileType="jpg"
@crop="handleCrop" :gpu="true"> @crop="handleCrop" :areaScale="0.1" :minScale="0.1" :gpu="true">
</qf-image-cropper> </qf-image-cropper>
</view> </view>
</template> </template>

View File

@ -234,10 +234,7 @@
hideLoading, hideLoading,
updateLoading updateLoading
} from '@/utils/loading.js' } from '@/utils/loading.js'
import { import request, { baseURL } from '@/utils/request.js';
request,
baseURL
} from '../../utils/request';
import usrApi from '@/api/670/HBY670.js' import usrApi from '@/api/670/HBY670.js'
const pagePath = "pages/6331/BJQ6331"; const pagePath = "pages/6331/BJQ6331";

View File

@ -56,6 +56,10 @@
</view> </view>
<view class="modeSetting"> <view class="modeSetting">
<view class="item" :class="formData.modeCurr=='smalllow'?'active':''"
@click="MainModeSetting('smalllow','staticBattery')">
<view class="p100 center">前置</view>
</view>
<view class="item" :class="formData.modeCurr=='low'?'active':''" <view class="item" :class="formData.modeCurr=='low'?'active':''"
@click="MainModeSetting('low','staticBattery')"> @click="MainModeSetting('low','staticBattery')">
<view class="p100 center">低档</view> <view class="p100 center">低档</view>
@ -68,10 +72,14 @@
@click="MainModeSetting('hight','staticBattery')"> @click="MainModeSetting('hight','staticBattery')">
<view class="p100 center">高档</view> <view class="p100 center">高档</view>
</view> </view>
<view class="item " :class="formData.modeCurr=='close'?'active':''"
<!-- <view class="item " :class="formData.modeCurr=='close'?'active':''"
@click="MainModeSetting('close','staticBattery')"> @click="MainModeSetting('close','staticBattery')">
<view class="p100 center">关闭</view> <view class="p100 center">关闭</view>
</view> </view> -->
</view> </view>
<view class="lampMode"> <view class="lampMode">
<view class="mode fleft" :class="formData.cMode?'active':''" v-on:click.stop="LampToggle()"> <view class="mode fleft" :class="formData.cMode?'active':''" v-on:click.stop="LampToggle()">
@ -181,10 +189,7 @@
hideLoading, hideLoading,
updateLoading updateLoading
} from '@/utils/loading.js' } from '@/utils/loading.js'
import { import request, { baseURL } from '@/utils/request.js';
request,
baseURL
} from '../../utils/request';
import usrApi from '@/api/670/HBY670.js' import usrApi from '@/api/670/HBY670.js'
const pagePath = "/pages/650/HBY650"; const pagePath = "/pages/650/HBY650";
@ -335,6 +340,7 @@
these.showBleUnConnect(); these.showBleUnConnect();
console.error("111111");
these.getDetail(); these.getDetail();
return; return;
} }
@ -348,13 +354,14 @@
} }
these.formData.blename = f.name ? f.name : "Unname"; these.formData.blename = f.name ? f.name : "Unname";
these.formData.deviceName = device.deviceName; these.formData.deviceName = device.deviceName;
these.formData.bleStatu = false; these.formData.bleStatu = false;
these.formData.deviceId = f.deviceId; these.formData.deviceId = f.deviceId;
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => { ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
these.formData.bleStatu = true; these.formData.bleStatu = true;
}); });
these.setBleFormData(); these.setBleFormData();
console.error("222222");
these.getDetail(); these.getDetail();
@ -566,7 +573,7 @@
getDetail() { getDetail() {
var that = this; var that = this;
usrApi.getDetail(this.device.id).then(res => { usrApi.getDetail(this.device.id).then(res => {
console.log("res=", res); console.log("获取人员信息=", res);
if (res && res.code == 200) { if (res && res.code == 200) {
res = res.data; res = res.data;
let personnelInfo = res.personnelInfo; let personnelInfo = res.personnelInfo;
@ -575,8 +582,24 @@
that.formData.name = personnelInfo.name; that.formData.name = personnelInfo.name;
that.formData.job = personnelInfo.position; that.formData.job = personnelInfo.position;
that.formData.id = personnelInfo.code that.formData.id = personnelInfo.code
return;
} }
} }
let phone = uni.getStorageSync('phone');
if (phone === '17671332251') {
console.log("default=",that.device);
that.formData.company = '湖北消防总队';
that.formData.name = '胡红军';
that.formData.job = '中队长';
let arr=that.device.bluetoothName.split('-');
if(arr.length>1){
that.formData.id =arr[arr.length-1];
}else{
that.formData.id =that.device.bluetoothName;
}
}
}); });
}, },
@ -594,16 +617,19 @@
}, },
MainModeSetting: function(type, byteType) { MainModeSetting: function(type, byteType) {
if (this.formData.modeCurr == type) { if (this.formData.modeCurr == type) {
return; type = 'close';
} }
showLoading(this, { showLoading(this, {
text: "请稍候..." text: "请稍候..."
}); });
let task = () => { let task = () => {
this.formData.modeCurr = type;
let dataValue = 0x00; let dataValue = 0x00;
let btype = 0x00; let btype = 0x00;
switch (type) { switch (type) {
case "smalllow":
dataValue = 0x68;
break;
case "low": //低档 case "low": //低档
dataValue = 0x67; dataValue = 0x67;
break; break;
@ -655,8 +681,7 @@
// 发送数据 // 发送数据
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 10).then(() => { ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 10).then(() => {
this.formData.modeCurr = type;
console.log("发送成功了"); console.log("发送成功了");
}).catch((ex) => { }).catch((ex) => {
@ -1084,10 +1109,12 @@
hideLoading(these); hideLoading(these);
return; return;
} }
console.log("baseURL=", baseURL);
console.log("token", token);
console.log("clientID", clientid);
uni.uploadFile({ uni.uploadFile({
// url: 'http://114.55.111.217/video/upload', // url: 'http://114.55.111.217/video/upload',
url: baseURL + "app/video/upload", url: baseURL + "/app/video/upload",
filePath: videoPath, filePath: videoPath,
name: 'file', name: 'file',
header: { header: {
@ -1115,6 +1142,7 @@
let res = arr[1]; let res = arr[1];
res = JSON.parse(res.data); res = JSON.parse(res.data);
if (res.data) { if (res.data) {
these.videoHexArray = res.data; these.videoHexArray = res.data;
updateLoading(these, { updateLoading(these, {

View File

@ -1,10 +1,21 @@
<template> <template>
<view class="content contentBg"> <view class="content contentBg">
<custom-navbar :title="Status.navbar.title" :showBack="Status.navbar.showBack" color="#FFFFFF" <!-- <custom-navbar :title="Status.navbar.title" :showBack="Status.navbar.showBack" color="#FFFFFF"
:rightIcons="Status.navbar.icons" @icon-click="handleRightClick"></custom-navbar> :rightIcons="Status.navbar.icons" @icon-click="handleRightClick" backgroundColor="#121212"></custom-navbar>
<view> -->
<uni-nav-bar :border="false" @clickLeft="prevPage" fixed="true" statusBar="true"
background-color="#121212" color="#FFFFFF" :title="Status.navbar.title">
<template v-slot:left><view>
<uni-icons type="left" size="24" color="#FFFFFF"></uni-icons>
</view></template>
<block slot="right">
<view class="navbarRight center">
<image @click.stop="handleRightClick(index,item)" v-for="item,index in Status.navbar.icons" class="img" :src="item.src" mode="aspectFit"></image>
</view>
</block>
</uni-nav-bar>
</view>
<view class="eq" :style="{marginTop:Status.navbar.height+'px'}"> <view class="eq" :style="{marginTop:Status.navbar.height+'px'}">
<view class="leftImg" @click.stop="previewImg(device.devicePic?device.devicePic:formData.img)"> <view class="leftImg" @click.stop="previewImg(device.devicePic?device.devicePic:formData.img)">
<image class="img" :src="device.devicePic?device.devicePic:formData.img" mode="aspectFit"></image> <image class="img" :src="device.devicePic?device.devicePic:formData.img" mode="aspectFit"></image>
@ -90,8 +101,7 @@
<view :class="getWarnStyle(5)" class="net netfive"></view> <view :class="getWarnStyle(5)" class="net netfive"></view>
</view> </view>
</view> </view>
<view class="warnnig" :class="formData.qzwarn ?'':'displayNone'" <view class="warnnig" :class="formData.qzwarn ?'':'displayNone'" @click="CloseWarn(true)">
@click="CloseWarn(true)">
<view>设备强制报警中</view> <view>设备强制报警中</view>
<view class="netContent" :class="{'displayNone':!Status.staticWarn.time}"> <view class="netContent" :class="{'displayNone':!Status.staticWarn.time}">
{{Status.staticWarn.time}}s {{Status.staticWarn.time}}s
@ -219,8 +229,8 @@
<view> <view>
<view class="item"> <view class="item">
<input maxlength="16" class="value" style="text-indent: 20rpx;" v-model="formData.msgTxt" placeholder="请输入文字" <input maxlength="16" class="value" style="text-indent: 20rpx;" v-model="formData.msgTxt"
placeholder-class="usrplace" /> placeholder="请输入文字" placeholder-class="usrplace" />
</view> </view>
</view> </view>
@ -294,11 +304,8 @@
hideLoading, hideLoading,
updateLoading updateLoading
} from '@/utils/loading.js' } from '@/utils/loading.js'
import { import request, { baseURL } from '@/utils/request.js';
request, import lnglatConvert from '@/utils/wgs84_to_gcj02.js';
baseURL
} from '../../utils/request';
import lnglatConvert from '@/utils/wgs84_to_gcj02.js'
const pagePath = "/pages/670/HBY670"; const pagePath = "/pages/670/HBY670";
var ble = null; var ble = null;
@ -560,6 +567,11 @@
}, },
methods: { methods: {
prevPage() {
uni.navigateBack({
})
},
deviceRecovry(res) { deviceRecovry(res) {
if (this.Status.pageHide) { if (this.Status.pageHide) {
return; return;
@ -679,20 +691,24 @@
}); });
}, },
gotoMap() { gotoMap() {
let lnglat = lnglatConvert.wgs84_to_gcj02(this.formData.Lon, this.formData.Lat); let promise = lnglatConvert.wgs84_to_gcj02(this.formData.Lon, this.formData.Lat);
this.detailData.longitude = lnglat[0]; promise.then(lnglat => {
this.detailData.latitude = lnglat[1];
uni.navigateTo({ this.detailData.longitude = lnglat[0];
url: '/pages/common/map/index', this.detailData.latitude = lnglat[1];
events: { uni.navigateTo({
ack: function(data) {} url: '/pages/common/map/index',
}, events: {
success: (res) => { ack: function(data) {}
res.eventChannel.emit('Map', { },
data: this.detailData success: (res) => {
}); res.eventChannel.emit('Map', {
} data: this.detailData
}) });
}
})
});
}, },
getDetail() { getDetail() {
var that = this; var that = this;
@ -799,7 +815,7 @@
return className; return className;
}, },
handleRightClick: function(s, e) { handleRightClick: function(s, e) {
if (s === 0) { if (s === 0) {
console.log("消息"); console.log("消息");
uni.navigateTo({ uni.navigateTo({
@ -832,8 +848,8 @@
}, },
initMQ() { initMQ() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (mqttClient) { if (mqttClient) {
// console.log("无需再次初始化") // console.log("无需再次初始化")
resolve(); resolve();
@ -869,7 +885,8 @@
if (keys.indexOf('sta_BreakNews') > - if (keys.indexOf('sta_BreakNews') > -
1) { //紧急通知 1) { //紧急通知
if (json.sta_BreakNews === if (json.sta_BreakNews ===
'I get it') // && this.Status.msgOkTime && this.Status.msgOkIntval){ 'I get it'
) // && this.Status.msgOkTime && this.Status.msgOkIntval){
{ {
these.showPop({ these.showPop({
showPop: true, showPop: true,
@ -973,9 +990,9 @@
if ("sta_SOSGrade" in json) { if ("sta_SOSGrade" in json) {
let sosText = json.sta_SOSGrade === 2 ? 'rb' : json.sta_SOSGrade === 1 ? "sg" : "close"; let sosText = json.sta_SOSGrade === 2 ? 'rb' : json.sta_SOSGrade === 1 ? "sg" : "close";
receiveData.SOS = sosText; receiveData.SOS = sosText;
receiveData.qzwarn=sosText==='sg'; receiveData.qzwarn = sosText === 'sg';
} }
if ("sta_ShakeBit" in json) { if ("sta_ShakeBit" in json) {
@ -1059,14 +1076,14 @@
if (this.formData.imei) { if (this.formData.imei) {
this.initMQ(); this.initMQ();
} }
let msgs=[]; let msgs = [];
if(this.formData.qzwarn){ if (this.formData.qzwarn) {
msgs.push("设备强制报警中"); msgs.push("设备强制报警中");
} }
if (this.formData.staticWarn) { //有静止报警 if (this.formData.staticWarn) { //有静止报警
msgs.push("设备静止报警中"); msgs.push("设备静止报警中");
} }
if(msgs.length>0){ if (msgs.length > 0) {
this.showPop({ this.showPop({
message: msgs.join(";"), message: msgs.join(";"),
iconUrl: "/static/images/6155/DeviceDetail/warnning.png", iconUrl: "/static/images/6155/DeviceDetail/warnning.png",
@ -1076,7 +1093,7 @@
clickEvt: "staticWarn" clickEvt: "staticWarn"
}); });
} }
this.setBleFormData(); this.setBleFormData();
}, },
@ -3320,4 +3337,13 @@
.net.active { .net.active {
background: #FFFFFF !important; background: #FFFFFF !important;
} }
.navbarRight .img{
width: 35rpx;
height: 35rpx;
margin-right: 20rpx;
}
.uni-navbar--fixed{
top:0rpx;
}
</style> </style>

View File

@ -483,8 +483,9 @@
if (this.Status.pageHide) { if (this.Status.pageHide) {
return; return;
} }
let json = recei.ReceiveData(receive, device, path, recArr); let json = recei.ReceiveData(receive, device, path, recArr);
console.log("收到消息:",receive.hexs);
if (!json) { if (!json) {
return; return;
} }

View File

@ -46,7 +46,7 @@
var these = null; var these = null;
var eventChannel = null; var eventChannel = null;
var ble = null; var ble = null;
var inteval=null;
export default { export default {
data() { data() {
return { return {
@ -118,7 +118,7 @@
onUnload() { onUnload() {
console.log("返回取消订阅"); console.log("返回取消订阅");
clearInterval(inteval);
ble.removeAllCallback(pagePath); ble.removeAllCallback(pagePath);
}, },
onLoad(option) { onLoad(option) {
@ -226,7 +226,7 @@
} }
}) })
let inteval = setInterval(this.initDevice, 10000); inteval = setInterval(this.initDevice, 10000);
} }
@ -291,6 +291,7 @@
} }
} }
}); });
clearInterval(inteval);
} else { } else {
deviceInvalid(); deviceInvalid();
} }

View File

@ -120,6 +120,7 @@
var ble = null; var ble = null;
var these = null; var these = null;
var eventChannel = null; var eventChannel = null;
export default { export default {
data() { data() {
return { return {
@ -334,7 +335,7 @@
//搜索到新设备的回调 (Always active) //搜索到新设备的回调 (Always active)
ble.addDeviceFound((arr) => { ble.addDeviceFound((arr) => {
console.log("--- 收到原始扫描数据 ---", JSON.stringify(arr)); // console.log("--- 收到原始扫描数据 ---", JSON.stringify(arr));
if (these.Status.isPageHidden) { if (these.Status.isPageHidden) {
return; return;
} }
@ -343,7 +344,7 @@
} }
arr = arr.devices; arr = arr.devices;
console.log(`本次扫描批次发现 ${arr.length} 个设备`); // console.log(`本次扫描批次发现 ${arr.length} 个设备`);
for (var i = 0; i < arr.length; i++) { for (var i = 0; i < arr.length; i++) {
let device = arr[i]; let device = arr[i];
@ -351,9 +352,9 @@
let f = these.EquipMents.find((v, index) => { let f = these.EquipMents.find((v, index) => {
if (v.deviceId == device.deviceId) { if (v.deviceId == device.deviceId) {
console.log( // console.log(
`更新设备信号: ${device.name || device.deviceId}, RSSI: ${device.RSSI}` // `更新设备信号: ${device.name || device.deviceId}, RSSI: ${device.RSSI}`
); // );
these.$set(these.EquipMents[index], 'RSSI', device.RSSI); these.$set(these.EquipMents[index], 'RSSI', device.RSSI);
return true; return true;
} }
@ -361,7 +362,7 @@
}); });
if (!f) { if (!f) {
console.log("+++ 发现新设备,准备添加到列表:", JSON.stringify(device)); // console.log("+++ 发现新设备,准备添加到列表:", JSON.stringify(device));
if (these.device && these.device.bluetoothName && device.name) { if (these.device && these.device.bluetoothName && device.name) {
if (these.device.bluetoothName === device.name || (device.name && device.name if (these.device.bluetoothName === device.name || (device.name && device.name
@ -417,27 +418,32 @@
//收到设备的消息回调 //收到设备的消息回调
ble.addReceiveCallback((receivData, f, path, arr) => { ble.addReceiveCallback((receivData, f, path, arr) => {
console.log("000000"); console.log("000000",receivData);
if (these.Status.isPageHidden) { if (these.Status.isPageHidden) {
return; return;
} }
console.log("1111111"); if(receivData.bytes[0]===0xFC && receivData.hexs.length>=7){
if (f.macAddress && these.device) { console.log("22222222");
console.log("222222");
clearInterval(this.Status.intval);
this.Status.intval = null;
this.Status.time = null;
showLoading(these, {
text: '正在验证设备'
});
setTimeout(() => {
these.DeviceVerdict(f.deviceId);
}, 0);
} }
if(receivData.str.indexOf('mac address:')>-1 || receivData.str.indexOf('sta_address')>-1
|| (receivData.bytes[0]===0xFC && receivData.bytes.length>=7))
{
console.log("1111111");
if (f.macAddress && these.device) {
console.log("222222");
clearInterval(this.Status.intval);
this.Status.intval = null;
this.Status.time = null;
showLoading(these, {
text: '正在验证设备'
});
setTimeout(() => {
these.DeviceVerdict(f.deviceId);
}, 0);
}
}
}, pagePath); }, pagePath);
} }
} }
@ -452,7 +458,7 @@
} }
startValidDevice(); startValidDevice();
these.refreshBleList();
}); });
}, },
@ -502,6 +508,8 @@
}); });
}, },
async refreshBleList() { async refreshBleList() {
const systemInfo = uni.getSystemInfoSync(); const systemInfo = uni.getSystemInfoSync();
if (systemInfo.uniPlatform == 'web') { if (systemInfo.uniPlatform == 'web') {
return; return;
@ -520,37 +528,42 @@
return; return;
} }
} }
ble.StopSearch().finally(() => {
let disconnectPromises = []; ble.StopSearch().finally(() => {
if (ble.data && ble.data.LinkedList) {
ble.data.LinkedList.forEach(device => { let disconnectPromises = [];
console.log(`Requesting disconnect for ${device.deviceId}`); if (ble.data && ble.data.LinkedList) {
disconnectPromises.push(ble.disconnectDevice(device.deviceId)); ble.data.LinkedList.forEach(device => {
}); console.log(`Requesting disconnect for ${device.deviceId}`);
} disconnectPromises.push(ble.disconnectDevice(device.deviceId));
});
Promise.allSettled(disconnectPromises).finally(() => { }
these.EquipMents = []; Promise.allSettled(disconnectPromises).finally(() => {
these.PairEquip = [];
these.EquipMents = [];
ble.StartSearch().then(result => { these.PairEquip = [];
console.log("Fresh scan started successfully.");
}).catch(err => { ble.StartSearch().then(result => {
console.error("Failed to start fresh scan:", err); console.log("Fresh scan started successfully.");
if (err.code === 10001) { }).catch(err => {
these.showOpenSetting(); console.error("Failed to start fresh scan:", err);
} else { if (err.code === 10001) {
uni.showModal({ these.showOpenSetting();
title: '提示', } else {
content: '开始搜索失败:' + err.msg uni.showModal({
}); title: '提示',
} content: '开始搜索失败:' + err.msg
});
}
});
}); });
}); });
});
}, },
isItemLink: function(item, index) { isItemLink: function(item, index) {
let src = '/static/images/BLEAdd/noLink.png'; let src = '/static/images/BLEAdd/noLink.png';
@ -599,8 +612,6 @@
if (index > -1) { if (index > -1) {
this.PairEquip.splice(index, 1); this.PairEquip.splice(index, 1);
} }
} }
console.log("f=", f); console.log("f=", f);
@ -708,8 +719,8 @@
}); });
return; return;
} }
console.log("验证设备") // console.log("验证设备")
these.DeviceVerdict(item.deviceId); // these.DeviceVerdict(item.deviceId);
} }
let execLink = () => { let execLink = () => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {

View File

@ -2,9 +2,9 @@
<view class="alltype"> <view class="alltype">
<!-- 车辆列表 --> <!-- 车辆列表 -->
<view class="vehicle-list" v-if="vehicles.length>0"> <view class="vehicle-list" v-if="vehicles.length>0">
<view v-for="(item, index) in vehicles" :key="index"> <view class="typeContent" v-for="(item, index) in vehicles" :key="index">
<view class="vehicle-item" @click="alltypeInfo(item)"> <view class="vehicle-item" @click="alltypeInfo(item)">
<image src="/static/images/common/bip.6.png" mode="" class="IMG"></image> <image :src="item.img" mode="aspectFit" class="IMG"></image>
</view> </view>
<view class="plate-number">{{ item.typeName }}</view> <view class="plate-number">{{ item.typeName }}</view>
</view> </view>
@ -20,30 +20,130 @@
<script> <script>
import { import {
deviceTypeList, deviceTypeList,
typeAll
} from '@/api/common/index.js' } from '@/api/common/index.js'
export default { export default {
data() { data() {
return { return {
vehicles: [], vehicles: [],
typeImgs: [{
"Name": "HBY018A",
"sigName": "018A",
"url": "/static/images/common/018A.png"
},
{
"Name": "HBY102",
"sigName": "102",
"url": "/static/images/common/HBY102.png"
},
{
"Name": "BJQ6075",
"sigName": "6075",
"url": "/static/images/common/BJQ6075.png"
},
{
"Name": "HBY100",
"sigName": "100",
"url": "/static/images/common/HBY100J.png"
},
{
"Name": "BJQ4877",
"sigName": "4877",
"url": "/static/images/common/BJQ4877.png"
},
{
"Name": "BJQ7307",
"sigName": "7307",
"url": "/static/images/common/7307.png"
},
{
"Name": "BJQ7305",
"sigName": "7305",
"url": "/static/images/common/7305.png"
},
{
"Name": "HBY650",
"sigName": "650",
"url": "/static/images/common/HBY650.png"
},
{
"Name": "BJQ6155",
"sigName": "6155",
"url": "/static/images/common/HBY6155.png"
},
{
"Name": "HBY670",
"sigName": "670",
"url": "/static/images/common/HBY670.png"
},
{
"Name": "HBY210",
"sigName": "210",
"url": "/static/images/common/210.png"
},
{
"Name": "BJQ6170",
"sigName": "6170",
"url": "/static/images/common/bip.6.png"
}
]
} }
}, },
methods: { methods: {
getTab() { getTab() {
deviceTypeList({}).then((res) => { let p1 = deviceTypeList({});
let p2 = typeAll();
Promise.allSettled([p1, p2]).then(result => {
let res = result[0].status === 'fulfilled' ? result[0].value : {};
let res1 = result[1].status === 'fulfilled' ? result[1].value : {};
if (res.code == 200) { if (res.code == 200) {
this.vehicles = res.data if (res1.code != 200) {
for (let i = 0; i < res.data.length; i++) {
let f = this.typeImgs.find(v => {
if (res.data[i].typeName.toLowerCase() === v.Name.toLowerCase()) {
return true;
}
return false;
});
if (f) {
res.data[i].img = f.url;
}else{
res.data[i].img = "/static/images/common/bip.6.png";
}
}
} else {
let all = res1.data;
for (let i = 0; i < res.data.length; i++) {
let f = all.find(v => {
if (res.data[i].id === v.deviceTypeId) {
return true;
}
return false;
});
if (f && f.devicePic) {
res.data[i].img = f.devicePic;
}else{
res.data[i].img = "/static/images/common/bip.6.png";
}
}
}
this.vehicles = res.data;
} }
})
});
}, },
alltypeInfo(item) { alltypeInfo(item) {
uni.switchTab({ uni.switchTab({
url: '/pages/common/index/index', url: '/pages/common/index/index',
success: (res) => { success: (res) => {
res.eventChannel.emit('index', { let eventChannel = this.getOpenerEventChannel();
data: item eventChannel.emit('index', item);
});
} }
}) });
} }
}, },
@ -65,8 +165,10 @@
.vehicle-list { .vehicle-list {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
flex-direction: row;
align-content: center;
justify-content: space-around;
align-items: center; align-items: center;
text-align: center;
} }
@ -77,14 +179,17 @@
} }
.vehicle-item { .vehicle-item {
padding: 24rpx 0;
background: rgba(26, 26, 26, 1); background: rgba(26, 26, 26, 1);
border-radius: 16rpx; border-radius: 9px;
width: 156rpx; width: 140rpx;
height: 156rpx; height: 140rpx;
margin-right: 16rpx;
margin-bottom: 16rpx; margin-bottom: 15rpx;
line-height: 156rpx;
display: grid;
align-content: center;
justify-content: center;
} }
@ -96,6 +201,9 @@
.plate-number { .plate-number {
color: rgba(255, 255, 255, 0.87); color: rgba(255, 255, 255, 0.87);
font-size: 27rpx;
font-family: 'PingFang SC';
text-align: center;
} }
.noDATA { .noDATA {
@ -103,4 +211,8 @@
color: rgba(255, 255, 255, 0.87); color: rgba(255, 255, 255, 0.87);
transform: translate(-0%, 100%); transform: translate(-0%, 100%);
} }
.typeContent {
padding-bottom: 15rpx;
}
</style> </style>

View File

@ -24,7 +24,7 @@
<view class="Sendmessage" @click="handleSend">发送信息</view> <view class="Sendmessage" @click="handleSend">发送信息</view>
</view> </view>
<!-- <scroll-view class="device-list" scroll-y @scrolltolower="onScrollToLower" :lower-threshold="100" style="height:80vh;"> --> <!-- <scroll-view class="device-list" scroll-y @scrolltolower="onScrollToLower" :lower-threshold="100" style="height:80vh;"> -->
<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">
@ -146,16 +146,17 @@
} from '@/api/common/index.js' } from '@/api/common/index.js'
import bleTool from '@/utils/BleHelper.js'; import bleTool from '@/utils/BleHelper.js';
import MescrollUni from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-uni.vue' import MescrollUni from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-uni.vue'
import BleReceive from '@/utils/BleReceive';
var pagePath = 'pages/common/index'; var pagePath = 'pages/common/index';
var ble = null; var ble = null;
var timeout = null; var timeout = null;
var recei=null;
export default { export default {
components: { components: {
MescrollUni MescrollUni
}, },
data() { data() {
return { return {
mescroll: null, mescroll: null,
@ -224,7 +225,7 @@
textNoMore: '没有更多数据了' textNoMore: '没有更多数据了'
}, },
mescrollHeight: 0, mescrollHeight: 0,
size: 10, // 每页条数 size: 10, // 每页条数
total: 0, // 总数据量 total: 0, // 总数据量
@ -251,31 +252,31 @@
}, },
// 下拉刷新 // 下拉刷新
downCallback() { downCallback() {
console.log("下拉加载") console.log("下拉加载")
if(this.mescroll){ if (this.mescroll) {
this.mescroll.resetUpScroll(false); this.mescroll.resetUpScroll(false);
this.mescroll.scrollTo(0,0); this.mescroll.scrollTo(0, 0);
} }
this.getData(); this.getData();
}, },
// 上拉加载 // 上拉加载
upCallback() { upCallback() {
console.log("上拉加载") console.log("上拉加载")
this.getData(); this.getData();
}, },
bleStateBreak(){ bleStateBreak() {
console.error("蓝牙适配器不可用"); console.error("蓝牙适配器不可用");
this.updateBleStatu(); this.updateBleStatu();
}, },
bleStateRecovery() { bleStateRecovery() {
console.log("蓝牙适配器恢复可用,重连断开的设备"); console.log("蓝牙适配器恢复可用,重连断开的设备");
ble.linkAllDevices(); ble.linkAllDevices();
}, },
bleBreak(res) { bleBreak(res) {
console.error("蓝牙断开连接", res); console.error("蓝牙断开连接", res);
@ -292,28 +293,39 @@
}, },
updateBleStatu(deviceId) { //更新列表的蓝牙连接状态 updateBleStatu() { //更新列表的蓝牙连接状态,电池 电量
if (ble) { if (ble) {
for (var i = 0; i < this.deviceList.length; i++) { for (var i = 0; i < this.deviceList.length; i++) {
let bleStatu = false;
let f = null;
if (ble.data && ble.data.LinkedList) { if (ble.data && ble.data.LinkedList) {
ble.data.LinkedList.find(v => { f = ble.data.LinkedList.find(v => {
if (deviceId && v.deviceId != deviceId) {
return false;
}
if (v.macAddress && v.device && v.device.id) { if (v.macAddress && v.device && v.device.id) {
if (v.device.id == this.deviceList[i].id && v.Linked) { return v.device.id == this.deviceList[i].id;
bleStatu = true;
return true;
}
} }
return false;
}); });
} }
this.$set(this.deviceList[i], 'bleStatu', bleStatu); if (f) {
this.$set(this.deviceList[i], 'bleStatu', f.Linked);
if (f.formData) {
let battary = 0;
if ('battary' in f.formData) {
battary = f.formData.battary;
} else if ('sta_PowerPercent' in f.formData) {
battary = f.formData.sta_PowerPercent;
} else if ('sta_battery' in f.formData) {
battary = f.formData.sta_battery;
}
this.$set(this.deviceList[i], 'battery', battary);
}
}
@ -329,22 +341,37 @@
// 所有分享,所有类型 // 所有分享,所有类型
handleshareClick(item) { handleshareClick(item) {
this.showshare = false; // 关闭弹窗 this.showshare = false; // 关闭弹窗
var that = this;
switch (item.action) { switch (item.action) {
case 'type': case 'type':
uni.navigateTo({ uni.navigateTo({
url: '/pages/common/allType/index' url: '/pages/common/allType/index',
events: {
index(data) {
if (data && data.id) {
that.tabs.find((v, i) => {
if (v.id === data.id) {
that.switchTab(v, i);
return true;
}
return false;
})
}
}
}
}); });
break; break;
case 'share': case 'share':
uni.navigateTo({ uni.navigateTo({
url: "/pages/common/allShare/index" url: "/pages/common/allShare/index",
}) })
break; break;
} }
}, },
// 点击弹框外的区域关闭 // 点击弹框外的区域关闭
closePopup(type) { closePopup(type) {
if (type === 'delete') { if (type === 'delete') {
this.deleteShow = false; this.deleteShow = false;
uni.showTabBar(); // 显示TabBar uni.showTabBar(); // 显示TabBar
@ -378,7 +405,7 @@
this.deviceList = []; this.deviceList = [];
this.activeTab = index; this.activeTab = index;
this.activeTabInfo = tab this.activeTabInfo = tab
this.downCallback(); this.downCallback();
@ -393,10 +420,10 @@
pageNum: this.mescroll.num, pageNum: this.mescroll.num,
pageSize: this.size, pageSize: this.size,
deviceType: this.activeTabInfo ? this.activeTabInfo.id : '', // 使用传入的设备类型 deviceType: this.activeTabInfo ? this.activeTabInfo.id : '', // 使用传入的设备类型
isAsc:'desc', isAsc: 'desc',
orderByColumn:'bindingTime' orderByColumn: 'bindingTime'
} }
if(!data.pageNum){ if (!data.pageNum) {
this.mescroll.endSuccess(0, false); this.mescroll.endSuccess(0, false);
resolve(); resolve();
return; return;
@ -410,33 +437,34 @@
})); }));
// 如果是第一页或切换分类,替换数据 // 如果是第一页或切换分类,替换数据
if(data.pageNum === 1){ if (data.pageNum === 1) {
this.deviceList =newDevices this.deviceList = newDevices
}else{ } else {
//防止后端返回的数据包含已有数据 //防止后端返回的数据包含已有数据
for (var i = 0; i < newDevices.length; i++) { for (var i = 0; i < newDevices.length; i++) {
let device=newDevices[i]; let device = newDevices[i];
let f=this.deviceList.find(v=>{ let f = this.deviceList.find(v => {
return v.id===device.id; return v.id === device.id;
}); });
if(!f){ if (!f) {
this.deviceList.push(device); this.deviceList.push(device);
} }
} }
} }
this.updateBleStatu(); this.updateBleStatu();
this.total = res.total; this.total = res.total;
// 判断是否加载完成 // 判断是否加载完成
let hasNext = true; let hasNext = true;
if (res.rows.length < this.size || this.deviceList.length >= this.total) { if (res.rows.length < this.size || this.deviceList.length >= this
.total) {
hasNext = false; hasNext = false;
} else { } else {
hasNext = true; hasNext = true;
} }
this.mescroll.endSuccess(res.rows.length, hasNext); this.mescroll.endSuccess(res.rows.length, hasNext);
}else{ } else {
this.mescroll.endSuccess(0, false); this.mescroll.endSuccess(0, false);
} }
}).finally(() => { }).finally(() => {
@ -448,16 +476,16 @@
//防止下拉刷新的同时会调用一次上拉加载的问题 //防止下拉刷新的同时会调用一次上拉加载的问题
timeout = setTimeout(task, 50); timeout = setTimeout(task, 50);
}, },
// 添加扫一扫图标 // 添加扫一扫图标
scan() { scan() {
this.showTooltip = !this.showTooltip; this.showTooltip = !this.showTooltip;
}, },
closePopMenu(){ closePopMenu() {
setTimeout(()=>{ setTimeout(() => {
this.showTooltip = false; this.showTooltip = false;
this.showshare = false; this.showshare = false;
},100); }, 100);
}, },
closePopupTooltip() { closePopupTooltip() {
this.showTooltip = !this.showTooltip this.showTooltip = !this.showTooltip
@ -470,6 +498,9 @@
case 'scan': case 'scan':
// 扫一扫 // 扫一扫
uni.scanCode({ uni.scanCode({
autoDecodeCharset:true,
autoZoom:true,
barCodeInput:true,
success: (res) => { success: (res) => {
console.log('条码内容:', res); console.log('条码内容:', res);
// 清除之前的数据 // 清除之前的数据
@ -484,14 +515,19 @@
if ('imei' in json) { if ('imei' in json) {
url = url =
`/pages/common/qrcode/qrcode?deviceId=${encodeURIComponent(json.imei)}`; `/pages/common/qrcode/qrcode?deviceId=${encodeURIComponent(json.imei)}`;
} else if ('blue' in json) { } else if ('blue' in json || 'ble' in json) {
if (!json.blue.includes(':')) { if(json.ble){
json.blue = json.blue.replace( json.blue=json.ble;
/(.{2})/g, '$1:')
.slice(0, -1)
} }
url = if(json.blue){
`/pages/common/addBLE/LinkBle?mac=${encodeURIComponent(json.blue)}`; if (!json.blue.includes(':')) {
json.blue = json.blue.replace(
/(.{2})/g, '$1:')
.slice(0, -1)
}
}
url =`/pages/common/addBLE/LinkBle?mac=${encodeURIComponent(json.blue)}`;
} }
} catch (ex) { } catch (ex) {
@ -519,7 +555,9 @@
}, },
// 右滑点击事件处理 // 右滑点击事件处理
handleSwipeClick(e, item, index) { handleSwipeClick(e, item, index) {
const {content} = e const {
content
} = e
setTimeout(() => { setTimeout(() => {
console.log(item, 'eeeee'); console.log(item, 'eeeee');
switch (e.content.text) { switch (e.content.text) {
@ -554,10 +592,10 @@
icon: 'none', icon: 'none',
duration: 1000 duration: 1000
}); });
this.deviceList.find((v,i)=>{ this.deviceList.find((v, i) => {
if(v.id==data.id){ if (v.id == data.id) {
this.deviceList.splice(i,1); this.deviceList.splice(i, 1);
return true; return true;
} }
return false; return false;
@ -595,10 +633,10 @@
icon: 'none', icon: 'none',
duration: 1000 duration: 1000
}); });
this.deviceList.find((v,i)=>{ this.deviceList.find((v, i) => {
if(v.id===data.id){ if (v.id === data.id) {
this.$set(this.deviceList[i],'deviceName',data.deviceName); this.$set(this.deviceList[i], 'deviceName', data.deviceName);
return true; return true;
} }
return false; return false;
@ -671,7 +709,7 @@
let url = item.detailPageUrl; let url = item.detailPageUrl;
// console.log("url=",url); // console.log("url=",url);
// if(!url){ // if(!url){
//url="/pages/670/HBY670" // url="/pages/6075/BJQ6075"
// } // }
uni.navigateTo({ uni.navigateTo({
url: url, url: url,
@ -691,7 +729,7 @@
} }
}) })
}, },
updateDeviceStatus(data) { updateDeviceStatus(data) {
this.deviceList = this.deviceList this.deviceList = this.deviceList
.map(item => { .map(item => {
@ -717,7 +755,16 @@
.filter(Boolean); .filter(Boolean);
}, },
}, },
onShow() {
if (ble) {
//因为vue视图只能后退不能隐藏后再显示
//所以回到首页后将其他所有页面的订阅都删除
ble.removeAllCallbackByRetain(pagePath);
}
},
onLoad() { onLoad() {
console.error("首页加载"); console.error("首页加载");
this.getTab() this.getTab()
this.downCallback(); this.downCallback();
@ -732,7 +779,7 @@
this.downCallback(); this.downCallback();
}); });
ble = bleTool.getBleTool(); ble = bleTool.getBleTool();
recei = BleReceive.getBleReceive();
//蓝牙连接成功的回调 //蓝牙连接成功的回调
ble.addRecoveryCallback((res) => { ble.addRecoveryCallback((res) => {
console.log("蓝牙连接成功的回调"); console.log("蓝牙连接成功的回调");
@ -750,12 +797,19 @@
console.log("蓝牙适配器恢复可用的回调"); console.log("蓝牙适配器恢复可用的回调");
this.bleStateRecovery(); this.bleStateRecovery();
}, pagePath); }, pagePath);
//蓝牙适配器不可用的回调 //蓝牙适配器不可用的回调
ble.addStateBreakCallback(res=>{ ble.addStateBreakCallback(res => {
console.error("蓝牙适配器不可用的回调"); console.error("蓝牙适配器不可用的回调");
this.bleStateBreak(); this.bleStateBreak();
},pagePath); }, pagePath);
//接收到消息的回调
ble.addReceiveCallback((receive, device, path, recArr) => {
console.error("首页收到消息了");
recei.ReceiveData(receive, device, path, recArr);
this.updateBleStatu();
}, pagePath);
this.getSystemInfoSyncH(); this.getSystemInfoSyncH();
}, },
@ -765,8 +819,9 @@
uni.$off('refreshDeviceList'); uni.$off('refreshDeviceList');
}, },
onUnload() { onUnload() {
console.log("onUnload...");
uni.$off('deviceStatusUpdate'); uni.$off('deviceStatusUpdate');
ble && ble.removeAllCallback(); ble && ble.removeAllCallback(pagePath);
} }
} }
@ -1139,13 +1194,15 @@
background-color: rgba(35, 35, 35, 0.87); background-color: rgba(35, 35, 35, 0.87);
color: rgba(255, 255, 255, 1); color: rgba(255, 255, 255, 1);
} }
.mask{
.mask {
position: fixed; position: fixed;
width: 100%; width: 100%;
height: 100%; height: 100%;
z-index: 9998; z-index: 9998;
background-color: #00000000; background-color: #00000000;
} }
/* 提示框样式 */ /* 提示框样式 */
.tooltip-box { .tooltip-box {
position: fixed; position: fixed;

View File

@ -65,7 +65,7 @@
<script> <script>
import { import {
deviceShareId,
deviceShareCode, deviceShareCode,
deviceShareAdd deviceShareAdd
} from '@/api/6170/share.js' } from '@/api/6170/share.js'

BIN
static/images/6107/fan.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1003 B

BIN
static/images/6107/ju.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1003 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 522 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1021 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

File diff suppressed because it is too large Load Diff

View File

@ -1,42 +0,0 @@
// store/index.js
import Vue from 'vue';
import Vuex from 'vuex';
Vue.use(Vuex);
const store = new Vuex.Store({
state: {
userInfo: null, // 用户信息
theme: 'light', // 主题
token: '', // 登录凭证
},
mutations: {
setUserInfo(state, userInfo) {
state.userInfo = userInfo;
},
setTheme(state, theme) {
state.theme = theme;
},
setToken(state, token) {
state.token = token;
}
},
actions: {
updateUserInfo({ commit }, userInfo) {
commit('setUserInfo', userInfo);
},
updateTheme({ commit }, theme) {
commit('setTheme', theme);
},
updateToken({ commit }, token) {
commit('setToken', token);
}
},
getters: {
getUserInfo: (state) => state.userInfo,
getTheme: (state) => state.theme,
getToken: (state) => state.token
}
});
export default store;

View File

@ -1,5 +1,7 @@
## 2.0.102024-06-07 ## 2.0.122025-08-26
- 优化 uni-app x 中,size 属性的类型 - 优化 uni-app x size 类型问题
## 2.0.112025-08-18
- 修复 图标点击事件返回
## 2.0.92024-01-12 ## 2.0.92024-01-12
fix: 修复图标大小默认值错误的问题 fix: 修复图标大小默认值错误的问题
## 2.0.82023-12-14 ## 2.0.82023-12-14

View File

@ -1,91 +1,91 @@
<template> <template>
<text class="uni-icons" :style="styleObj"> <text class="uni-icons" :style="styleObj">
<slot>{{unicode}}</slot> <slot>{{unicode}}</slot>
</text> </text>
</template> </template>
<script> <script>
import { fontData, IconsDataItem } from './uniicons_file' import { fontData, IconsDataItem } from './uniicons_file'
/** /**
* Icons 图标 * Icons 图标
* @description 用于展示 icon 图标 * @description 用于展示 icon 图标
* @tutorial https://ext.dcloud.net.cn/plugin?id=28 * @tutorial https://ext.dcloud.net.cn/plugin?id=28
* @property {Number,String} size 图标大小 * @property {Number} size 图标大小
* @property {String} type 图标图案,参考示例 * @property {String} type 图标图案,参考示例
* @property {String} color 图标颜色 * @property {String} color 图标颜色
* @property {String} customPrefix 自定义图标 * @property {String} customPrefix 自定义图标
* @event {Function} click 点击 Icon 触发事件 * @event {Function} click 点击 Icon 触发事件
*/ */
export default { export default {
name: "uni-icons", name: "uni-icons",
props: { props: {
type: { type: {
type: String, type: String,
default: '' default: ''
}, },
color: { color: {
type: String, type: String,
default: '#333333' default: '#333333'
}, },
size: { size: {
type: [Number, String], type: [Number, String],
default: 16 default: 16
}, },
fontFamily: { fontFamily: {
type: String, type: String,
default: '' default: ''
} }
}, },
data() { data() {
return {}; return {};
}, },
computed: { computed: {
unicode() : string { unicode() : string {
let codes = fontData.find((item : IconsDataItem) : boolean => { return item.font_class == this.type }) let codes = fontData.find((item : IconsDataItem) : boolean => { return item.font_class == this.type })
if (codes !== null) { if (codes !== null) {
return codes.unicode return codes.unicode
} }
return '' return ''
}, },
iconSize() : string { iconSize() : string {
const size = this.size const size = this.size
if (typeof size == 'string') { if (typeof size == 'string') {
const reg = /^[0-9]*$/g const reg = /^[0-9]*$/g
return reg.test(size as string) ? '' + size + 'px' : '' + size; return reg.test(size as string) ? '' + size + 'px' : '' + size;
// return '' + this.size // return '' + this.size
} }
return this.getFontSize(size as number) return this.getFontSize(size as number)
}, },
styleObj() : UTSJSONObject { styleObj() : UTSJSONObject {
if (this.fontFamily !== '') { if (this.fontFamily !== '') {
return { color: this.color, fontSize: this.iconSize, fontFamily: this.fontFamily } return { color: this.color, fontSize: this.iconSize, fontFamily: this.fontFamily }
} }
return { color: this.color, fontSize: this.iconSize } return { color: this.color, fontSize: this.iconSize }
} }
}, },
created() { }, created() { },
methods: { methods: {
/** /**
* 字体大小 * 字体大小
*/ */
getFontSize(size : number) : string { getFontSize(size : number) : string {
return size + 'px'; return size + 'px';
}, },
}, },
} }
</script> </script>
<style scoped> <style scoped>
@font-face { @font-face {
font-family: UniIconsFontFamily; font-family: UniIconsFontFamily;
src: url('./uniicons.ttf'); src: url('./uniicons.ttf');
} }
.uni-icons { .uni-icons {
font-family: UniIconsFontFamily; font-family: UniIconsFontFamily;
font-size: 18px; font-size: 18px;
font-style: normal; font-style: normal;
color: #333; color: #333;
} }
</style> </style>

View File

@ -85,8 +85,8 @@
} }
}, },
methods: { methods: {
_onClick() { _onClick(e) {
this.$emit('click') this.$emit('click', e)
} }
} }
} }
@ -107,4 +107,4 @@
text-decoration: none; text-decoration: none;
text-align: center; text-align: center;
} }
</style> </style>

View File

@ -1,7 +1,7 @@
{ {
"id": "uni-icons", "id": "uni-icons",
"displayName": "uni-icons 图标", "displayName": "uni-icons 图标",
"version": "2.0.10", "version": "2.0.12",
"description": "图标组件,用于展示移动端常见的图标,可自定义颜色、大小。", "description": "图标组件,用于展示移动端常见的图标,可自定义颜色、大小。",
"keywords": [ "keywords": [
"uni-ui", "uni-ui",
@ -11,12 +11,14 @@
], ],
"repository": "https://github.com/dcloudio/uni-ui", "repository": "https://github.com/dcloudio/uni-ui",
"engines": { "engines": {
"HBuilderX": "^3.2.14" "HBuilderX": "^3.2.14",
"uni-app": "^4.08",
"uni-app-x": "^4.61"
}, },
"directories": { "directories": {
"example": "../../temps/example_temps" "example": "../../temps/example_temps"
}, },
"dcloudext": { "dcloudext": {
"sale": { "sale": {
"regular": { "regular": {
"price": "0.00" "price": "0.00"
@ -34,56 +36,76 @@
"permissions": "无" "permissions": "无"
}, },
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui", "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
"type": "component-vue" "type": "component-vue",
"darkmode": "x",
"i18n": "x",
"widescreen": "x"
}, },
"uni_modules": { "uni_modules": {
"dependencies": ["uni-scss"], "dependencies": [
"uni-scss"
],
"encrypt": [], "encrypt": [],
"platforms": { "platforms": {
"cloud": { "cloud": {
"tcb": "y", "tcb": "x",
"aliyun": "y", "aliyun": "x",
"alipay": "n" "alipay": "x"
}, },
"client": { "client": {
"App": { "uni-app": {
"app-vue": "y", "vue": {
"app-nvue": "y", "vue2": "",
"app-uvue": "y" "vue3": ""
},
"web": {
"safari": "√",
"chrome": "√"
},
"app": {
"vue": "√",
"nvue": "-",
"android": {
"extVersion": "",
"minVersion": "29"
},
"ios": "√",
"harmony": "√"
},
"mp": {
"weixin": "√",
"alipay": "√",
"toutiao": "√",
"baidu": "√",
"kuaishou": "-",
"jd": "-",
"harmony": "-",
"qq": "√",
"lark": "-"
},
"quickapp": {
"huawei": "√",
"union": "√"
}
}, },
"H5-mobile": { "uni-app-x": {
"Safari": "y", "web": {
"Android Browser": "y", "safari": "",
"微信浏览器(Android)": "y", "chrome": ""
"QQ浏览器(Android)": "y" },
}, "app": {
"H5-pc": { "android": {
"Chrome": "y", "extVersion": "",
"IE": "y", "minVersion": "29"
"Edge": "y", },
"Firefox": "y", "ios": "",
"Safari": "y" "harmony": ""
}, },
"小程序": { "mp": {
"微信": "y", "weixin": ""
"阿里": "y", }
"百度": "y",
"字节跳动": "y",
"QQ": "y",
"钉钉": "y",
"快手": "y",
"飞书": "y",
"京东": "y"
},
"快应用": {
"华为": "y",
"联盟": "y"
},
"Vue": {
"vue2": "y",
"vue3": "y"
} }
} }
} }
} }
} }

View File

@ -0,0 +1,60 @@
## 1.3.172025-09-03
- 修复 内部样式问题
## 1.3.162025-08-18
- 修复 微信小程序 fixed 下避让胶囊优化标题居中默认showMenuButtonWidth 不开启下,右侧插槽会被 胶囊覆盖
- 新增 showMenuButtonWidth 右侧是否避让胶囊,即 显示区域为胶囊左侧,默认不开启,开启后会导致标题不在页面水平居中
## 1.3.152025-06-24
- 适配微信小程序固定导航栏时,右侧插槽避让胶囊按钮
## 1.3.142024-10-15
- 修复 微信小程序中的getSystemInfo警告
## 1.3.112023-03-29
- 修复 自定义状态栏高度闪动BUG
## 1.3.102023-03-29
- 修复 暗黑模式下边线颜色错误的bug
## 1.3.92022-10-13
- 修复 条件编译错误的bug
## 1.3.82022-10-12
- 修复 nvue 环境 fixed 为 true 的情况下,无法置顶的 bug
## 1.3.72022-08-11
- 修复 nvue 环境下 fixed 为 true 的情况下,无法置顶的 bug
## 1.3.62022-06-30
- 修复 组件示例中插槽用法无法显示内容的bug
## 1.3.52022-05-24
- 新增 stat 属性 可开启统计title 上报 仅使用了title 属性且项目开启了uni统计生效
## 1.3.42022-01-24
- 更新 组件示例
## 1.3.32022-01-24
- 新增 left-width/right-width属性 ,可修改左右两侧的宽度
## 1.3.22022-01-18
- 修复 在vue下标题不垂直居中的bug
## 1.3.12022-01-18
- 修复 height 属性类型错误
## 1.3.02022-01-18
- 新增 height 属性,可修改组件高度
- 新增 dark 属性可可开启暗黑模式
- 优化 标题字数过多显示省略号
- 优化 插槽,插入内容可完全覆盖
## 1.2.12022-01-10
- 修复 color 属性不生效的bug
## 1.2.02021-11-19
- 优化 组件UI并提供设计资源详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource)
- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-nav-bar](https://uniapp.dcloud.io/component/uniui/uni-nav-bar)
## 1.1.02021-07-30
- 组件兼容 vue3如何创建vue3项目详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
## 1.0.112021-05-12
- 新增 组件示例地址
## 1.0.102021-04-30
- 修复 在nvue下fixed为true宽度不能撑满的Bug
## 1.0.92021-04-21
- 优化 添加依赖 uni-icons, 导入后自动下载依赖
## 1.0.82021-04-14
- uni-ui 修复 uni-nav-bar 当 fixed 属性为 true 时铺不满屏幕的 bug
## 1.0.72021-02-25
- 修复 easycom 下,找不到 uni-status-bar 的bug
## 1.0.62021-02-05
- 优化 组件引用关系通过uni_modules引用组件
## 1.0.52021-02-05
- 调整为uni_modules目录规范

View File

@ -0,0 +1,383 @@
<template>
<view class="uni-navbar" :class="{'uni-dark':dark, 'uni-nvue-fixed': fixed}">
<view class="uni-navbar__content" :class="{ 'uni-navbar--fixed': fixed, 'uni-navbar--shadow': shadow, 'uni-navbar--border': border }" :style="{ 'background-color': themeBgColor }">
<status-bar v-if="statusBar" />
<view :style="{ color: themeColor,backgroundColor: themeBgColor ,height:navbarHeight,width:showMenuButtonWidth?navWidth+'px':'100%'}" class="uni-navbar__header">
<view @tap="onClickLeft" class="uni-navbar__header-btns uni-navbar__header-btns-left" :style="{width:leftIconWidth}">
<slot name="left">
<view class="uni-navbar__content_view" v-if="leftIcon.length > 0">
<uni-icons :color="themeColor" :type="leftIcon" size="20" />
</view>
<view :class="{ 'uni-navbar-btn-icon-left': !leftIcon.length > 0 }" class="uni-navbar-btn-text" v-if="leftText.length">
<text :style="{ color: themeColor, fontSize: '12px' }">{{ leftText }}</text>
</view>
</slot>
</view>
<view class="uni-navbar__header-container " @tap="onClickTitle">
<slot>
<view class="uni-navbar__header-container-inner" v-if="title.length>0">
<text class="uni-nav-bar-text uni-ellipsis-1" :style="{color: themeColor }">{{ title }}</text>
</view>
</slot>
</view>
<view @click="onClickRight" class="uni-navbar__header-btns uni-navbar__header-btns-right" :style="{width:rightIconWidth}">
<slot name="right">
<view v-if="rightIcon.length">
<uni-icons :color="themeColor" :type="rightIcon" size="22" />
</view>
<view class="uni-navbar-btn-text" v-if="rightText.length && !rightIcon.length">
<text class="uni-nav-bar-right-text" :style="{ color: themeColor}">{{ rightText }}</text>
</view>
</slot>
</view>
</view>
</view>
<view class="uni-navbar__placeholder" v-if="fixed">
<status-bar v-if="statusBar" />
<view class="uni-navbar__placeholder-view" :style="{ height:navbarHeight}" />
</view>
</view>
</template>
<script>
import statusBar from "./uni-status-bar.vue";
const getVal = (val) => typeof val === 'number' ? val + 'px' : val;
/**
*
*
* NavBar 自定义导航栏
* @description 导航栏组件,主要用于头部导航
* @tutorial https://ext.dcloud.net.cn/plugin?id=52
* @property {Boolean} dark 开启黑暗模式
* @property {String} title 标题文字
* @property {String} leftText 左侧按钮文本
* @property {String} rightText 右侧按钮文本
* @property {String} leftIcon 左侧按钮图标(图标类型参考 [Icon 图标](http://ext.dcloud.net.cn/plugin?id=28) type 属性)
* @property {String} rightIcon 右侧按钮图标(图标类型参考 [Icon 图标](http://ext.dcloud.net.cn/plugin?id=28) type 属性)
* @property {String} color 图标和文字颜色
* @property {String} backgroundColor 导航栏背景颜色
* @property {Boolean} fixed = [true|false] 是否固定顶部
* @property {Boolean} statusBar = [true|false] 是否包含状态栏
* @property {Boolean} shadow = [true|false] 导航栏下是否有阴影
* @property {Boolean} stat 是否开启统计标题上报
* @event {Function} clickLeft 左侧按钮点击时触发
* @event {Function} clickRight 右侧按钮点击时触发
* @event {Function} clickTitle 中间标题点击时触发
*/
export default {
name: "UniNavBar",
components: {
statusBar
},
emits: ['clickLeft', 'clickRight', 'clickTitle'],
props: {
dark: {
type: Boolean,
default: true
},
title: {
type: String,
default: ""
},
leftText: {
type: String,
default: ""
},
rightText: {
type: String,
default: ""
},
leftIcon: {
type: String,
default: ""
},
rightIcon: {
type: String,
default: ""
},
fixed: {
type: [Boolean, String],
default: true
},
color: {
type: String,
default: ""
},
backgroundColor: {
type: String,
default: ""
},
statusBar: {
type: [Boolean, String],
default: true
},
shadow: {
type: [Boolean, String],
default: false
},
border: {
type: [Boolean, String],
default: false
},
height: {
type: [Number, String],
default: 44
},
leftWidth: {
type: [Number, String],
default: 90
},
rightWidth: {
type: [Number, String],
default: 90
},
showMenuButtonWidth: {
type: Boolean,
default: false
},
stat: {
type: [Boolean, String],
default: ''
}
},
data() {
return {
navWidth: 'auto'
}
},
computed: {
themeBgColor() {
if (this.dark) {
// 默认值
if (this.backgroundColor) {
return this.backgroundColor
} else {
return this.dark ? '#121212' : '#FFF'
}
}
return this.backgroundColor || '#FFF'
},
themeColor() {
if (this.dark) {
// 默认值
if (this.color) {
return this.color
} else {
return this.dark ? '#fff' : '#333'
}
}
return this.color || '#333'
},
navbarHeight() {
// #ifdef MP-WEIXIN
if (this.fixed && this.height === 0) {
const menuBtnInfo = uni.getMenuButtonBoundingClientRect()
const winInfo = uni.getWindowInfo()
const statusHeight = winInfo.statusBarHeight
const spaceHeight = menuBtnInfo.top - statusHeight
return getVal(menuBtnInfo.height + spaceHeight * 2)
}
// #endif
// #ifndef MP-WEIXIN
if (this.fixed && this.height === 0) {
return getVal(44)
}
// #endif
return getVal(this.height)
},
leftIconWidth() {
return getVal(this.leftWidth)
},
rightIconWidth() {
return getVal(this.rightWidth)
}
},
created() {
// #ifdef MP-WEIXIN
if (this.fixed) {
const menuBtnInfo = uni.getMenuButtonBoundingClientRect()
this.navWidth = menuBtnInfo.left
}
// #endif
},
mounted() {
if (uni.report && this.stat && this.title !== '') {
uni.report('title', this.title)
}
},
methods: {
onClickLeft() {
this.$emit("clickLeft");
},
onClickRight() {
this.$emit("clickRight");
},
onClickTitle() {
this.$emit("clickTitle");
}
}
};
</script>
<style lang="scss" scoped>
$nav-height: 44px;
.uni-nvue-fixed {
/* #ifdef APP-NVUE */
position: sticky;
/* #endif */
}
.uni-navbar {
// box-sizing: border-box;
}
.uni-nav-bar-text {
/* #ifdef APP-PLUS */
font-size: 34rpx;
/* #endif */
/* #ifndef APP-PLUS */
font-size: 14px;
/* #endif */
}
.uni-nav-bar-right-text {
font-size: 12px;
}
.uni-navbar__content {
position: relative;
// background-color: #fff;
// box-sizing: border-box;
background-color: transparent;
}
.uni-navbar__content_view {
// box-sizing: border-box;
}
.uni-navbar-btn-text {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: column;
justify-content: flex-start;
align-items: center;
line-height: 12px;
}
.uni-navbar__header {
padding: 0 10px;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
height: $nav-height;
font-size: 12px;
box-sizing: border-box;
}
.uni-navbar__header-btns {
/* #ifndef APP-NVUE */
overflow: hidden;
display: flex;
/* #endif */
flex-wrap: nowrap;
flex-direction: row;
width: 120rpx;
// padding: 0 6px;
justify-content: center;
align-items: center;
/* #ifdef H5 */
cursor: pointer;
/* #endif */
}
.uni-navbar__header-btns-left {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
width: 120rpx;
justify-content: flex-start;
align-items: center;
}
.uni-navbar__header-btns-right {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
// width: 150rpx;
// padding-right: 30rpx;
justify-content: flex-end;
align-items: center;
}
.uni-navbar__header-container {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex: 1;
padding: 0 10px;
overflow: hidden;
}
.uni-navbar__header-container-inner {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex: 1;
flex-direction: row;
align-items: center;
justify-content: center;
font-size: 12px;
overflow: hidden;
// box-sizing: border-box;
}
.uni-navbar__placeholder-view {
height: $nav-height;
}
.uni-navbar--fixed {
position: fixed;
z-index: 998;
/* #ifdef H5 */
left: var(--window-left);
right: var(--window-right);
/* #endif */
/* #ifndef H5 */
left: 0;
right: 0;
/* #endif */
}
.uni-navbar--shadow {
box-shadow: 0 1px 6px #ccc;
}
.uni-navbar--border {
border-bottom-width: 1rpx;
border-bottom-style: solid;
border-bottom-color: #eee;
}
.uni-ellipsis-1 {
overflow: hidden;
/* #ifndef APP-NVUE */
white-space: nowrap;
text-overflow: ellipsis;
/* #endif */
/* #ifdef APP-NVUE */
lines: 1;
text-overflow: ellipsis;
/* #endif */
}
// 暗主题配置
.uni-dark {}
</style>

View File

@ -0,0 +1,30 @@
<template>
<view :style="{ height: statusBarHeight }" class="uni-status-bar">
<slot />
</view>
</template>
<script>
export default {
name: 'UniStatusBar',
data() {
return {
// #ifdef MP-WEIXIN
statusBarHeight: uni.getWindowInfo().statusBarHeight + 'px',
// #endif
// #ifndef MP-WEIXIN
statusBarHeight: uni.getSystemInfoSync().statusBarHeight + 'px',
// #endif
}
}
}
</script>
<style lang="scss" >
.uni-status-bar {
// width: 750rpx;
height: 20px;
// height: var(--status-bar-height);
}
</style>

View File

@ -0,0 +1,106 @@
{
"id": "uni-nav-bar",
"displayName": "uni-nav-bar 自定义导航栏",
"version": "1.3.17",
"description": "自定义导航栏组件,主要用于头部导航。",
"keywords": [
"uni-ui",
"导航",
"导航栏",
"自定义导航栏"
],
"repository": "https://github.com/dcloudio/uni-ui",
"engines": {
"HBuilderX": "",
"uni-app": "^4.07",
"uni-app-x": ""
},
"directories": {
"example": "../../temps/example_temps"
},
"dcloudext": {
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "无",
"permissions": "无"
},
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
"type": "component-vue",
"darkmode": "x",
"i18n": "x",
"widescreen": "x"
},
"uni_modules": {
"dependencies": [
"uni-scss",
"uni-icons"
],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "x",
"aliyun": "x",
"alipay": "x"
},
"client": {
"uni-app": {
"vue": {
"vue2": "√",
"vue3": "√"
},
"web": {
"safari": "√",
"chrome": "√"
},
"app": {
"vue": "√",
"nvue": "√",
"android": "√",
"ios": "√",
"harmony": "√"
},
"mp": {
"weixin": "√",
"alipay": "√",
"toutiao": "√",
"baidu": "√",
"kuaishou": "-",
"jd": "-",
"harmony": "-",
"qq": "√",
"lark": "-"
},
"quickapp": {
"huawei": "√",
"union": "√"
}
},
"uni-app-x": {
"web": {
"safari": "-",
"chrome": "-"
},
"app": {
"android": "-",
"ios": "-",
"harmony": "-"
},
"mp": {
"weixin": "-"
}
}
}
}
}
}

View File

@ -0,0 +1,15 @@
## NavBar 导航栏
> **组件名uni-nav-bar**
> 代码块: `uNavBar`
导航栏组件,主要用于头部导航。
### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-nav-bar)
#### 如使用过程中有任何问题或者您对uni-ui有一些好的建议欢迎加入 uni-ui 交流群871950839

View File

@ -56,7 +56,7 @@ class BleHelper {
isOpenBlue: false, //蓝牙模块是否开启 isOpenBlue: false, //蓝牙模块是否开启
available: false, //蓝牙状态是否可用 available: false, //蓝牙状态是否可用
discovering: false, //蓝牙是否正在搜索 discovering: false, //蓝牙是否正在搜索
searchList: [], //已搜索到的设备列表,
isSubscribe: false, //是否开启了订阅 isSubscribe: false, //是否开启了订阅
LinkedList: linkedDevices, //已连接的设备列表 LinkedList: linkedDevices, //已连接的设备列表
platform: systemInfo.uniPlatform, platform: systemInfo.uniPlatform,
@ -71,9 +71,10 @@ class BleHelper {
stateRecoveryCallback: [], //蓝牙适配器恢复可用事件 stateRecoveryCallback: [], //蓝牙适配器恢复可用事件
stateBreakCallback: [] //蓝牙适配器不可用事件 stateBreakCallback: [] //蓝牙适配器不可用事件
} }
this.addReceiveCallback((receive, f, path, recArr) => { //蓝牙模块不再订阅,改到首页订阅
recei.ReceiveData(receive, f, path, recArr); // this.addReceiveCallback((receive, f, path, recArr) => {
}, "BleReceiveData"); // recei.ReceiveData(receive, f, path, recArr);
// }, "BleReceiveData");
setTimeout(() => { setTimeout(() => {
this.OpenBlue().then(() => { this.OpenBlue().then(() => {
@ -229,8 +230,12 @@ class BleHelper {
} }
if (key) { if (key) {
// console.log("key=" + key); // console.log("key=" + key);
let f = this.cfg[type].findIndex((v) => { let f =-1;
return v.key == key;
this.cfg[type].find((v,index) => {
if(v.key == key){
f=index;
}
}); });
if (f > -1) { if (f > -1) {
// this.cfg[type][f].callback = callback; // this.cfg[type][f].callback = callback;
@ -253,8 +258,11 @@ class BleHelper {
if (key) { if (key) {
// console.log("key=" + key); // console.log("key=" + key);
let f = this.cfg[type].findIndex((v) => { let f =-1;
return v.key == key; this.cfg[type].find((v,index) => {
if(v.key == key){
f=index;
}
}); });
if (f > -1) { if (f > -1) {
this.cfg[type].splice(f, 1); this.cfg[type].splice(f, 1);
@ -268,8 +276,31 @@ class BleHelper {
} }
//获取某个事件的所有订阅者,但不包含某些订阅者
getCfgAllKeys(type,retains){
if(!retains){
retains=[];
}
if(!Array.isArray(retains)){
retains=[retains];
}
let keys=null;
for (let index = 0; index < this.cfg[type]; index++) {
let ele = this.cfg[type];
let f=retains.find(v=>{
return v.toLowerCase()==ele.key.toLowerCase();
});
if(!f){
if(!keys){
keys=[ele.key];
}else{
keys.push(ele.key);
}
}
}
return keys;
}
//设置蓝牙恢复连接的回调 //设置蓝牙恢复连接的回调
addRecoveryCallback(callback, currKey) { addRecoveryCallback(callback, currKey) {
@ -280,6 +311,17 @@ class BleHelper {
removeRecoveryCallback(currKey) { removeRecoveryCallback(currKey) {
this.removeCallback(currKey, 'recoveryCallback'); this.removeCallback(currKey, 'recoveryCallback');
} }
//移除所有蓝牙恢复连接的回调,但不包括currkey
removeAllRecoveryCallback(currKey) {
let keys=this.getCfgAllKeys('recoveryCallback',currKey);
if(keys){
for (let i = 0; i < keys.length; i++) {
let key = keys[i];
this.removeRecoveryCallback(key);
}
}
}
//设置蓝牙断开连接的回调 //设置蓝牙断开连接的回调
addDisposeCallback(callback, currKey) { addDisposeCallback(callback, currKey) {
@ -290,6 +332,16 @@ class BleHelper {
removeDisposeCallback(currKey) { removeDisposeCallback(currKey) {
this.removeCallback(currKey, 'bleDisposeCallback'); this.removeCallback(currKey, 'bleDisposeCallback');
} }
removeAllDisposeCallback(currKey) {
let keys=this.getCfgAllKeys('bleDisposeCallback',currKey);
if(keys){
for (let i = 0; i < keys.length; i++) {
let key = keys[i];
this.removeDisposeCallback(key);
}
}
}
//设置发现新设备的回调 //设置发现新设备的回调
@ -301,6 +353,16 @@ class BleHelper {
removeDeviceFound(currKey) { removeDeviceFound(currKey) {
this.removeCallback(currKey, 'onDeviceFound'); this.removeCallback(currKey, 'onDeviceFound');
} }
removeAllDeviceFound(currKey) {
let keys=this.getCfgAllKeys('onDeviceFound',currKey);
if(keys){
for (let i = 0; i < keys.length; i++) {
let key = keys[i];
this.removeDeviceFound(key);
}
}
}
//添加接收到数据的回调 //添加接收到数据的回调
addReceiveCallback(callback, currKey) { addReceiveCallback(callback, currKey) {
@ -311,6 +373,16 @@ class BleHelper {
removeReceiveCallback(currKey) { removeReceiveCallback(currKey) {
this.removeCallback(currKey, 'receivDataCallback'); this.removeCallback(currKey, 'receivDataCallback');
} }
removeAllReceiveCallback(currKey) {
let keys=this.getCfgAllKeys('receivDataCallback',currKey);
if(keys){
for (let i = 0; i < keys.length; i++) {
let key = keys[i];
this.removeReceiveCallback(key);
}
}
}
//添加蓝牙不可用的回调 //添加蓝牙不可用的回调
addStateBreakCallback(callback, currKey) { addStateBreakCallback(callback, currKey) {
@ -321,7 +393,16 @@ class BleHelper {
removeStateBreakCallback(currKey) { removeStateBreakCallback(currKey) {
this.removeCallback(currKey, 'stateBreakCallback'); this.removeCallback(currKey, 'stateBreakCallback');
} }
removeAllStateBreakCallback(currKey) {
let keys=this.getCfgAllKeys('stateBreakCallback',currKey);
if(keys){
for (let i = 0; i < keys.length; i++) {
let key = keys[i];
this.removeStateBreakCallback(key);
}
}
}
//设置蓝牙适配器恢复可用的回调 //设置蓝牙适配器恢复可用的回调
addStateRecoveryCallback(callback, currKey) { addStateRecoveryCallback(callback, currKey) {
@ -332,6 +413,16 @@ class BleHelper {
removeStateRecoveryCallback(currKey) { removeStateRecoveryCallback(currKey) {
this.removeCallback(currKey, 'stateRecoveryCallback'); this.removeCallback(currKey, 'stateRecoveryCallback');
} }
removeAllStateRecoveryCallback(currKey) {
let keys=this.getCfgAllKeys('stateRecoveryCallback',currKey);
if(keys){
for (let i = 0; i < keys.length; i++) {
let key = keys[i];
this.removeStateRecoveryCallback(key);
}
}
}
//清除所有事件回调 //清除所有事件回调
removeAllCallback(currKey) { removeAllCallback(currKey) {
@ -342,7 +433,15 @@ class BleHelper {
this.removeStateRecoveryCallback(currKey); this.removeStateRecoveryCallback(currKey);
this.removeStateBreakCallback(currKey); this.removeStateBreakCallback(currKey);
} }
//清除所有事件回调不包含retain
removeAllCallbackByRetain(retain) {
this.removeAllDeviceFound(retain)
this.removeAllDisposeCallback(retain);
this.removeAllReceiveCallback(retain);
this.removeAllRecoveryCallback(retain);
this.removeAllStateRecoveryCallback(retain);
this.removeAllStateBreakCallback(retain);
}
getError(ex) { getError(ex) {
let code = ex.code; let code = ex.code;
@ -681,7 +780,6 @@ class BleHelper {
if (this.cfg.receivDataCallback.length > 0) { if (this.cfg.receivDataCallback.length > 0) {
let path = this.getCurrentPagePath();
// console.log("有人订阅消息") // console.log("有人订阅消息")
this.cfg.receivDataCallback.forEach(( this.cfg.receivDataCallback.forEach((
rec) => { rec) => {
@ -690,7 +788,7 @@ class BleHelper {
try { try {
// console.log("正在处理订阅消息",rec); // console.log("正在处理订阅消息",rec);
rec.callback(recData, f, rec.callback(recData, f,
path, this.cfg rec.key, this.cfg
.receivDataCallback .receivDataCallback
); );
// console.log("处理订阅消息完毕"); // console.log("处理订阅消息完毕");
@ -784,21 +882,24 @@ class BleHelper {
} }
BleConnChange() { BleConnChange() {
let stateTimeout=null;
uni.onBLEConnectionStateChange((res) => { uni.onBLEConnectionStateChange((res) => {
console.log("蓝牙连接状态变化了", res);
// 检查状态是否真的发生了变化 // 检查状态是否真的发生了变化
let ble = this.data.LinkedList.find(dev => { let ble = this.data.LinkedList.find(dev => {
return res.deviceId === dev.deviceId; return res.deviceId === dev.deviceId;
}); });
if (ble) { if (ble) {
if (ble.Linked === res.connected) { if (ble.Linked === res.connected) {
console.error("专业给UniApp填坑,蓝牙连接状态重复回调");
return; return;
} }
} }
console.log("蓝牙连接状态变化了", res);
clearTimeout(stateTimeout);
stateTimeout=setTimeout(() => {
setTimeout(() => {
if (!res.connected) { if (!res.connected) {
console.error("蓝牙已断开", res); console.error("蓝牙已断开", res);
let f = this.data.LinkedList.find(( let f = this.data.LinkedList.find((
@ -851,7 +952,7 @@ class BleHelper {
console.log("蓝牙连接已恢复", res); console.log("蓝牙连接已恢复", res);
} }
}, 0); }, 50);
}); });
} }
@ -881,8 +982,7 @@ class BleHelper {
return; return;
} }
res.devices = arr; res.devices = arr;
this.data.searchList = this.data.searchList.concat(
res);
if (this.cfg.onDeviceFound) { if (this.cfg.onDeviceFound) {
if (this.cfg.onDeviceFound.length > 0) { if (this.cfg.onDeviceFound.length > 0) {
this.cfg.onDeviceFound.forEach((found) => { this.cfg.onDeviceFound.forEach((found) => {
@ -907,7 +1007,7 @@ class BleHelper {
this.data.available = false; this.data.available = false;
this.data.discovering = false; this.data.discovering = false;
this.data.isOpenBlue = false; this.data.isOpenBlue = false;
this.data.searchList = [];
return Promise.resolve(); return Promise.resolve();
} }
@ -924,7 +1024,7 @@ class BleHelper {
this.data.available = false; this.data.available = false;
this.data.discovering = false; this.data.discovering = false;
this.data.isOpenBlue = false; this.data.isOpenBlue = false;
this.data.searchList = [];
resolve(); resolve();
}, },
fail: (ex) => { fail: (ex) => {
@ -959,20 +1059,15 @@ class BleHelper {
if (this.data.platform == 'web') { if (this.data.platform == 'web') {
return Promise.resolve({}); return Promise.resolve({});
} }
this.data.searchList = [];
var these = this; var these = this;
//开始搜索 //开始搜索
var Search = () => { var Search = () => {
//只搜索合作供应商的服务id
let serviceIds = serviceDic.map(v => {
return v.serviceId
});
//搜索一个服务id的设备循环调用 let RunSearch = () => {
let RunSearch = (serviceId) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
uni.startBluetoothDevicesDiscovery({ uni.startBluetoothDevicesDiscovery({
services: serviceId ? [serviceId] : [], services:[],
allowDuplicatesKey: true, allowDuplicatesKey: true,
success: (res) => { success: (res) => {
console.log('开始搜索蓝牙设备成功'); console.log('开始搜索蓝牙设备成功');
@ -992,14 +1087,8 @@ class BleHelper {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let promises = []; let promises = [];
// for (let i = 0; i < serviceIds.length; i++) {
// promises.push(RunSearch(serviceIds[i]));
// }
promises.push(RunSearch()); promises.push(RunSearch());
Promise.all(promises).then(resolve).catch(reject); Promise.all(promises).then(resolve).catch(reject);
}); });
@ -1278,7 +1367,6 @@ class BleHelper {
} else } else
{ {
console.error("预设的蓝牙服务和特征中找不到"); console.error("预设的蓝牙服务和特征中找不到");
for (var i = 0; i < res.services.length; i++) { for (var i = 0; i < res.services.length; i++) {
@ -1297,7 +1385,7 @@ class BleHelper {
}); });
} else { } else {
Promise.all(promises) Promise.allSettled(promises)
.then(results => { .then(results => {
console.log("results= ", results); console.log("results= ", results);
if (!s) { if (!s) {
@ -1512,12 +1600,23 @@ class BleHelper {
timeout: 30000, timeout: 30000,
success: (info) => { success: (info) => {
//释放连接锁 //释放连接锁
delete this.data.connectingDevices[deviceId]; delete this.data.connectingDevices[deviceId];
console.log("新连接成功", this.data.LinkedList); console.log("新连接成功", this.data.LinkedList);
// 处理 MTU 设置
if (plus.os.name === 'Android') {
this.setMtu(deviceId).catch(ex => {
console.error("mtu设置失败=", ex);
});
}
this.getLinkBlue().then((arr) => { this.getLinkBlue().then((arr) => {
let linkId=new Date().getTime();//本次连接的id
let cr = arr.devices.find(c => { let cr = arr.devices.find(c => {
if (c.deviceId == deviceId) { if (c.deviceId == deviceId) {
c.Linked = true; c.Linked = true;
c.linkId=linkId
return true; return true;
} }
return false; return false;
@ -1525,6 +1624,7 @@ class BleHelper {
if (fIndex > -1) { if (fIndex > -1) {
this.data.LinkedList[fIndex].Linked = true; this.data.LinkedList[fIndex].Linked = true;
this.data.LinkedList[fIndex].linkId=linkId;
} else { } else {
this.data.LinkedList.push(cr); this.data.LinkedList.push(cr);
} }
@ -1558,12 +1658,7 @@ class BleHelper {
}); });
} }
// 处理 MTU 设置
if (plus.os.name === 'Android') {
this.setMtu(deviceId).catch(ex => {
console.error("mtu设置失败=", ex);
});
}
resolve(true); resolve(true);
}).catch((ex) => { }).catch((ex) => {
@ -1970,5 +2065,6 @@ export default {
} }
return instance; return instance;
} },
} constService:serviceDic
}

View File

@ -1,18 +1,21 @@
import Common from '@/utils/Common.js'
class BleReceive { class BleReceive {
constructor() { constructor() {
this.StorageKey = "linkedDevices"; this.StorageKey = "linkedDevices";
this.HandlerMap = { this.HandlerMap = {
'/pages/6155/deviceDetail': this.Receive_6155.bind(this), '/pages/6155/deviceDetail': this.Receive_6155.bind(this),
'/pages/6155/BJQ6155': this.Receive_6155_XH.bind(this),
'/pages/7305/BJQ7305': this.Receive_6155.bind(this), '/pages/7305/BJQ7305': this.Receive_6155.bind(this),
'/pages/650/HBY650': this.Receive_650.bind(this), '/pages/650/HBY650': this.Receive_650.bind(this),
'/pages/670/HBY670': this.Receive_670.bind(this), '/pages/670/HBY670': this.Receive_670.bind(this),
'/pages/4877/BJQ4877': this.Receive_4877.bind(this), '/pages/4877/BJQ4877': this.Receive_4877.bind(this),
'/pages/100/HBY100': this.Receive_100.bind(this), '/pages/100/HBY100': this.Receive_100.bind(this),
'/pages/102/HBY102':this.Receive_102.bind(this) '/pages/102/HBY102': this.Receive_102.bind(this)
}; };
} }
setBleFormData(data, f) { setBleFormData(data, f) {
if (data) { if (data) {
let linkedList = uni.getStorageSync(this.StorageKey); let linkedList = uni.getStorageSync(this.StorageKey);
@ -59,7 +62,7 @@ class BleReceive {
if (handler) { if (handler) {
let data = handler(receive, f, path, recArr); let data = handler(receive, f, path, recArr);
// console.log("设备"+f.device.deviceName+"收到消息,数据:", data); // console.log("设备"+f.device.deviceName+"收到消息,数据:", data);
return data; return data;
} else { } else {
console.error("已收到消息,但无指定处理程序, deviceUrl:", f.device.detailPageUrl, "可用handlers:", keys); console.error("已收到消息,但无指定处理程序, deviceUrl:", f.device.detailPageUrl, "可用handlers:", keys);
@ -99,6 +102,10 @@ class BleReceive {
staticLevelText = '低档'; staticLevelText = '低档';
modeCurr = "low"; modeCurr = "low";
break; break;
case 0x68:
staticLevelText = '前置';
modeCurr = "smalllow";
break;
case 0x64: case 0x64:
staticLevelText = '关闭'; staticLevelText = '关闭';
modeCurr = "close"; modeCurr = "close";
@ -162,7 +169,7 @@ class BleReceive {
if (iswarn) { if (iswarn) {
uni.showModal({ uni.showModal({
content: "'"+f.device.deviceName+"'环境存在漏电电源", content: "'" + f.device.deviceName + "'环境存在漏电电源",
title: "警告", title: "警告",
success(res) { success(res) {
if (res.confirm) { if (res.confirm) {
@ -258,7 +265,7 @@ class BleReceive {
Receive_670(receive, f, path, recArr) { Receive_670(receive, f, path, recArr) {
// console.log("pagh=", path); // console.log("pagh=", path);
var todo = (bytes) => { var todo = (bytes) => {
console.log("todo",receive); console.log("todo", receive);
let receiveData = {}; let receiveData = {};
if (bytes[0] == 0x55) { if (bytes[0] == 0x55) {
try { try {
@ -319,7 +326,7 @@ class BleReceive {
receiveData.staticWarn = staticWarn; receiveData.staticWarn = staticWarn;
receiveData.fourGStrenth = fourGStrenth; receiveData.fourGStrenth = fourGStrenth;
receiveData.SOS = sosTxt; receiveData.SOS = sosTxt;
receiveData.qzwarn = sosTxt==='sg'; receiveData.qzwarn = sosTxt === 'sg';
this.setBleFormData(receiveData, f); this.setBleFormData(receiveData, f);
console.log("recArr=", recArr); console.log("recArr=", recArr);
let recCnt = recArr.find(v => { let recCnt = recArr.find(v => {
@ -327,22 +334,22 @@ class BleReceive {
.replace(/\//g, "").toLowerCase(); .replace(/\//g, "").toLowerCase();
}); });
if (!recCnt) { if (!recCnt) {
let msgs=[]; let msgs = [];
if(receiveData.qzwarn){ if (receiveData.qzwarn) {
msgs.push("声光报警中"); msgs.push("声光报警中");
} }
if (staticWarn) { //有静止报警 if (staticWarn) { //有静止报警
msgs.push("静止报警中"); msgs.push("静止报警中");
} }
if(msgs.length>0){ if (msgs.length > 0) {
msgs="设备'"+f.device.deviceName+msgs.join(";"); msgs = "设备'" + f.device.deviceName + msgs.join(";");
uni.showModal({ uni.showModal({
title: "警告", title: "警告",
content:msgs, content: msgs,
showCancel: false showCancel: false
}); });
} }
} }
} catch (error) { } catch (error) {
console.error('数据解析错误:', error); console.error('数据解析错误:', error);
@ -418,44 +425,132 @@ class BleReceive {
return data; return data;
} }
Receive_6155_XH(receive, f, path, recArr) {
let bytes = receive.bytes;
if (bytes[0] == 0xFB && bytes[1] == 0x64 && bytes.length >= 8) {
try {
let light = null;
let mode = null;
if (bytes[2] === 0x01 && bytes[3] === 0x00) {
light = 0;
mode = 'main';
} else if (bytes[2] === 0x02 && bytes[3] === 0x00) {
light = 1;
mode = 'main';
} else if (bytes[2] === 0x00 && bytes[3] === 0x01) {
light = 2;
mode = 'main';
} else if (bytes[2] === 0x03 && bytes[3] === 0x00) {
light = 0;
mode = 'fu';
} else if (bytes[2] === 0x04 && bytes[3] === 0x00) {
light = 1;
mode = 'fu';
}
if (bytes[2] === 0x05 && bytes[3] === 0x00) {
light = 3;
}
// 解析剩余电量
let batteryLevelByte = bytes[4];
// 电量百分比范围检查
let batteryLevel = Math.max(0, Math.min(100, batteryLevelByte));
//充电状态
let warn = bytes[5];
if (warn == 0x00) {
warn = '未充电';
} else if (warn == 0x01) {
warn = '充电中';
}
// 解析剩余照明时间(第三和第四字节,小端序)
let lightingTime = "";
let HH = Math.max(0, Math.min(100, bytes[6]));
let mm = Math.max(0, Math.min(100, bytes[7]));
lightingTime = HH + "小时" + mm + "分钟";
let formData = {};
formData.mode = mode;
formData.light = light;
formData.battary = batteryLevel;
formData.statu = warn;
formData.xuhang = lightingTime;
let recCnt = recArr.find(v => {
return v.key.replace(/\//g, "").toLowerCase() === f.device.detailPageUrl.replace(/\//g,
'').toLowerCase();
});
if (!recCnt) {
if (batteryLevel <= 20) {
// 会弹出两个框,暂且注释掉这段代码
uni.showModal({
content: "设备'" + f.device.deviceName + "'电量低",
title: "提示"
});
}
}
this.setBleFormData(formData, f);
return formData;
} catch (error) {
console.log('7305数据解析错误:', error);
return null;
}
}
return null;
}
Receive_6155(receive, f, path, recArr) { Receive_6155(receive, f, path, recArr) {
let bytes = receive.bytes; let bytes = receive.bytes;
if (bytes[0] == 0xFB && bytes[1] == 0x64 && bytes.length >= 8) { if (bytes[0] == 0xFB && bytes[1] == 0x64 && bytes.length >= 8) {
try { try {
let getName = function(type,) { let getName = function(type, ) {
let name = ""; let name = "";
switch (type) { switch (type) {
case 0x01: case 0x01:
// name = '强光'; // name = '强光';
name=0; name = 0;
break; break;
case 0x02: case 0x02:
// name = '弱光'; // name = '弱光';
name=1; name = 1;
break; break;
case 0x03: case 0x03:
// name = '爆闪'; // name = '爆闪';
name=2; name = 2;
break; break;
case 0x04: case 0x04:
name = 0;//泛光 name = 0; //泛光
break; break;
case 0x0A: case 0x0A:
name = 1;//强光&泛光 name = 1; //强光&泛光
break; break;
default: default:
// name = '关闭'; // name = '关闭';
name=null; name = null;
break; break;
} }
return name; return name;
} }
let staticLevelText = getName(bytes[2]); let staticLevelText = getName(bytes[2]);
// 解析照明档位 // 解析照明档位
@ -484,26 +579,27 @@ class BleReceive {
let mm = Math.max(0, Math.min(100, bytes[7])); let mm = Math.max(0, Math.min(100, bytes[7]));
lightingTime = HH + "小时" + mm + "分钟"; lightingTime = HH + "小时" + mm + "分钟";
let formData = {}; let formData = {};
formData.mode = (bytes[2]===0x00 || bytes[2]===0x0B)?'fu':'main'; formData.mode = (bytes[2] === 0x00 || bytes[2] === 0x0B) ? 'fu' : 'main';
formData.light=formData.mode=='fu'?lightingLevelText:staticLevelText; formData.light = formData.mode == 'fu' ? lightingLevelText : staticLevelText;
formData.battary = batteryLevel; formData.battary = batteryLevel;
formData.statu = warn; formData.statu = warn;
formData.xuhang = lightingTime; formData.xuhang = lightingTime;
let recCnt = recArr.find(v => { let recCnt = recArr.find(v => {
return v.key.replace(/\//g, "").toLowerCase() === f.device.detailPageUrl.replace(/\//g, '').toLowerCase(); return v.key.replace(/\//g, "").toLowerCase() === f.device.detailPageUrl.replace(/\//g,
'').toLowerCase();
}); });
if (!recCnt) { if (!recCnt) {
if (batteryLevel <= 20) { if (batteryLevel <= 20) {
// 会弹出两个框,暂且注释掉这段代码 // 会弹出两个框,暂且注释掉这段代码
uni.showModal({ uni.showModal({
content: "设备'"+f.device.deviceName+"'电量低", content: "设备'" + f.device.deviceName + "'电量低",
title: "提示" title: "提示"
}); });
} }
@ -520,102 +616,231 @@ class BleReceive {
return null; return null;
} }
Receive_4877(receive,f,path,recArr){ Receive_4877(receive, f, path, recArr) {
let receiveData={}; let receiveData = {};
try { try {
// console.log("str=",receive.str); // console.log("str=",receive.str);
receiveData = JSON.parse(receive.str); receiveData = JSON.parse(receive.str);
let recCnt = recArr.find(v => { let recCnt = recArr.find(v => {
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
.replace(/\//g, "").toLowerCase(); .replace(/\//g, "").toLowerCase();
}); });
if (!recCnt) { if (!recCnt) {
if (receiveData.sta_PowerPercent<=20) { if (receiveData.sta_PowerPercent <= 20) {
uni.showModal({ uni.showModal({
title: "提示", title: "提示",
content: "设备'"+f.device.deviceName+"'电量低", content: "设备'" + f.device.deviceName + "'电量低",
showCancel: false showCancel: false
}); });
}
} }
}
} catch (error) { } catch (error) {
receiveData = {}; receiveData = {};
console.log("文本解析失败",error) console.log("文本解析失败", error)
} }
return receiveData; return receiveData;
} }
Receive_100(receive,f,path,recArr){ Receive_100(receive, f, path, recArr) {
let receiveData={}; let receiveData = {};
try { try {
// console.log("str=",receive.str); // console.log("str=",receive.str);
receiveData = JSON.parse(receive.str); receiveData = JSON.parse(receive.str);
let recCnt = recArr.find(v => { let recCnt = recArr.find(v => {
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
.replace(/\//g, "").toLowerCase(); .replace(/\//g, "").toLowerCase();
}); });
if (!recCnt) { if (!recCnt) {
if (receiveData.sta_battery<=20) { if (receiveData.sta_battery <= 20) {
uni.showModal({ uni.showModal({
title: "提示", title: "提示",
content: "设备'"+f.device.deviceName+"'电量低", content: "设备'" + f.device.deviceName + "'电量低",
showCancel: false showCancel: false
}); });
}
} }
}
} catch (error) { } catch (error) {
receiveData = {}; receiveData = {};
console.log("文本解析失败",error) console.log("文本解析失败", error)
} }
return receiveData; return receiveData;
} }
Receive_102(receive,f,path,recArr){ Receive_102(receive, f, path, recArr) {
let receiveData={}; let receiveData = {};
try { try {
console.log("订阅消息者:", path);
// console.log("str=",receive.str); console.log("设备收到消息:", f);
console.log("消息内容:", receive);
receiveData = JSON.parse(receive.str); receiveData = JSON.parse(receive.str);
let recCnt = recArr.find(v => { let recCnt = recArr.find(v => {
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
.replace(/\//g, "").toLowerCase(); .replace(/\//g, "").toLowerCase();
}); });
if (!recCnt) { if (!recCnt) {
if (receiveData.sta_PowerPercent<=20) { if (receiveData.sta_PowerPercent <= 20) {
uni.showModal({ uni.showModal({
title: "提示", title: "提示",
content: "设备'"+f.device.deviceName+"'电量低", content: "设备'" + f.device.deviceName + "'电量低",
showCancel: false showCancel: false
}); });
}
if (receiveData.sta_Intrusion===1) {
uni.showModal({
title: "提示",
content: "闯入报警中",
showCancel: false
});
}
} }
if (receiveData.sta_Intrusion === 1) {
uni.showModal({
title: "提示",
content: "闯入报警中",
showCancel: false
});
}
}
if (f.device && path === "pages/common/index") { //仅在首页订阅此操作
console.error("1111111111");
let linkKey = "102_" + f.device.id + "_linked";
let warnKey = "102_" + f.device.id + "_warning";
let time = new Date(); //Common.DateFormat(new Date(),'yyyy-MM-dd HH:mmss');
if (receiveData.sta_tomac) { //某个设备上线了
if (receiveData.sta_tomac.indexOf(':') == -1) {
receiveData.sta_tomac = receiveData.sta_tomac.replace(/(.{2})/g, '$1:').slice(0, -
1); //mac地址自动补:
}
uni.getStorageInfo({
success: function(res) {
let arr = [];
let linked = {
linkId: f.linkId,
read: false,
linkEqs: [{
linkTime: time,
linkMac: f.macAddress
}, {
linkTime: time,
linkMac: receiveData.sta_tomac
}]
};
if (res.keys.includes(linkKey)) {
arr = uni.getStorageSync(linkKey);
}
if (arr.length == 0) {
arr.unshift(linked);
} else {
let dev = arr.find(v => {
if (v.linkId == f.linkId) {
let vl = v.linkEqs.find(cvl => {
if(cvl.linkMac === receiveData.sta_tomac){
v.read=false;
cvl.linkTime=time;
return true;
}
return false;
});
if (!vl) {
v.linkEqs.push({
linkTime: time,
linkMac: receiveData.sta_tomac
});
}
return vl;
}
return false;
});
if (!dev) {
arr.unshift(linked);
}
}
console.error("某个设备上线了", arr)
uni.setStorage({
key: linkKey,
data: arr
});
}
});
}
let warnArrs = [];
let guid = Common.guid();
if (receiveData.sta_sosadd) { //某个设备闯入报警
console.error("某个设备闯入报警");
if (receiveData.sta_sosadd.indexOf(':') == -1) {
receiveData.sta_sosadd = receiveData.sta_sosadd.replace(/(.{2})/g, '$1:').slice(0, -
1); //mac地址自动补:
}
warnArrs.push({
linkId: f.linkId,
read: false,
key: guid,
warnType: "闯入报警",
warnMac: receiveData.sta_sosadd,
warnTime: time,
warnName: ""
});
}
if (receiveData.sta_LedType === 'led_alarm' || receiveData.ins_LedType === 'led_alarm') { //强制报警
console.error("强制报警了", f);
warnArrs.push({
linkId: f.linkId,
read: false,
key: guid,
warnType: "强制报警",
warnMac: f.macAddress,
warnTime: time,
warnName: ""
});
}
if (warnArrs.length > 0) {
uni.getStorageInfo({
success: function(res) {
let arr = [];
if (res.keys.includes(warnKey)) {
arr = uni.getStorageSync(warnKey);
arr = warnArrs.concat(arr);
} else {
arr = warnArrs
}
uni.setStorage({
key: warnKey,
data: arr
});
}
});
}
}
} catch (error) { } catch (error) {
receiveData = {}; receiveData = {};
console.log("文本解析失败",error) console.log("文本解析失败", error)
} }
return receiveData; return receiveData;
} }
} }

View File

@ -218,7 +218,7 @@ export default {
value: "1", value: "1",
label: "灯光模式", label: "灯光模式",
checked: false, checked: false,
type: ['6170', '670'] type: ['6170', '670','102']
}, },
{ {
value: "2", value: "2",
@ -282,7 +282,7 @@ export default {
value: "46", value: "46",
label: "手动报警", label: "手动报警",
checked: false, checked: false,
type: ['210'] type: ['210','102']
}, },
{ {
value: "47", value: "47",
@ -290,6 +290,18 @@ export default {
checked: false, checked: false,
type: ['210'] type: ['210']
}, },
{
value: "48",
label: "物体感应",
checked: false,
type: ['102']
},
{
value: "49",
label: "联机模式",
checked: false,
type: ['102']
},
] ]
let arr = []; let arr = [];

View File

@ -1,4 +1,3 @@
//地标 转 国测 常量 //地标 转 国测 常量
var x_PI = (3.14159265358979324 * 3000.0) / 180.0; var x_PI = (3.14159265358979324 * 3000.0) / 180.0;
var PI = 3.1415926535897932384626; var PI = 3.1415926535897932384626;
@ -8,115 +7,241 @@ var ee = 0.00669342162296594323; //椭球的偏心率。
//判断是否在国内,在中国国内的经纬度才需要做偏移 //判断是否在国内,在中国国内的经纬度才需要做偏移
function out_of_china(lng, lat) { function out_of_china(lng, lat) {
return ( return (
lng < 72.004 || lng < 72.004 ||
lng > 137.8347 || lng > 137.8347 ||
(lat < 0.8293 || lat > 55.8271 || false) (lat < 0.8293 || lat > 55.8271 || false)
); );
} }
//转化经度 //转化经度
function transformlng(lng, lat) { function transformlng(lng, lat) {
var ret = var ret =
300.0 + 300.0 +
lng + lng +
2.0 * lat + 2.0 * lat +
0.1 * lng * lng + 0.1 * lng * lng +
0.1 * lng * lat + 0.1 * lng * lat +
0.1 * Math.sqrt(Math.abs(lng)); 0.1 * Math.sqrt(Math.abs(lng));
ret += ret +=
((20.0 * Math.sin(6.0 * lng * PI) + ((20.0 * Math.sin(6.0 * lng * PI) +
20.0 * Math.sin(2.0 * lng * PI)) * 20.0 * Math.sin(2.0 * lng * PI)) *
2.0) / 2.0) /
3.0; 3.0;
ret += ret +=
((20.0 * Math.sin(lng * PI) + ((20.0 * Math.sin(lng * PI) +
40.0 * Math.sin((lng / 3.0) * PI)) * 40.0 * Math.sin((lng / 3.0) * PI)) *
2.0) / 2.0) /
3.0; 3.0;
ret += ret +=
((150.0 * Math.sin((lng / 12.0) * PI) + ((150.0 * Math.sin((lng / 12.0) * PI) +
300.0 * Math.sin((lng / 30.0) * PI)) * 300.0 * Math.sin((lng / 30.0) * PI)) *
2.0) / 2.0) /
3.0; 3.0;
return ret; return ret;
} }
//转化纬度 //转化纬度
function transformlat(lng, lat) { function transformlat(lng, lat) {
var ret = var ret = -100.0 +
-100.0 + 2.0 * lng +
2.0 * lng + 3.0 * lat +
3.0 * lat + 0.2 * lat * lat +
0.2 * lat * lat + 0.1 * lng * lat +
0.1 * lng * lat + 0.2 * Math.sqrt(Math.abs(lng));
0.2 * Math.sqrt(Math.abs(lng)); ret +=
ret += ((20.0 * Math.sin(6.0 * lng * PI) +
((20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) *
20.0 * Math.sin(2.0 * lng * PI)) * 2.0) /
2.0) / 3.0;
3.0; ret +=
ret += ((20.0 * Math.sin(lat * PI) +
((20.0 * Math.sin(lat * PI) + 40.0 * Math.sin((lat / 3.0) * PI)) *
40.0 * Math.sin((lat / 3.0) * PI)) * 2.0) /
2.0) / 3.0;
3.0; ret +=
ret += ((160.0 * Math.sin((lat / 12.0) * PI) +
((160.0 * Math.sin((lat / 12.0) * PI) + 320 * Math.sin((lat * PI) / 30.0)) *
320 * Math.sin((lat * PI) / 30.0)) * 2.0) /
2.0) / 3.0;
3.0; return ret;
return ret;
} }
//经纬度互相转换
function convertByNet(lng,lat,from){
return new Promise((resolve, reject) => {
if(!from){
from='wgs84'
}
let url = 'https://openapi.lddgo.net/base/gtool/api/v1/CoordinateTransform'
uni.request({
url: url,
method: 'POST',
timeout: 10000,
header:{
'content-type':'application/json;charset=UTF-8'
},
data:
{
"from": "wgs84",
"coordinateList": [
{
"sourceLng": lng,
"sourceLat": lat
}
]
}
,
dataType: 'json',
success(res) {
if (res.statusCode == 200) {
if (res.data.code===0) {
console.log("坐标转换接口成功", res);
let lnglag=res.data.data.coordinateList[0];
resolve([lnglag.gLng,lnglag.gLat]);
return;
}
}
console.error("坐标转换异常", res);
resolve(null)
},
fail(err) {
console.error("坐标转换接口出现异常", err);
resolve(null);
}
})
});
}
//wgs84 to gcj02 地球坐标系 转 火星坐标系 function wgs84_to_gcj02_old(lng, lat) {
function wgs84_to_gcj02(lng, lat) { if (out_of_china(lng, lat)) {
if (out_of_china(lng, lat)) { return [lng, lat];
return [lng, lat]; } else {
} else { var dlat = transformlat(lng - 105.0, lat - 35.0);
var dlat = transformlat(lng - 105.0, lat - 35.0); var dlng = transformlng(lng - 105.0, lat - 35.0);
var dlng = transformlng(lng - 105.0, lat - 35.0); var radlat = (lat / 180.0) * PI;
var radlat = (lat / 180.0) * PI; var magic = Math.sin(radlat);
var magic = Math.sin(radlat); magic = 1 - ee * magic * magic;
magic = 1 - ee * magic * magic; var sqrtmagic = Math.sqrt(magic);
var sqrtmagic = Math.sqrt(magic); dlat =
dlat = (dlat * 180.0) /
(dlat * 180.0) / (((a * (1 - ee)) / (magic * sqrtmagic)) * PI);
(((a * (1 - ee)) / (magic * sqrtmagic)) * PI); dlng =
dlng = (dlng * 180.0) / ((a / sqrtmagic) * Math.cos(radlat) * PI);
(dlng * 180.0) / ((a / sqrtmagic) * Math.cos(radlat) * PI); var mglat = lat + dlat;
var mglat = lat + dlat; var mglng = lng + dlng;
var mglng = lng + dlng;
return [mglng, mglat]; return [mglng, mglat];
} }
}
//wgs84 to gcj02 wgs84转gcj02,返回Promise
function wgs84_to_gcj02(lng, lat) {
//调用高德的接口进行坐标转换
let convertByGD = () => {
return new Promise((resolve, reject) => {
let url = 'https://restapi.amap.com/v3/assistant/coordinate/convert?locations=' + lng + ',' +
lat + '&coordsys=gps&output=json&key=ca3af8a20d628897020893892bda5ae4'
uni.request({
url: url,
method: 'GET',
timeout: 10000,
dataType: 'json',
success(res) {
if (res.statusCode == 200) {
if (res.data.status == "1" && res.data.infocode=='10000') {
console.log("坐标转换接口成功", res);
resolve(res.data.locations.split(','));
return;
}
}
console.error("坐标转换异常", res);
resolve(null)
},
fail(err) {
console.error("坐标转换接口出现异常", err);
resolve(null);
}
})
});
}
let convertOrains=()=>{
let newLnglat=wgs84_to_gcj02_old(lng,lat);
return Promise.resolve(newLnglat);
}
let task=()=>{
return new Promise((resolve,reject)=>{
let promises=[convertByGD(),convertByNet(lng,lat),convertOrains()];
Promise.allSettled(promises).then(
res=>{
for (let i = 0; i < res.length; i++) {
let item = res[i];
if(item.status==='fulfilled' && item.value){
resolve(item.value);
break;
}
}
}
);
});
}
return task();
} }
//gcj02 to wgs84 火星坐标系 转 地球坐标系 //gcj02 to wgs84 火星坐标系 转 地球坐标系
function gcj02_to_wgs84(lng, lat) { function gcj02_to_wgs84_old(lng, lat) {
if (out_of_china(lng, lat)) { if (out_of_china(lng, lat)) {
return [lng, lat] return [lng, lat]
} } else {
else { var dlat = transformlat(lng - 105.0, lat - 35.0);
var dlat = transformlat(lng - 105.0, lat - 35.0); var dlng = transformlng(lng - 105.0, lat - 35.0);
var dlng = transformlng(lng - 105.0, lat - 35.0); var radlat = lat / 180.0 * PI;
var radlat = lat / 180.0 * PI; var magic = Math.sin(radlat);
var magic = Math.sin(radlat); magic = 1 - ee * magic * magic;
magic = 1 - ee * magic * magic; var sqrtmagic = Math.sqrt(magic);
var sqrtmagic = Math.sqrt(magic); dlat = (dlat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * PI);
dlat = (dlat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * PI); dlng = (dlng * 180.0) / (a / sqrtmagic * Math.cos(radlat) * PI);
dlng = (dlng * 180.0) / (a / sqrtmagic * Math.cos(radlat) * PI); var mglat = lat + dlat;
var mglat = lat + dlat; var mglng = lng + dlng;
var mglng = lng + dlng; return [lng * 2 - mglng, lat * 2 - mglat]
return [lng * 2 - mglng, lat * 2 - mglat] }
} }
//gcj02转wgs84
function gcj02_to_wgs84(lng, lat){
let task=()=>{
return new Promise((resolve,reject)=>{
convertByNet(lng,lat,'gcj02').then(res=>{
if(res){
resolve(res);
return;
}
resolve(gcj02_to_wgs84_old(lng,lat));
})
});
}
return task();
} }
export default { export default {
gcj02_to_wgs84, gcj02_to_wgs84,
wgs84_to_gcj02 wgs84_to_gcj02
} }