|
|
|
|
@ -4,7 +4,8 @@
|
|
|
|
|
//引进检查版本
|
|
|
|
|
// import callCheckVersion from '@/uni_modules/uni-upgrade-center-app/utils/call-check-version';
|
|
|
|
|
|
|
|
|
|
import { myCache } from '@/utils/utils.js';
|
|
|
|
|
import { mapState, mapActions } from 'vuex'
|
|
|
|
|
import { myCache } from '@/utils/utils.js';
|
|
|
|
|
import * as wsApi from './common/wssocket';
|
|
|
|
|
import chatStore from "./store/chatStore";
|
|
|
|
|
import * as enums from "./common/enums";
|
|
|
|
|
@ -26,6 +27,9 @@
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
...mapState('chatStore', ['chats'])
|
|
|
|
|
},
|
|
|
|
|
onLaunch() {
|
|
|
|
|
// 判断版本更新 需要真机进行测试
|
|
|
|
|
//checkupdate();
|
|
|
|
|
@ -37,7 +41,7 @@
|
|
|
|
|
jpushModule.initJPushService()
|
|
|
|
|
jpushModule.addConnectEventListener(result=>{
|
|
|
|
|
let connectEnable = result.connectEnable
|
|
|
|
|
console.log("jpush连接", connectEnable)
|
|
|
|
|
console.log("极光推送--jpush连接", connectEnable)
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
jpushModule.addTagAliasListener(result => {
|
|
|
|
|
@ -47,7 +51,7 @@
|
|
|
|
|
let tag = result.tag
|
|
|
|
|
let tagEnable = result.tagEnable
|
|
|
|
|
let alias = result.alias
|
|
|
|
|
console.log(alias, '别名')
|
|
|
|
|
console.log('极光推送--别名',alias)
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 通知事件回调
|
|
|
|
|
@ -57,87 +61,79 @@
|
|
|
|
|
let title = result.title
|
|
|
|
|
let content = result.content
|
|
|
|
|
let extras = result.extras
|
|
|
|
|
console.log("消息通知", result);
|
|
|
|
|
console.log("消息通知extras", extras)
|
|
|
|
|
console.log("极光推送--消息通知", result);
|
|
|
|
|
console.log("极光推送--消息通知extras", extras);
|
|
|
|
|
// 点击事件
|
|
|
|
|
if(extras && extras.type && extras.type == 'bookCourses') {
|
|
|
|
|
var bookId=extras.bookId?extras.bookId:'';
|
|
|
|
|
if(bookId){
|
|
|
|
|
// 预约课程详情
|
|
|
|
|
if (notificationEventType == 'notificationOpened') {
|
|
|
|
|
if(extras && extras.type && extras.type == 'bookCourses') {
|
|
|
|
|
var bookId=extras.bookId?extras.bookId:'';
|
|
|
|
|
if(bookId){
|
|
|
|
|
// 预约课程详情
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: `/pages/book/bookinfo?id=${bookId}`
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
// 预约课程列表
|
|
|
|
|
uni.reLaunch({
|
|
|
|
|
url: `/pages/book/booklist`
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(extras && extras.type && extras.type == 'groupMessage') {
|
|
|
|
|
// 群聊消息
|
|
|
|
|
// let chat = {
|
|
|
|
|
// type: 'GROUP',
|
|
|
|
|
// targetId: extras.groupId,
|
|
|
|
|
// showName: '加载中...',
|
|
|
|
|
// headImage: '/static/image/kf.png',
|
|
|
|
|
// };
|
|
|
|
|
// this.$store.dispatch('chatStore/openChat', chat);
|
|
|
|
|
// let chatIdx = this.$store.getters['chatStore/findChatIdx'](chat);
|
|
|
|
|
// uni.reLaunch({
|
|
|
|
|
// url: `/pages/chatbox/chat-box?chatIdx=${chatIdx}`
|
|
|
|
|
// });
|
|
|
|
|
uni.reLaunch({
|
|
|
|
|
url: `/pages/book/bookinfo?id=${bookId}`
|
|
|
|
|
url: `/pages/chatbox/chat`
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
// 预约课程列表
|
|
|
|
|
if(extras && extras.type && extras.type == 'privateMessage') {
|
|
|
|
|
// 私信消息
|
|
|
|
|
// let chat = {
|
|
|
|
|
// type: 'PRIVATE',
|
|
|
|
|
// targetId: extras.senderId,
|
|
|
|
|
// showName: '加载中...',
|
|
|
|
|
// headImage: '/static/image/kf.png',
|
|
|
|
|
// };
|
|
|
|
|
// this.$store.dispatch('chatStore/openChat', chat);
|
|
|
|
|
// let chatIdx = this.$store.getters['chatStore/findChatIdx'](chat)
|
|
|
|
|
// uni.reLaunch({
|
|
|
|
|
// url: `/pages/chatbox/chat-box?chatIdx=${chatIdx}`
|
|
|
|
|
// });
|
|
|
|
|
uni.reLaunch({
|
|
|
|
|
url: `/pages/book/booklist`
|
|
|
|
|
url: `/pages/chatbox/chat`
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!extras){
|
|
|
|
|
uni.reLaunch({
|
|
|
|
|
url: `/pages/chatbox/chat`
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(extras && extras.type && extras.type == 'groupMessage') {
|
|
|
|
|
// 群聊消息
|
|
|
|
|
// var pagePath=extras.pagePath;
|
|
|
|
|
// var groupId=extras.groupId;
|
|
|
|
|
// if(pagePath&&groupId){
|
|
|
|
|
// uni.reLaunch({
|
|
|
|
|
// url: `${pagePath}?chatIdx=${groupId}`
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// else{
|
|
|
|
|
// uni.reLaunch({
|
|
|
|
|
// url: `/pages/chatbox/chat`
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
let chat = {
|
|
|
|
|
type: 'GROUP',
|
|
|
|
|
targetId: extras.groupId,
|
|
|
|
|
showName: '加载中...',
|
|
|
|
|
headImage: '/static/image/kf.png',
|
|
|
|
|
};
|
|
|
|
|
this.$store.dispatch('chatStore/openChat', chat);
|
|
|
|
|
let chatIdx = this.$store.getters['chatStore/findChatIdx'](chat)
|
|
|
|
|
uni.reLaunch({url: `/pages/chatbox/chat-box?chatIdx=${chatIdx}`});
|
|
|
|
|
}
|
|
|
|
|
if(extras && extras.type && extras.type == 'privateMessage') {
|
|
|
|
|
// 私信消息
|
|
|
|
|
// var pagePath=extras.pagePath;
|
|
|
|
|
// var senderId=extras.senderId;
|
|
|
|
|
// if(pagePath&&senderId){
|
|
|
|
|
// uni.reLaunch({
|
|
|
|
|
// url: `${pagePath}?chatIdx=${senderId}`
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// else{
|
|
|
|
|
// uni.reLaunch({
|
|
|
|
|
// url: `/pages/chatbox/chat`
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
let chat = {
|
|
|
|
|
type: 'PRIVATE',
|
|
|
|
|
targetId: extras.senderId,
|
|
|
|
|
showName: '加载中...',
|
|
|
|
|
headImage: '/static/image/kf.png',
|
|
|
|
|
};
|
|
|
|
|
this.$store.dispatch('chatStore/openChat', chat);
|
|
|
|
|
let chatIdx = this.$store.getters['chatStore/findChatIdx'](chat)
|
|
|
|
|
uni.reLaunch({
|
|
|
|
|
url: `/pages/chatbox/chat-box?chatIdx=${chatIdx}`
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
jpushModule.getRegistrationID(result => {
|
|
|
|
|
console.log("注册ID", result.registerID)
|
|
|
|
|
console.log("极光推送--注册ID", result.registerID)
|
|
|
|
|
if (result.registerID) {
|
|
|
|
|
uni.setStorageSync("register_id", result.registerID)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
jpushModule.addCustomMessageListener(result => {
|
|
|
|
|
let messageID = result.messageID
|
|
|
|
|
let content = result.content
|
|
|
|
|
let extras = result.extras
|
|
|
|
|
console.log("自定义消息", result)
|
|
|
|
|
})
|
|
|
|
|
console.log("极光推送--自定义消息", result)
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//#endif
|
|
|
|
|
// 极光推送end--------------
|
|
|
|
|
@ -162,11 +158,23 @@
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: "/pages/login/login"
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 未读消息总数(用于角标)
|
|
|
|
|
let count = 0
|
|
|
|
|
myCache("this.chats",this.chats);
|
|
|
|
|
this.chats.forEach(chat => {
|
|
|
|
|
if (!chat.delete) {
|
|
|
|
|
count += chat.unreadCount
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
myCache("massageCount",count);
|
|
|
|
|
console.log("massageCountmassageCount",count);
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
...mapActions('chatStore'),
|
|
|
|
|
//---------------------------------------------------
|
|
|
|
|
init(userId) {
|
|
|
|
|
|
|
|
|
|
|