<script> var AndroidLog = uni.requireNativePlugin("AndroidLog") var device = uni.requireNativePlugin("DeviceInfo") export default { onLaunch: function() { //判断客户端类别 const _handlePush = function(message) { // console.log("接收到推送消息:" ,message); // alert(message) //{"message":{"__UUID__":"androidPushMsg222631973","appid":"__UNI__29ECCC8","content":"{\"type\":2,\"jumpTo\":\"pages/login/login\"}","payload":{"jumpTo":"pages/login/login","type":2},"title":"智慧停车PDA"}} AndroidLog.info({message: message.content}) let content = JSON.parse(message.content) AndroidLog.info({message: content.jumpTo}) }; setTimeout(()=>{ var pinf = plus.push.getClientInfo(); var cid = pinf.clientid;//客户端标识 if(cid != null && cid != '' && cid != 'null'){ //注册设备 var deviceInfo = device.getDeviceInfo() this.$u.api.deviceReg({deviceNo:deviceInfo.deviceId,pushCid: cid}) .then(res=>{ if (res.code == 200){ plus.nativeUI.toast('设备注册成功'); }else{ plus.nativeUI.toast('设备注册失败'); } }).catch(err=>{ plus.nativeUI.toast('设备注册失败'); }); clearTimeout() } }, 400); //监听系统通知栏消息点击事件 plus.push.addEventListener('click', _handlePush,false); //监听接收透传消息事件 plus.push.addEventListener('receive', _handlePush,false); // this.$wxApi.config(); }, onShow: function() { // console.log('App Show') }, onHide: function() { // console.log('App Hide') } } </script> <style lang="scss"> @import "uview-ui/index.scss"; /*每个页面公共css */ </style>