|
@@ -1,47 +1,17 @@
|
|
|
<script>
|
|
|
//#ifdef APP-PLUS
|
|
|
var alog = uni.requireNativePlugin("AndroidLog")
|
|
|
- var device = uni.requireNativePlugin("DeviceInfo")
|
|
|
+ // var device = uni.requireNativePlugin("DeviceInfo")
|
|
|
import update from '@/utils/update.js';
|
|
|
+ import deviceUt from '@/utils/deviceUtils.js';
|
|
|
+ import pushreg from '@/utils/pushUtils.js';
|
|
|
//#endif
|
|
|
export default {
|
|
|
onLaunch: function() {
|
|
|
-
|
|
|
//#ifdef APP-PLUS
|
|
|
-
|
|
|
- update(this);
|
|
|
- //判断客户端类别
|
|
|
- const _handlePush = function(message) {
|
|
|
- //{"message":{"__UUID__":"androidPushMsg222631973","appid":"__UNI__29ECCC8","content":"{\"type\":2,\"jumpTo\":\"pages/login/login\"}","payload":{"jumpTo":"pages/login/login","type":2},"title":"智慧停车PDA"}}
|
|
|
-
|
|
|
- };
|
|
|
- //
|
|
|
- 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);
|
|
|
+ update(this); //软件更新
|
|
|
+ deviceUt.devicereg(this); //设备注册
|
|
|
+ pushreg(); //推送注册
|
|
|
//#endif
|
|
|
//#ifdef H5
|
|
|
this.$u.api.deviceReg({
|