完成008A功能开发
This commit is contained in:
75
pages/common/Msgs/deviceMsg.vue
Normal file
75
pages/common/Msgs/deviceMsg.vue
Normal file
@ -0,0 +1,75 @@
|
||||
<template>
|
||||
<view class="maincontent contentBg">
|
||||
<view>通知标题:{{payload.title}}</view>
|
||||
<view>设备信息:{{device.deviceName}}</view>
|
||||
<view>Mac地址:{{device.deviceMac}}</view>
|
||||
<view>设备IMEI:{{device.deviceImei}}</view>
|
||||
<view>通知详情:{{payload.content}}</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {deviceInfo} from '@/api/common/index.js';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
payload: {
|
||||
device_mac: '',
|
||||
device_imei: '',
|
||||
content: '',
|
||||
title: ''
|
||||
},
|
||||
device: {
|
||||
"id": "",
|
||||
"deviceName": "",
|
||||
"deviceImei": "",
|
||||
"deviceMac": "",
|
||||
"communicationMode": null,
|
||||
"devicePic": "",
|
||||
"typeName": "",
|
||||
"bluetoothName": "",
|
||||
"deviceStatus": null,
|
||||
"bindingTime": "",
|
||||
"onlineStatus": null,
|
||||
"battery": "",
|
||||
"latitude": "",
|
||||
"longitude": "",
|
||||
"alarmStatus": null,
|
||||
"detailPageUrl": ""
|
||||
}
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
var eventChannel = this.getOpenerEventChannel();
|
||||
|
||||
eventChannel.on('pushMsg', (res) => {
|
||||
this.payload.content = res.data.content;
|
||||
this.payload.title = res.data.payload.title;
|
||||
this.payload.device_mac = res.data.payload.device_mac;
|
||||
this.payload.device_imei = res.data.payload.device_imei;
|
||||
|
||||
this.getDevice();
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
getDevice() {
|
||||
deviceInfo({
|
||||
pageNum: 1,
|
||||
pageSize: 1,
|
||||
deviceMac: this.payload.device_mac
|
||||
}).then(res => {
|
||||
if (res.code == 200) {
|
||||
if (res.rows && res.rows.length) {
|
||||
let device=res.rows[0];
|
||||
this.device=device;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
@ -2,7 +2,7 @@
|
||||
<view class="content">
|
||||
<view class="deviceDetail">
|
||||
<view class="imgContent">
|
||||
<image src="/static/images/BLEAdd/addBleDevice.png" class="titleIco" mode="aspectFit">
|
||||
<image src="/static/images/common/svg.png" class="titleIco" mode="aspectFit">
|
||||
</image>
|
||||
</view>
|
||||
<view class="deviceName">
|
||||
@ -46,7 +46,7 @@
|
||||
var these = null;
|
||||
var eventChannel = null;
|
||||
var ble = null;
|
||||
var inteval=null;
|
||||
var inteval = null;
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@ -54,8 +54,8 @@
|
||||
bound: null,
|
||||
timeInteval: null,
|
||||
isSearch: false,
|
||||
pageHide:false,
|
||||
isBind:false
|
||||
pageHide: false,
|
||||
isBind: false
|
||||
},
|
||||
device: {
|
||||
"deviceId": "",
|
||||
@ -72,9 +72,9 @@
|
||||
"imei": ""
|
||||
},
|
||||
serverDevice: null,
|
||||
groupid:null,
|
||||
typeList:[],
|
||||
uploadStatu:null
|
||||
groupid: null,
|
||||
typeList: [],
|
||||
uploadStatu: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -110,54 +110,54 @@
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
return "找到有效设备"
|
||||
|
||||
|
||||
|
||||
return "找到有效设备"
|
||||
|
||||
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
this.Statu.pageHide=false;
|
||||
this.Statu.pageHide = false;
|
||||
},
|
||||
onHide() {
|
||||
this.Statu.pageHide=true;
|
||||
this.Statu.pageHide = true;
|
||||
},
|
||||
onUnload() {
|
||||
console.log("返回取消订阅");
|
||||
clearInterval(inteval);
|
||||
ble.removeAllCallback(pagePath);
|
||||
clearTimeout(this.Statu.timeInteval);
|
||||
this.uploadStatu=null;
|
||||
if(!this.Statu.isBind && these.device.deviceId){
|
||||
ble.disconnectDevice(these.device.deviceId).catch(ex=>{
|
||||
this.uploadStatu = null;
|
||||
if (!this.Statu.isBind && these.device.deviceId) {
|
||||
ble.disconnectDevice(these.device.deviceId).catch(ex => {
|
||||
console.error("无法断开蓝牙连接");
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
onLoad(option) {
|
||||
these = this;
|
||||
this.groupid=new Date().getTime()+"";
|
||||
|
||||
this.groupid = new Date().getTime() + "";
|
||||
|
||||
ble = bleTool.getBleTool();
|
||||
|
||||
ble.addStateBreakCallback(res => {
|
||||
if(this.Statu.pageHide){
|
||||
if (this.Statu.pageHide) {
|
||||
return;
|
||||
}
|
||||
these.device.linkStatu = false;
|
||||
hideLoading(these);
|
||||
uni.showToast({
|
||||
icon:'fail',
|
||||
title:'蓝牙已不可用'
|
||||
icon: 'fail',
|
||||
title: '蓝牙已不可用'
|
||||
})
|
||||
},pagePath);
|
||||
|
||||
}, pagePath);
|
||||
|
||||
ble.addStateRecoveryCallback(res => {
|
||||
if(this.Statu.pageHide){
|
||||
if (this.Statu.pageHide) {
|
||||
return;
|
||||
}
|
||||
if (these.device.deviceId) {
|
||||
@ -167,9 +167,9 @@
|
||||
|
||||
these.reLinkdevice();
|
||||
}
|
||||
},pagePath);
|
||||
}, pagePath);
|
||||
ble.addDisposeCallback(res => {
|
||||
if(this.Statu.pageHide){
|
||||
if (this.Statu.pageHide) {
|
||||
return;
|
||||
}
|
||||
console.log("处理蓝牙断开连接");
|
||||
@ -181,59 +181,56 @@
|
||||
});
|
||||
these.reLinkdevice();
|
||||
}
|
||||
},pagePath);
|
||||
}, pagePath);
|
||||
|
||||
ble.addReceiveCallback((receive, f, path) => {
|
||||
if(this.Statu.pageHide){
|
||||
if (this.Statu.pageHide) {
|
||||
return;
|
||||
}
|
||||
console.log("收到设备消息,", receive);
|
||||
if (these.device.deviceId == receive.deviceId) {
|
||||
console.log("11111:", receive);
|
||||
these.device.imei = f.imei;
|
||||
let flag=false;
|
||||
if (receive.bytes && receive.bytes.length && receive.bytes[0] == 0xFC) {//6155 7305
|
||||
let flag = false;
|
||||
if (receive.bytes && receive.bytes.length && receive.bytes[0] == 0xFC) { //6155 7305
|
||||
if (f && f.macAddress) {
|
||||
flag=true;
|
||||
}
|
||||
}
|
||||
else if(receive.str.indexOf('mac address:') == 0){//650 670
|
||||
flag = true;
|
||||
}
|
||||
} else if (receive.str.indexOf('mac address:') == 0) { //650 670
|
||||
if (f && f.macAddress) {
|
||||
flag=true;
|
||||
}
|
||||
}
|
||||
else{
|
||||
try{
|
||||
console.log("str=",receive.str)
|
||||
let json=JSON.parse(receive.str);
|
||||
let key = "sta_address";
|
||||
if (key in json) {//100
|
||||
flag = true;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
console.log("str=", receive.str)
|
||||
let json = JSON.parse(receive.str);
|
||||
let key = "sta_address";
|
||||
if (key in json) { //100
|
||||
if (f && f.macAddress) {
|
||||
flag=true;
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
}catch(err){
|
||||
console.log("出现异常,",err);
|
||||
} catch (err) {
|
||||
console.log("出现异常,", err);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(flag){
|
||||
|
||||
|
||||
if (flag) {
|
||||
these.device.macAddress = f.macAddress;
|
||||
console.log("222222");
|
||||
these.Statu.isSearch = false;
|
||||
these.initDevice();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}, pagePath);
|
||||
eventChannel = this.getOpenerEventChannel();
|
||||
|
||||
if(option.mac){
|
||||
this.device.macAddress=option.mac;
|
||||
|
||||
if (option.mac) {
|
||||
this.device.macAddress = option.mac;
|
||||
these.initDevice();
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
eventChannel.on('LinkItem', function(data) {
|
||||
console.log("data=", data);
|
||||
let f = ble.data.LinkedList.find((v) => {
|
||||
@ -244,126 +241,140 @@
|
||||
keys.forEach((v, index) => {
|
||||
these.device[v] = f[v];
|
||||
})
|
||||
these.device.name = data.name;
|
||||
// console.log("LinkedList=", ble.data.LinkedList)
|
||||
// console.log("f=", f);
|
||||
// console.log("获取到设备", these.device);
|
||||
console.log("获取到设备", these.device);
|
||||
if (f.macAddress) {
|
||||
these.device.macAddress = f.macAddress;
|
||||
|
||||
|
||||
these.initDevice();
|
||||
}
|
||||
} else {
|
||||
console.log("未获取到设备");
|
||||
}
|
||||
})
|
||||
|
||||
inteval = setInterval(this.initDevice, 10000);
|
||||
|
||||
inteval = setInterval(this.initDevice, 10000);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
},
|
||||
methods: {
|
||||
getDevList() {
|
||||
return new Promise((resolve,reject)=>{
|
||||
return new Promise((resolve, reject) => {
|
||||
let arr = [
|
||||
|
||||
];
|
||||
request({
|
||||
url: '/app/xinghan/device/typeAll',
|
||||
method: 'get'
|
||||
}).then(res => {
|
||||
if (res && res.code == 200) {
|
||||
console.log("获取到类型", res.data);
|
||||
arr = res.data;
|
||||
this.typeList = arr;
|
||||
resolve(arr);
|
||||
return;
|
||||
}
|
||||
reject();
|
||||
|
||||
}).catch(ex => {
|
||||
console.error("获取设备类型列表失败",ex);
|
||||
reject();
|
||||
})
|
||||
});
|
||||
|
||||
},
|
||||
uploadItem() {
|
||||
if(this.uploadStatu!==null){
|
||||
console.error("执行过上传,不再执行");
|
||||
return;
|
||||
}
|
||||
|
||||
this.uploadStatu="start";
|
||||
console.log("开始上传设备");
|
||||
|
||||
let type=this.device.name.toLowerCase();
|
||||
if(type.indexOf("bjq6155-")>-1){//6155特别处理
|
||||
type="xh6155"
|
||||
}
|
||||
if(type.indexOf("bjq6155-")>-1){//6155特别处理
|
||||
type="xh6155"
|
||||
}
|
||||
if(type.indexOf("bjq6075-")>-1){//6075j特别处理
|
||||
bype='bjq6075j';
|
||||
}
|
||||
type=type.replace(/-/g,'');
|
||||
let upload=()=>{
|
||||
let f=this.typeList.find((v,i)=>{
|
||||
if(type.indexOf(v.typeName.replace(/-/g,'').toLowerCase())>-1){
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
if(!f){
|
||||
this.uploadStatu="type is valid";
|
||||
console.error("找不到此类型名称",type);
|
||||
console.error("tpelist=",this.typeList);
|
||||
return;
|
||||
}
|
||||
let json = {
|
||||
"deviceType": f.id,
|
||||
"deviceName": this.device.name,
|
||||
"deviceMac": this.device.macAddress,
|
||||
"bluetoothName": this.device.name,
|
||||
"deviceImei":this.device.imei?this.device.imei:'',
|
||||
"remark": "com.chxhyc.cn auto upload"
|
||||
}
|
||||
|
||||
];
|
||||
request({
|
||||
url: '/app/xinghan/device/add',
|
||||
method: 'post',
|
||||
data: json
|
||||
url: '/app/xinghan/device/typeAll',
|
||||
method: 'get'
|
||||
}).then(res => {
|
||||
if (res && res.code == 200) {
|
||||
this.uploadStatu="success";
|
||||
console.log("上传成功",res);
|
||||
} else {
|
||||
this.uploadStatu="upload error";
|
||||
console.error("上传失败,",res);
|
||||
console.log("获取到类型", res.data);
|
||||
arr = res.data;
|
||||
this.typeList = arr;
|
||||
resolve(arr);
|
||||
return;
|
||||
}
|
||||
reject();
|
||||
|
||||
}).catch(ex => {
|
||||
this.uploadStatu="upload error";
|
||||
console.error("上传失败,",ex);
|
||||
});
|
||||
}
|
||||
|
||||
let exec = () => {
|
||||
|
||||
if(this.typeList.length==0){
|
||||
this.getDevList().then(results=>{
|
||||
upload();
|
||||
}).catch(ex=>{
|
||||
this.uploadStatu="get types error";
|
||||
console.error("获取类型失败,",ex);
|
||||
});
|
||||
}else{
|
||||
upload();
|
||||
console.error("获取设备类型列表失败", ex);
|
||||
reject();
|
||||
})
|
||||
});
|
||||
|
||||
},
|
||||
uploadItem() {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.uploadStatu !== null) {
|
||||
let err = "执行过上传,不再执行";
|
||||
console.error(err);
|
||||
reject(err);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
setTimeout(exec, 10)
|
||||
|
||||
this.uploadStatu = "start";
|
||||
console.log("开始上传设备");
|
||||
|
||||
let type = this.device.name.toLowerCase();
|
||||
|
||||
if (type.indexOf("bjq6155-") > -1) { //6155特别处理
|
||||
type = "xh6155"
|
||||
}
|
||||
if (type.indexOf("bjq6075-") > -1) { //6075j特别处理
|
||||
type = 'bjq6075j';
|
||||
}
|
||||
type = type.replace(/-/g, '');
|
||||
let upload = () => {
|
||||
let f = this.typeList.find((v, i) => {
|
||||
if (type.indexOf(v.typeName.replace(/-/g, '').toLowerCase()) > -1) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
if (!f) {
|
||||
this.uploadStatu = "type is valid";
|
||||
console.error("找不到此类型名称", type);
|
||||
console.error("tpelist=", this.typeList);
|
||||
reject(this.uploadStatu);
|
||||
return;
|
||||
}
|
||||
let json = {
|
||||
"deviceType": f.id,
|
||||
"deviceName": this.device.name,
|
||||
"deviceMac": this.device.macAddress,
|
||||
"bluetoothName": this.device.name,
|
||||
"remark": "com.chxhyc.cn auto upload"
|
||||
}
|
||||
|
||||
if (this.device.imei) {
|
||||
json.deviceImei = this.device.imei;
|
||||
}
|
||||
request({
|
||||
url: '/app/xinghan/device/add',
|
||||
method: 'post',
|
||||
data: json
|
||||
}).then(res => {
|
||||
if (res && res.code == 200) {
|
||||
this.uploadStatu = "success";
|
||||
console.log("上传成功", res);
|
||||
resolve();
|
||||
} else {
|
||||
this.uploadStatu = "upload error";
|
||||
console.error("上传失败,", res);
|
||||
console.error("上传失败,", json);
|
||||
reject(this.uploadStatu);
|
||||
}
|
||||
}).catch(ex => {
|
||||
this.uploadStatu = "upload error";
|
||||
console.error("上传失败,", ex);
|
||||
reject(this.uploadStatu);
|
||||
});
|
||||
}
|
||||
|
||||
let exec = () => {
|
||||
|
||||
if (this.typeList.length == 0) {
|
||||
this.getDevList().then(results => {
|
||||
upload();
|
||||
}).catch(ex => {
|
||||
this.uploadStatu = "get types error";
|
||||
console.error("获取类型失败,", ex);
|
||||
reject(this.uploadStatu);
|
||||
});
|
||||
} else {
|
||||
upload();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
setTimeout(exec, 10)
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
reLinkdevice() {
|
||||
ble.LinkBlue(these.device.deviceId).then(res => {
|
||||
@ -388,10 +399,10 @@
|
||||
return;
|
||||
}
|
||||
//无效的设备回调
|
||||
let deviceInvalid = () => {
|
||||
these.$set(these.device, "deviceName", "");
|
||||
|
||||
|
||||
let deviceInvalid = () => {
|
||||
these.$set(these.device, "deviceName", "");
|
||||
|
||||
|
||||
}
|
||||
clearTimeout(this.Statu.timeInteval);
|
||||
|
||||
@ -427,10 +438,16 @@
|
||||
clearInterval(inteval);
|
||||
} else {
|
||||
deviceInvalid();
|
||||
this.uploadItem();
|
||||
if (this.uploadStatu==null) {
|
||||
this.uploadItem().then(res => {
|
||||
this.initDevice();
|
||||
}).catch(err => {
|
||||
console.error("上传失败", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.serverDevice =null;
|
||||
this.serverDevice = null;
|
||||
deviceInvalid();
|
||||
}
|
||||
|
||||
@ -447,15 +464,67 @@
|
||||
},
|
||||
Bind() {
|
||||
// 调用绑定设备接口
|
||||
|
||||
// let f = ble.data.LinkedList.find((v) => {
|
||||
// return v.deviceId == these.device.deviceId;
|
||||
// });
|
||||
// if (!f) {
|
||||
// these.Statu.bound = false;
|
||||
// these.Statu.boundRemark = "蓝牙连接不成功";
|
||||
// return;
|
||||
// }
|
||||
|
||||
let task = () => {
|
||||
these.Statu.bound = null;
|
||||
these.Statu.boundRemark = "";
|
||||
showLoading(these, {
|
||||
|
||||
text: "绑定中..."
|
||||
})
|
||||
let promise = request({
|
||||
url: '/app/device/bind',
|
||||
method: 'POST',
|
||||
data: {
|
||||
deviceImei: '',
|
||||
deviceMac: these.device.macAddress,
|
||||
communicationMode: 1, //0是4g,1是蓝牙,2蓝牙&4G
|
||||
}
|
||||
});
|
||||
promise.then((res) => {
|
||||
console.log("1111" + JSON.stringify(res));
|
||||
if (res.code == 200) {
|
||||
these.Statu.bound = true;
|
||||
these.Statu.boundRemark = "设备绑定成功!";
|
||||
let data = these.serverDevice;
|
||||
let keys = Object.keys(data);
|
||||
ble.data.LinkedList.find((v) => {
|
||||
if (v.deviceId == these.device.deviceId) {
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
let key = keys[i];
|
||||
if (!v.device) {
|
||||
v.device = {};
|
||||
}
|
||||
v.device[key] = data[key];
|
||||
}
|
||||
|
||||
ble.updateCache();
|
||||
}
|
||||
});
|
||||
|
||||
ble.removeReceiveCallback(pagePath);
|
||||
clearTimeout(this.Statu.timeInteval);
|
||||
this.device.macAddress = null;
|
||||
this.Statu.timeInteval = null;
|
||||
this.Statu.isBind = true;
|
||||
uni.$emit("refreshDeviceList");
|
||||
setTimeout(() => {
|
||||
uni.switchTab({
|
||||
url: "/pages/common/index/index"
|
||||
});
|
||||
}, 500);
|
||||
} else {
|
||||
these.Statu.bound = false;
|
||||
these.Statu.boundRemark = res.msg;
|
||||
}
|
||||
}).catch((ex) => {
|
||||
these.Statu.bound = false;
|
||||
these.Statu.boundRemark = '出现了未知的异常,操作失败';
|
||||
console.log("ex=", ex);
|
||||
}).finally(() => {
|
||||
hideLoading(this);
|
||||
});
|
||||
}
|
||||
if (!this.device.macAddress) {
|
||||
these.Statu.bound = false;
|
||||
these.Statu.boundRemark = "获取设备Mac地址异常";
|
||||
@ -466,64 +535,9 @@
|
||||
these.Statu.boundRemark = "设备未入库";
|
||||
return;
|
||||
}
|
||||
these.Statu.bound = null;
|
||||
these.Statu.boundRemark = "";
|
||||
showLoading(these, {
|
||||
|
||||
text: "绑定中..."
|
||||
})
|
||||
let promise = request({
|
||||
url: '/app/device/bind',
|
||||
method: 'POST',
|
||||
data: {
|
||||
deviceImei: '',
|
||||
deviceMac: these.device.macAddress,
|
||||
communicationMode: 1, //0是4g,1是蓝牙,2蓝牙&4G
|
||||
}
|
||||
});
|
||||
promise.then((res) => {
|
||||
console.log("1111" + JSON.stringify(res));
|
||||
if (res.code == 200) {
|
||||
these.Statu.bound = true;
|
||||
these.Statu.boundRemark = "设备绑定成功!";
|
||||
let data = these.serverDevice;
|
||||
let keys = Object.keys(data);
|
||||
ble.data.LinkedList.find((v) => {
|
||||
if (v.deviceId == these.device.deviceId) {
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
let key = keys[i];
|
||||
if (!v.device) {
|
||||
v.device = {};
|
||||
}
|
||||
v.device[key] = data[key];
|
||||
}
|
||||
task();
|
||||
|
||||
ble.updateCache();
|
||||
}
|
||||
});
|
||||
|
||||
ble.removeReceiveCallback(pagePath);
|
||||
clearTimeout(this.Statu.timeInteval);
|
||||
this.device.macAddress = null;
|
||||
this.Statu.timeInteval = null;
|
||||
this.Statu.isBind=true;
|
||||
uni.$emit("refreshDeviceList");
|
||||
setTimeout(() => {
|
||||
uni.switchTab({
|
||||
url: "/pages/common/index/index"
|
||||
});
|
||||
}, 500);
|
||||
} else {
|
||||
these.Statu.bound = false;
|
||||
these.Statu.boundRemark = res.msg;
|
||||
}
|
||||
}).catch((ex) => {
|
||||
these.Statu.bound = false;
|
||||
these.Statu.boundRemark = '出现了未知的异常,操作失败';
|
||||
console.log("ex=", ex);
|
||||
}).finally(() => {
|
||||
hideLoading(this);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -991,17 +991,17 @@
|
||||
});
|
||||
}
|
||||
|
||||
for (let i = 0; i < this.EquipMents.length; i++) {
|
||||
let element = this.EquipMents[i];
|
||||
if (!element.isValid) {
|
||||
task(element).catch(ex => {
|
||||
if (ex === null && element.advertisData) {
|
||||
console.log("广播自动入库");
|
||||
this.uploadItem(element);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
// for (let i = 0; i < this.EquipMents.length; i++) {
|
||||
// let element = this.EquipMents[i];
|
||||
// if (!element.isValid) {
|
||||
// task(element).catch(ex => {
|
||||
// if (ex === null && element.advertisData) {
|
||||
// console.log("广播自动入库");
|
||||
// this.uploadItem(element);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
},
|
||||
scan() {
|
||||
@ -1111,9 +1111,7 @@
|
||||
this.EquipMents = [];
|
||||
this.PairEquip = [];
|
||||
setTimeout(() => {
|
||||
ble.StartSearch().then(result => {
|
||||
|
||||
}).catch(err => {
|
||||
ble.StartSearch().then(result => {}).catch(err => {
|
||||
console.error("err=", err);
|
||||
MsgError("出现错误:" + err.msg, '', these);
|
||||
}).finally(() => {
|
||||
@ -1228,8 +1226,16 @@
|
||||
|
||||
these.PairEquip.push(item);
|
||||
}
|
||||
console.log("连接成功", these.device);
|
||||
console.log("连接成功,开始发送识别指令", these.device);
|
||||
hideLoading(these);
|
||||
|
||||
let json = {
|
||||
ins_disc: 1
|
||||
}
|
||||
ble.sendString(item.deviceId, json, item.writeServiceId, item.wirteCharactId, 30).then(res => {
|
||||
}).catch(ex => {
|
||||
console.error("蓝牙识别指令发送失败", ex);
|
||||
});
|
||||
}
|
||||
let execLink = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
@ -58,7 +58,11 @@
|
||||
<view>电量:{{item.battery || '0'}}%</view>
|
||||
</view>
|
||||
|
||||
<!-- <view @click.stop="Disc()">识别</view> -->
|
||||
<view @click.stop="Disc(item,index)" class="disc center" :class="{active:item.isDisc}">
|
||||
<image src="/static/images/common/disc.png"
|
||||
class="discImg" mode="aspectFit"></image>
|
||||
<text>识别</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -158,26 +162,28 @@
|
||||
deviceInfo,
|
||||
deviceUnbind, //删除设备
|
||||
deviceReName
|
||||
} from '@/api/common/index.js'
|
||||
} from '@/api/common/index.js'
|
||||
import MescrollUni from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-uni.vue';
|
||||
import bleTool from '@/utils/BleHelper.js';
|
||||
import MescrollUni from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-uni.vue'
|
||||
import BleReceive from '@/utils/BleReceive';
|
||||
import {
|
||||
MsgError
|
||||
MsgError, MsgSuccess
|
||||
} from '@/utils/MsgPops';
|
||||
import MqttClient from '@/utils/mqtt.js';
|
||||
|
||||
var pagePath = 'pages/common/index';
|
||||
var ble = null;
|
||||
|
||||
var mq=null;
|
||||
var timeout = null;
|
||||
var ble = null;
|
||||
var recei = null;
|
||||
var these=null;
|
||||
export default {
|
||||
components: {
|
||||
MescrollUni
|
||||
},
|
||||
computed: {
|
||||
showSendFlex() {
|
||||
// return this.activeTab && this.activeTab.id !== ''&& (this.activeTabInfo.communicationMode==0 || this.activeTabInfo.communicationMode==2);
|
||||
showSendFlex() {
|
||||
if (this.showMap || this.ShowSendmessage || this.showWarn) {
|
||||
return true;
|
||||
}
|
||||
@ -243,6 +249,11 @@
|
||||
text: '所有分享',
|
||||
icon: '/static/images/common/share.png',
|
||||
action: 'share'
|
||||
},
|
||||
{
|
||||
text: '预警布防',
|
||||
icon: '/static/images/common/defence.png',
|
||||
action: 'defence'
|
||||
}
|
||||
],
|
||||
downOption: {
|
||||
@ -299,21 +310,14 @@
|
||||
},
|
||||
// 下拉刷新
|
||||
downCallback() {
|
||||
|
||||
|
||||
if (this.mescroll) {
|
||||
this.mescroll.resetUpScroll(false);
|
||||
this.mescroll.scrollTo(0, 0);
|
||||
}
|
||||
this.getData();
|
||||
|
||||
|
||||
},
|
||||
// 上拉加载
|
||||
upCallback() {
|
||||
|
||||
|
||||
|
||||
this.getData();
|
||||
},
|
||||
bleStateBreak() {
|
||||
@ -325,22 +329,18 @@
|
||||
console.log("蓝牙适配器恢复可用,重连断开的设备");
|
||||
ble.linkAllDevices();
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
bleBreak(res) {
|
||||
console.error("蓝牙断开连接", res);
|
||||
if (res.deviceId) {
|
||||
this.updateBleStatu(res.deviceId);
|
||||
}
|
||||
|
||||
},
|
||||
bleRecovery(res) {
|
||||
// console.log("蓝牙连接成功", res);
|
||||
if (res.deviceId) {
|
||||
this.updateBleStatu(res.deviceId);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
updateBleStatu() { //更新列表的蓝牙连接状态,电池 电量
|
||||
@ -390,6 +390,7 @@
|
||||
},
|
||||
// 所有分享,所有类型
|
||||
handleshareClick(item) {
|
||||
debugger;
|
||||
this.showshare = false; // 关闭弹窗
|
||||
var that = this;
|
||||
switch (item.action) {
|
||||
@ -414,8 +415,12 @@
|
||||
case 'share':
|
||||
uni.navigateTo({
|
||||
url: "/pages/common/allShare/index",
|
||||
|
||||
})
|
||||
});
|
||||
break;
|
||||
case 'defence':
|
||||
uni.navigateTo({
|
||||
url: "/pages/common/linkDefence/defence"
|
||||
});
|
||||
break;
|
||||
}
|
||||
},
|
||||
@ -720,6 +725,8 @@
|
||||
this.$set(this.deviceList[index], 'showOption', 'none');
|
||||
},
|
||||
Disc(item, index) { //发送识别指令
|
||||
|
||||
this.$set(this.deviceList[index], 'isDisc', true);
|
||||
let json = {
|
||||
ins_disc: 1
|
||||
};
|
||||
@ -729,51 +736,100 @@
|
||||
return v.macAddress == item.deviceMac;
|
||||
});
|
||||
if (f) {
|
||||
console.log("f=",f);
|
||||
ble.sendString(f.deviceId, json, f.writeServiceId, f.wirteCharactId, 30).then(res => {
|
||||
index++;
|
||||
setTimeout(sendNextPacket, 300);
|
||||
MsgSuccess("发送识别指令成功",'',these);
|
||||
this.$set(this.deviceList[index], 'isDisc', false);
|
||||
}).catch(err => {
|
||||
console.error('err=',err);
|
||||
if (item.communicationMode == 1) {
|
||||
MsgError(err.msg, '', this);
|
||||
this.$set(this.deviceList[index], 'isDisc', false);
|
||||
return;
|
||||
}
|
||||
mqSend();
|
||||
mqSend(true);
|
||||
});
|
||||
}else{
|
||||
if (item.communicationMode == 1) {
|
||||
MsgError("请连接蓝牙后再试", '去连接', this,()=>{
|
||||
uni.navigateTo({
|
||||
url: "/pages/common/addBLE/addEquip",
|
||||
events: {
|
||||
BindOver(data) {
|
||||
console.log("蓝牙配对成功了");
|
||||
}
|
||||
},
|
||||
success: function(res) {
|
||||
res.eventChannel.emit('detailData', {
|
||||
data: item
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
this.$set(this.deviceList[index], 'isDisc', false);
|
||||
return;
|
||||
}
|
||||
mqSend(true);
|
||||
}
|
||||
}
|
||||
|
||||
let mqSend = () => {
|
||||
let mqSend = (isBle) => {
|
||||
|
||||
if(!item.deviceImei){
|
||||
if(ble){
|
||||
MsgError("发送识别指令,蓝牙发送失败、IMEI缺失4G发送也失败",'',these);
|
||||
}else{
|
||||
MsgError("发送识别指令失败,设备IMEI缺失",'',these);
|
||||
}
|
||||
this.$set(this.deviceList[index], 'isDisc', false);
|
||||
return;
|
||||
}
|
||||
|
||||
let Send = () => {
|
||||
|
||||
let flag = mq.publish("B/" + item.deviceImei, JSON.stringify(json));
|
||||
if (!flag) {
|
||||
MsgError("识别设备失败,请检查手机网络连接", '', this);
|
||||
MsgError("发送识别指令失败,请检查手机网络连接", '', this);
|
||||
this.$set(this.deviceList[index], 'isDisc', false);
|
||||
return;
|
||||
}
|
||||
this.$set(this.deviceList[index], 'isDisc', false);
|
||||
}
|
||||
|
||||
if (!mq) {
|
||||
|
||||
mq = new MqttClient();
|
||||
mq.connect(() => {
|
||||
console.log("MQTT连接成功")
|
||||
Send();
|
||||
},()=>{
|
||||
MsgError("发送识别指令时,无法连接消息服务器");
|
||||
mq.disconnect();
|
||||
mq=null;
|
||||
}).catch(ex=>{
|
||||
console.error("ex=",ex);
|
||||
this.$set(this.deviceList[index], 'isDisc', false);
|
||||
});
|
||||
|
||||
return ;
|
||||
}else{
|
||||
console.log("mq=",mq);
|
||||
Send();
|
||||
}
|
||||
Send();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (item.communicationMode == 1 || item.communicationMode == 2) {
|
||||
bleSend.catch(ex => {
|
||||
mqSend();
|
||||
});
|
||||
setTimeout(()=>{
|
||||
if (item.communicationMode == 1 || item.communicationMode == 2) {
|
||||
bleSend();
|
||||
return;
|
||||
}
|
||||
if (item.communicationMode == 0) {
|
||||
mqSend();
|
||||
return;
|
||||
}
|
||||
},250);
|
||||
|
||||
},
|
||||
// 列表跳转
|
||||
handleFile(item, index) {
|
||||
@ -781,6 +837,7 @@
|
||||
this.$set(this.deviceList[index], 'showOption', 'none');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
this.$set(this.deviceList[index], 'active', true);
|
||||
setTimeout(() => {
|
||||
@ -846,6 +903,7 @@
|
||||
},
|
||||
onLoad() {
|
||||
// console.error("首页加载");
|
||||
these=this;
|
||||
this.getTab()
|
||||
this.downCallback();
|
||||
|
||||
@ -914,6 +972,9 @@
|
||||
console.log("onUnload...");
|
||||
uni.$off('deviceStatusUpdate');
|
||||
ble && ble.removeAllCallback(pagePath);
|
||||
if(mq){
|
||||
mq.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1387,15 +1448,26 @@
|
||||
}
|
||||
|
||||
.splitLine {
|
||||
background: linear-gradient(90.00deg, rgba(0, 0, 0, 0), rgba(255, 255, 255, 1) 44.525%, rgba(255, 254.75, 254.75, 0) 92%);
|
||||
background: linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(255, 255, 255, 1) 44.525%, rgba(255, 254.75, 254.75, 0) 92%);
|
||||
opacity: 0.2;
|
||||
width: 25rpx;
|
||||
height: 4rpx;
|
||||
margin: 0rpx 10rpx;
|
||||
transform: rotate(90.00deg);
|
||||
width: 4rpx;
|
||||
height: 25rpx;
|
||||
margin: 0rpx 20rpx;
|
||||
}
|
||||
|
||||
.p10 {
|
||||
padding-left: 20rpx;
|
||||
}
|
||||
.disc{
|
||||
padding: 5rpx 10rpx;
|
||||
margin-right: -30rpx;
|
||||
}
|
||||
.disc.active{
|
||||
background-color: #2a2a2a !important;;
|
||||
}
|
||||
.discImg{
|
||||
width:24rpx;
|
||||
height: 24rpx;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
</style>
|
||||
447
pages/common/linkDefence/addDefence.vue
Normal file
447
pages/common/linkDefence/addDefence.vue
Normal file
@ -0,0 +1,447 @@
|
||||
<template>
|
||||
<view class="content contentBg">
|
||||
|
||||
<SubStep :steps="Status.steps.list" :height="'140rpx'" :curr="Status.steps.curr" @stepClick="stepClick">
|
||||
</SubStep>
|
||||
|
||||
|
||||
<view class="mainPanel" v-show="Status.steps.curr===0">
|
||||
<view class="main">
|
||||
<uni-easyinput maxlength="30" class="txteare" v-model="formData.name" :trim="true" placeholder="输入编组名称"
|
||||
type="textarea" autoHeight :inputBorder="false" :border="false"></uni-easyinput>
|
||||
</view>
|
||||
<button class="btnNext" :disabled="!formData.name" :class="{'active':formData.name}"
|
||||
@click="gotoStep(1)">下一步</button>
|
||||
</view>
|
||||
|
||||
<view class="mainPanel" v-show="Status.steps.curr===1">
|
||||
<view class="btnAdd" @click="goCheckDevice('main')">
|
||||
<image class="img" mode="aspectFit" src="/static/images/common/add.png"></image>
|
||||
<text>添加预警主机</text>
|
||||
</view>
|
||||
|
||||
<scroll-view scroll-y="true" scroll-with-animation class="checkedList" v-show="formData.main.length>0">
|
||||
<view class="item " v-for="item,index in formData.main">
|
||||
<view class="panel imgContent center" @click.stop="imgView(item,index)">
|
||||
<image class="img" :src="item.devicePic" mode="aspectFit"></image>
|
||||
</view>
|
||||
|
||||
<view class="panel centerCol lbl">
|
||||
<view class="LargeTxt">{{item.deviceName}}</view>
|
||||
<view class="smallTxt">ID:{{item.deviceImei?item.deviceImei:item.deviceMac}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<button class="btnNext" :class="{'active':formData.main.length>0}" :disabled="formData.main.length==0"
|
||||
@click="gotoStep(1)">下一步</button>
|
||||
</view>
|
||||
|
||||
<view class="mainPanel" v-show="Status.steps.curr===2">
|
||||
<view class="btnAdd" @click="goCheckDevice('sub')">
|
||||
<image class="img" mode="aspectFit" src="/static/images/common/add.png"></image>
|
||||
<text>添加布防联机</text>
|
||||
</view>
|
||||
<scroll-view scroll-y="true" scroll-with-animation class="checkedList" v-show="formData.sub.length>0">
|
||||
<view class="item center" v-for="item,index in formData.sub">
|
||||
<view class="panel imgContent center" @click.stop="imgView(item,index)">
|
||||
<image class="img" :src="item.devicePic" mode="aspectFit"></image>
|
||||
</view>
|
||||
|
||||
<view class="panel centerCol lbl">
|
||||
<view class="LargeTxt">{{item.deviceName}}</view>
|
||||
<view class="smallTxt">ID:{{item.deviceImei?item.deviceImei:item.deviceMac}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<button class="btnNext" :class="{'active':formData.sub.length>0}" :disabled="formData.sub.length==0"
|
||||
@click="gotoStep(1)">下一步</button>
|
||||
</view>
|
||||
|
||||
<view class="mainPanel" v-show="Status.steps.curr===3">
|
||||
<view class="btnAdd" @click="goCheckDevice('notify')">
|
||||
<image class="img" mode="aspectFit" src="/static/images/common/add.png"></image>
|
||||
<text>添加接收设备</text>
|
||||
</view>
|
||||
<scroll-view scroll-y="true" scroll-with-animation class="checkedList" v-show="formData.notify.length>0">
|
||||
<view class="item" v-for="item,index in formData.notify">
|
||||
<view class="panel imgContent center" @click.stop="imgView(item,index)">
|
||||
<image class="img" :src="item.devicePic" mode="aspectFit"></image>
|
||||
</view>
|
||||
|
||||
<view class="panel centerCol lbl">
|
||||
<view class="LargeTxt">{{item.deviceName}}</view>
|
||||
<view class="smallTxt">ID:{{item.deviceImei?item.deviceImei:item.deviceMac}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<button class="btnNext" :class="{'active':formData.notify.length>0}" :disabled="formData.notify.length==0"
|
||||
@click="Send">发送</button>
|
||||
</view>
|
||||
|
||||
|
||||
<MsgBox ref="msgPop" />
|
||||
<global-loading ref="loading" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import request from '@/utils/request.js';
|
||||
import {
|
||||
showLoading,
|
||||
hideLoading,
|
||||
updateLoading
|
||||
} from '@/utils/loading.js';
|
||||
|
||||
import {
|
||||
MsgSuccess,
|
||||
MsgError,
|
||||
MsgClose,
|
||||
MsgWarning,
|
||||
showPop,
|
||||
MsgInfo
|
||||
} from '@/utils/MsgPops.js'
|
||||
import Common from '@/utils/Common.js';
|
||||
|
||||
var these = null;
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
|
||||
Status: {
|
||||
steps: {
|
||||
list: [{
|
||||
text: '设置名称'
|
||||
},
|
||||
{
|
||||
text: '设置主机'
|
||||
},
|
||||
{
|
||||
text: '设置联机'
|
||||
},
|
||||
{
|
||||
text: '发送编组'
|
||||
}
|
||||
],
|
||||
curr: 0
|
||||
}
|
||||
},
|
||||
formData: {
|
||||
id: '',
|
||||
name: '',
|
||||
main: [], //通知设备
|
||||
sub: [], //预警设备
|
||||
notify: [] //发送设备
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
||||
},
|
||||
created() {
|
||||
|
||||
},
|
||||
onUnload() {
|
||||
|
||||
|
||||
},
|
||||
onBackPress() {
|
||||
if (this.Status.steps.curr > 0) {
|
||||
this.gotoStep(-1);
|
||||
return true;
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
|
||||
},
|
||||
onHide: function() {
|
||||
|
||||
},
|
||||
|
||||
onLoad(opt) {
|
||||
these = this;
|
||||
let eventChannel = this.getOpenerEventChannel();
|
||||
|
||||
eventChannel.on('detailData', (res) => {
|
||||
let data = res.data;
|
||||
if (data) {
|
||||
this.formData.id = data.id;
|
||||
this.formData.name = data.name;
|
||||
this.formData.main = [];
|
||||
this.formData.sub = [];
|
||||
this.formData.notify = [];
|
||||
setTimeout(this.initData, 0);
|
||||
}
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
imgView(item,index){
|
||||
if(!item.devicePic){
|
||||
return;
|
||||
}
|
||||
|
||||
uni.previewImage({
|
||||
urls: [item.devicePic]
|
||||
});
|
||||
},
|
||||
goCheckDevice(type) {
|
||||
let json = {
|
||||
type: type,
|
||||
formData:this.formData
|
||||
};
|
||||
Object.assign(json, this.formData);
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/linkDefence/checkDevice',
|
||||
success(res) {
|
||||
res.eventChannel.emit("detailData", {
|
||||
data: json
|
||||
});
|
||||
},
|
||||
events: {
|
||||
checkOver(res) {
|
||||
these.$set(these.formData, res.type, res.arr)
|
||||
}
|
||||
},
|
||||
fail(ex) {
|
||||
console.error("出现异常", ex);
|
||||
}
|
||||
});
|
||||
},
|
||||
initData() {
|
||||
|
||||
if (!this.formData.id) {
|
||||
return;
|
||||
}
|
||||
let url = '';
|
||||
if (!url) {
|
||||
MsgWarning('后端未开发此接口,敬请期待', '', this);
|
||||
return;
|
||||
}
|
||||
request({
|
||||
url: url,
|
||||
data: {
|
||||
id: this.formData.id
|
||||
},
|
||||
method: 'POST'
|
||||
}).then(res => {
|
||||
if (res && res.code == 200) {
|
||||
console.log("请求数据成功", res);
|
||||
this.formData.main = res.data.filter(v => {
|
||||
return v.type == 'notify';
|
||||
});
|
||||
this.formData.sub = res.data.filter(v => {
|
||||
return v.type == 'warn';
|
||||
});
|
||||
} else {
|
||||
MsgError(res.msg, '', this);
|
||||
}
|
||||
}).catch(ex => {
|
||||
console.log("ex=", ex);
|
||||
MsgError(ex.errMsg, '', this);
|
||||
});
|
||||
|
||||
},
|
||||
stepClick(item, index) {
|
||||
console.log("步骤被点击:", item);
|
||||
},
|
||||
Send() {
|
||||
showLoading(these, {
|
||||
text: '发送中'
|
||||
});
|
||||
let task = () => {
|
||||
hideLoading(these);
|
||||
MsgSuccess("敬请期待", '', these);
|
||||
}
|
||||
|
||||
setTimeout(task, 800);
|
||||
},
|
||||
gotoStep(intval) {
|
||||
if (this.Status.steps.curr + intval > this.Status.steps.list.length - 1) {
|
||||
return;
|
||||
} else if (this.Status.steps.curr + intval < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.Status.steps.curr += intval;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.content {
|
||||
padding: 30rpx;
|
||||
box-sizing: border-box;
|
||||
|
||||
width: 100%;
|
||||
|
||||
}
|
||||
|
||||
/* #ifdef APP */
|
||||
.content {
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
/* #endif */
|
||||
/* #ifdef WEB|H5 */
|
||||
.content {
|
||||
height: calc(100vh - 44px);
|
||||
}
|
||||
|
||||
/* #endif */
|
||||
|
||||
.mainPanel {
|
||||
width: 100%;
|
||||
height: calc(100% - 140rpx);
|
||||
position: relative;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #FFFFFF00;
|
||||
}
|
||||
|
||||
.mainPanel .btnNext {
|
||||
width: 90%;
|
||||
transform: translateX(5%);
|
||||
position: absolute;
|
||||
bottom: 0rpx;
|
||||
border-radius: 45rpx;
|
||||
background: #1A1A1A;
|
||||
color: rgba(255, 255, 255, 0.4);
|
||||
font-family: "PingFang SC";
|
||||
height: 80rpx;
|
||||
font-size: 28rpx;
|
||||
line-height: 80rpx;
|
||||
letter-spacing: 0px;
|
||||
text-align: center;
|
||||
|
||||
|
||||
}
|
||||
|
||||
.mainPanel .btnNext.active {
|
||||
background: #BBE600;
|
||||
color: #232323;
|
||||
}
|
||||
|
||||
/deep/ .uni-easyinput__content,
|
||||
.uni-easyinput__content {
|
||||
background-color: #1A1A1A !important;
|
||||
border-radius: 16rpx;
|
||||
color: #FFFFFF;
|
||||
text-indent: 10rpx;
|
||||
box-sizing: border-box;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
/deep/ .uni-textarea-placeholder,
|
||||
.uni-textarea-placeholder {
|
||||
color: rgba(255, 255, 255, 0.5);
|
||||
|
||||
font-family: "PingFang SC";
|
||||
font-style: Regular;
|
||||
font-size: 24rpx;
|
||||
font-weight: 400;
|
||||
letter-spacing: 0.14rpx;
|
||||
}
|
||||
|
||||
.mainPanel .main {
|
||||
transform: translateY(30rpx);
|
||||
}
|
||||
|
||||
.mainPanel .btnAdd {
|
||||
|
||||
width: 100%;
|
||||
height: 150rpx;
|
||||
border-radius: 16rpx;
|
||||
background: rgba(26, 26, 26, 1);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-evenly;
|
||||
align-items: center;
|
||||
flex-wrap: nowrap;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
font-family: "PingFang SC";
|
||||
font-style: Regular;
|
||||
font-size: 24rpx;
|
||||
font-weight: 400;
|
||||
letter-spacing: 0.14rpx;
|
||||
margin-top: 30rpx;
|
||||
}
|
||||
|
||||
.mainPanel .btnAdd .img {
|
||||
width: 50rpx;
|
||||
height: 50rpx;
|
||||
}
|
||||
|
||||
.mainPanel .checkedList {
|
||||
width: 100%;
|
||||
height: calc(100% - 300rpx);
|
||||
transform: translateY(20rpx);
|
||||
border-radius: 16rpx;
|
||||
background-color: #1A1A1A;
|
||||
box-sizing: border-box;
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.mainPanel .checkedList .item {
|
||||
width: 100%;
|
||||
height: 100rpx;
|
||||
overflow: hidden;
|
||||
margin-bottom: 20rpx;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
align-content: center;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
|
||||
}
|
||||
.mainPanel .checkedList .item .panel{
|
||||
height: 100%;
|
||||
|
||||
}
|
||||
.mainPanel .checkedList .item .lbl{
|
||||
width: calc(100% - 120rpx);
|
||||
height: 100%;
|
||||
transform: translateX(24rpx);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-wrap: wrap;
|
||||
align-content: flex-start;
|
||||
align-items: flex-start;
|
||||
justify-content: space-evenly;
|
||||
}
|
||||
.mainPanel .checkedList .item .imgContent {
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
background-color: #2A2A2A;
|
||||
border-radius: 16rpx;
|
||||
}
|
||||
|
||||
.mainPanel .checkedList .item .img {
|
||||
width: 80%;
|
||||
height: 80%;
|
||||
}
|
||||
|
||||
.checkedList .LargeTxt{
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
|
||||
font-family: "PingFang SC";
|
||||
font-style: Regular;
|
||||
font-size: 32rpx;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.checkedList .smallTxt{
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
|
||||
font-family: "PingFang SC";
|
||||
font-style: Regular;
|
||||
font-size: 24rpx;
|
||||
font-weight: 400;
|
||||
|
||||
letter-spacing: 0.14rpx;
|
||||
|
||||
}
|
||||
</style>
|
||||
882
pages/common/linkDefence/checkDevice.vue
Normal file
882
pages/common/linkDefence/checkDevice.vue
Normal file
@ -0,0 +1,882 @@
|
||||
<template>
|
||||
<view class="maincontent contentBg">
|
||||
<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 class="tab-bar-wrap" v-show="!Status.Search">
|
||||
<scroll-view class="tab-bar" scroll-x="true" scroll-with-animation>
|
||||
<view class="tab-container">
|
||||
<view v-for="(tab, index) in tabs" :key="index"
|
||||
:class="['tab-item', activeTab === index ? 'active' : '']" @click="switchTab(tab,index)">
|
||||
{{tab.typeName}}
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<view class="tab-more" @click="Status.Search=!Status.Search">
|
||||
<image src="/static/images/common/search.png" mode="aspectFit" class="more"></image>
|
||||
</view>
|
||||
</view>
|
||||
<view class="searchRow" v-show="Status.Search">
|
||||
<view class="ipt">
|
||||
<uni-easyinput class="txteare" maxlength="30" v-model="filter.txt" :trim="true" placeholder="搜索设备"
|
||||
type="text" :inputBorder="false" :border="false"></uni-easyinput>
|
||||
</view>
|
||||
|
||||
<view class="btn" @click.stop="Status.Search=false">取消</view>
|
||||
<view class="clear"></view>
|
||||
</view>
|
||||
<view class="listContent">
|
||||
<mescroll-uni class="device-list" @init="mescrollInit" @down="downCallback" @up="upCallback" :up="upOption"
|
||||
:down="downOption" :fixed="false">
|
||||
<view class="listItem center" v-for="item,index in deviceList">
|
||||
<view class="opt center">
|
||||
<view class="checkbox center" @click.stop="checkToggle(item,index)"
|
||||
:class="{active:checks.find((v,i)=>{return v.id===item.id})}">
|
||||
<uni-icons class="icon" type="checkmarkempty" size="17" color="#000000"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
<view class="main">
|
||||
<view class="device-header">
|
||||
<view class="deviceIMG" @click.stop="imgView(item,index)">
|
||||
<image :src="item.devicePic" class="IMG" mode="aspectFit"></image>
|
||||
</view>
|
||||
<view class="device-name">
|
||||
<view>设备:{{item.deviceName}}</view>
|
||||
|
||||
<view class="ID">
|
||||
ID:{{item.deviceImei?item.deviceImei:item.deviceMac}}
|
||||
</view>
|
||||
|
||||
|
||||
<view class="ID">
|
||||
|
||||
<view class="center ">
|
||||
<view :class="{'onlines':item.onlineStatus==1,'offlines':item.onlineStatus==0}">
|
||||
{{item.onlineStatus==1?'在线':'离线'}}
|
||||
</view>
|
||||
<view class="splitLine"></view>
|
||||
|
||||
<view>电量:{{item.battery || '0'}}%</view>
|
||||
</view>
|
||||
|
||||
<view @click.stop="Disc(item,index)" class="disc center"
|
||||
:class="{active:item.isDisc}">
|
||||
<image src="/static/images/common/disc.png" class="discImg" mode="aspectFit">
|
||||
</image>
|
||||
<text>识别</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="device-callpolice"
|
||||
v-if="item.communicationMode==0 && item.onlineStatus==1 && item.alarmStatus==1">
|
||||
报警中</view>
|
||||
<view v-if="item.communicationMode==1 || item.communicationMode==2">
|
||||
<view class="device-status" :class="item.bleStatu?'online':'unline'">
|
||||
{{item.bleStatu?'已连接':'未连接'}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</mescroll-uni>
|
||||
</view>
|
||||
|
||||
<view :class="{active:checks.length>0}" class="btnOK" @click.stop="OkCheck()">确定</view>
|
||||
<global-loading ref="loading" />
|
||||
|
||||
<MsgBox ref="msgPop" />
|
||||
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
var timeout = null;
|
||||
var these = null;
|
||||
var eventChannel = null;
|
||||
var ble = null;
|
||||
var recei = null;
|
||||
var pagePath = "pages/common/linkDefence/checkDevice";
|
||||
import request, {
|
||||
baseURL
|
||||
} from '@/utils/request.js';
|
||||
import {
|
||||
showLoading,
|
||||
hideLoading,
|
||||
updateLoading
|
||||
} from '@/utils/loading.js';
|
||||
import {
|
||||
MsgSuccess,
|
||||
MsgError,
|
||||
MsgClose,
|
||||
MsgWarning,
|
||||
showPop,
|
||||
MsgInfo,
|
||||
MsgClear,
|
||||
MsgPrompt
|
||||
} from '@/utils/MsgPops.js';
|
||||
import {
|
||||
deviceInfo,
|
||||
deviceTypeList
|
||||
} from '@/api/common/index.js'
|
||||
import Common from '@/utils/Common.js';
|
||||
import bleTool from '@/utils/BleHelper.js';
|
||||
import BleReceive from '@/utils/BleReceive';
|
||||
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
filter: {
|
||||
txt: ''
|
||||
},
|
||||
Status: {
|
||||
navbar: {
|
||||
icons: [{
|
||||
src: '/static/images/common/add.png',
|
||||
type: 'add'
|
||||
}],
|
||||
title: '选择设备',
|
||||
showBack: true,
|
||||
height: 90,
|
||||
|
||||
},
|
||||
type: null,
|
||||
Search: false
|
||||
|
||||
},
|
||||
|
||||
mescroll: null,
|
||||
downOption: {
|
||||
auto: false,
|
||||
autoShowLoading: false,
|
||||
},
|
||||
upOption: {
|
||||
auto: false,
|
||||
noMoreSize: 0,
|
||||
offset: 10,
|
||||
isLock: false,
|
||||
empty: {
|
||||
tip: '暂无数据',
|
||||
hideScroll: false,
|
||||
icon: '/static/images/common/empty.png'
|
||||
},
|
||||
textNoMore: '没有更多数据了'
|
||||
},
|
||||
deviceList: [],
|
||||
checks: [],
|
||||
tabs: [],
|
||||
activeTabInfo: '',
|
||||
activeTab: 0,
|
||||
formData: {
|
||||
id: '',
|
||||
name: '',
|
||||
main: [], //通知设备
|
||||
sub: [], //预警设备
|
||||
notify: [] //发送设备
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.Status.navbar.height = uni.getSystemInfoSync().statusBarHeight + 44;
|
||||
},
|
||||
onLoad() {
|
||||
this.getTab();
|
||||
these = this;
|
||||
this.$watch("filter.txt",(newVal,oldVal)=>{
|
||||
if(this.mescroll){
|
||||
this.mescroll.triggerDownScroll();
|
||||
}
|
||||
});
|
||||
eventChannel = this.getOpenerEventChannel();
|
||||
eventChannel.on('detailData', (res) => {
|
||||
let data = res.data;
|
||||
console.log("收到上级页面传参", data);
|
||||
this.Status.type = data.type;
|
||||
let keys = Object.keys(data.formData);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
let key = keys[i];
|
||||
this.formData[key] = data.formData[key];
|
||||
}
|
||||
if (data.type == 'main') {
|
||||
this.checks = data.main;
|
||||
this.Status.navbar.title = "选择预警主机";
|
||||
} else if (data.type == 'sub') {
|
||||
this.checks = data.sub;
|
||||
this.Status.navbar.title = "选择布防联机";
|
||||
} else if (data.type == 'notify') {
|
||||
this.checks = data.notify;
|
||||
this.Status.navbar.title = "选择接收设备";
|
||||
|
||||
}
|
||||
setTimeout(() => {
|
||||
if (this.mescroll) {
|
||||
this.mescroll.triggerDownScroll();
|
||||
}
|
||||
}, 0);
|
||||
|
||||
});
|
||||
|
||||
|
||||
ble = bleTool.getBleTool();
|
||||
|
||||
recei = BleReceive.getBleReceive();
|
||||
//蓝牙连接成功的回调
|
||||
ble.addRecoveryCallback((res) => {
|
||||
// console.log("蓝牙连接成功的回调");
|
||||
this.bleRecovery(res);
|
||||
}, pagePath);
|
||||
|
||||
//蓝牙断开连接的回调
|
||||
ble.addDisposeCallback((res) => {
|
||||
console.log("蓝牙断开连接的回调");
|
||||
this.bleBreak(res);
|
||||
}, pagePath);
|
||||
|
||||
//蓝牙适配器恢复可用的回调,一般是重连设备
|
||||
ble.addStateRecoveryCallback(res => {
|
||||
// console.log("蓝牙适配器恢复可用的回调");
|
||||
this.bleStateRecovery();
|
||||
}, pagePath);
|
||||
|
||||
//蓝牙适配器不可用的回调
|
||||
ble.addStateBreakCallback(res => {
|
||||
// console.error("蓝牙适配器不可用的回调");
|
||||
this.bleStateBreak();
|
||||
}, pagePath);
|
||||
|
||||
//接收到消息的回调
|
||||
ble.addReceiveCallback((receive, device, path, recArr) => {
|
||||
// console.error("首页收到消息了");
|
||||
let json = recei.ReceiveData(receive, device, path, recArr);
|
||||
// console.error("消息内容",json);
|
||||
this.updateBleStatu();
|
||||
}, pagePath);
|
||||
// eventChannel.emit('checkOver', {type:'',arr:[]});//
|
||||
},
|
||||
methods: {
|
||||
imgView(item, index) {
|
||||
if (!item.devicePic) {
|
||||
return;
|
||||
}
|
||||
|
||||
uni.previewImage({
|
||||
urls: [item.devicePic]
|
||||
});
|
||||
},
|
||||
checkToggle(item, index) {
|
||||
|
||||
let f = this.checks.find((v, i) => {
|
||||
if (v.id === item.id) {
|
||||
this.checks.splice(i, 1);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
if (!f) {
|
||||
this.checks.push({
|
||||
id: item.id,
|
||||
deviceName: item.deviceName,
|
||||
deviceImei: item.deviceImei,
|
||||
deviceMac: item.deviceMac,
|
||||
devicePic: item.devicePic
|
||||
});
|
||||
}
|
||||
|
||||
console.log("checks=", this.checks);
|
||||
},
|
||||
bleStateBreak() {
|
||||
console.error("蓝牙适配器不可用");
|
||||
this.updateBleStatu();
|
||||
},
|
||||
bleStateRecovery() {
|
||||
if (this.isPageShow) {
|
||||
console.log("蓝牙适配器恢复可用,重连断开的设备");
|
||||
ble.linkAllDevices();
|
||||
}
|
||||
},
|
||||
bleBreak(res) {
|
||||
console.error("蓝牙断开连接", res);
|
||||
if (res.deviceId) {
|
||||
this.updateBleStatu(res.deviceId);
|
||||
}
|
||||
},
|
||||
bleRecovery(res) {
|
||||
// console.log("蓝牙连接成功", res);
|
||||
if (res.deviceId) {
|
||||
this.updateBleStatu(res.deviceId);
|
||||
}
|
||||
},
|
||||
|
||||
updateBleStatu() { //更新列表的蓝牙连接状态,电池 电量
|
||||
if (ble) {
|
||||
|
||||
for (var i = 0; i < this.deviceList.length; i++) {
|
||||
|
||||
|
||||
let f = null;
|
||||
if (ble.data && ble.data.LinkedList) {
|
||||
f = ble.data.LinkedList.find(v => {
|
||||
|
||||
if (v.macAddress && v.device && v.device.id) {
|
||||
return v.device.id == this.deviceList[i].id;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
console.error("ble is null")
|
||||
},
|
||||
getTab() {
|
||||
deviceTypeList({}).then((res) => {
|
||||
if (res.code == 200) {
|
||||
//console.log("deviceTypeList=" + JSON.stringify(res.data));
|
||||
this.tabs = [{
|
||||
id: '',
|
||||
name: '全部设备',
|
||||
typeName: '全部设备'
|
||||
},
|
||||
...res.data.map(item => ({
|
||||
id: item.id,
|
||||
name: item.typeName,
|
||||
typeName: item.typeName,
|
||||
communicationMode: item.communicationMode
|
||||
}))
|
||||
];
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
isChecked(item, index) {
|
||||
let f = this.checks.find((v, i) => {
|
||||
return v.id == item.id;
|
||||
});
|
||||
if (f) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
OkCheck() {
|
||||
if (this.checks.length == 0) {
|
||||
return;
|
||||
}
|
||||
eventChannel.emit('checkOver', {
|
||||
type: this.Status.type,
|
||||
arr: this.checks
|
||||
});
|
||||
uni.navigateBack();
|
||||
},
|
||||
onClick(btn, i, item, index) {
|
||||
if (btn.type == 'rename') {
|
||||
console.log("执行重命名");
|
||||
MsgPrompt(this, btn.type, () => {
|
||||
console.log("确定被点击");
|
||||
}, false, true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (btn.type == 'drop') {
|
||||
console.log("执行删除");
|
||||
MsgError('删除后不可恢复,您确认删除"' + item + '"吗?', '确定', this, () => {
|
||||
this.deviceList.splice(index, 1);
|
||||
}, true);
|
||||
return;
|
||||
}
|
||||
},
|
||||
change(event) {
|
||||
console.log('改变事件', event);
|
||||
},
|
||||
swipeChange(e, index) {
|
||||
console.log('当前状态:' + e + ',下标:' + index)
|
||||
},
|
||||
gotoDetail(item, index) {
|
||||
console.log("item=", item);
|
||||
},
|
||||
mescrollInit(mescroll) {
|
||||
this.mescroll = mescroll;
|
||||
},
|
||||
// 下拉刷新
|
||||
downCallback() {
|
||||
if (this.mescroll) {
|
||||
this.mescroll.resetUpScroll(false);
|
||||
this.mescroll.scrollTo(0, 0);
|
||||
}
|
||||
this.getData();
|
||||
},
|
||||
// 上拉加载
|
||||
upCallback() {
|
||||
this.getData();
|
||||
},
|
||||
getData() {
|
||||
var task = () => {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!this.Status.type) {
|
||||
this.mescroll.endSuccess(0, false);
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
let data = {
|
||||
pageNum: this.mescroll.num,
|
||||
pageSize: 10,
|
||||
deviceType: this.activeTabInfo ? this.activeTabInfo.id : '', // 使用传入的设备类型
|
||||
isAsc: 'desc',
|
||||
orderByColumn: 'bindingTime',
|
||||
deviceName:this.filter.txt
|
||||
}
|
||||
if (!data.pageNum) {
|
||||
this.mescroll.endSuccess(0, false);
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
let method = deviceInfo;
|
||||
if (this.Status.type == 'notify') {
|
||||
method = () => {
|
||||
let rows=this.formData.main;
|
||||
rows=rows.concat(this.formData.sub);
|
||||
rows=rows.filter(v=>{
|
||||
return v.deviceName.toLowerCase().indexOf(this.filter.txt.toLowerCase())>-1;
|
||||
})
|
||||
let json = {
|
||||
code: 200,
|
||||
rows: rows
|
||||
};
|
||||
|
||||
return Promise.resolve(json);
|
||||
}
|
||||
}
|
||||
method(data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
|
||||
const newDevices = res.rows.map(device => ({
|
||||
...device,
|
||||
showConfirm: false
|
||||
}));
|
||||
|
||||
// 如果是第一页或切换分类,替换数据
|
||||
if (data.pageNum === 1) {
|
||||
this.deviceList = newDevices
|
||||
} else {
|
||||
//防止后端返回的数据包含已有数据
|
||||
for (var i = 0; i < newDevices.length; i++) {
|
||||
let device = newDevices[i];
|
||||
let f = this.deviceList.find(v => {
|
||||
return v.id === device.id;
|
||||
});
|
||||
if (!f) {
|
||||
this.deviceList.push(device);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.updateBleStatu();
|
||||
|
||||
|
||||
// 判断是否加载完成
|
||||
let hasNext = true;
|
||||
if (res.rows.length < data.pageSize || this.deviceList.length >= this
|
||||
.total) {
|
||||
hasNext = false;
|
||||
} else {
|
||||
hasNext = true;
|
||||
}
|
||||
this.mescroll.endSuccess(res.rows.length, hasNext);
|
||||
} else {
|
||||
this.mescroll.endSuccess(0, false);
|
||||
}
|
||||
}).finally(() => {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
clearTimeout(timeout);
|
||||
//防止下拉刷新的同时会调用一次上拉加载的问题
|
||||
timeout = setTimeout(task, 50);
|
||||
|
||||
},
|
||||
prevPage() {
|
||||
uni.navigateBack({
|
||||
|
||||
});
|
||||
},
|
||||
handleRightClick(s, e) {
|
||||
|
||||
if (s === 0) {
|
||||
|
||||
} else if (s === 1) {
|
||||
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.maincontent {
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.listContent {
|
||||
height: calc(100% - 270rpx);
|
||||
transform: translateY(20rpx);
|
||||
}
|
||||
|
||||
.listItem {
|
||||
width: 100%;
|
||||
min-height: 140rpx;
|
||||
box-sizing: border-box;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.swipBtn {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-wrap: wrap;
|
||||
align-content: center;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.uni-swipe .icon,
|
||||
/deep/ .uni-swipe .icon {
|
||||
width: 35rpx;
|
||||
height: 35rpx;
|
||||
}
|
||||
|
||||
.uni-swipe .txt,
|
||||
/deep/ .uni-swipe .txt {
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
|
||||
font-family: "PingFang SC";
|
||||
font-style: Regular;
|
||||
font-size: 24rpx;
|
||||
font-weight: 400;
|
||||
|
||||
letter-spacing: 0.14rpx;
|
||||
|
||||
}
|
||||
|
||||
.uni-swipe,
|
||||
/deep/ .uni-swipe {
|
||||
margin-bottom: 20rpx;
|
||||
border-radius: 16rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.tab-bar-wrap {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
margin-top: 90rpx;
|
||||
height: 66rpx;
|
||||
}
|
||||
|
||||
.tab-bar {
|
||||
width: 100%;
|
||||
color: rgb(255, 255, 255);
|
||||
white-space: nowrap;
|
||||
/* 禁止换行 */
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
|
||||
}
|
||||
|
||||
.tab-container {
|
||||
display: flex;
|
||||
cursor: pointer;
|
||||
align-items: center;
|
||||
padding-right: 80rpx;
|
||||
/* 预留更多按钮空间 */
|
||||
}
|
||||
|
||||
.tab-item {
|
||||
font-size: 28rpx;
|
||||
padding: 0 30rpx;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.tab-item.active {
|
||||
color: #bbe600;
|
||||
|
||||
height: 66rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.tab-item.active::before {
|
||||
content: "";
|
||||
background-color: #bbe600;
|
||||
position: absolute;
|
||||
top: 90%;
|
||||
left: 35%;
|
||||
width: 30%;
|
||||
height: 6rpx;
|
||||
border-radius: 6rpx;
|
||||
}
|
||||
|
||||
.tab-more {
|
||||
margin-left: 10rpx;
|
||||
/* 与Tab的间距 */
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: linear-gradient(-88.60deg, rgba(18, 18, 18, 1), rgba(18, 18, 18, 0) 100%);
|
||||
height: 66rpx;
|
||||
}
|
||||
|
||||
.more {
|
||||
width: 30rpx;
|
||||
height: 30rpx;
|
||||
margin-top: 5rpx;
|
||||
}
|
||||
|
||||
.listItem .opt {
|
||||
width: 70rpx;
|
||||
height: 210rpx;
|
||||
|
||||
}
|
||||
|
||||
.listItem .opt .checkbox {
|
||||
width: 35rpx;
|
||||
height: 35rpx;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid rgba(255, 255, 255, 0.4);
|
||||
border-radius: 8rpx;
|
||||
background-color: #00000000;
|
||||
}
|
||||
|
||||
.listItem .opt .checkbox .icon {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.listItem .opt .checkbox.active {
|
||||
background-color: #AED600 !important;
|
||||
}
|
||||
|
||||
.listItem .opt .checkbox.active .icon {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.listItem .main {
|
||||
width: calc(100% - 70rpx);
|
||||
height: 210rpx;
|
||||
}
|
||||
|
||||
.device-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 15rpx;
|
||||
padding: 30rpx 0 10rpx 30rpx;
|
||||
background: rgba(26, 26, 26, 1);
|
||||
}
|
||||
|
||||
.device-name {
|
||||
font-size: 32rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
margin-left: 24rpx;
|
||||
line-height: 50rpx;
|
||||
width: 75%;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.ID {
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
font-size: 26rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
position: relative;
|
||||
|
||||
}
|
||||
|
||||
.deviceIMG {
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
border-radius: 16rpx;
|
||||
position: relative;
|
||||
background-color: rgba(42, 42, 42, 0.6);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.p10 {
|
||||
padding-left: 20rpx;
|
||||
}
|
||||
|
||||
.splitLine {
|
||||
background: linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(255, 255, 255, 1) 44.525%, rgba(255, 254.75, 254.75, 0) 92%);
|
||||
opacity: 0.2;
|
||||
width: 4rpx;
|
||||
height: 25rpx;
|
||||
margin: 0rpx 20rpx;
|
||||
}
|
||||
|
||||
.disc {
|
||||
padding: 5rpx 10rpx;
|
||||
margin-right: -30rpx;
|
||||
}
|
||||
|
||||
.disc.active {
|
||||
background-color: #2a2a2a !important;
|
||||
;
|
||||
}
|
||||
|
||||
.discImg {
|
||||
width: 24rpx;
|
||||
height: 24rpx;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
|
||||
.IMG {
|
||||
width: 68rpx;
|
||||
height: 50rpx;
|
||||
margin-left: 17%;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.device-callpolice {
|
||||
width: 122rpx;
|
||||
height: 52rpx;
|
||||
font-size: 24rpx;
|
||||
border-radius: 0px 8px 0px 8px;
|
||||
background-color: rgba(224, 52, 52, 1);
|
||||
position: absolute;
|
||||
top: 0rpx;
|
||||
right: -4rpx;
|
||||
text-align: center;
|
||||
line-height: 52rpx;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.device-status {
|
||||
width: 122rpx;
|
||||
height: 52rpx;
|
||||
font-size: 26rpx;
|
||||
border-radius: 0px 8px 0px 8px;
|
||||
background-color: rgb(42, 42, 42);
|
||||
position: absolute;
|
||||
top: 0rpx;
|
||||
right: 0rpx;
|
||||
text-align: center;
|
||||
line-height: 52rpx;
|
||||
}
|
||||
|
||||
.online {
|
||||
color: rgb(187, 230, 0);
|
||||
}
|
||||
|
||||
.unline {
|
||||
color: rgba(255, 255, 255, 0.4);
|
||||
}
|
||||
|
||||
.btnOK.active {
|
||||
background: rgba(187, 230, 0, 1) !important;
|
||||
color: rgba(35, 35, 35, 1) !important;
|
||||
}
|
||||
|
||||
.btnOK {
|
||||
/* 矩形 7 */
|
||||
width: 80%;
|
||||
height: 90rpx;
|
||||
line-height: 90rpx;
|
||||
border-radius: 90rpx;
|
||||
text-align: center;
|
||||
color: rgba(255, 255, 255, 0.4);
|
||||
background: rgba(26, 26, 26, 1);
|
||||
font-family: "PingFang SC";
|
||||
font-style: Bold;
|
||||
font-size: 28rpx;
|
||||
font-weight: 400;
|
||||
box-shadow: 0px 0px 2px 0px rgb(255 255 255 / 30%);
|
||||
position: fixed;
|
||||
z-index: 1;
|
||||
bottom: 50rpx;
|
||||
left: 10%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.searchRow {
|
||||
width: 100%;
|
||||
height: 70rpx;
|
||||
margin-top: 90rpx;
|
||||
|
||||
}
|
||||
|
||||
|
||||
.searchRow .ipt {
|
||||
width: calc(100% - 80rpx);
|
||||
height: 100%;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.searchRow .btn {
|
||||
width: 80rpx;
|
||||
height: 100%;
|
||||
line-height: 70rpx;
|
||||
text-align: right;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
font-family: "PingFang SC";
|
||||
font-style: Regular;
|
||||
font-size: 28rpx;
|
||||
font-weight: 400;
|
||||
letter-spacing: 0.14rpx;
|
||||
float: left;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/deep/ .uni-easyinput__content,
|
||||
.uni-easyinput__content {
|
||||
background-color: #1A1A1A !important;
|
||||
border-radius: 70rpx;
|
||||
color: #FFFFFF;
|
||||
text-indent: 10rpx;
|
||||
box-sizing: border-box;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
/deep/ .uni-textarea-placeholder,
|
||||
.uni-textarea-placeholder {
|
||||
color: rgba(255, 255, 255, 0.5);
|
||||
|
||||
font-family: "PingFang SC";
|
||||
font-style: Regular;
|
||||
font-size: 24rpx;
|
||||
font-weight: 400;
|
||||
letter-spacing: 0.14rpx;
|
||||
}
|
||||
</style>
|
||||
509
pages/common/linkDefence/defence.vue
Normal file
509
pages/common/linkDefence/defence.vue
Normal file
@ -0,0 +1,509 @@
|
||||
<template>
|
||||
<view class="maincontent contentBg">
|
||||
<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 class="listContent">
|
||||
<mescroll-uni class="device-list" @init="mescrollInit" @down="downCallback" @up="upCallback" :up="upOption"
|
||||
:down="downOption" :fixed="false">
|
||||
|
||||
<uni-swipe-action>
|
||||
<uni-swipe-action-item v-for="item,index in deviceList" @click="onClick"
|
||||
@change="swipeChange($event, 0)" :autoClose="false">
|
||||
<view class="listItem" @click.stop="gotoDetail(item,index)">
|
||||
<view class="itemMain">
|
||||
|
||||
|
||||
<view class="title">{{item.name?item.name:'预警设防'+index}}</view>
|
||||
<view class="splitLine"></view>
|
||||
<view class="row">
|
||||
<view class="lbl">布防联机:{{item.total}}</view>
|
||||
<view class="lbl">接收设备:{{item.notify}}</view>
|
||||
</view>
|
||||
<view class="row">
|
||||
<view class="lbl">布防联机:{{item.sub}}</view>
|
||||
<view class="lbl">预警主机:{{item.warn}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<template v-slot:right>
|
||||
<view class="swipBtn" @click.stop="onClick(btn,i,item,index)"
|
||||
v-for="btn,i in Status.SwipOptions"
|
||||
:style="{'backgroundColor':btn.style.backgroundColor,'width':btn.style.width}">
|
||||
|
||||
<image :src="btn.style.icon" mode="aspectFit" class="icon"
|
||||
:style="{'filter':btn.style.filter}"></image>
|
||||
<text class="txt">{{btn.text}}</text>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
</uni-swipe-action-item>
|
||||
|
||||
</uni-swipe-action>
|
||||
|
||||
|
||||
</mescroll-uni>
|
||||
</view>
|
||||
|
||||
<global-loading ref="loading" />
|
||||
|
||||
<MsgBox ref="msgPop" />
|
||||
|
||||
<MsgBox ref="rename">
|
||||
<view class="renamePop center">
|
||||
<view class="lbl">设备名称</view>
|
||||
<input class="txt" v-model="cEdit.name" type="text" placeholder="输入名称" maxlength="20"
|
||||
placeholder-class="txtplace" />
|
||||
</view>
|
||||
</MsgBox>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import request, {
|
||||
baseURL
|
||||
} from '@/utils/request.js';
|
||||
import {
|
||||
showLoading,
|
||||
hideLoading,
|
||||
updateLoading
|
||||
} from '@/utils/loading.js';
|
||||
import {
|
||||
MsgSuccess,
|
||||
MsgError,
|
||||
MsgClose,
|
||||
MsgWarning,
|
||||
showPop,
|
||||
MsgInfo,
|
||||
MsgClear,
|
||||
MsgPrompt
|
||||
} from '@/utils/MsgPops.js';
|
||||
import Common from '@/utils/Common.js';
|
||||
|
||||
var timeout = null;
|
||||
var these = null;
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
Status: {
|
||||
navbar: {
|
||||
icons: [{
|
||||
src: '/static/images/common/add.png',
|
||||
type: 'add'
|
||||
}],
|
||||
title: '预警布防',
|
||||
showBack: true,
|
||||
height: 90
|
||||
},
|
||||
SwipOptions: [{
|
||||
type: "rename",
|
||||
text: '重命名',
|
||||
style: {
|
||||
backgroundColor: '#E09319',
|
||||
icon: '/static/images/common/rename.png',
|
||||
width: '120rpx', // 初始宽度
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'drop',
|
||||
text: '删除',
|
||||
style: {
|
||||
backgroundColor: 'rgb(240, 60, 60)',
|
||||
icon: '/static/images/common/dell.png',
|
||||
width: '120rpx', // 初始宽度
|
||||
filter: 'brightness(0) invert(0.87)'
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
mescroll: null,
|
||||
downOption: {
|
||||
auto: true,
|
||||
autoShowLoading: false,
|
||||
},
|
||||
upOption: {
|
||||
auto: false,
|
||||
noMoreSize: 0,
|
||||
offset: 10,
|
||||
isLock: false,
|
||||
empty: {
|
||||
tip: '暂无数据',
|
||||
hideScroll: false,
|
||||
icon: '/static/images/common/empty.png'
|
||||
},
|
||||
textNoMore: '没有更多数据了'
|
||||
},
|
||||
deviceList: [],
|
||||
cEdit: {
|
||||
id: null,
|
||||
name: null,
|
||||
total: null,
|
||||
notify: null,
|
||||
sub: null,
|
||||
warn: null
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.Status.navbar.height = uni.getSystemInfoSync().statusBarHeight + 44;
|
||||
},
|
||||
onLoad() {
|
||||
these = this;
|
||||
},
|
||||
methods: {
|
||||
ReName() {
|
||||
if (!this.cEdit.name) {
|
||||
MsgError('请输入名称', '', these, null, false);
|
||||
return;
|
||||
}
|
||||
let ok = () => {
|
||||
this.deviceList.find((v, i) => {
|
||||
if (v.id == this.cEdit.id) {
|
||||
this.$set(this.deviceList[i], "name", this.cEdit.name)
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
let url = '';
|
||||
if (url) {
|
||||
request({
|
||||
url: url,
|
||||
data: this.cEdit,
|
||||
method: 'update'
|
||||
}).then(res => {
|
||||
if (res && res.code == 200) {
|
||||
ok();
|
||||
}
|
||||
}).catch(ex => {
|
||||
MsgError(ex.msg, '', these);
|
||||
});
|
||||
} else {
|
||||
ok();
|
||||
}
|
||||
},
|
||||
onClick(btn, i, item, index) {
|
||||
if (btn.type == 'rename') {
|
||||
these.cEdit = Object.assign(these.cEdit, item);
|
||||
console.log("执行重命名");
|
||||
MsgPrompt(this, btn.type, this.ReName, false, true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (btn.type == 'drop') {
|
||||
console.log("执行删除");
|
||||
MsgError('删除后不可恢复,您确认删除"' + item.name + '"吗?', '确定', this, () => {
|
||||
this.deviceList.splice(index, 1);
|
||||
}, true);
|
||||
return;
|
||||
}
|
||||
},
|
||||
change(event) {
|
||||
console.log('改变事件', event);
|
||||
},
|
||||
swipeChange(e, index) {
|
||||
console.log('当前状态:' + e + ',下标:' + index)
|
||||
},
|
||||
gotoDetail(item, index) {
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/linkDefence/addDefence',
|
||||
success(res) {
|
||||
res.eventChannel.emit('detailData',{data:item})
|
||||
}
|
||||
});
|
||||
},
|
||||
mescrollInit(mescroll) {
|
||||
this.mescroll = mescroll;
|
||||
},
|
||||
// 下拉刷新
|
||||
downCallback() {
|
||||
|
||||
|
||||
if (this.mescroll) {
|
||||
this.mescroll.resetUpScroll(false);
|
||||
this.mescroll.scrollTo(0, 0);
|
||||
}
|
||||
this.getData();
|
||||
|
||||
|
||||
},
|
||||
// 上拉加载
|
||||
upCallback() {
|
||||
this.getData();
|
||||
},
|
||||
getData() {
|
||||
let task = () => {
|
||||
|
||||
let data = {
|
||||
pageNum: this.mescroll.num,
|
||||
pageSize: 10,
|
||||
}
|
||||
|
||||
if (!data.pageNum) {
|
||||
this.mescroll.endSuccess(0, false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
let result = (res) => {
|
||||
|
||||
// 分页处理
|
||||
if (data.pageNum === 1) {
|
||||
this.deviceList = res.rows;
|
||||
} else {
|
||||
this.deviceList = this.deviceList.concat(res.rows);
|
||||
}
|
||||
|
||||
let hasNext = true;
|
||||
|
||||
if (res.rows.length < data.pageSize || this.deviceList.length >= res.total) {
|
||||
|
||||
hasNext = false;
|
||||
} else {
|
||||
|
||||
hasNext = true;
|
||||
}
|
||||
this.mescroll.endSuccess(res.rows.length, hasNext);
|
||||
}
|
||||
let url = ''; //请求地址
|
||||
if (url) {
|
||||
request({
|
||||
url: url,
|
||||
data: data,
|
||||
method: 'GET'
|
||||
}).then((res) => {
|
||||
if (res.code == 200) {
|
||||
result(res);
|
||||
} else {
|
||||
this.mescroll.endSuccess(0, false);
|
||||
}
|
||||
}).catch(ex => {
|
||||
MsgError(ex.errMsg, '', this);
|
||||
this.mescroll.endSuccess(0, false);
|
||||
});
|
||||
} else {
|
||||
if (data.pageNum === 1) {
|
||||
//开发时做假数据模拟成功
|
||||
MsgWarning("这是测试数据,非真实场景,真实功能敬请期待", '', this, true, null, false);
|
||||
}
|
||||
let res = {
|
||||
code: 200,
|
||||
total: 108,
|
||||
rows: []
|
||||
};
|
||||
let currLen = this.deviceList.length;
|
||||
|
||||
for (let i = 0; i < data.pageSize; i++) {
|
||||
if (currLen + i + 1 >= res.total) {
|
||||
break;
|
||||
}
|
||||
let json = {
|
||||
id: Common.guid(),
|
||||
name: '预警设防 ' + (i + (data.pageNum - 1) * data.pageSize + 1),
|
||||
total: (Math.random() * 100).toFixed(0),
|
||||
notify: (Math.random() * 100).toFixed(0),
|
||||
sub: (Math.random() * 100).toFixed(0),
|
||||
warn: (Math.random() * 100).toFixed(0)
|
||||
};
|
||||
res.rows.push(json);
|
||||
}
|
||||
result(res);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(task, 50);
|
||||
|
||||
},
|
||||
prevPage() {
|
||||
uni.navigateBack({
|
||||
|
||||
});
|
||||
},
|
||||
handleRightClick(s, e) {
|
||||
|
||||
if (s === 0) {
|
||||
uni.navigateTo({
|
||||
url: '/pages/common/linkDefence/addDefence'
|
||||
})
|
||||
} else if (s === 1) {
|
||||
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.maincontent {
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.listContent {
|
||||
height: calc(100% - 90rpx);
|
||||
margin-top: 90rpx;
|
||||
}
|
||||
|
||||
.listItem {
|
||||
|
||||
|
||||
background: rgba(26, 26, 26, 1);
|
||||
width: 100%;
|
||||
min-height: 140rpx;
|
||||
height: auto;
|
||||
|
||||
box-sizing: border-box;
|
||||
padding: 20rpx 30rpx;
|
||||
}
|
||||
|
||||
.listItem .itemMain {
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.listItem .title {
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
|
||||
font-family: "PingFang SC";
|
||||
|
||||
font-size: 32rpx;
|
||||
font-weight: 400;
|
||||
|
||||
letter-spacing: 0.14rpx;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.listItem .splitLine {
|
||||
border-bottom: 1rpx solid rgba(255, 255, 255, 1);
|
||||
width: 10000px;
|
||||
height: 0rpx;
|
||||
margin-top: 15rpx;
|
||||
margin-bottom: 15rpx;
|
||||
transform: scale(0.1);
|
||||
margin-left: -5000px;
|
||||
}
|
||||
|
||||
.listItem .row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
align-content: center;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 15rpx;
|
||||
|
||||
color: rgba(255, 255, 255, 1);
|
||||
|
||||
font-family: "PingFang SC";
|
||||
font-style: Regular;
|
||||
font-size: 24rpx;
|
||||
font-weight: 200;
|
||||
|
||||
letter-spacing: 0.07px;
|
||||
|
||||
}
|
||||
|
||||
/* .listItem .row .lbl{
|
||||
padding: 0rpx 30rpx 0rpx 0rpx;
|
||||
text-align: left;
|
||||
} */
|
||||
.listItem .row:last-of-type {
|
||||
margin-bottom: 0rpx;
|
||||
}
|
||||
|
||||
.swipBtn {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-wrap: wrap;
|
||||
align-content: center;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.uni-swipe .icon,
|
||||
/deep/ .uni-swipe .icon {
|
||||
width: 35rpx;
|
||||
height: 35rpx;
|
||||
}
|
||||
|
||||
.uni-swipe .txt,
|
||||
/deep/ .uni-swipe .txt {
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
|
||||
font-family: "PingFang SC";
|
||||
font-style: Regular;
|
||||
font-size: 24rpx;
|
||||
font-weight: 400;
|
||||
|
||||
letter-spacing: 0.14rpx;
|
||||
|
||||
}
|
||||
|
||||
.uni-swipe,
|
||||
/deep/ .uni-swipe {
|
||||
margin-bottom: 20rpx;
|
||||
border-radius: 16rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.renamePop {
|
||||
width: 100%;
|
||||
height: 80rpx;
|
||||
padding: 60rpx 0rpx 30rpx 0rpx;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.renamePop .lbl {
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
font-family: "PingFang SC";
|
||||
font-style: Regular;
|
||||
font-size: 26rpx;
|
||||
letter-spacing: 0.14rpx;
|
||||
width: auto;
|
||||
padding: 0rpx 10rpx 0rpx 0rpx;
|
||||
}
|
||||
|
||||
.renamePop .txt {
|
||||
flex: 1;
|
||||
height: 60rpx;
|
||||
box-sizing: border-box;
|
||||
border: 1rpx solid rgba(255, 255, 255, 0.4);
|
||||
border-radius: 8rpx;
|
||||
text-align: left;
|
||||
text-indent: 10rpx;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
|
||||
font-family: "PingFang SC";
|
||||
|
||||
font-size: 28rpx;
|
||||
|
||||
letter-spacing: 0.14rpx;
|
||||
|
||||
}
|
||||
|
||||
.txtplace {
|
||||
color: rgba(255, 255, 255, 0.43);
|
||||
|
||||
font-family: "PingFang SC";
|
||||
|
||||
font-size: 26rpx;
|
||||
}
|
||||
</style>
|
||||
@ -68,6 +68,8 @@
|
||||
login,
|
||||
resourceSmsCode
|
||||
} from '@/api/common/login.js';
|
||||
import mqplus from '@/utils/MqPlus.js';
|
||||
var mqcommon=null;
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@ -85,6 +87,7 @@
|
||||
},
|
||||
onLoad() {
|
||||
this.phone= uni.getStorageSync('phone');
|
||||
mqcommon=mqplus.getMqPlus();
|
||||
if (uni.getStorageSync("token") && uni.getStorageSync("clientID")) { //免登陆
|
||||
let time = uni.getStorageSync("tokenTime");
|
||||
if (!time) {
|
||||
@ -258,10 +261,14 @@
|
||||
uni.showToast({
|
||||
title: '登录成功',
|
||||
icon: 'success'
|
||||
})
|
||||
});
|
||||
|
||||
uni.switchTab({
|
||||
url: '/pages/common/index/index'
|
||||
})
|
||||
});
|
||||
if(mqcommon){
|
||||
mqcommon.sendUsrLogin();
|
||||
}
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg || '服务器异常,请稍后重试',
|
||||
@ -294,8 +301,9 @@
|
||||
},
|
||||
// 同意
|
||||
handleAgree() {
|
||||
this.isChecked = !this.isChecked
|
||||
this.showAgreement = false
|
||||
this.isChecked = !this.isChecked;
|
||||
this.showAgreement = false;
|
||||
this.handleLogin();
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@ -1,6 +1,22 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<map class="map" :latitude="latitude" :longitude="longitude" :markers="covers" @markertap="onMarkerTap"
|
||||
<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>
|
||||
|
||||
<map id="map" ref="map" class="map" :latitude="latitude" :longitude="longitude" :markers="covers" @markertap="onMarkerTap"
|
||||
:scale="16"></map>
|
||||
|
||||
<!-- 加载提示 -->
|
||||
@ -13,6 +29,7 @@
|
||||
|
||||
<script>
|
||||
import Common from "@/utils/Common.js";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@ -79,6 +96,17 @@
|
||||
showMask: true,
|
||||
maskBgColor: '#00000066',
|
||||
showClose: false
|
||||
},
|
||||
navbar: {
|
||||
icons: [
|
||||
// {
|
||||
// type:'msg',
|
||||
// src: '/static/images/common/guiji.png'
|
||||
// }
|
||||
],
|
||||
title: '查看位置',
|
||||
showBack: true,
|
||||
height: 90
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,9 +141,20 @@
|
||||
this.loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
prevPage() {
|
||||
uni.navigateBack({
|
||||
|
||||
});
|
||||
},
|
||||
handleRightClick: function(s, e) {
|
||||
|
||||
console.log("敬请期待");
|
||||
},
|
||||
showAction() {
|
||||
|
||||
let gd=plus.runtime.isApplicationExist({
|
||||
@ -277,4 +316,22 @@
|
||||
background-color: rgba(0, 0, 0, 0.7);
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.img {
|
||||
width: 35rpx;
|
||||
height: 35rpx;
|
||||
margin-right: 30rpx;
|
||||
}
|
||||
|
||||
.uni-navbar--fixed {
|
||||
top: 0rpx;
|
||||
}
|
||||
|
||||
.uni-navbar--fixed {
|
||||
top: 0px;
|
||||
}
|
||||
|
||||
.uni-navbar__placeholder {
|
||||
display: none !important;
|
||||
}
|
||||
</style>
|
||||
@ -53,8 +53,11 @@
|
||||
MsgPrompt
|
||||
} from '@/utils/MsgPops.js'
|
||||
import Common from '@/utils/Common.js';
|
||||
import api from '@/api/670/HBY670.js';
|
||||
|
||||
var these = null;
|
||||
var eventChannel = null;
|
||||
import {deviceInfo} from '@/api/common/index.js'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@ -86,7 +89,9 @@
|
||||
longitude: null,
|
||||
alarmStatus: null,
|
||||
detailPageUrl: "/pages/650/HBY650",
|
||||
showConfirm: false
|
||||
showConfirm: false,
|
||||
contact1Phone:null,
|
||||
contact2Phone:null
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -125,14 +130,41 @@
|
||||
console.log("收到父页面的参数:" + JSON.stringify(data));
|
||||
these.device = data;
|
||||
|
||||
this.list[0] = data.contact1Phone;
|
||||
this.list[1] = data.contact2Phone;
|
||||
|
||||
|
||||
this.init();
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
methods: {
|
||||
init(){
|
||||
api.getDetail(this.device.id).then(res => {
|
||||
|
||||
if (res && res.code == 200) {
|
||||
let data = res.data;
|
||||
if(data.length){
|
||||
data=data[0];
|
||||
}
|
||||
let keys = Object.keys(data);
|
||||
let dKeys = Object.keys(this.device);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
let key = keys[i];
|
||||
|
||||
let dk = dKeys.find(k => {
|
||||
return key.toLowerCase() == k.toLowerCase();
|
||||
});
|
||||
if (dk) {
|
||||
this.$set(this.device, dk, data[key]);
|
||||
} else {
|
||||
this.$set(this.device, key, data[key]);
|
||||
}
|
||||
}
|
||||
|
||||
this.list[0] = data.contact1Phone;
|
||||
this.list[1] = data.contact2Phone;
|
||||
}
|
||||
});
|
||||
},
|
||||
notifyPrevPage(){//通知上一个页面
|
||||
if (eventChannel) {
|
||||
eventChannel.emit('linkManOver', this.list);
|
||||
@ -231,9 +263,7 @@
|
||||
|
||||
let requestCall = () => {
|
||||
|
||||
this.$set(this.list, this.cEdit.index, this.cEdit.txt)
|
||||
|
||||
|
||||
this.$set(this.list, this.cEdit.index, this.cEdit.txt)
|
||||
this.cEdit.txt = "";
|
||||
this.cEdit.index = -1;
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
MsgInfo
|
||||
} from '@/utils/MsgPops.js'
|
||||
import Common from '@/utils/Common.js';
|
||||
|
||||
import api from '@/api/670/HBY670.js';
|
||||
|
||||
var these = null;
|
||||
var eventChannel = null;
|
||||
@ -67,7 +67,8 @@
|
||||
longitude: null,
|
||||
alarmStatus: null,
|
||||
detailPageUrl: "",
|
||||
showConfirm: false
|
||||
showConfirm: false,
|
||||
sosSmsMsg:null
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -101,11 +102,24 @@
|
||||
if(data.sosSmsMsg){
|
||||
this.txt=data.sosSmsMsg;
|
||||
}
|
||||
this.init();
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
methods: {
|
||||
init(){
|
||||
api.getDetail(this.device.id).then(res => {
|
||||
|
||||
if (res && res.code == 200) {
|
||||
let data = res.data;
|
||||
if(data.length){
|
||||
data=data[0];
|
||||
}
|
||||
this.txt=data.sosSmsMsg;
|
||||
}
|
||||
});
|
||||
},
|
||||
copyTo(item, index) {
|
||||
this.txt = item;
|
||||
},
|
||||
|
||||
@ -27,6 +27,12 @@
|
||||
<text class="title">版本更新 ({{appVersion}})</text>
|
||||
<uni-icons type="right" size="25" color="rgba(255, 255, 255, 0.4)" class="uniIcon"></uni-icons>
|
||||
</view>
|
||||
<view class="menu-item" @click="clearCatch">
|
||||
<image src="/static/images/common/clear.png" class="icon"></image>
|
||||
<text class="title">清理缓存</text>
|
||||
<uni-icons type="right" size="25" color="rgba(255, 255, 255, 0.4)" class="uniIcon"></uni-icons>
|
||||
</view>
|
||||
|
||||
<view class="menu-item" @click="sendCounsel">
|
||||
<image src="/static/images/common/yijianfankui.png" class="icon"></image>
|
||||
<text class="title">举报反馈</text>
|
||||
@ -37,16 +43,11 @@
|
||||
<text class="title">关于我们</text>
|
||||
<uni-icons type="right" size="25" color="rgba(255, 255, 255, 0.4)" class="uniIcon"></uni-icons>
|
||||
</view>
|
||||
<!-- <view class="menu-item" @click="logOff">
|
||||
<image src="/static/images/common/zhuxiao.png" class="icon"></image>
|
||||
<text class="title">注销账号</text>
|
||||
<uni-icons type="right" size="25" color="rgba(255, 255, 255, 0.4)" class="uniIcon"></uni-icons>
|
||||
</view> -->
|
||||
<view class="menu-item" @click="account">
|
||||
<image src="/static/images/common/wm.png" class="icon"></image>
|
||||
<text class="title">账号</text>
|
||||
<uni-icons type="right" size="25" color="rgba(255, 255, 255, 0.4)" class="uniIcon"></uni-icons>
|
||||
</view>
|
||||
<view class="menu-item" @click="account">
|
||||
<image src="/static/images/common/wm.png" class="icon"></image>
|
||||
<text class="title">账号</text>
|
||||
<uni-icons type="right" size="25" color="rgba(255, 255, 255, 0.4)" class="uniIcon"></uni-icons>
|
||||
</view>
|
||||
<view class="btn_footer">
|
||||
<button class="logout" @click="logout">退出登录</button>
|
||||
</view>
|
||||
@ -69,6 +70,8 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<MsgBox ref="msgPop" />
|
||||
</view>
|
||||
|
||||
</template>
|
||||
@ -78,6 +81,15 @@
|
||||
Logout
|
||||
} from '@/api/common/login.js'
|
||||
import bleTool from '@/utils/BleHelper.js';
|
||||
import {
|
||||
MsgSuccess,
|
||||
MsgError,
|
||||
MsgClose,
|
||||
MsgWarning,
|
||||
showPop,
|
||||
MsgInfo,
|
||||
MsgClear
|
||||
} from '@/utils/MsgPops.js'
|
||||
var ble=null;
|
||||
export default {
|
||||
data() {
|
||||
@ -106,6 +118,32 @@
|
||||
|
||||
},
|
||||
methods: {
|
||||
clearCatch(){
|
||||
MsgWarning("将清除以下缓存数据:设备配对、网络缓存、音频、视频,清除后下次使用将重新加载,您确认清除?",'确定',this,true,()=>{
|
||||
let store = uni.getStorageInfoSync();
|
||||
store.keys.forEach((val, index, array) => {
|
||||
if (val == "linkedDevices") {
|
||||
//设备配对只保留已连接的数据
|
||||
if(ble){
|
||||
let linked=ble.data.LinkedList.filter((v,i)=>{
|
||||
return v.Linked;
|
||||
});
|
||||
|
||||
ble.data.LinkedList=linked;
|
||||
ble.updateCache();
|
||||
}
|
||||
|
||||
} else if (val == "tokenTime" || val == "token" || val == "clientID" || val == 'phone') {
|
||||
console.log("忽略登陆信息");
|
||||
} else {
|
||||
uni.removeStorageSync(val);
|
||||
}
|
||||
});
|
||||
|
||||
MsgSuccess("清理成功",'',this);
|
||||
},true);
|
||||
|
||||
},
|
||||
//版本更新
|
||||
gotoAppStore(){
|
||||
let os=uni.getSystemInfoSync().platform;
|
||||
@ -196,6 +234,7 @@
|
||||
url: '/pages/common/account/index'
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user