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

View File

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