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

消息推送

上级 795a92cc
<script>
export default {
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')
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 token = uni.getStorageSync('token')
var time = uni.getStorageSync('time')
......@@ -18,7 +42,7 @@
getApp().globalData.runningRecordStorageCount = uni.getStorageSync('runningRecordStorageCount')
getApp().globalData.walkingRecordStorageCount = uni.getStorageSync('walkingRecordStorageCount')
} else {
if(token){
if (token) {
uni.removeStorageSync('token')
}
uni.reLaunch({
......@@ -70,6 +94,7 @@
teamNameStorageCount: 1,
runningRecordStorageCount: 1,
walkingRecordStorageCount: 1,
push_clientid: '',
}
}
</script>
......
......@@ -81,6 +81,13 @@
})
.then(res => {
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.name = res.result.data.name
getApp().globalData.type = res.result.data.type
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册