zouyanyan 3 weeks ago
parent dc8f3a905c
commit b42c72344c

@ -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) {

@ -2,8 +2,8 @@
"name" : "瑜伽汇",
"appid" : "__UNI__B6E0086",
"description" : "瑜伽汇",
"versionName" : "1.0.20",
"versionCode" : 1020,
"versionName" : "1.0.21",
"versionCode" : 1021,
"transformPx" : false,
"app-plus" : {
"flexible" : true,
@ -69,7 +69,8 @@
"<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
],
"abiFilters" : [ "armeabi-v7a", "arm64-v8a" ]
"abiFilters" : [ "armeabi-v7a", "arm64-v8a" ],
"minSdkVersion" : 21
},
"ios" : {
"privacyDescription" : {

@ -168,6 +168,9 @@
this.id=options.id;
this.getinfo();
}
// app
this.setBadge();
},
onShow(){
this.openId = myCache('openId');
@ -181,6 +184,22 @@
}
},
methods: {
// app
setBadge() {
var count = myCache("massageCount")?myCache("massageCount"):-1;
if (count > 0) {
// app
//#ifdef APP-PLUS
plus.runtime.setBadgeNumber(count);
//#endif
} else {
// app
//#ifdef APP-PLUS
plus.runtime.setBadgeNumber(-1);
//#endif
}
},
formatTime(timeStr) {
// timeStr "HH:MM:SS"
return timeStr.slice(0, 5); // 5 "HH:MM"

@ -115,15 +115,26 @@ export default {
//
setBadge(count) {
myCache("massageCount",count);
if (count > 0) {
uni.setTabBarBadge({
index: 3, // tabBar
text: count + ''
})
});
// app
//#ifdef APP-PLUS
plus.runtime.setBadgeNumber(count);
//#endif
} else {
uni.removeTabBarBadge({
index: 3
})
});
// app
//#ifdef APP-PLUS
plus.runtime.setBadgeNumber(-1);
//#endif
}
},

@ -309,7 +309,7 @@
uni.showLoading({
title: '正在登录...'
});
console.log("login--登录参数",this.form)
const {data: res} = await uni.$http.post('/api/login',this.form);
if(res&&res.code=="200"){
uni.setStorageSync("loginindex", "1");

@ -591,6 +591,11 @@
index: 4
})
}
// app
//#ifdef APP-PLUS
plus.runtime.setBadgeNumber(-1);
//#endif
this.$refs.uToast.show({
title: '已退出登录!',

@ -124,20 +124,24 @@ function getcartLoseNum() {
}
return num
};
function getmessageNum() {
var user=myCache("user");
var userid = user.userid? user.userid:'';
var num=0;
if(userid){
var grouplist=myCache("chatlist-"+userid)?myCache("chatlist-"+userid):[];
for(let i=0;i<grouplist.length;i++){
num=num+1*(grouplist[i].sl?grouplist[i].sl:0);
}
return num
}
else{
return num
}
// function getmessageNum() {
// var user=myCache("user");
// var userid = user.userid? user.userid:'';
// var num=0;
// if(userid){
// var grouplist=myCache("chatlist-"+userid)?myCache("chatlist-"+userid):[];
// for(let i=0;i<grouplist.length;i++){
// num=num+1*(grouplist[i].sl?grouplist[i].sl:0);
// }
// return num
// }
// else{
// return num
// }
// };
function getmessageNum() {
var num= myCache("massageCount")?myCache("massageCount"):0;
return num;
};
export {
myCache,

Loading…
Cancel
Save