在chatList页面,使用下面的监听方法,即监听到新消息,查询所有已打开页面,调用聊天页面chat的
getNewMsg方法更新聊天内容:
ry.messageListener(function (msg) {
var pages = getCurrentPages(); // 获取当前所有打开的页面
for (var i = 0; i < pages.length; i++){
if (pages[i].route === 'pages/index/chat/chat' || pages[i].route === 'pages/index/chatgroup/chatgroup'){
pages[i].getNewMsg(msg);
break;
}
}
//更新当前列表代码省略
}
