uniapp push2.0版
在uni.onPunshMessage会返回类型为receive的数据,这是我们要使用uni.createPushMessage创建消息推送。消息就会推送到手机,点击的时候uni.onPunshMessage的类型就会变成click,这是就可以进行页面跳转操作。
let timer = false; uni.onPushMessage((msg)=>{ console.log(msg,'msg*-*-*-') if(msg.type=='receive'){ uni.createPushMessage({ title:msg.data.title, content:msg.data.content, payload:msg.data.payload, success:(res)=> { console.log(111111) }, fail:(res)=>{ console.log(222) } }) }else{ if(msg.data.payload.page){ clearTimeout(timer); timer = setTimeout(() => { console.log(1111, msg.data.payload); if (msg.data.payload) { if(msg.data.payload.page=='/pages/order/serverNeedDetail' || msg.data.payload.page=='/pages/order/myNeedDetail'){ uni.navigateTo({ url: `${msg.data.payload.page}?id=${msg.data.payload.id}` }) }else if(msg.data.payload.page=='/pages/order/detail1' || msg.data.payload.page=='/pages/order/detail'){ uni.navigateTo({ url: `${msg.data.payload.page}?orderId=${msg.data.payload.id}&type=1` }) } } }, 1500) } } })
复制