1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <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>
|