123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <script>
- var AndroidLog = uni.requireNativePlugin("AndroidLog")
- var device = uni.requireNativePlugin("DeviceInfo")
- export default {
- onLaunch: function() {
-
- const _handlePush = function(message) {
-
-
-
- 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);
-
- },
- onShow: function() {
-
-
- },
- onHide: function() {
-
- }
- }
- </script>
- <style lang="scss">
- @import "uview-ui/index.scss";
-
- </style>
|