1
0
forked from dyf/APP

常规小优化

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

View File

@ -65,7 +65,8 @@
</view>
</view>
<view class="warnnig" v-show="formData.sta_ShakeBit!='' && formData.sta_ShakeBit!='0'">
<view class="warnnig" v-show="formData.sta_ShakeBit!='' && formData.sta_ShakeBit!='0'"
@click="showAction('map')">
<view>{{ShakeBit}}</view>
</view>
@ -135,6 +136,8 @@
<ProParams :id="device.id"></ProParams>
<BottomSlideMenuPlus v-for="item,index in dic.actionSheets" :config="item" @close="item.closeMenu"
@itemClick="item.handleItemClick" @btnClick="item.btnClick"></BottomSlideMenuPlus>
<global-loading ref="loading" />
@ -188,7 +191,7 @@
pageHide: false,
usrToggle: false,
usrToggle: false
},
formData: {
img: '/static/images/common/HBY018A.png',
@ -201,6 +204,7 @@
sta_ShakeBit: 0, //报警状态
sta_system: '', //0关机 1关机充电 2开机未充电 3开机充电
bleStatu: '',
},
dic: {
sta_Side_Light: [
@ -235,7 +239,8 @@
sta_charge: {
"0": '未充电',
"1": '充电中'
}
},
actionSheets: []
},
device: {
@ -251,8 +256,8 @@
bindingTime: "",
onlineStatus: 0,
battery: "0",
latitude: '30.495455',
longitude: '114.409500',
latitude: '',
longitude: '',
alarmStatus: null,
detailPageUrl: "/pages/018A/HBY018A",
showConfirm: false,
@ -281,8 +286,8 @@
ble.addDisposeCallback(this.deviceDispose, pagePath);
ble.addRecoveryCallback(this.deviceRecovry, pagePath);
this.initWatch();
this.initActionData();
let eventChannel = this.getOpenerEventChannel();
@ -306,6 +311,9 @@
these.formData[key] = form[key];
}
}
these.device.longitude = form.sta_longitude;
these.device.latitude = form.sta_latitude;
these.formData.blename = f.name ? f.name : "Unname";
these.formData.deviceName = device.deviceName;
@ -322,7 +330,7 @@
these.setBleFormData();
this.initWatch();
});
},
@ -365,7 +373,6 @@
let dic = {
"1": "设备SOS求救中",
"2": "设备静止报警中",
"6": "设备遇水报警中"
};
let keys = Object.keys(dic);
let f = keys.find(key => {
@ -382,23 +389,157 @@
},
methods: {
closeAction() {
for (let index = 0; index < this.dic.actionSheets.length; index++) {
let menu = this.dic.actionSheets[index];
if (menu.show) {
this.$set(this.dic.actionSheets[index], 'show', false);
break;
}
}
},
showAction(name) {
if (this.formData.sta_ShakeBit == 2) {
for (let index = 0; index < this.dic.actionSheets.length; index++) {
let menu = this.dic.actionSheets[index];
if (menu.name == name) {
this.$set(this.dic.actionSheets[index], 'show', true);
if (index == 2) {
this.$set(this.dic.actionSheets[index], 'value', '');
this.$set(this.dic.actionSheets[index], 'activeIndex', -1);
}
} else {
this.$set(this.dic.actionSheets[index], 'show', false);
}
}
}
},
initActionData() { //初始化ActionSheet菜单
let json = {
name: '',
show: false,
showHeader: true,
menuItems: [],
activeIndex: -1,
bgColor: '#2a2a2a',
itemBgColor: '#3a3a3a',
textColor: '#ffffffde',
textAlign: 'flex-start',
title: '请选择',
value: '',
valueMember: 'value',
showDivider: false,
dividerColor: '#00000000',
dividerThickness: '0rpx',
dividerMargin: '10rpx',
itemHeight: '80rpx',
type: '',
showBtn: true,
btnBgColor: "#bbe600",
btnText: "确定",
btnTextColor: "#232323de",
showMask: true,
maskBgColor: '#00000066',
showClose: false,
closeMenu: these.closeAction,
btnClick: (li, i) => {
debugger;
},
handleItemClick: (li, i) => {
debugger;
}
};
let item = Object.assign({}, json);
item.name = 'map';
item.title = '选择地图'
item.menuItems = [{
text: '高德地图',
icon: '/static/images/lightImg/qiang.png',
value: 'amap',
key: 'map'
},
{
text: '百度地图',
icon: '/static/images/lightImg/work.png',
value: 'baidumap',
key: 'map'
}
];
item.handleItemClick = (li, i) => {
this.$set(this.dic.actionSheets[0], 'value', li.value);
};
item.btnClick = (li, i) => {
console.log("li=", li);
this.$set(this.dic.actionSheets[0], 'show', false);
console.log("device=", this.device);
if (this.device.longitude && this.device.latitude) {
Common.MapNavi(this.device.longitude, this.device.latitude, '', li.value).catch(ex => {
MsgError(ex, "", these);
});
} else {
if (this.formData.sta_longitude && this.formData.sta_latitude) {
// let promise = lnglatConvert.wgs84_to_gcj02(this.formData.sta_longitude, this.formData
// .sta_latitude);
// promise.then(lnglat => {
this.device.longitude = this.formData.sta_longitude;
this.device.latitude = this.formData.sta_latitude;
// Common.regeo(lnglat[0], lnglat[1]).then(res => {
// this.formData.address = res.regeocode.formatted_address;
Common.MapNavi(this.device.longitude, this.device.latitude, this.formData.address, li
.value).catch(ex => {
MsgError(ex, "", these);
})
// }).catch(ex => {
// console.error("逆地理失败了")
// });
// }).catch(err => {
// console.error("坐标转换失败了");
// });
}
}
}
this.dic.actionSheets = [item];
},
getDeviceDetail() {
api.getDetail(this.device.id).then(res => {
if (res && res.code == 200) {
let data = res.data;
let keys = Object.keys(data);
let dKeys=Object.keys(this.device);
let dKeys = Object.keys(this.device);
for (let i = 0; i < keys.length; i++) {
let key = keys[i];
let dk=dKeys.find(k=>{
return key.toLowerCase()==k.toLowerCase();
let dk = dKeys.find(k => {
return key.toLowerCase() == k.toLowerCase();
});
if(dk){
this.$set(this.device,dk,data[key]);
}else{
this.$set(this.device,key,data[key]);
if (dk) {
this.$set(this.device, dk, data[key]);
} else {
this.$set(this.device, key, data[key]);
}
}
}
@ -445,19 +586,19 @@
}
});
this.$watch("formData.sta_longitude", (newVal, oldVal) => {
if (newVal) {
this.reGeo();
}
this.$watch("formData.sta_ShakeBit", (newVal, oldVal) => {
this.routePlan();
});
this.$watch("formData.sta_latitude", (newVal, oldVal) => {
if (newVal) {
this.reGeo();
}
});
},
routePlan() {
if (this.formData.sta_ShakeBit == 2) {
MsgError(["设备静止报警中!", "请注意接听设备来电和短信!"], "位置导航", these, () => {
these.showAction('map');
});
}
},
reGeo() {
console.log("经纬度发生变化,执行逆地理")
@ -470,11 +611,13 @@
this.device.longitude = lnglat[0];
this.device.latitude = lnglat[1];
Common.regeo(lnglat[0], lnglat[1]).then(res => {
this.formData.address = res.regeocode.formatted_address
}).catch(ex => {
console.error("逆地理失败了")
})
}).finally(this.routePlan);
}).catch(err => {
console.error("坐标转换失败了");
});
@ -493,13 +636,13 @@
success(res) {
res.eventChannel.emit('device', these.device);
},
events:{
linkManOver:(data)=>{
this.device.contact1Phone=data[0];
this.device.contact2Phone=data[1];
events: {
linkManOver: (data) => {
this.device.contact1Phone = data[0];
this.device.contact2Phone = data[1];
},
MsgOver:(data)=>{
this.device.sosSmsMsg=data;
MsgOver: (data) => {
this.device.sosSmsMsg = data;
}
}
});
@ -622,23 +765,28 @@
MsgError("获取设备位置异常", '', these);
return;
}
let promise = lnglatConvert.wgs84_to_gcj02(this.formData.sta_longitude, this.formData.sta_latitude);
promise.then(lnglat => {
// let promise = lnglatConvert.wgs84_to_gcj02(this.formData.sta_longitude, this.formData.sta_latitude);
// promise.then(lnglat => {
// console.log("坐标转换成功", lnglat);
this.device.longitude = this.formData.sta_longitude;
this.device.latitude = this.formData.sta_latitude;
this.detailData.longitude = lnglat[0];
this.detailData.latitude = lnglat[1];
uni.navigateTo({
url: '/pages/common/map/index',
events: {
ack: function(data) {}
},
success: (res) => {
res.eventChannel.emit('Map', {
data: this.detailData
});
}
})
});
console.log("device=",this.device);
uni.navigateTo({
url: '/pages/common/map/index',
events: {
ack: function(data) {}
},
success: (res) => {
res.eventChannel.emit('Map', {
data: this.device
});
},
fail(ex) {
console.error("跳转失败", ex);
}
})
// });
},
LighSetting(item, index) {
@ -717,6 +865,20 @@
}, these, false);
},
receivData(json) {
let keys = Object.keys(json);
keys.forEach(key => {
if (key in this.formData) {
this.formData[key] = json[key];
}
});
if ('sta_longitude' in json) {
this.reGeo();
}
these.setBleFormData();
},
deviceRecovry(res) {
console.log("蓝牙连接成功", these.formData);
@ -808,27 +970,12 @@
}
let json = recei.ReceiveData(receive, device, pagePath, recArr);
this.receivData(json);
console.log("json=", json)
let msg = [];
if (json.sta_PowerPercent <= 20 && (json.sta_system != 1 || json.sta_system != 3)) {
msg.push("设备电量低");
}
let keys = Object.keys(json);
keys.forEach(key => {
if (key in this.formData) {
this.formData[key] = json[key];
}
});
if (msg.length > 0) {
MsgError(msg.join(','), '', these);
}
these.setBleFormData();
},
getDevice: function() {