diff --git a/App.vue b/App.vue
index 7f7df70..139c7ec 100644
--- a/App.vue
+++ b/App.vue
@@ -19,7 +19,8 @@ import { isWxApp } from "@/utils/im/index";
/** 国际化*/
import { setLanguage } from "@/utils/im/i18n";
import BASE_URL from "@/utils/config.js"
-
+import my_api from '@/api/my_api.js'
+import GlobalDialog from "@/components/GlobalDialog.vue"
// #ifdef APP-PLUS
/** 推送插件 */
const nimPushPlugin = uni.requireNativePlugin("NIMUniPlugin-PluginModule");
@@ -42,9 +43,35 @@ export default {
uni.getPushClientId({
success: (res) => {
let push_clientid = res.cid
- uni.setStorageSync("push_clientid", push_clientid)
- console.log('客户端推送标识cid:',push_clientid)
- },
+ uni.setStorageSync("push_clientid", push_clientid)
+ console.log('客户端推送标识cid:',push_clientid)
+
+ 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)
}
@@ -53,28 +80,39 @@ export default {
uni.onPushMessage((res)=>{
console.log("收到推送消息:", res)
- uni.showModal({
+
+ 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{
- uni.createPushMessage({
- title: res.data.title,
- content: res.data.content,
- payload: res.data.payload,
- delay: 1,
- success: (res) => {
- console.log("创建推送消息成功", res)
- }
- })
- }
-
-
-
+ }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切换语言,将其存到本地,实际需根据业务情况设置)*/
@@ -141,23 +179,25 @@ export default {
// #ifdef APP-PLUS
console.log("onShow");
uni?.$UIKitNIM?.V2NIMSettingService?.setAppBackground(false);
-
+ uni.setStorageSync("app_isback", false)
// 点击通知栏推送监听
- nimPushPlugin.addOpenNotificationListener((res) => {
- console.log("推送监听");
- console.log("res",res);
- if (typeof res == "object" && res?.sessionId && res?.sessionType) {
- // 当前登录账号id 具体获取根据您的业务逻辑调整
- const imOptions = uni.getStorageSync(STORAGE_KEY);
- // 会话类型
- const type = res?.sessionType;
- // 拼装会话ID
- startByNotificationId = `${imOptions.account}|${type}|${res?.sessionId}`;
- }
- });
+ // nimPushPlugin.addOpenNotificationListener((res) => {
+ // console.log("推送监听");
+ // console.log("res",res);
+ // if (typeof res == "object" && res?.sessionId && res?.sessionType) {
+ // // 当前登录账号id 具体获取根据您的业务逻辑调整
+ // const imOptions = uni.getStorageSync(STORAGE_KEY);
+ // // 会话类型
+ // const type = res?.sessionType;
+ // // 拼装会话ID
+ // startByNotificationId = `${imOptions.account}|${type}|${res?.sessionId}`;
+ // }
+ // });
// #endif
},
onHide() {
+ console.log("onHide");
+ uni.setStorageSync("app_isback", true)
// #ifdef APP-PLUS
uni?.$UIKitNIM?.V2NIMSettingService?.setAppBackground(true);
// #endif
@@ -165,6 +205,9 @@ export default {
// 重置推送 startByNotificationId
startByNotificationId = "";
},
+ components:{
+ GlobalDialog
+ },
methods: {
initNim(opts) {
console.log("initNim1111111111");
@@ -349,12 +392,12 @@ export default {
// appId: "",
// certificateName: "",
// },
- // oppoPush: {
- // appId: "",
- // appKey: "",
- // certificateName: "",
- // secret: "",
- // },
+ oppoPush: {
+ appId: "3364888",
+ appKey: "75D5Vqsg63wok0S0w4SKog0w8",
+ certificateName: "Expert_Op_Push",
+ secret: "9e93Ce2AbA97E15F3852279b639b014e",
+ },
vivoPush: {
appId: "100034326",
appKey: "e789634c1f76c8f184b1def1101ce824",
@@ -464,6 +507,10 @@ export default {
};
+
+
+
+
+
diff --git a/components/tabBar/tabBar.vue b/components/tabBar/tabBar.vue
index 54db3e4..467eaf0 100644
--- a/components/tabBar/tabBar.vue
+++ b/components/tabBar/tabBar.vue
@@ -33,11 +33,13 @@
+