From b42c72344cbd7c865ba706ffcfa1dc75198c7334 Mon Sep 17 00:00:00 2001 From: zouyanyan <254651820@qq.com> Date: Sat, 18 Jul 2026 12:01:22 +0800 Subject: [PATCH] upbug --- App.vue | 150 +++++++++++++++++++++------------------- manifest.json | 7 +- pages/book/bookinfo.vue | 19 +++++ pages/chatbox/chat.vue | 15 +++- pages/login/login.vue | 2 +- pages/user/user.vue | 5 ++ utils/utils.js | 32 +++++---- 7 files changed, 139 insertions(+), 91 deletions(-) diff --git a/App.vue b/App.vue index dfce2dd..704a00d 100644 --- a/App.vue +++ b/App.vue @@ -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) { diff --git a/manifest.json b/manifest.json index 667799d..cbc320f 100644 --- a/manifest.json +++ b/manifest.json @@ -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 @@ "", "" ], - "abiFilters" : [ "armeabi-v7a", "arm64-v8a" ] + "abiFilters" : [ "armeabi-v7a", "arm64-v8a" ], + "minSdkVersion" : 21 }, "ios" : { "privacyDescription" : { diff --git a/pages/book/bookinfo.vue b/pages/book/bookinfo.vue index d205aae..6be3a09 100644 --- a/pages/book/bookinfo.vue +++ b/pages/book/bookinfo.vue @@ -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" diff --git a/pages/chatbox/chat.vue b/pages/chatbox/chat.vue index 048f8aa..b4ccdc8 100644 --- a/pages/chatbox/chat.vue +++ b/pages/chatbox/chat.vue @@ -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 } }, diff --git a/pages/login/login.vue b/pages/login/login.vue index 9eff6cf..d5a6cea 100644 --- a/pages/login/login.vue +++ b/pages/login/login.vue @@ -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"); diff --git a/pages/user/user.vue b/pages/user/user.vue index ca1750f..5d57ed4 100644 --- a/pages/user/user.vue +++ b/pages/user/user.vue @@ -591,6 +591,11 @@ index: 4 }) } + + // app清除角标的数量 + //#ifdef APP-PLUS + plus.runtime.setBadgeNumber(-1); + //#endif this.$refs.uToast.show({ title: '已退出登录!', diff --git a/utils/utils.js b/utils/utils.js index 8cf9471..fd5db45 100644 --- a/utils/utils.js +++ b/utils/utils.js @@ -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