5***@qq.com
5***@qq.com
  • 发布:2018-07-13 09:16
  • 更新:2018-07-13 09:16
  • 阅读:1977

mui push消息后无法监听点击事件

分类:MUI

vue项目打包成app,用了mui的东西,但是能收到消息,无法监听点击事件,在create里写的监听事件,代码如下:
created () {
let that = this
document.addEventListener('plusready', function() {
var webview = plus.webview.currentWebview();
plus.key.addEventListener('backbutton', function() {
webview.canBack(function(e) {
if(e.canBack) {
that.change_is_go_back({data: false})
webview.back();
// mui.toast('触发了该回调');
} else {
//webview.close();
//首页返回键处理
//处理逻辑:1秒内,连续两次按返回键,则退出应用;
var first = null;
plus.key.addEventListener('backbutton', function() {
//首次按键,提示‘再按一次退出应用’
if (!first) {
first = new Date().getTime();
let where = that.where;
if (where == 'home' || where == 'login') {
Toast({
message: '再按一次退出应用',
position: 'bottom',
duration: 1000
})
setTimeout(function() {
first = null;
}, 1000);
}
} else {
if (new Date().getTime() - first < 1500) {
plus.runtime.quit();
}
}
}, false);
// })
}
})
});
let message = document.getElementById("message");
console.log(plus.push)
// 监听点击消息事件
plus.push.addEventListener( "click", function( msg ) {
// 判断是从本地创建还是离线推送的消息
/let type = Number(JSON.parse(msg.payload)['type'])
if (type >= 1 && type <=4999) {
that.$router.push({
path: '/kind'
})
}
if (type >= 5000 && type <= 5199) {
that.$router.push({
path: '/receive-text'
})
}
if (type >= 5200 && type <= 5299) {
that.$router.push({
path: '/receive-text'
})
}
/
// 提示点击的内容
plus.ui.alert( msg.content );
// that.msg = msg;
// 处理其它数据
logoutPushMsg( msg );
alert(msg)
setTimeout(() => {
}, 1000)
}, false );
// 监听在线消息事件
plus.push.addEventListener( "receive", function( msg ) {
if ( msg.aps ) { // Apple APNS message
outSet( "接收到在线APNS消息:" );
} else {
outSet( "接收到在线透传消息:" );
that.$router.push({
path: '/receive-text'
})
}
that.msg = msg;
logoutPushMsg( msg );
}, false );
});
},

2018-07-13 09:16 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复