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 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 * as wsApi from './common/wssocket';
import chatStore from "./store/chatStore"; import chatStore from "./store/chatStore";
import * as enums from "./common/enums"; import * as enums from "./common/enums";
@ -26,6 +27,9 @@
} }
}, },
computed: {
...mapState('chatStore', ['chats'])
},
onLaunch() { onLaunch() {
// //
//checkupdate(); //checkupdate();
@ -37,7 +41,7 @@
jpushModule.initJPushService() jpushModule.initJPushService()
jpushModule.addConnectEventListener(result=>{ jpushModule.addConnectEventListener(result=>{
let connectEnable = result.connectEnable let connectEnable = result.connectEnable
console.log("jpush连接", connectEnable) console.log("极光推送--jpush连接", connectEnable)
}); });
jpushModule.addTagAliasListener(result => { jpushModule.addTagAliasListener(result => {
@ -47,7 +51,7 @@
let tag = result.tag let tag = result.tag
let tagEnable = result.tagEnable let tagEnable = result.tagEnable
let alias = result.alias let alias = result.alias
console.log(alias, '别名') console.log('极光推送--别名',alias)
}); });
// //
@ -57,87 +61,79 @@
let title = result.title let title = result.title
let content = result.content let content = result.content
let extras = result.extras let extras = result.extras
console.log("消息通知", result); console.log("极光推送--消息通知", result);
console.log("消息通知extras", extras) console.log("极光推送--消息通知extras", extras);
// //
if(extras && extras.type && extras.type == 'bookCourses') { if (notificationEventType == 'notificationOpened') {
var bookId=extras.bookId?extras.bookId:''; if(extras && extras.type && extras.type == 'bookCourses') {
if(bookId){ 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({ 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({ 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 => { jpushModule.getRegistrationID(result => {
console.log("注册ID", result.registerID) console.log("极光推送--注册ID", result.registerID)
if (result.registerID) { if (result.registerID) {
uni.setStorageSync("register_id", result.registerID) uni.setStorageSync("register_id", result.registerID)
} }
}) });
jpushModule.addCustomMessageListener(result => { jpushModule.addCustomMessageListener(result => {
let messageID = result.messageID let messageID = result.messageID
let content = result.content let content = result.content
let extras = result.extras let extras = result.extras
console.log("自定义消息", result) console.log("极光推送--自定义消息", result)
}) });
//#endif //#endif
// end-------------- // end--------------
@ -162,11 +158,23 @@
uni.navigateTo({ uni.navigateTo({
url: "/pages/login/login" 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: { methods: {
...mapActions('chatStore'),
//--------------------------------------------------- //---------------------------------------------------
init(userId) { init(userId) {

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

@ -168,6 +168,9 @@
this.id=options.id; this.id=options.id;
this.getinfo(); this.getinfo();
} }
// app
this.setBadge();
}, },
onShow(){ onShow(){
this.openId = myCache('openId'); this.openId = myCache('openId');
@ -181,6 +184,22 @@
} }
}, },
methods: { 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) { formatTime(timeStr) {
// timeStr "HH:MM:SS" // timeStr "HH:MM:SS"
return timeStr.slice(0, 5); // 5 "HH:MM" return timeStr.slice(0, 5); // 5 "HH:MM"

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

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

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

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

Loading…
Cancel
Save