zouyanyan 3 weeks ago
parent dc8f3a905c
commit b42c72344c

@ -4,6 +4,7 @@
// //
// 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 { mapState, mapActions } from 'vuex'
import { myCache } from '@/utils/utils.js'; 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";
@ -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,14 +61,15 @@
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 (notificationEventType == 'notificationOpened') {
if(extras && extras.type && extras.type == 'bookCourses') { if(extras && extras.type && extras.type == 'bookCourses') {
var bookId=extras.bookId?extras.bookId:''; var bookId=extras.bookId?extras.bookId:'';
if(bookId){ if(bookId){
// //
uni.reLaunch({ uni.navigateTo({
url: `/pages/book/bookinfo?id=${bookId}` url: `/pages/book/bookinfo?id=${bookId}`
}); });
} }
@ -77,67 +82,58 @@
} }
if(extras && extras.type && extras.type == 'groupMessage') { if(extras && extras.type && extras.type == 'groupMessage') {
// //
// var pagePath=extras.pagePath; // let chat = {
// var groupId=extras.groupId; // type: 'GROUP',
// if(pagePath&&groupId){ // targetId: extras.groupId,
// uni.reLaunch({ // showName: '...',
// url: `${pagePath}?chatIdx=${groupId}` // headImage: '/static/image/kf.png',
// }); // };
// } // this.$store.dispatch('chatStore/openChat', chat);
// else{ // let chatIdx = this.$store.getters['chatStore/findChatIdx'](chat);
// uni.reLaunch({ // uni.reLaunch({
// url: `/pages/chatbox/chat` // url: `/pages/chatbox/chat-box?chatIdx=${chatIdx}`
// }); // });
// } uni.reLaunch({
let chat = { url: `/pages/chatbox/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') { if(extras && extras.type && extras.type == 'privateMessage') {
// //
// var pagePath=extras.pagePath; // let chat = {
// var senderId=extras.senderId; // type: 'PRIVATE',
// if(pagePath&&senderId){ // targetId: extras.senderId,
// uni.reLaunch({ // showName: '...',
// url: `${pagePath}?chatIdx=${senderId}` // headImage: '/static/image/kf.png',
// }); // };
// } // this.$store.dispatch('chatStore/openChat', chat);
// else{ // let chatIdx = this.$store.getters['chatStore/findChatIdx'](chat)
// uni.reLaunch({ // uni.reLaunch({
// url: `/pages/chatbox/chat` // url: `/pages/chatbox/chat-box?chatIdx=${chatIdx}`
// }); // });
// }
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({ uni.reLaunch({
url: `/pages/chatbox/chat-box?chatIdx=${chatIdx}` url: `/pages/chatbox/chat`
}); });
} }
})
if(!extras){
uni.reLaunch({
url: `/pages/chatbox/chat`
});
}
}
});
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--------------
@ -164,9 +160,21 @@
}) })
} }
//
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");

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

@ -124,20 +124,24 @@ function getcartLoseNum() {
} }
return num 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() { function getmessageNum() {
var user=myCache("user"); var num= myCache("massageCount")?myCache("massageCount"):0;
var userid = user.userid? user.userid:''; return num;
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
}
}; };
export { export {
myCache, myCache,

Loading…
Cancel
Save