This commit is contained in:
haomingming 2025-10-15 13:48:52 +08:00
parent d44cd1516a
commit ea320f4e54
2 changed files with 66 additions and 87 deletions

132
App.vue
View File

@ -73,80 +73,80 @@ export default {
// #endif
// uni-apppushApp.vue
uni.getPushClientId({
success: (res) => {
let push_clientid = res.cid
uni.setStorageSync("push_clientid", push_clientid)
console.log('客户端推送标识cid:',push_clientid)
// uni.getPushClientId({
// success: (res) => {
// let push_clientid = res.cid
// uni.setStorageSync("push_clientid", push_clientid)
// console.log('cid:',push_clientid)
const systemInfo = uni.getSystemInfoSync();
console.log("systemInfo:", systemInfo)
// const systemInfo = uni.getSystemInfoSync();
// console.log("systemInfo:", systemInfo)
let userInfo= uni.getStorageSync('userInfo')
console.log("userinfo:", userInfo)
if(!userInfo){
return
}
if(userInfo.uuid){
let client_type = ""
if (systemInfo.platform === 'android') {
client_type = "A"
} else if (systemInfo.platform === 'ios') {
client_type = "I"
}
console.log("client_type:", client_type)
if(client_type){
my_api.addUniappCid({
user_uuid: userInfo.uuid,
client_type:client_type,
cid: push_clientid
})
}
}
},
fail(err) {
console.error("unipush: ", err)
}
})
// let userInfo= uni.getStorageSync('userInfo')
// console.log("userinfo:", userInfo)
// if(!userInfo){
// return
// }
// if(userInfo.uuid){
// let client_type = ""
// if (systemInfo.platform === 'android') {
// client_type = "A"
// } else if (systemInfo.platform === 'ios') {
// client_type = "I"
// }
// console.log("client_type:", client_type)
// if(client_type){
// my_api.addUniappCid({
// user_uuid: userInfo.uuid,
// client_type:client_type,
// cid: push_clientid
// })
// }
// }
// },
// fail(err) {
// console.error("unipush: ", err)
// }
// })
uni.onPushMessage((res)=>{
console.log("收到推送消息:", res)
// uni.onPushMessage((res)=>{
// console.log("", res)
let app_isback = uni.getStorageSync("app_isback")
console.log("app_isback", app_isback)
uni.showModal({
title: res.data.title,
content: res.type,
showCancel: false
});
// let app_isback = uni.getStorageSync("app_isback")
// console.log("app_isback", app_isback)
// uni.showModal({
// title: res.data.title,
// content: res.type,
// showCancel: false
// });
if(res.type === 'click' ){
// if(res.type === 'click' ){
}else{
if(app_isback){
uni.createPushMessage({
title: res.data.title,
content: res.data.content,
payload: res.data.payload,
delay: 1,
success: (res) => {
console.log("创建推送消息成功", res)
}
})
}else{
console.log('[App] emit global-dialog:show', res)
uni.$emit('global-dialog:show', {
title: res.data.title || '消息通知',
content: res.data.content || '',
confirmText: '我知道了',
position: 'top',
offsetTop: '160rpx'
})
}
}
})
// }else{
// if(app_isback){
// uni.createPushMessage({
// title: res.data.title,
// content: res.data.content,
// payload: res.data.payload,
// delay: 1,
// success: (res) => {
// console.log("", res)
// }
// })
// }else{
// console.log('[App] emit global-dialog:show', res)
// uni.$emit('global-dialog:show', {
// title: res.data.title || '',
// content: res.data.content || '',
// confirmText: '',
// position: 'top',
// offsetTop: '160rpx'
// })
// }
// }
// })
/** 设置语言 此处为了方便demo切换语言将其存到本地实际需根据业务情况设置*/
setLanguage(

View File

@ -21,13 +21,8 @@
"Payment" : {},
"Share" : {},
"Webview-x5" : {},
<<<<<<< HEAD
"UIWebview" : {}
=======
"UIWebview" : {},
"Push" : {},
"VideoPlayer" : {}
>>>>>>> 2532aa055c0df42bb4696ce75410718e31df24d1
},
/* */
"distribute" : {
@ -82,23 +77,7 @@
}
},
"speech" : {},
<<<<<<< HEAD
"push" : {}
=======
"push" : {
"unipush" : {
"version" : "2",
"offline" : false,
"honor" : {},
"meizu" : {},
"mi" : {},
"vivo" : {},
"oppo" : {},
"hms" : {},
"fcm" : {}
}
}
>>>>>>> 2532aa055c0df42bb4696ce75410718e31df24d1
},
"splashscreen" : {
"androidStyle" : "common",