保活逻辑优化;上报iot验证

main
zhangqun 3 years ago
parent 3ed68e7fa3
commit bc49799595
  1. 89
      App.vue
  2. 24
      pages/patrolRecord/report.vue
  3. 24
      pages/voiceRecord/report.vue
  4. BIN
      unpackage/cache/apk/__UNI__B814B58_cm.apk
  5. 2
      unpackage/cache/apk/apkurl
  6. 2
      unpackage/cache/apk/cmManifestCache.json
  7. 2
      unpackage/cache/wgt/__UNI__B814B58/app-service.js
  8. 2
      unpackage/dist/build/app-plus/app-service.js
  9. 26
      unpackage/dist/dev/app-plus/app-service.js
  10. BIN
      unpackage/release/apk/__UNI__60FDF23__20230707163431.apk
  11. BIN
      unpackage/release/apk/__UNI__60FDF23__20230707172417.apk
  12. BIN
      unpackage/release/apk/__UNI__B814B58__20230807152309.apk
  13. BIN
      unpackage/release/apk/__UNI__B814B58__20230815143501.apk
  14. BIN
      unpackage/release/apk/__UNI__B814B58__20230816131150.apk

@ -12,52 +12,76 @@
},
data() {
return {
heartBeatEate: 60, //
heartBeatEate: 10, //
employeeId: '',
message: '', //
timer: null,
reportLastTime: null,//
reportLastTime: null, //
}
},
onLaunch: function() {
console.log('App Launch');
/********设置开机自动启动开始********/
// this.onKeep();
this.requestAndroidPermission().then(res => {
if (res == 0) {
let userInfo = uni.getStorageSync('mobileInfo') ? JSON.parse(uni.getStorageSync('mobileInfo')) : null;
if (userInfo && userInfo.employeeId != this.employeeId) {
this.employeeId = userInfo.employeeId;
// this.getStatus();
} else {
uni.navigateTo({
url: '/pages/setting/user'
})
}
} else {
uni.showModal({
title: '是否忽略电池优化',
content: '忽略后才能在后台保持连接接收消息通知,请前往设置!',
confirmText: '去设置',
success: (res) => {
if (res.confirm) {
var main = plus.android.runtimeMainActivity();
var Intent = plus.android.importClass('android.content.Intent'); //
var Settings = plus.android.importClass('android.provider.Settings'); //
var intent = new Intent(Intent.ACTION_POWER_USAGE_SUMMARY); //
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
main.startActivity(intent); //
}
}
});
}
});
/********设置开机自动启动结束********/
},
beforeDestroy() {
console.log('销毁');
weboscket.stop();
this.stop();
},
onShow: function() {
console.log('App Show');
let userInfo = uni.getStorageSync('mobileInfo') ? JSON.parse(uni.getStorageSync('mobileInfo')) : null;
if (userInfo && userInfo.employeeId != this.employeeId) {
this.employeeId = userInfo.employeeId;
// this.getStatus();
}
if (keepAlive) {
console.log('清除消息');
this.onCancelNotify();
this.getStatus();
this.subStatus();
}
},
onHide: function() {
console.log('App Hide');
if(this.employeeId) {
console.log('App Hide', this.employeeId);
if (this.employeeId) {
this.sendMsg();
this.getStatus();
this.receiveMsg();
this.getStatus(1);
this.subStatus();
} else {
let userInfo = uni.getStorageSync('mobileInfo') ? JSON.parse(uni.getStorageSync('mobileInfo')) : null;
if (userInfo && userInfo.employeeId != this.employeeId) {
this.employeeId = userInfo.employeeId;
this.sendMsg();
this.getStatus();
this.receiveMsg();
this.subStatus();
}
}
},
methods: {
@ -76,7 +100,7 @@
stop() {
//
websocket.stop(res => {
console.log('关闭websocket',res);
console.log('关闭websocket', res);
});
},
receiveMsg() {
@ -85,9 +109,10 @@
console.log(res);
if (res.ok && res.msg != '连接成功' && res.msg != 'header' && res.msg.indexOf('拒绝') < 0) {
let obj = JSON.parse(res.msg);
if(this.reportLastTime != obj.reportTime) {
if (this.reportLastTime != obj.reportTime) {
this.reportLastTime = obj.reportTime;
this.message = obj.buildId + '号楼' + obj.floorNo + '层' + dateFormat(new Date(obj.reportTime)) + '发生报警:' + obj
this.message = obj.buildId + '号楼' + obj.floorNo + '层' + dateFormat(new Date(obj.reportTime)) +
'发生报警:' + obj
.content;
this.onShowNotify();
}
@ -106,7 +131,13 @@
console.log('监听状态')
websocket.subStatus(res => {
console.log("监听 websocket 连接状态", res);
if (!res.serviceStatus && !res.websocketStatus) {
keepAlive.onShowNotify({
ID: new Date().getTime(),
title: "监听 websocket 连接状态",
content: res.serviceStatus + ' - ' + res.websocketStatus,
},
(res) => {});
if (res.serviceStatus && !res.websocketStatus) {
this.stop();
this.timer && clearTimeout(this.timer);
this.timer = setTimeout(() => {
@ -119,11 +150,8 @@
// websocket
websocket.getStatus(res => {
console.log("websocket开启状态", res);
if (res.data.serviceStatus) {
if(type == 1) {
this.subStatus();
}
}else if(!res.data.serviceStatus && !res.data.websocketStatus){
if (!res.data.websocketStatus) {
this.stop();
this.timer && clearTimeout(this.timer);
this.timer = setTimeout(() => {
this.start();
@ -135,10 +163,9 @@
onKeep() {
//
keepAlive.onKeep({
//channelId: "Ba-KeepAlive",
//channelName: "Ba-KeepAlive",
// title: "",
// content: "",
title: "齐鲁医院报警通知",
content: "保持通知",
isRouge: true
},
(res) => {
console.log(res);
@ -211,7 +238,7 @@
return new Promise((resolve, reject) => {
plus.android.requestPermissions(
[
"android.permission.RECEIVE_BOOT_COMPLETED",
"android.permission.RECEIVE_BOOT_COMPLETED", //
"android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS", //
],
(resultObj) => {
@ -232,16 +259,6 @@
result = -1;
}
resolve(result);
//,APP,APP
if (result == -1) {
reject("授权失败:" + JSON.stringify(resultObj.deniedAlways));
if (resultObj.deniedAlways.indexOf('android.permission.RECEIVE_BOOT_COMPLETED') > -1) {
this.onAutoStart();
} else if (resultObj.deniedAlways.indexOf(
'android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS') > -1) {
this.requestIgnoreBattery();
}
}
},
(error) => {
console.log('申请权限错误:' + error.code + " = " + error.message);

@ -223,28 +223,6 @@
files.forEach(item => {
_arr.push({url:getApp().globalData.fileUrl + item});
})
// let data = {
// "regionId": "000000000001",
// "alarmList": [{
// "alarmId": "0000001",
// "alarmType": 700006,
// "alarmMsg": "",
// "handleStatus": 0,
// "srcType": 3,
// "srcDeviceId": this.form.deviceId,
// "srcReporter": "DINGXIN",
// "startTime": new Date().getTime(),
// "endTime": new Date().getTime(),
// "latitude ": this.form.latidute,
// "longitude": this.form.longidute,
// "videoList": _arr,
// "params": {
// "happentime": new Date().getTime(),
// "alarmType": 700006,
// "alarmMsg": ""
// }
// }]
// }
let data = {
"alarmTypeIdentity": "700006",
"description": "巡更照片上报",
@ -259,7 +237,7 @@
data: data,
success: (res) => {
let _data = JSON.parse(res.data.data);
if (_data.resultCode == 200) {
if (_data.resultCode == 0) {
uni.showToast({
title: '成功'
});

@ -276,28 +276,6 @@
this.voices.forEach(item => {
_arr.push({url:getApp().globalData.fileUrl + item});
})
// let data = {
// "regionId": "000000000001",
// "alarmList": [{
// "alarmId": "0000001",
// "alarmType": 700005,
// "alarmMsg": "",
// "handleStatus": 0,
// "srcType": 3,
// "srcDeviceId": this.form.deviceId,
// "srcReporter": "DINGXIN",
// "startTime": new Date().getTime(),
// "endTime": new Date().getTime(),
// "latitude ": this.form.latidute,
// "longitude": this.form.longidute,
// "videoList": this.voices,
// "params": {
// "happentime": new Date().getTime(),
// "alarmType": 700005,
// "alarmMsg": ""
// }
// }]
// }
let data = {
"alarmTypeIdentity": "700005",
"description": "语音上报",
@ -311,7 +289,7 @@
data: data,
success: (res) => {
let _data = JSON.parse(res.data.data);
if (_data.resultCode == 200) {
if (_data.resultCode == 0) {
uni.showToast({
title: '成功',
success: () => {

Binary file not shown.

@ -1 +1 @@
https://ide.dcloud.net.cn/build/download/ba63e9e0-3a3f-11ee-bebc-2d939bb31dd1
https://ide.dcloud.net.cn/build/download/680488f0-3bf3-11ee-ba98-5b7f97e98b39

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save