提交 3e37e205 编写于 作者: Y yyt

消息推送

上级 795a92cc
<script> <script>
export default { export default {
onLaunch: function() { onLaunch: function() {
let push_clientid;
uni.getPushClientId({
success: (res) => {
getApp().globalData.push_clientid = res.cid
push_clientid = res.cid
console.log('客户端推送标识:', push_clientid)
},
fail(err) {
console.log(err)
}
})
console.log('App Launch') console.log('App Launch')
uni.onPushMessage((res) => {
console.log(res)
if (res.type == 'click') {
setTimeout(function() {
uni.navigateTo({
url: '/pages/team/main'
})
}, 1000)
}
})
var now = new Date().getTime() var now = new Date().getTime()
var token = uni.getStorageSync('token') var token = uni.getStorageSync('token')
var time = uni.getStorageSync('time') var time = uni.getStorageSync('time')
...@@ -18,7 +42,7 @@ ...@@ -18,7 +42,7 @@
getApp().globalData.runningRecordStorageCount = uni.getStorageSync('runningRecordStorageCount') getApp().globalData.runningRecordStorageCount = uni.getStorageSync('runningRecordStorageCount')
getApp().globalData.walkingRecordStorageCount = uni.getStorageSync('walkingRecordStorageCount') getApp().globalData.walkingRecordStorageCount = uni.getStorageSync('walkingRecordStorageCount')
} else { } else {
if(token){ if (token) {
uni.removeStorageSync('token') uni.removeStorageSync('token')
} }
uni.reLaunch({ uni.reLaunch({
...@@ -70,6 +94,7 @@ ...@@ -70,6 +94,7 @@
teamNameStorageCount: 1, teamNameStorageCount: 1,
runningRecordStorageCount: 1, runningRecordStorageCount: 1,
walkingRecordStorageCount: 1, walkingRecordStorageCount: 1,
push_clientid: '',
} }
} }
</script> </script>
......
...@@ -81,6 +81,13 @@ ...@@ -81,6 +81,13 @@
}) })
.then(res => { .then(res => {
if (res.result.code === 200) { if (res.result.code === 200) {
uniCloud.callFunction({
name: 'uni-cloud-push',
date: {
uid: res.result.data.userId,
cid: getApp().globalData.push_clientid
}
})
getApp().globalData.userId = res.result.data.userId getApp().globalData.userId = res.result.data.userId
getApp().globalData.name = res.result.data.name getApp().globalData.name = res.result.data.name
getApp().globalData.type = res.result.data.type getApp().globalData.type = res.result.data.type
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册