This commit is contained in:
cansnow
2026-01-09 09:15:59 +08:00
parent 78386d4cc1
commit 7913a63a39
51 changed files with 1048 additions and 449 deletions
+39 -28
View File
@@ -36,6 +36,10 @@
},
onReady() {
//console.log('onReady');
// uni.navigateTo({
// url:"/pages/common/upgrade"
// });
// return ;
// #ifdef APP
this.checkUpdate();
this.tryLogin();
@@ -148,7 +152,6 @@
if (this.storeIsSyncing) {
return;
}
console.log(data);
data.forEach(this.handleNewMessage);
});
@@ -282,8 +285,8 @@
//设置了批量消息监听setBatchMsgListener时,此回调不会触发。
//IMSDK.subscribe(IMSDK.IMEvents.onRecvOfflineNewMessage,({ data })=>{});
//当应用在后台运行,接收到新消息时,会收到该回调,回调中可能会携带多条消息。
IMSDK.subscribe(IMSDK.IMEvents.OnRecvOfflineNewMessages,(res)=>{
console.log(res);
IMSDK.subscribe(IMSDK.IMEvents.OnRecvOfflineNewMessages,({data})=>{
data.forEach(this.handleOfflineNewMessages);
});
//已订阅用户的在线状态发生变化时,会触发此回调。
//IMSDK.subscribe(IMSDK.IMEvents.onUserStatusChanged,({ data })=>{});
@@ -404,6 +407,35 @@
}
},
handleOfflineNewMessages(newServerMsg) {
console.log(newServerMsg);
console.log( getConversationContent(newServerMsg));
uni.createPushMessage({
title:"您的朋友发来新的消息",
content:getConversationContent(newServerMsg),
payload:{
type:"msg",
data:newServerMsg
},
//icon:'',
//sound:'',
//cover:'false',
//delay:0,
//when:0,//消息上显示的提示时间
//channelId:"",
//category:"",
success(res){
//console.log(res);
},
fail(res){
//console.log(res);
},
complete(res){
//console.log(res);
}
});
},
handleNewMessage(newServerMsg) {
if (this.inCurrentConversation(newServerMsg)) {
if (
@@ -416,30 +448,7 @@
uni.$u.debounce(this.markConversationAsRead, 2000);
}
}else{
console.log(newServerMsg);
console.log( getConversationContent(newServerMsg));
uni.createPushMessage({
title:"您的朋友发来新的消息",
content:getConversationContent(newServerMsg),
payload:newServerMsg,
//icon:'',
//sound:'',
//cover:'false',
//delay:0,
//when:0,//消息上显示的提示时间
//channelId:"",
//category:"",
success(res){
console.log(res);
},
fail(res){
console.log(res);
},
complete(res){
console.log(res);
}
});
this.handleOfflineNewMessages(newServerMsg);
}
},
@@ -497,10 +506,10 @@
let system = uni.getSystemInfoSync()
plus.runtime.getProperty(plus.runtime.appid, function(inf) {
checkUpgrade({version:system.appVersion,platform:system.platform,version_wgt:inf.versionCode}).then(res=>{
console.log(res.version,skip_version);
let skip_version = uni.getStorageSync('skip_version')
if(res && res.version!=skip_version){
uni.$emit('closeWebview')
this.setShow(this.current, false)
router('/pages/common/upgrade?model=' + JSON.stringify(res), '', 'fade-in')
}
})
@@ -523,6 +532,7 @@
});
// #endif
}
}
}
</script>
@@ -537,5 +547,6 @@
.gif-image {
width: 50%;
border-radius: 10%;
}
</style>