|
@@ -1,20 +1,14 @@
|
|
|
<script>
|
|
|
+ //#ifdef APP-PLUS
|
|
|
var AndroidLog = uni.requireNativePlugin("AndroidLog")
|
|
|
var device = uni.requireNativePlugin("DeviceInfo")
|
|
|
+ //#endif
|
|
|
export default {
|
|
|
onLaunch: function() {
|
|
|
+ //#ifdef APP-PLUS
|
|
|
//判断客户端类别
|
|
|
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
|
|
|
- })
|
|
|
|
|
|
};
|
|
|
//
|
|
@@ -40,14 +34,35 @@
|
|
|
clearTimeout()
|
|
|
}
|
|
|
}, 400);
|
|
|
- //
|
|
|
-
|
|
|
//监听系统通知栏消息点击事件
|
|
|
plus.push.addEventListener('click', _handlePush, false);
|
|
|
-
|
|
|
//监听接收透传消息事件
|
|
|
plus.push.addEventListener('receive', _handlePush, false);
|
|
|
- // this.$wxApi.config();
|
|
|
+ //#endif
|
|
|
+ //#ifdef H5
|
|
|
+ this.$u.api.deviceReg({
|
|
|
+ deviceNo: '123456789',
|
|
|
+ pushCid: '123456789'
|
|
|
+ })
|
|
|
+ .then(res => {
|
|
|
+ if (res.code == 200) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '设备注册成功',
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: '设备注册失败',
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ uni.showToast({
|
|
|
+ title: '设备注册失败',
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+ });
|
|
|
+ //#endif
|
|
|
},
|
|
|
onShow: function() {
|
|
|
// console.log('App Show')
|