Compare commits
4 Commits
7c2e68bca2
...
4c3999251e
| Author | SHA1 | Date | |
|---|---|---|---|
| 4c3999251e | |||
| f629a08385 | |||
| 4f3a8bb3ec | |||
| e042436c5b |
1
App.vue
@ -26,6 +26,7 @@
|
||||
// uni.removeStorageSync(val);
|
||||
// }
|
||||
// });
|
||||
// uni.clearStorageSync();
|
||||
//以上代码仅在开发时使用,否则会出现不可预知的问题。
|
||||
|
||||
uni.getSystemInfo({success:function(res){
|
||||
|
||||
@ -5,14 +5,14 @@ const config = {
|
||||
BASE_URL: 'http://192.168.110.56:8000',
|
||||
API_PREFIX: '',
|
||||
// MQTT 配置
|
||||
MQTT_HOST: '47.120.79.150',
|
||||
MQTT_HOST: 'www.cnxhyc.com',
|
||||
MQTT_PORT: 8083,
|
||||
MQTT_USERNAME: 'admin',
|
||||
MQTT_PASSWORD: '#YtvpSfCNG'
|
||||
},
|
||||
// 生产环境
|
||||
production: {
|
||||
BASE_URL: 'https://www.cnxhyc.com/jingquan',
|
||||
BASE_URL: 'https://www.cnxhyc.com/jq',
|
||||
API_PREFIX: '',
|
||||
// MQTT 配置
|
||||
MQTT_HOST: 'www.cnxhyc.com',
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"name" : "星汉物联",
|
||||
"appid" : "__UNI__A21EF43",
|
||||
"description" : "设备管控",
|
||||
"versionName" : "1.0.2",
|
||||
"versionName" : "1.0.3",
|
||||
"versionCode" : "100",
|
||||
"transformPx" : false,
|
||||
/* 5+App特有相关 */
|
||||
|
||||
@ -1246,14 +1246,14 @@
|
||||
these.setBleFormData();
|
||||
|
||||
|
||||
let json = {
|
||||
deviceId: these.device.id,
|
||||
name: these.formData.company,
|
||||
position: these.formData.name,
|
||||
unitName: these.formData.job,
|
||||
code: these.formData.id
|
||||
};
|
||||
usrApi.sendUsr(json)
|
||||
// let json = {
|
||||
// deviceId: these.device.id,
|
||||
// name: these.formData.company,
|
||||
// position: these.formData.name,
|
||||
// unitName: these.formData.job,
|
||||
// code: these.formData.id
|
||||
// };
|
||||
// usrApi.sendUsr(json)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -282,7 +282,7 @@
|
||||
request,
|
||||
baseURL
|
||||
} from '../../utils/request';
|
||||
|
||||
import lnglatConvert from '@/utils/wgs84_to_gcj02.js'
|
||||
|
||||
const pagePath = "pages/670/HBY670";
|
||||
var ble = null;
|
||||
@ -369,6 +369,7 @@
|
||||
showClose: false
|
||||
},
|
||||
usrToggle: true,
|
||||
bleLinkCnt:0
|
||||
},
|
||||
formData: {
|
||||
battary: "", //电量
|
||||
@ -380,9 +381,9 @@
|
||||
modeCurr: "", //档位
|
||||
SOS: "", //sos
|
||||
lightCurr: "qiang", //照明模式
|
||||
company: "", //单位
|
||||
usrname: "", //姓名
|
||||
job: "", //职位
|
||||
company: "湖北消防总队", //单位
|
||||
usrname: "胡红军", //姓名
|
||||
job: "中队长", //职位
|
||||
usrid: "", //id
|
||||
msgTxt: "", //消息1
|
||||
qzwarn: false, //是否强制报警
|
||||
@ -469,6 +470,7 @@
|
||||
var device = data.data;
|
||||
these.Status.apiType = data.apiType;
|
||||
these.device = device;
|
||||
these.formData.usrid = device.deviceImei;
|
||||
if (data.apiType !== 'listA') {
|
||||
Common.getdeviceShareId(data.data.id).then(res => {
|
||||
if (res.code == 200) {
|
||||
@ -523,7 +525,10 @@
|
||||
},
|
||||
methods: {
|
||||
showBleUnConnect() {
|
||||
|
||||
this.Status.bleLinkCnt++;
|
||||
if(this.Status.bleLinkCnt>3){
|
||||
return;
|
||||
}
|
||||
this.showPop({
|
||||
message: "蓝牙未连接过该设备,请使用蓝牙重新添加该设备",
|
||||
iconUrl: "/static/images/6155/DeviceDetail/uploadErr.png",
|
||||
@ -557,8 +562,9 @@
|
||||
});
|
||||
},
|
||||
gotoMap() {
|
||||
this.detailData.longitude = this.formData.Lon;
|
||||
this.detailData.latitude = this.formData.Lat;
|
||||
let lnglat=lnglatConvert.wgs84_to_gcj02(this.formData.Lon,this.formData.Lat);
|
||||
this.detailData.longitude = lnglat[0];
|
||||
this.detailData.latitude = lnglat[1];
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/map/index',
|
||||
events: {
|
||||
@ -2196,14 +2202,14 @@
|
||||
hideLoading(these);
|
||||
|
||||
|
||||
let json = {
|
||||
deviceId: these.device.id,
|
||||
name: these.formData.company,
|
||||
position: these.formData.usrname,
|
||||
unitName: these.formData.job,
|
||||
code: these.formData.usrid
|
||||
};
|
||||
api.sendUsr(json)
|
||||
// let json = {
|
||||
// deviceId: these.device.id,
|
||||
// name: these.formData.company,
|
||||
// position: these.formData.usrname,
|
||||
// unitName: these.formData.job,
|
||||
// code: these.formData.usrid
|
||||
// };
|
||||
// api.sendUsr(json)
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2221,7 +2227,7 @@
|
||||
let s = (text.length * 2).toString(16);
|
||||
let len = String(s).padStart(4, '0')
|
||||
len = len.match(/.{1,2}/g);
|
||||
|
||||
|
||||
// 填充头部
|
||||
dataView.setUint8(0, 0x55); // 帧头
|
||||
dataView.setUint8(1, 0x03); // 帧类型:文字
|
||||
@ -2251,10 +2257,10 @@
|
||||
|
||||
// 发送下一个包
|
||||
currentPacket++;
|
||||
setTimeout(sendNextPacket, 0);
|
||||
setTimeout(sendNextPacket, 2000);
|
||||
}).catch(err => {
|
||||
if (err.code == '10007') {
|
||||
setTimeout(sendNextPacket, 0);
|
||||
setTimeout(sendNextPacket,2000);
|
||||
} else {
|
||||
requestSend();
|
||||
}
|
||||
@ -2276,7 +2282,7 @@
|
||||
these.HoldYouHand("word transmit start", 120, f.deviceId, f.writeServiceId, f
|
||||
.wirteCharactId).then(
|
||||
() => {
|
||||
setTimeout(sendText, 200);
|
||||
setTimeout(sendText, 2000);
|
||||
}).catch((ex) => {
|
||||
requestSend();
|
||||
// console.log("握手没有成功", ex);
|
||||
|
||||
@ -67,7 +67,7 @@
|
||||
<text class="smallTxt">泛光模式</text>
|
||||
</view>
|
||||
</view> -->
|
||||
<view class="mode fleft" v-on:click.stop="UploadOpenImg()">
|
||||
<view class="mode marginLeft fleft" v-on:click.stop="UploadOpenImg()">
|
||||
<view class="leftImg">
|
||||
<image class="img" src="/static/images/6155/DeviceDetail/open.png" mode="aspectFit"></image>
|
||||
</view>
|
||||
@ -611,7 +611,7 @@
|
||||
let clength = 0;
|
||||
for (let j = 0; j < item.length; j++) {
|
||||
const element = item[j];
|
||||
console.log("第" + i + "包,第" + j + "小包,长度:" + element.length)
|
||||
// console.log("第" + i + "包,第" + j + "小包,长度:" + element.length)
|
||||
length += element.length;
|
||||
clength += element.length;
|
||||
|
||||
@ -714,7 +714,7 @@
|
||||
|
||||
//发送数据包
|
||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId,
|
||||
30)
|
||||
1000)
|
||||
.then(() => {
|
||||
|
||||
let curr = childPacket + (currentPacket - 1) *
|
||||
@ -732,10 +732,10 @@
|
||||
childPacket++;
|
||||
}
|
||||
|
||||
setTimeout(sendNextPacket, 100);
|
||||
setTimeout(sendNextPacket, 1000);
|
||||
}).catch(err => {
|
||||
if (err.code == 10007) {
|
||||
setTimeout(sendNextPacket, 100);
|
||||
setTimeout(sendNextPacket, 1000);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -927,7 +927,7 @@
|
||||
text: "请稍候..."
|
||||
});
|
||||
|
||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 30).then(() => {
|
||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 100).then(() => {
|
||||
this.formData.mode = mode;
|
||||
this.setBleFormData();
|
||||
}).catch((ex) => {
|
||||
@ -1091,7 +1091,7 @@
|
||||
let inteval = parseInt(this.inteval ? this.inteval : 50);
|
||||
console.log("inteval=", inteval)
|
||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f
|
||||
.wirteCharactId, 30).then(() => {
|
||||
.wirteCharactId, 100).then(() => {
|
||||
|
||||
curr++;
|
||||
setTimeout(sendNext, inteval);
|
||||
@ -1259,7 +1259,7 @@
|
||||
if (f) {
|
||||
// 发送数据
|
||||
|
||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 30);
|
||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 100);
|
||||
|
||||
}
|
||||
|
||||
@ -1301,7 +1301,7 @@
|
||||
if (f) {
|
||||
// 发送数据
|
||||
|
||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 30);
|
||||
ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 100);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
|
||||
<view class="imgContent center">
|
||||
<view class="img center">
|
||||
<image src="/static/images/common/bluetooth.png" class="titleIco" mode="aspectFit">
|
||||
<image src="/static/images/BLEAdd/bluetooth.png" class="titleIco" mode="aspectFit">
|
||||
</image>
|
||||
</view>
|
||||
|
||||
@ -44,19 +44,31 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="lblTitle">搜索设备</view>
|
||||
<view class="lblTitle">
|
||||
<text>搜索设备</text>
|
||||
<view @click="refreshBleList()">刷新</view>
|
||||
</view>
|
||||
<view class="list searchList">
|
||||
<view class="item" v-on:click="Link(item,index)" v-for="item, index in EquipMents"
|
||||
v-show="!item['linkStatu']">
|
||||
<view class="leftImg ">
|
||||
<image src="/static/images/common/bluetooth.png" class="titleIco" mode="heightFix">
|
||||
<image src="/static/images/BLEAdd/bluetooth.png" class="titleIco" mode="heightFix">
|
||||
</image>
|
||||
</view>
|
||||
<view class="centertxt ">
|
||||
<view class="name" v-text="item.name?item.name:'Unnamed'"></view>
|
||||
<view class="id" v-text="item.deviceId"></view>
|
||||
<view class="name">
|
||||
<text>{{item.name?item.name:'Unnamed'}}</text>
|
||||
|
||||
</view>
|
||||
<view class="id" >
|
||||
<text>信号强度:{{110+item.RSSI>100?100:110+item.RSSI}}%</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="rightIco center">
|
||||
|
||||
|
||||
|
||||
<image :src="isItemLink(item,index)" class="img" mode="aspectFit">
|
||||
</image>
|
||||
</view>
|
||||
@ -154,34 +166,34 @@
|
||||
these = this;
|
||||
ble = bleTool.getBleTool();
|
||||
//已连接过但删除了设备
|
||||
let delArr = ble.data.deletedEqs.map(v => {
|
||||
return {
|
||||
"deviceId": v.deviceId,
|
||||
"name": v.name,
|
||||
"RSSI": -99,
|
||||
"localName": v.name,
|
||||
}
|
||||
});
|
||||
//已连接过但没绑定过的设备
|
||||
let noDev = ble.data.LinkedList.filter(v => {
|
||||
return !(v.device && v.device.id);
|
||||
}).map(v => {
|
||||
return {
|
||||
"deviceId": v.deviceId,
|
||||
"name": v.name,
|
||||
"RSSI": -99,
|
||||
"localName": v.name,
|
||||
}
|
||||
});
|
||||
delArr = delArr.concat(noDev);
|
||||
// let delArr = ble.data.deletedEqs.map(v => {
|
||||
// return {
|
||||
// "deviceId": v.deviceId,
|
||||
// "name": v.name,
|
||||
// "RSSI": -99,
|
||||
// "localName": v.name,
|
||||
// }
|
||||
// });
|
||||
// //已连接过但没绑定过的设备
|
||||
// let noDev = ble.data.LinkedList.filter(v => {
|
||||
// return !(v.device && v.device.id);
|
||||
// }).map(v => {
|
||||
// return {
|
||||
// "deviceId": v.deviceId,
|
||||
// "name": v.name,
|
||||
// "RSSI": -99,
|
||||
// "localName": v.name,
|
||||
// }
|
||||
// });
|
||||
// delArr = delArr.concat(noDev);
|
||||
|
||||
console.log("可能搜不到的设备=", delArr);
|
||||
this.EquipMents = delArr;
|
||||
// console.log("可能搜不到的设备=", delArr);
|
||||
this.EquipMents = []; //delArr;
|
||||
|
||||
|
||||
|
||||
ble.addDeviceFound((arr) => {
|
||||
// console.log("发现新设备,",arr);
|
||||
|
||||
arr = arr.devices;
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
|
||||
@ -190,15 +202,18 @@
|
||||
continue;
|
||||
}
|
||||
|
||||
let f = these.EquipMents.find(function(v) {
|
||||
return v.deviceId == arr[i].deviceId;
|
||||
let f = these.EquipMents.find((v, index) => {
|
||||
if (v.deviceId == arr[i].deviceId) {
|
||||
// v.RSSI=arr[i].RSSI;//同一设备上报更新信号强度
|
||||
these.$set(these.EquipMents[index], 'RSSI', arr[i].RSSI);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
if (!f) {
|
||||
if (arr[i].deviceId == '35:06:00:EF:46:51') {
|
||||
console.log("EquipMents=", these.EquipMents);
|
||||
console.log("arr[i]=", arr[i]);
|
||||
}
|
||||
console.log("发现新设备,", arr[i]);
|
||||
arr[i].name=arr[i].name.replace('JQZM-','');
|
||||
these.EquipMents.push(arr[i]);
|
||||
} else {
|
||||
|
||||
@ -237,7 +252,7 @@
|
||||
|
||||
// this.EquipMents = [];
|
||||
|
||||
this.PairEquip = [];
|
||||
// this.PairEquip = [];
|
||||
ble && ble.StartSearch().then(res => {
|
||||
console.log("开始搜索成功", res);
|
||||
}).catch((ex) => {
|
||||
@ -248,6 +263,23 @@
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
refreshBleList() {
|
||||
if (!ble) {
|
||||
return;
|
||||
}
|
||||
console.log("111111");
|
||||
ble.StopSearch().then(res => {
|
||||
console.log("停止搜索成功");
|
||||
this.EquipMents = [];
|
||||
ble.StartSearch().then(result => {
|
||||
console.log("开始搜索成功");
|
||||
}).catch(err => {
|
||||
console.log("err=", err);
|
||||
});
|
||||
}).catch(ex => {
|
||||
console.log("ex=", ex);
|
||||
});
|
||||
},
|
||||
isItemLink: function(item, index) {
|
||||
let src = '/static/images/BLEAdd/noLink.png';
|
||||
|
||||
@ -458,7 +490,7 @@
|
||||
}
|
||||
|
||||
.content {
|
||||
background-color: #1d1d1d;
|
||||
background-color: #121212;
|
||||
color: #ffffffde;
|
||||
box-sizing: border-box;
|
||||
overflow: hidden;
|
||||
@ -533,6 +565,7 @@
|
||||
.animate .titleIco {
|
||||
width: 36rpx;
|
||||
height: 36rpx;
|
||||
|
||||
}
|
||||
|
||||
.circle {
|
||||
@ -542,7 +575,7 @@
|
||||
animation: expand 4s infinite ease-out;
|
||||
display: inline-block;
|
||||
transform: translate(-50%, -50%);
|
||||
|
||||
border:1rpx solid #bbe6003d;
|
||||
}
|
||||
|
||||
.circle:nth-child(2) {
|
||||
@ -561,7 +594,7 @@
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
100% {
|
||||
width: 18.75rem;
|
||||
@ -575,10 +608,10 @@
|
||||
padding: 30rpx;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
height: calc(100% - 400rpx);
|
||||
height: calc(100% - 300rpx);
|
||||
overflow-y: scroll;
|
||||
position: absolute;
|
||||
top: 400rpx;
|
||||
top: 300rpx;
|
||||
left: 0rpx;
|
||||
}
|
||||
|
||||
@ -594,6 +627,13 @@
|
||||
width: 100%;
|
||||
height: 28rpx;
|
||||
line-height: 28rpx;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
align-content: center;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.list {
|
||||
@ -608,9 +648,10 @@
|
||||
|
||||
.list .item {
|
||||
width: 100%;
|
||||
height: 120rpx;
|
||||
min-height: 120rpx;
|
||||
height: auto;
|
||||
box-sizing: border-box;
|
||||
padding: 30rpx;
|
||||
padding: 20rpx;
|
||||
border-radius: 8px;
|
||||
background: #1a1a1a;
|
||||
display: flex;
|
||||
@ -627,7 +668,7 @@
|
||||
}
|
||||
|
||||
.list .item .centertxt {
|
||||
width: calc(100% - 150rpx);
|
||||
width: calc(100% - 100rpx);
|
||||
height: 100%;
|
||||
padding-left: 10rpx;
|
||||
display: flex;
|
||||
@ -640,14 +681,21 @@
|
||||
}
|
||||
|
||||
.list .item .rightIco {
|
||||
width: 50rpx;
|
||||
width: 40rpx;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
align-content: center;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
|
||||
.list .item .leftImg .titleIco {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
filter:invert(100%);
|
||||
}
|
||||
|
||||
.list .item .name {
|
||||
@ -662,7 +710,7 @@
|
||||
.list .item .id {
|
||||
color: #ffffff99;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 24rpx;
|
||||
font-size: 26rpx;
|
||||
font-weight: 400;
|
||||
line-height: 36rpx;
|
||||
text-align: left;
|
||||
@ -670,8 +718,8 @@
|
||||
|
||||
|
||||
.list .item .rightIco .img {
|
||||
width: 45rpx;
|
||||
height: 45rpx;
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
}
|
||||
|
||||
.openBlue {
|
||||
|
||||
@ -23,58 +23,59 @@
|
||||
<view class="Sendmessage" @click="location">位置</view>
|
||||
<view class="Sendmessage" @click="handleSend">发送信息</view>
|
||||
</view>
|
||||
<mescroll-uni v-if="deviceList.length > 0" class="device-list" @init="mescrollInit" @down="downCallback" @up="upCallback" :up="upOption"
|
||||
:down="downOption" :fixed="false">
|
||||
<uni-swipe-action ref="swipeAction">
|
||||
<block v-for="(item, index) in deviceList" :key="index" :ref="'swipeItem_' + index">
|
||||
<uni-swipe-action-item :right-options="Options"
|
||||
@click="handleSwipeClick($event, item, index)" class="device-card"
|
||||
:style="{ border: item.communicationMode == 0 && item.onlineStatus == 1 && item.alarmStatus == 1 ? '1px solid rgba(224, 52, 52, 1)' : 'none' }">
|
||||
<view @click.stop="handleFile(item)">
|
||||
<view class="device-header">
|
||||
<view class="deviceIMG">
|
||||
<image :src="item.devicePic" class="IMG" mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="device-name">
|
||||
<view>设备:{{ item.deviceName }}</view>
|
||||
<view class="ID">
|
||||
<view class="ID" v-if="item.communicationMode == 0">ID:{{
|
||||
item.deviceImei }}
|
||||
</view>
|
||||
<view class="ID" v-else>ID:{{ item.deviceMac }}</view>
|
||||
<!-- 在线状态 -->
|
||||
<view class="onlines"
|
||||
v-if="item.communicationMode == 0 && item.onlineStatus == 1">在线
|
||||
</view>
|
||||
<!-- 离线状态 -->
|
||||
<view class="offlines"
|
||||
v-if="item.communicationMode == 0 && item.onlineStatus == 0">离线
|
||||
</view>
|
||||
<view class="offlines"
|
||||
v-if="item.communicationMode == 0 && item.onlineStatus == 2">故障
|
||||
</view>
|
||||
<view>电量:{{ item.battery || '0' }}%</view>
|
||||
</view>
|
||||
</view>
|
||||
<mescroll-uni v-if="deviceList.length > 0" class="device-list" @init="mescrollInit" @down="downCallback"
|
||||
@up="upCallback" :up="upOption" :down="downOption" :fixed="false"
|
||||
:style="{ height: mescrollHeight + 'px' }">
|
||||
<uni-swipe-action ref="swipeAction">
|
||||
<block v-for="(item, index) in deviceList" :key="index" :ref="'swipeItem_' + index">
|
||||
<uni-swipe-action-item :right-options="Options" @click="handleSwipeClick($event, item, index)"
|
||||
class="device-card"
|
||||
:style="{ border: item.communicationMode == 0 && item.onlineStatus == 1 && item.alarmStatus == 1 ? '1px solid rgba(224, 52, 52, 1)' : 'none' }">
|
||||
<view @click.stop="handleFile(item)">
|
||||
<view class="device-header">
|
||||
<view class="deviceIMG">
|
||||
<image :src="item.devicePic" class="IMG" mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="device-callpolice"
|
||||
v-if="item.communicationMode == 0 && item.onlineStatus == 1 && item.alarmStatus == 1">
|
||||
报警中</view>
|
||||
<view v-if="item.communicationMode == 1">
|
||||
<view class="device-status online">已连接</view>
|
||||
<view class="device-status unline">未连接</view>
|
||||
<view class="device-name">
|
||||
<view>设备:{{ item.deviceName }}</view>
|
||||
<view class="ID">
|
||||
<view class="ID" v-if="item.communicationMode == 0">ID:{{
|
||||
item.deviceImei }}
|
||||
</view>
|
||||
<view class="ID" v-else>ID:{{ item.deviceMac }}</view>
|
||||
<!-- 在线状态 -->
|
||||
<view class="onlines"
|
||||
v-if="item.communicationMode == 0 && item.onlineStatus == 1">在线
|
||||
</view>
|
||||
<!-- 离线状态 -->
|
||||
<view class="offlines"
|
||||
v-if="item.communicationMode == 0 && item.onlineStatus == 0">离线
|
||||
</view>
|
||||
<view class="offlines"
|
||||
v-if="item.communicationMode == 0 && item.onlineStatus == 2">故障
|
||||
</view>
|
||||
<view>电量:{{ item.battery || '0' }}%</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<image src="/static/images/common/cires.png" class="circle" mode="aspectFit"></image>
|
||||
</uni-swipe-action-item>
|
||||
</block>
|
||||
</uni-swipe-action>
|
||||
<!-- 加载状态提示 -->
|
||||
<view class="loading-status">
|
||||
<text v-if="loading">加载中...</text>
|
||||
<text v-if="finished">没有更多数据了</text>
|
||||
</view>
|
||||
|
||||
<view class="device-callpolice"
|
||||
v-if="item.communicationMode == 0 && item.onlineStatus == 1 && item.alarmStatus == 1">
|
||||
报警中</view>
|
||||
<view v-if="item.communicationMode == 1">
|
||||
<view class="device-status online">已连接</view>
|
||||
<view class="device-status unline">未连接</view>
|
||||
</view>
|
||||
</view>
|
||||
<image src="/static/images/common/cires.png" class="circle" mode="aspectFit"></image>
|
||||
</uni-swipe-action-item>
|
||||
</block>
|
||||
</uni-swipe-action>
|
||||
<!-- 加载状态提示 -->
|
||||
<view class="loading-status">
|
||||
<text v-if="loading">加载中...</text>
|
||||
<text v-if="finished">没有更多数据了</text>
|
||||
</view>
|
||||
|
||||
</mescroll-uni>
|
||||
<view v-else class="noDATA">
|
||||
<view> <uni-icons type="image-filled" size="120" color="rgba(255, 255, 255, 0.9)"></uni-icons>
|
||||
@ -210,23 +211,25 @@
|
||||
auto: false
|
||||
},
|
||||
upOption: {
|
||||
auto: false,
|
||||
noMoreSize: 1,
|
||||
offset: 80,
|
||||
empty: {
|
||||
tip: '暂无相关数据'
|
||||
}
|
||||
auto: false,
|
||||
noMoreSize: 0,
|
||||
offset: 50,
|
||||
isLock: false,
|
||||
empty: {
|
||||
tip: '暂无数据',
|
||||
hideScroll: false
|
||||
}
|
||||
},
|
||||
|
||||
page: 1, // 当前页码
|
||||
size: 10, // 每页条数
|
||||
size: 12, // 每页条数
|
||||
total: 0, // 总数据量
|
||||
loadedCount: 0,
|
||||
loading: false,
|
||||
finished: false,
|
||||
deviceId: '',
|
||||
deviceName: "", //重命名
|
||||
activeTabInfo: ''
|
||||
activeTabInfo: '',
|
||||
mescrollHeight: 0,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@ -237,39 +240,34 @@
|
||||
downCallback() {
|
||||
const currentDeviceType = this.activeTabInfo?.id === '' ? undefined : this.activeTabInfo?.id;
|
||||
const tempList = [...this.deviceList];
|
||||
|
||||
// 重置分页参数
|
||||
this.page = 1;
|
||||
this.finished = false;
|
||||
this.loadedCount = 0;
|
||||
|
||||
this.total = 0; // 重置总数
|
||||
this.getData(currentDeviceType)
|
||||
.then(() => {
|
||||
|
||||
this.mescroll.endDownScroll(true);
|
||||
})
|
||||
.catch(() => {
|
||||
|
||||
this.deviceList = tempList;
|
||||
this.mescroll.endDownScroll(false);
|
||||
});
|
||||
},
|
||||
// 上拉加载
|
||||
upCallback() {
|
||||
// 防止重复加载
|
||||
if (this.finished || this.loading) {
|
||||
if (this.loading) {
|
||||
this.mescroll.endUpScroll(false);
|
||||
return;
|
||||
}
|
||||
const currentDeviceType = this.activeTabInfo?.id === '' ? undefined : this.activeTabInfo?.id;
|
||||
this.getData(currentDeviceType)
|
||||
.then(() => {
|
||||
const hasMore = this.loadedCount < this.total;
|
||||
console.log(`上拉加载 - 已加载: ${this.loadedCount}, 总数: ${this.total}, 是否还有更多: ${hasMore}`);
|
||||
// 如果本次加载的数据量为0,则说明没有更多数据
|
||||
const hasMore = this.deviceList.length > 0 && this.deviceList.length % this.size === 0;
|
||||
this.mescroll.endUpScroll(hasMore);
|
||||
})
|
||||
.catch(() => {
|
||||
// 失败时回退页码
|
||||
this.page--;
|
||||
this.mescroll.endUpScroll(false);
|
||||
});
|
||||
@ -332,53 +330,48 @@
|
||||
this.page = 1;
|
||||
this.finished = false;
|
||||
this.loadedCount = 0;
|
||||
|
||||
this.total = 0; // 重置总数
|
||||
const deviceType = tab.id === '' ? undefined : tab.id;
|
||||
this.$nextTick(() => {
|
||||
this.getSystemInfoSyncH();
|
||||
});
|
||||
this.getData(deviceType);
|
||||
|
||||
if (this.mescroll) {
|
||||
this.mescroll.resetUpScroll();
|
||||
}
|
||||
},
|
||||
// 获取设备列表 - 核心修复
|
||||
// 获取设备列表
|
||||
getData(deviceType = '') {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.loading || this.finished) {
|
||||
reject('正在加载或已无更多数据');
|
||||
return;
|
||||
}
|
||||
|
||||
this.loading = true;
|
||||
let data = {
|
||||
pageNum: this.page,
|
||||
pageSize: this.size,
|
||||
deviceType: deviceType
|
||||
}
|
||||
|
||||
deviceInfo(data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
// 第一页加载时初始化总数据量
|
||||
if (this.page === 1) {
|
||||
this.total = res.total;
|
||||
this.loadedCount = 0; // 重置计数
|
||||
console.log(`第1页加载 - 总数据量: ${this.total}`);
|
||||
}
|
||||
const newDevices = res.rows.map(device => ({
|
||||
...device,
|
||||
showConfirm: false
|
||||
}));
|
||||
this.loadedCount += newDevices.length;
|
||||
console.log(`第${this.page}页加载 - 新增: ${newDevices.length}, 累计: ${this.loadedCount}`);
|
||||
// 数据累加
|
||||
if (this.page === 1) {
|
||||
this.total = Number(res.total) || 0;
|
||||
this.deviceList = newDevices;
|
||||
this.loadedCount = newDevices.length;
|
||||
} else {
|
||||
this.deviceList = [...this.deviceList, ...newDevices];
|
||||
this.loadedCount += newDevices.length;
|
||||
}
|
||||
// 判断是否加载完成
|
||||
if (this.loadedCount >= this.total || newDevices.length < this.size) {
|
||||
const hasMoreData = this.loadedCount < this.total;
|
||||
if (!hasMoreData) {
|
||||
this.finished = true;
|
||||
} else {
|
||||
}
|
||||
if (hasMoreData) {
|
||||
this.page++;
|
||||
}
|
||||
resolve();
|
||||
@ -565,7 +558,8 @@
|
||||
onIntall() {
|
||||
this.page = 1;
|
||||
this.finished = false;
|
||||
this.loadedCount = 0; // 重置计数
|
||||
this.loadedCount = 0;
|
||||
this.total = 0;
|
||||
const deviceType = this.activeTabInfo?.id === '' ? undefined : this.activeTabInfo?.id;
|
||||
this.getData(deviceType);
|
||||
setTimeout(() => {
|
||||
@ -595,8 +589,19 @@
|
||||
})
|
||||
.filter(Boolean);
|
||||
},
|
||||
// 动态计算屏幕高度
|
||||
getSystemInfoSyncH() {
|
||||
const sysInfo = uni.getSystemInfoSync();
|
||||
const tabBarHeight = 80;
|
||||
const sendBarHeight = 60;
|
||||
const padding = 60;
|
||||
const totalTopHeight = (this.navBarHeight) + (tabBarHeight + sendBarHeight + padding) * (sysInfo
|
||||
.screenWidth / 750);
|
||||
this.mescrollHeight = sysInfo.screenHeight - totalTopHeight;
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.getSystemInfoSyncH()
|
||||
this.getTab()
|
||||
this.onIntall()
|
||||
uni.$on('refreshDeviceList', () => {
|
||||
@ -975,4 +980,4 @@
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.3 KiB |
BIN
static/images/BLEAdd/bluetooth.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
@ -453,7 +453,7 @@ class BleHelper {
|
||||
|
||||
uni.openBluetoothAdapter({
|
||||
success: (args) => {
|
||||
// console.log("蓝牙初始化成功:" + JSON.stringify(args));
|
||||
console.log("蓝牙初始化成功:" + JSON.stringify(args));
|
||||
this.data.isOpenBlue = true;
|
||||
this.data.available = true;
|
||||
resolve(true);
|
||||
@ -461,7 +461,7 @@ class BleHelper {
|
||||
if (this.data.isSubscribe) { //整个App生命周期,只订阅一次
|
||||
return;
|
||||
}
|
||||
// console.log("开始订阅各类变化消息");
|
||||
console.log("开始订阅各类变化消息");
|
||||
this.data.isSubscribe = true;
|
||||
|
||||
|
||||
@ -519,14 +519,29 @@ class BleHelper {
|
||||
}
|
||||
});
|
||||
|
||||
uni.onBluetoothDeviceFound((devices) => {
|
||||
uni.onBluetoothDeviceFound((res) => {
|
||||
// console.log("发现新设备:" + JSON.stringify(devices));
|
||||
let arr=[];
|
||||
for (var i = 0; i < res.devices.length; i++) {
|
||||
let item = res.devices[i];
|
||||
let f=serviceDic.find(v=>{
|
||||
return item.advertisServiceUUIDs.includes(v.serviceId);
|
||||
});
|
||||
if(f){
|
||||
arr.push(item);
|
||||
}
|
||||
|
||||
}
|
||||
if(arr.length===0){
|
||||
return;
|
||||
}
|
||||
res.devices=arr;
|
||||
this.data.searchList = this.data.searchList.concat(
|
||||
devices);
|
||||
res);
|
||||
if (this.cfg.onDeviceFound) {
|
||||
if (this.cfg.onDeviceFound.length > 0) {
|
||||
this.cfg.onDeviceFound.forEach((found) => {
|
||||
found.callback(devices);
|
||||
found.callback(res);
|
||||
});
|
||||
}
|
||||
|
||||
@ -779,19 +794,40 @@ class BleHelper {
|
||||
|
||||
//停止搜索
|
||||
StopSearch() {
|
||||
return new Promise((resolve, reject) => {
|
||||
let p1= new Promise((resolve, reject) => {
|
||||
uni.stopBluetoothDevicesDiscovery({
|
||||
success: (res) => {
|
||||
//console.log("停止搜索蓝牙设备成功");
|
||||
console.log("停止搜索蓝牙设备成功");
|
||||
resolve();
|
||||
},
|
||||
fail: (ex) => {
|
||||
//console.log("无法停止蓝牙搜索");
|
||||
console.log("无法停止蓝牙搜索");
|
||||
|
||||
reject(this.getError(ex));
|
||||
}
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
let p2 = new Promise((succ, err) => {
|
||||
setTimeout(() => {
|
||||
err({
|
||||
code: -1
|
||||
});
|
||||
}, 50);
|
||||
});
|
||||
|
||||
|
||||
return new Promise((resolve,reject)=>{
|
||||
Promise.race([p1,p2]).then(resolve).catch(ex=>{
|
||||
if (ex.code == -1) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
reject(ex);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
//获取已连接的设备
|
||||
|
||||
@ -12,26 +12,25 @@ function checkAndUpdateWgt(updateUrl) {
|
||||
}
|
||||
// 显示加载提示
|
||||
|
||||
let urls = ['http://114.55.111.217/app/CheckUpdate', 'https://t3v3e2xsjv.by.takin.cc/app/CheckUpdate'];
|
||||
|
||||
|
||||
|
||||
let urls = ['https://dmsapp.skf.com.cn/HummerService/app/CheckUpdate'];
|
||||
|
||||
// 1. 获取当前应用版本信息
|
||||
plus.runtime.getProperty(plus.runtime.appid, (widgetInfo) => {
|
||||
const currentVersion = widgetInfo.version;
|
||||
console.log("当前版本:" + currentVersion);
|
||||
|
||||
|
||||
|
||||
|
||||
let callbck = (res) => {
|
||||
let flag = false;
|
||||
uni.hideLoading();
|
||||
// console.log("检查更新成功=", res)
|
||||
console.log("检查更新成功=", res)
|
||||
if (res.statusCode === 200) {
|
||||
|
||||
|
||||
const updateInfo = res.data.data;
|
||||
if (!updateInfo.hasUpdate) {
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
flag = true;
|
||||
// 3. 显示更新提示
|
||||
uni.showModal({
|
||||
title: '检测到更新',
|
||||
@ -45,16 +44,14 @@ function checkAndUpdateWgt(updateUrl) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '当前已是最新版本',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
console.log('当前已是最新版本');
|
||||
}
|
||||
|
||||
return flag;
|
||||
};
|
||||
|
||||
|
||||
let Update = (url) => {
|
||||
console.log("url=",url);
|
||||
console.log("url=", url);
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.request({
|
||||
url: url,
|
||||
@ -62,42 +59,57 @@ function checkAndUpdateWgt(updateUrl) {
|
||||
data: {
|
||||
currentVersion: currentVersion,
|
||||
platform: uni.getSystemInfoSync().platform,
|
||||
appId:"xhyc"
|
||||
appId: "xhyc"
|
||||
},
|
||||
success: (res) => {
|
||||
// console.log("res=>",res)
|
||||
res.type='1';
|
||||
resolve(res);
|
||||
if (res.statusCode === 200) {
|
||||
res.type = '1';
|
||||
resolve(res);
|
||||
} else {
|
||||
reject(res);
|
||||
}
|
||||
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log("err=",err);
|
||||
console.log("err=", err);
|
||||
reject(err);
|
||||
},
|
||||
complete:()=>{
|
||||
complete: () => {
|
||||
console.log("complete");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
let Callback1 = (res) => {
|
||||
console.log("检查版本更新:", res);
|
||||
let os = plus.os.name.toLowerCase();
|
||||
|
||||
let flag = false;
|
||||
if (res.code != 200) {
|
||||
return;
|
||||
return flag;
|
||||
}
|
||||
let f = res.data.find(v => {
|
||||
|
||||
if (v.dictLabel.toLowerCase() == os) {
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
console.log("f=", f)
|
||||
if (f) {
|
||||
if (f.dictValue == currentVersion) {
|
||||
flag = false;
|
||||
return flag;
|
||||
}
|
||||
if(!f.dictValue || !f.remark){
|
||||
flag=false;
|
||||
return;
|
||||
}
|
||||
|
||||
flag = true;
|
||||
uni.showModal({
|
||||
title: '检测到更新',
|
||||
content: '当前版本“' + currentVersion + '”,发现新版本“' + f.dictValue + '”,是否立即更新?',
|
||||
@ -109,17 +121,20 @@ function checkAndUpdateWgt(updateUrl) {
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
flag = false;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
||||
let Update1 = () => {
|
||||
return request({
|
||||
url: '/app/auth/version',
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
let promises = [];
|
||||
for (var i = 0; i < urls.length; i++) {
|
||||
promises.push(Update(urls[i]));
|
||||
@ -128,25 +143,25 @@ function checkAndUpdateWgt(updateUrl) {
|
||||
|
||||
Promise.allSettled(promises).then(results => {
|
||||
let length = results.length;
|
||||
let flag=false;
|
||||
let flag = false;
|
||||
for (var i = 0; i < length; i++) {
|
||||
console.log('results['+i+']=',results[i]);
|
||||
if (results[i].status == 'fulfilled' && results[i].value.type==='1' && !flag ) {
|
||||
flag=true;
|
||||
callbck(results[i].value)
|
||||
|
||||
console.log('results[' + i + ']=', results[i]);
|
||||
if (results[i].status == 'fulfilled' && results[i].value.type === '1' && !flag) {
|
||||
if (results[i].value.statusCode === 200) {
|
||||
flag = callbck(results[i].value)
|
||||
}
|
||||
// break;
|
||||
}
|
||||
|
||||
if(results[i].status == 'fulfilled' && results[i].value.type!=='1' && !flag){
|
||||
flag=true;
|
||||
Callback1(results[i].value);
|
||||
|
||||
if (results[i].status == 'fulfilled' && results[i].value.type !== '1' && !flag) {
|
||||
|
||||
flag = Callback1(results[i].value);
|
||||
// break;
|
||||
}
|
||||
}
|
||||
if(!flag){
|
||||
if (!flag) {
|
||||
console.log("检查更新失败了");
|
||||
}else{
|
||||
} else {
|
||||
console.log("检查更新成功");
|
||||
}
|
||||
});
|
||||
|
||||
122
utils/wgs84_to_gcj02.js
Normal file
@ -0,0 +1,122 @@
|
||||
|
||||
//地标 转 国测 常量
|
||||
var x_PI = (3.14159265358979324 * 3000.0) / 180.0;
|
||||
var PI = 3.1415926535897932384626;
|
||||
var a = 6378245.0; //卫星椭球坐标投影到平面地图坐标系的投影因子。
|
||||
var ee = 0.00669342162296594323; //椭球的偏心率。
|
||||
|
||||
|
||||
//判断是否在国内,在中国国内的经纬度才需要做偏移
|
||||
function out_of_china(lng, lat) {
|
||||
return (
|
||||
lng < 72.004 ||
|
||||
lng > 137.8347 ||
|
||||
(lat < 0.8293 || lat > 55.8271 || false)
|
||||
);
|
||||
}
|
||||
|
||||
//转化经度
|
||||
function transformlng(lng, lat) {
|
||||
var ret =
|
||||
300.0 +
|
||||
lng +
|
||||
2.0 * lat +
|
||||
0.1 * lng * lng +
|
||||
0.1 * lng * lat +
|
||||
0.1 * Math.sqrt(Math.abs(lng));
|
||||
ret +=
|
||||
((20.0 * Math.sin(6.0 * lng * PI) +
|
||||
20.0 * Math.sin(2.0 * lng * PI)) *
|
||||
2.0) /
|
||||
3.0;
|
||||
ret +=
|
||||
((20.0 * Math.sin(lng * PI) +
|
||||
40.0 * Math.sin((lng / 3.0) * PI)) *
|
||||
2.0) /
|
||||
3.0;
|
||||
ret +=
|
||||
((150.0 * Math.sin((lng / 12.0) * PI) +
|
||||
300.0 * Math.sin((lng / 30.0) * PI)) *
|
||||
2.0) /
|
||||
3.0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
//转化纬度
|
||||
function transformlat(lng, lat) {
|
||||
var ret =
|
||||
-100.0 +
|
||||
2.0 * lng +
|
||||
3.0 * lat +
|
||||
0.2 * lat * lat +
|
||||
0.1 * lng * lat +
|
||||
0.2 * Math.sqrt(Math.abs(lng));
|
||||
ret +=
|
||||
((20.0 * Math.sin(6.0 * lng * PI) +
|
||||
20.0 * Math.sin(2.0 * lng * PI)) *
|
||||
2.0) /
|
||||
3.0;
|
||||
ret +=
|
||||
((20.0 * Math.sin(lat * PI) +
|
||||
40.0 * Math.sin((lat / 3.0) * PI)) *
|
||||
2.0) /
|
||||
3.0;
|
||||
ret +=
|
||||
((160.0 * Math.sin((lat / 12.0) * PI) +
|
||||
320 * Math.sin((lat * PI) / 30.0)) *
|
||||
2.0) /
|
||||
3.0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
//wgs84 to gcj02 地球坐标系 转 火星坐标系
|
||||
function wgs84_to_gcj02(lng, lat) {
|
||||
if (out_of_china(lng, lat)) {
|
||||
return [lng, lat];
|
||||
} else {
|
||||
var dlat = transformlat(lng - 105.0, lat - 35.0);
|
||||
var dlng = transformlng(lng - 105.0, lat - 35.0);
|
||||
var radlat = (lat / 180.0) * PI;
|
||||
var magic = Math.sin(radlat);
|
||||
magic = 1 - ee * magic * magic;
|
||||
var sqrtmagic = Math.sqrt(magic);
|
||||
dlat =
|
||||
(dlat * 180.0) /
|
||||
(((a * (1 - ee)) / (magic * sqrtmagic)) * PI);
|
||||
dlng =
|
||||
(dlng * 180.0) / ((a / sqrtmagic) * Math.cos(radlat) * PI);
|
||||
var mglat = lat + dlat;
|
||||
var mglng = lng + dlng;
|
||||
|
||||
return [mglng, mglat];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//gcj02 to wgs84 火星坐标系 转 地球坐标系
|
||||
function gcj02_to_wgs84(lng, lat) {
|
||||
if (out_of_china(lng, lat)) {
|
||||
return [lng, lat]
|
||||
}
|
||||
else {
|
||||
var dlat = transformlat(lng - 105.0, lat - 35.0);
|
||||
var dlng = transformlng(lng - 105.0, lat - 35.0);
|
||||
var radlat = lat / 180.0 * PI;
|
||||
var magic = Math.sin(radlat);
|
||||
magic = 1 - ee * magic * magic;
|
||||
var sqrtmagic = Math.sqrt(magic);
|
||||
dlat = (dlat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * PI);
|
||||
dlng = (dlng * 180.0) / (a / sqrtmagic * Math.cos(radlat) * PI);
|
||||
var mglat = lat + dlat;
|
||||
var mglng = lng + dlng;
|
||||
return [lng * 2 - mglng, lat * 2 - mglat]
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
gcj02_to_wgs84,
|
||||
wgs84_to_gcj02
|
||||
}
|
||||
|
||||
|
||||
|
||||