|
|
@@ -115,7 +115,6 @@
|
|
|
<view></view>
|
|
|
</template>
|
|
|
</common-list>
|
|
|
-
|
|
|
</scroll-view>
|
|
|
|
|
|
<!-- 底部 TabBar -->
|
|
|
@@ -151,61 +150,6 @@
|
|
|
// });
|
|
|
// };
|
|
|
|
|
|
- const handleKeepAlive = (userId: string)=>{
|
|
|
- var keep=new KeepLive()
|
|
|
- keep.setTitle("工效通")
|
|
|
- keep.setContent("工效通正在运行")
|
|
|
- // keep.setLargeIcon("icon");
|
|
|
- keep.setSmallIcon("icon"); //图标名字 图标放在 插件下面的 uni_modules\android-keeplive\utssdk\app-android\res 文件夹下
|
|
|
- keep.onAddBackgroundCallback(function(res:boolean){
|
|
|
- console.log("后台运行 "+res)
|
|
|
- })
|
|
|
- keep.onAddScrrenListenerCallback(function(res:boolean){
|
|
|
- console.log("屏幕开启状态 "+res)
|
|
|
- })
|
|
|
- keep.setWakeLock(1,"keeptag");// 设置唤醒类型
|
|
|
- keep.setAutoStartEnable(true)
|
|
|
- keep.doStartApplicationWithPackageName("uni.app.UNI1050C07");
|
|
|
-
|
|
|
- if(!keep.checkAppNotification()){
|
|
|
- keep.onOpenNotificationSetting(function(res:boolean){
|
|
|
- keep.register();
|
|
|
- var ignoring= keep.isIgnoringBatteryOptimizations();
|
|
|
- if(!ignoring){
|
|
|
- keep.requestIgnoreBatteryOptimizations();
|
|
|
- }
|
|
|
- })
|
|
|
- }else{
|
|
|
- keep.register();
|
|
|
- var ignoring= keep.isIgnoringBatteryOptimizations();
|
|
|
- if(!ignoring){
|
|
|
- keep.requestIgnoreBatteryOptimizations();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // keep.wifilock();
|
|
|
- // 稳定定时器 需要的用户使用(默认定时器1 )
|
|
|
- keep.onStartCSystemTimer(10,function(){
|
|
|
- console.log("onStartCSystemTimer ");
|
|
|
- getMyNotify(userId).then((result:any) => {
|
|
|
- const jsonData = JSON.stringify(result)
|
|
|
- const respData = JSON.parse(jsonData) as UTSJSONObject
|
|
|
- if (respData['code'] == 200 &&
|
|
|
- respData.hasOwnProperty('data') && respData['data'] != null) {
|
|
|
- const data = respData['data'] as UTSJSONObject
|
|
|
- const title = data["title"] as string
|
|
|
- const desc = data["desc"] as string
|
|
|
- keep.setTitle(title);
|
|
|
- keep.setContent(desc);
|
|
|
- keep.updateNotification();
|
|
|
- }
|
|
|
- }).catch((error) => {
|
|
|
- console.error('Promise 执行失败:', error)
|
|
|
- });
|
|
|
- keep.acquire(1000);// 唤醒一秒钟
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
// 用户名
|
|
|
const userName = ref<string>('用户')
|
|
|
|
|
|
@@ -400,88 +344,89 @@
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- const handleCreateChannel = (showToast : boolean) => {
|
|
|
- // #ifdef APP-ANDROID
|
|
|
- const manager = uni.getPushChannelManager()
|
|
|
- manager.setPushChannel({
|
|
|
- channelId: "msg-pass",
|
|
|
- channelDesc: "留言审核通过",
|
|
|
- soundName: "#填写配置的声音文件名#",
|
|
|
- enableLights: true,
|
|
|
- enableVibration: true,
|
|
|
- importance: 4,
|
|
|
- lockscreenVisibility: 1
|
|
|
- } as SetPushChannelOptions)
|
|
|
- if (showToast) {
|
|
|
- uni.showToast({
|
|
|
- title: "设置渠道成功"
|
|
|
- })
|
|
|
- }
|
|
|
- // #endif
|
|
|
- }
|
|
|
-
|
|
|
- const handleCreateLocalNotification = () => {
|
|
|
- if (uni.getAppAuthorizeSetting().notificationAuthorized == "authorized") {
|
|
|
- handleCreateChannel(false)
|
|
|
- const date = new Date();
|
|
|
- const hour = date.getHours()
|
|
|
- const minute = date.getMinutes()
|
|
|
- const second = date.getSeconds()
|
|
|
- const formateTime = (target : number) : string => {
|
|
|
- return target < 10 ? `0${target}` : `${target}`
|
|
|
- }
|
|
|
- uni.createPushMessage({
|
|
|
- title: "主标题(title)",
|
|
|
- content: `内容(content),创建时间: ${formateTime(hour)}:${formateTime(minute)}:${formateTime(second)}`,
|
|
|
- cover: false,
|
|
|
- channelId: "msg-pass",
|
|
|
- when: Date.now() + 10000,
|
|
|
- icon: "/static/uni.png",
|
|
|
- sound: "system",
|
|
|
- delay: 1,
|
|
|
- payload: {
|
|
|
- pkey: "pvalue1"
|
|
|
- },
|
|
|
- // #ifdef APP-HARMONY
|
|
|
- category: "SOCIAL_COMMUNICATION",
|
|
|
- // #endif
|
|
|
- // #ifndef APP-HARMONY
|
|
|
- category: "IM",
|
|
|
- // #endif
|
|
|
- success(res) {
|
|
|
- console.log("res: " + res);
|
|
|
- uni.hideToast()
|
|
|
- uni.showToast({
|
|
|
- title: "创建本地通知消息成功"
|
|
|
- })
|
|
|
- },
|
|
|
- fail(e) {
|
|
|
- console.log("fail :" + e);
|
|
|
- uni.hideToast()
|
|
|
- uni.showToast({
|
|
|
- title: "创建本地通知消息失败",
|
|
|
- icon: "error"
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- } else {
|
|
|
- uni.showToast({
|
|
|
- title: "请在设置中开启通知权限",
|
|
|
- icon: "error"
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- const handlePush = () => {
|
|
|
- // uni.navigateTo({
|
|
|
- // url: '/pages/push/index',
|
|
|
- // fail: (err: any) => {
|
|
|
- // console.log('导航失败', err)
|
|
|
- // }
|
|
|
- // })
|
|
|
- handleCreateLocalNotification();
|
|
|
- };
|
|
|
-
|
|
|
+ const getNofiyMes = (): void=>{
|
|
|
+ const userInfo = getUserInfo()
|
|
|
+ if (userInfo != null) {
|
|
|
+ const userId = userInfo['userId']?.toString()
|
|
|
+ if(userId!=null){
|
|
|
+ getMyNotify(userId).then((result:any) => {
|
|
|
+ const jsonData = JSON.stringify(result)
|
|
|
+ const respData = JSON.parse(jsonData) as UTSJSONObject
|
|
|
+ if (respData['code'] == 200 &&
|
|
|
+ respData.hasOwnProperty('data') && respData['data'] != null) {
|
|
|
+ const data = respData['data'] as UTSJSONObject
|
|
|
+ const badge = data["num"] as number
|
|
|
+ console.log("======" + badge)
|
|
|
+ setTimeout(() => {
|
|
|
+ uni.setAppBadgeNumber(badge);
|
|
|
+ if(data.hasOwnProperty("title") && data["title"] != null
|
|
|
+ && data.hasOwnProperty("desc") && data["desc"] != null){
|
|
|
+ const title = data["title"] as string
|
|
|
+ const desc = data["desc"] as string
|
|
|
+ uni.createPushMessage({
|
|
|
+ title: title,
|
|
|
+ content: desc,
|
|
|
+ when: Date.now() + 10000,
|
|
|
+ icon: "/static/login/2.png",
|
|
|
+ sound: "system",
|
|
|
+ success: (res) => {
|
|
|
+ console.log('创建推送消息成功', res);
|
|
|
+ },
|
|
|
+ fail: (err) => {
|
|
|
+ console.error('创建推送消息失败', err);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }, 0);
|
|
|
+ }
|
|
|
+ }).catch((error) => {
|
|
|
+ console.error('Promise 执行失败:', error)
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const handleKeepAlive = ()=>{
|
|
|
+ var keep=new KeepLive()
|
|
|
+ keep.setTitle("工效通")
|
|
|
+ keep.setContent("工效通正在运行")
|
|
|
+ // keep.setLargeIcon("icon");
|
|
|
+ keep.setSmallIcon("icon"); //图标名字 图标放在 插件下面的 uni_modules\android-keeplive\utssdk\app-android\res 文件夹下
|
|
|
+ keep.onAddBackgroundCallback(function(res:boolean){
|
|
|
+ console.log("后台运行 "+res)
|
|
|
+ })
|
|
|
+ keep.onAddScrrenListenerCallback(function(res:boolean){
|
|
|
+ console.log("屏幕开启状态 "+res)
|
|
|
+ })
|
|
|
+ keep.setWakeLock(1,"keeptag");// 设置唤醒类型
|
|
|
+ keep.setAutoStartEnable(true)
|
|
|
+ keep.doStartApplicationWithPackageName("uni.app.UNI1050C07");
|
|
|
+
|
|
|
+ if(!keep.checkAppNotification()){
|
|
|
+ keep.onOpenNotificationSetting(function(res:boolean){
|
|
|
+ keep.register();
|
|
|
+ var ignoring= keep.isIgnoringBatteryOptimizations();
|
|
|
+ if(!ignoring){
|
|
|
+ keep.requestIgnoreBatteryOptimizations();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ keep.register();
|
|
|
+ var ignoring= keep.isIgnoringBatteryOptimizations();
|
|
|
+ if(!ignoring){
|
|
|
+ keep.requestIgnoreBatteryOptimizations();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // keep.wifilock();
|
|
|
+ // 稳定定时器 需要的用户使用(默认定时器1 )
|
|
|
+ keep.onStartCSystemTimer(10,function(){
|
|
|
+ console.log("onStartCSystemTimer ");
|
|
|
+ getNofiyMes();
|
|
|
+ keep.acquire(1000);// 唤醒一秒钟
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
// 辅助函数:从 any 类型提取属性
|
|
|
const getWorkOrderProjectNo = (item: any | null): string | null => {
|
|
|
if (item == null) return ''
|
|
|
@@ -598,7 +543,7 @@
|
|
|
const userId = userInfo['userId']?.toString()
|
|
|
if(userId!=null){
|
|
|
console.log("监听:"+userId)
|
|
|
- handleKeepAlive(userId)
|
|
|
+ handleKeepAlive()
|
|
|
}
|
|
|
}
|
|
|
|