|
|
@ -1,4 +1,5 @@ |
|
|
|
<script> |
|
|
|
import index from '@/store/index.js'; |
|
|
|
import Api from '@/common/api'; |
|
|
|
// #ifdef APP-PLUS |
|
|
|
import APPUpdate from "plugins/APPUpdate/index.js"; |
|
|
@ -54,6 +55,7 @@ |
|
|
|
getCid() { |
|
|
|
// #ifdef APP-PLUS |
|
|
|
var t1_time = 0; |
|
|
|
let that = this; |
|
|
|
var t1 = setInterval(function() { |
|
|
|
var cid = plus.push.getClientInfo().clientid; |
|
|
|
console.log(cid != undefined, cid != "undefined", cid) |
|
|
@ -61,43 +63,99 @@ |
|
|
|
if (cid != null || cid != "null") { |
|
|
|
uni.setStorageSync('cid', cid); |
|
|
|
clearInterval(t1); |
|
|
|
that.pushCid(); |
|
|
|
return |
|
|
|
} |
|
|
|
}, 130); |
|
|
|
// #endif |
|
|
|
}, |
|
|
|
async pushCid() { |
|
|
|
console.log('pushCid1111111>>>>>') |
|
|
|
let params = { |
|
|
|
cid: uni.getStorageSync('cid') |
|
|
|
}; |
|
|
|
console.log("pushCid>>>>", params); |
|
|
|
let data = await Api.apiCall('post', Api.index.pushCid, params); |
|
|
|
console.log('pushCid22222222>>>>>', data) |
|
|
|
}, |
|
|
|
// 监听通知信息 |
|
|
|
handlePush() { |
|
|
|
let that = this; |
|
|
|
// #ifdef APP-PLUS |
|
|
|
const _handlePush = function(message) { |
|
|
|
|
|
|
|
console.log("message>>>>>>>>>>", message) |
|
|
|
uni.setStorageSync('message', message); |
|
|
|
获取自定义信息 |
|
|
|
let payload = message.payload; |
|
|
|
|
|
|
|
// uni.switchTab({ |
|
|
|
// url: `${payload.path}` |
|
|
|
// }) |
|
|
|
|
|
|
|
// uni.navigateTo({ |
|
|
|
// url: '/pages/index/messageDetail', |
|
|
|
// // 版本2.8.9+ 支持 |
|
|
|
// success: (res) => { |
|
|
|
// // 和上面其实没差什么,但是这种方式是可以的 这里不是$emit |
|
|
|
// res.eventChannel.emit('sendTestValue', { |
|
|
|
// info: item |
|
|
|
// }) |
|
|
|
// } |
|
|
|
// }); |
|
|
|
|
|
|
|
console.log("payload>>>>>>>>>>", message.payload.code) |
|
|
|
// uni.setStorageSync('message', message); |
|
|
|
//获取自定义信息 |
|
|
|
// let payload = message.payload; |
|
|
|
// console.log("payload>>>>>>>>>>", payload.code) |
|
|
|
if ("系统消息" == message.payload.code) { |
|
|
|
// 系统消息 |
|
|
|
console.log("系统消息>>>>>>>>>>", message.payload.code) |
|
|
|
that.goToMessageDetail(message.payload) |
|
|
|
} else { |
|
|
|
// 非系统消息 |
|
|
|
|
|
|
|
if (that.hasLogin) { |
|
|
|
// 登录状态 |
|
|
|
console.log("登录状态>>>>>>>>>>", message.payload.code) |
|
|
|
that.goToMessageDetail(message.payload) |
|
|
|
} else { |
|
|
|
|
|
|
|
// 非登录状态 |
|
|
|
console.log("非登录状态>>>>>>>>>>", message.payload.code) |
|
|
|
// uni.navigateTo({ |
|
|
|
// url: "/pages/public/login" |
|
|
|
// }); |
|
|
|
uni.showToast({ |
|
|
|
title: '请先登录', |
|
|
|
icon: 'none' |
|
|
|
}); |
|
|
|
|
|
|
|
uni.switchTab({ |
|
|
|
url: '/pages/index/messageList' |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 事件处理 |
|
|
|
plus.push.addEventListener('click', _handlePush) |
|
|
|
|
|
|
|
// 从系统消息中心点击消息启动应用事件 |
|
|
|
// plus.push.addEventListener('click', _handlePush) |
|
|
|
// 应用从推送服务器接收到推送消息事件 |
|
|
|
plus.push.addEventListener('receive', _handlePush) |
|
|
|
// #endif |
|
|
|
}, |
|
|
|
|
|
|
|
goToMessageDetail(payload) { |
|
|
|
|
|
|
|
let item = { |
|
|
|
params: payload.params, |
|
|
|
code: payload.code, |
|
|
|
ctime: payload.ctime, |
|
|
|
content: payload.content, |
|
|
|
} |
|
|
|
console.log("goToMessageDetail>>>>>>>>>>", item) |
|
|
|
uni.navigateTo({ |
|
|
|
url: '/pages/index/messageDetail', |
|
|
|
// 版本2.8.9+ 支持 |
|
|
|
success: (res) => { |
|
|
|
// 和上面其实没差什么,但是这种方式是可以的 这里不是$emit |
|
|
|
res.eventChannel.emit('sendTestValue', { |
|
|
|
info: item |
|
|
|
}) |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
onLaunch: function() { |
|
|
|
// uni.removeStorageSync('userInfo'); |
|
|
@ -108,14 +166,14 @@ |
|
|
|
console.log('App onLaunch>>>', userInfo) |
|
|
|
console.log('App onLaunch>>>', token) |
|
|
|
if (token) { |
|
|
|
index.state.hasLogin = true |
|
|
|
//更新登陆状态 |
|
|
|
uni.getStorage({ |
|
|
|
key: 'userInfo', |
|
|
|
success: (res) => { |
|
|
|
console.log('App onLaunch>>', res) |
|
|
|
this.login(res.data); |
|
|
|
} |
|
|
|
data: userInfo |
|
|
|
}); |
|
|
|
|
|
|
|
console.log('hasLogin>>>', index.state.hasLogin) |
|
|
|
} |
|
|
|
|
|
|
|
let isWeiXin = this.$common.isWeiXinBrowser() |
|
|
@ -135,7 +193,7 @@ |
|
|
|
|
|
|
|
this.handlePush(); |
|
|
|
this.getCid(); |
|
|
|
console.log('App onLaunch111111111111>>>', token) |
|
|
|
// console.log('App onLaunch111111111111>>>', token) |
|
|
|
// let sss = { |
|
|
|
// "url": "http://mall.yyundong.com/portalapi/api/appVersion/versioninfo", |
|
|
|
// "resolve": { |
|
|
|