常驻保活逻辑优化

main
zhangqun 2 years ago
parent 622086f18e
commit fd3200b19c
  1. 74
      App.vue
  2. 3
      manifest.json
  3. 2
      pages/index/index.vue
  4. 20
      pages/setting/index.vue
  5. 50
      unpackage/dist/dev/app-plus/app-service.js
  6. 40
      unpackage/dist/dev/app-plus/app-view.js
  7. 2
      unpackage/dist/dev/app-plus/manifest.json

@ -17,60 +17,45 @@
message: '', //
timer: null,
reportLastTime: null, //
msgIds:[]
}
},
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;
// } 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('销毁');
this.stop();
},
onShow: function() {
//
this.msgIds.map(id => {
console.log('取消通知', id)
this.onCancelNotify(id);
})
this.msgIds = [];
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();
// this.subStatus();
}else{
} else {
// uni.navigateTo({
// url: '/pages/setting/user'
// })
}
},
onHide: function() {
setTimeout(() => {
console.log('通知', new Date().getTime())
this.onShowNotify();
}, 1000)
setTimeout(() => {
console.log('通知', new Date().getTime())
this.onShowNotify();
}, 3000)
console.log('App Hide', this.employeeId);
if (this.employeeId) {
// this.getStatus();
@ -131,7 +116,7 @@
subStatus(num) {
// websocket
websocket.subStatus(res => {
console.log("监听 websocket 连接状态"+num, res);
console.log("监听 websocket 连接状态" + num, res);
if (!res.websocketStatus) {
this.stop();
this.timer && clearTimeout(this.timer);
@ -159,11 +144,14 @@
//
keepAlive.onKeep({
title: "齐鲁医院报警通知",
content: "保持运行",
content: "保持运行中...",
isRouge: true
},
(res) => {
console.log(res);
console.log('onkeep', res);
// if (res.ok) {
// this.isIgnoringBattery();
// }
});
},
onAutoStart() { //
@ -204,26 +192,26 @@
});
},
onShowNotify() { //
let id = new Date().getTime();
keepAlive.onShowNotify({
//channelId: "Ba-KeepAlive",
//channelName: "Ba-KeepAlive",
ID: new Date().getTime(),
// channelId: "Ba-KeepAlive",
// channelName: "Ba-KeepAlive",
ID: id,
title: "入侵报警信息",
content: this.message,
},
(res) => {
console.log(res);
this.msgIds.push(id);
this.message = '';
});
},
onCancelNotify() {
onCancelNotify(id) {
//
keepAlive.onCancelNotify({
//channelId: "Ba-KeepAlive",
//channelName: "Ba-KeepAlive",
//ID:99
//title: "",
//content: "",
// channelId: "Ba-KeepAlive",
// channelName: "Ba-KeepAlive",
ID:id
},
(res) => {
console.log(res);

@ -54,7 +54,8 @@
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
]
],
"schemes" : "qlhospital"
},
"ios" : {
"dSYMs" : false

@ -38,7 +38,7 @@
export default {
data() {
return {
url: 'http://192.168.3.109:89',
url: 'http://192.168.1.36:89',
employeeId: '',
lat: '',
lng: '',

@ -3,11 +3,17 @@
<view class="padding-wrap">
<view class="nav-list" @click="goPage('/pages/setting/user')">
<text style="flex:1;">远端设置</text>
<uni-icons type="right" size="26"></uni-icons>
<uni-icons type="right" size="18" color="#999"></uni-icons>
</view>
<view class="nav-list" @click="goPage('/pages/setting/other')">
<text style="flex:1;">常用报警位置设置</text>
<uni-icons type="right" size="26"></uni-icons>
<uni-icons type="right" size="18" color="#999"></uni-icons>
</view>
<view class="nav-list" @click="doSetAuto">
<text style="flex:1;">设置自启后台运行</text>
</view>
<view class="nav-list" @click="doSetBattery">
<text style="flex:1;">电池优化白名单配置</text>
</view>
</view>
</view>
@ -23,7 +29,15 @@
uni.navigateTo({
url: url
})
}
},
//
doSetBattery() {
getApp().isIgnoringBattery();
},
//
doSetAuto() {
getApp().onAutoStart();
},
}
}
</script>

File diff suppressed because one or more lines are too long

@ -5103,6 +5103,46 @@ var render = function () {
],
1
),
_c(
"uni-view",
{
staticClass: _vm._$g(8, "sc"),
attrs: { _i: 8 },
on: {
click: function ($event) {
return _vm.$handleViewEvent($event)
},
},
},
[
_c(
"v-uni-text",
{ staticStyle: { flex: "1" }, attrs: { _i: 9 } },
[_vm._v("设置自启、后台运行")]
),
],
1
),
_c(
"uni-view",
{
staticClass: _vm._$g(10, "sc"),
attrs: { _i: 10 },
on: {
click: function ($event) {
return _vm.$handleViewEvent($event)
},
},
},
[
_c(
"v-uni-text",
{ staticStyle: { flex: "1" }, attrs: { _i: 11 } },
[_vm._v("电池优化白名单配置")]
),
],
1
),
],
1
),

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