This commit is contained in:
lr 2025-02-21 17:57:08 +08:00
parent 46f55d8b0e
commit a0925a4ec7
12 changed files with 134 additions and 108 deletions

View File

@ -14,8 +14,6 @@ onLaunch(() => {
getUserinfo() getUserinfo()
// //
getConfig() getConfig()
//
getNoReadNum()
}) })
// //
@ -53,41 +51,6 @@ function getConfig() {
} }
}) })
} }
//
async function getNoReadNum() {
// uni.removeTabBarBadge({
// index: 2,
// text: "",
// });
// api.getNoReadNum().then(rs => {
// if (rs.code == 200) {
// uni.setTabBarBadge({
// index: 0,
// text: "11",
// });
// }
// })
// uni.setTabBarBadge({
// index: 2,
// text: "11",
// });
// const res = await uni.request({ url: 'API_URL' });
// const count = res.data.unread;
// setTimeout(() => {
// uni.setTabBarBadge({
// index: 1,
// text: '10',
// success: function () {
// console.log(11111);
// },
// })
// }, 1000)
}
</script> </script>
<style lang="scss"> <style lang="scss">

View File

@ -7,7 +7,7 @@ const config = {
// #endif // #endif
// #ifndef H5 // #ifndef H5
host: 'http://91f.xyz:8080', host: 'http://91f.xyz:8080',
host: 'https://b433d23.r24.cpolar.top/', // host: 'https://1e49a851.r24.cpolar.top/',
// #endif // #endif
// 支付方式配置 // 支付方式配置
payType: { payType: {

View File

@ -1427,6 +1427,7 @@ const util = {
uni.$emit('login') uni.$emit('login')
setTimeout(() => { setTimeout(() => {
util.loginTencent(userinfo)
uni.reLaunch({ uni.reLaunch({
url: '/pages/index/index' url: '/pages/index/index'
}) })

View File

@ -138,6 +138,12 @@ const showMenu = computed(() => {
// //
const noReadNum = ref(0) const noReadNum = ref(0)
const getReadNum = () => {
getNoReadNum()
}
defineExpose({ getReadNum })
// //
onMounted(() => { onMounted(() => {
// //
@ -153,7 +159,7 @@ onMounted(() => {
// proxy.$refs.alert.open() // proxy.$refs.alert.open()
}) })
onLoad(()=>{ onLoad(() => {
// //
getNoReadNum() getNoReadNum()
}) })
@ -228,7 +234,7 @@ function getNoReadNum() {
} }
// #ifdef APP // #ifdef APP
const unreadCount = uni.$chat.getTotalUnreadMessageCount(); const unreadCount = uni.$chat.getTotalUnreadMessageCount();
noReadNum.value = +unreadCount > 99 ? '99+' : unreadCount; noReadNum.value = +unreadCount > 99 ? '99+' : unreadCount;
// #endif // #endif
@ -245,7 +251,7 @@ function getNoReadNum() {
<view class="option" :class="{ active: item.page === page }" v-if="item.type == 'option'"> <view class="option" :class="{ active: item.page === page }" v-if="item.type == 'option'">
<text class="text">{{ item.name }}</text> <text class="text">{{ item.name }}</text>
<span class="pot" v-if="item.page == 'news' && noReadNum != 0">{{ noReadNum }}</span> <view class="pot" v-if="item.page == 'news' && noReadNum != 0">{{ noReadNum }}</view>
</view> </view>
<view class="middle" v-else-if="item.type === 'middle'"> <view class="middle" v-else-if="item.type === 'middle'">
@ -351,23 +357,28 @@ $boderSize: 2rpx;
color: #999; color: #999;
} }
.option { }
position: relative;
.pot { .option {
position: absolute; position: relative;
top: -16rpx; z-index: 1;
right: -30rpx;
height: 24rpx; .pot {
min-width: 24rpx; position: absolute;
line-height: 24rpx; top: -16rpx;
border-radius: 24rpx; right: -30rpx;
background: #FF6B17; height: 24rpx;
color: #fff; /* #ifndef APP-NVUE */
font-size: 20rpx; min-width: 24rpx;
padding: 4rpx; /* #endif */
text-align: center; line-height: 24rpx;
} border-radius: 24rpx;
background: #FF6B17;
color: #fff;
font-size: 20rpx;
padding: 4rpx;
text-align: center;
z-index: 11;
} }
} }

View File

@ -52,7 +52,7 @@
// //
function removeListener() { function removeListener() {
uni.$chat.off(TencentCloudChat.EVENT.FRIEND_LIST_UPDATED); uni.$chat.off(TencentCloudChat.EVENT.FRIEND_LIST_UPDATED,()=>{});
} }
// //

View File

@ -93,28 +93,66 @@ function addListener() {
// //
function removeListener() { function removeListener() {
// #ifdef APP uni.$chat.off(TencentCloudChat.EVENT.CONVERSATION_LIST_UPDATED, () => { });
uni.$chat.off(TencentCloudChat.EVENT.CONVERSATION_LIST_UPDATED);
// #endif
} }
// //
function getList() { function getList() {
api.news.getMessageList({ // sdk
query: { let isReady = uni.$chat.isReady();
userId: userinfo.value.id, if (!isReady) {
} setTimeout(function () {
}).then(rs => { getList();
if (rs.code == 200) { }, 800);
// list.data = handleList(rs.data); return
list.data = handleList(JSON.parse(rs.msg).SessionItem); }
return
} uni.$emit('updateNum', {})
util.alert({
content: rs.msg, uni.$chat.getConversationList().then(rs => {
showCancel: false, let res = rs.data.conversationList
let arr = []
res.forEach(item => {
let obj = {}
obj.type = item.type;
obj.chatText = item.lastMessage.messageForShow;
obj.MsgTime = handleDate(item.lastMessage.lastTime);
obj.unreadCount = item.unreadCount;
if (item.type == 'C2C') {
obj.avatar = item.userProfile.avatar;
obj.name = item.userProfile.nick;
obj.userID = item.userProfile.userID;
} else if (item.type == 'GROUP') {
obj.avatar = item.groupProfile.avatar;
obj.name = item.groupProfile.name;
obj.num = item.groupProfile.memberCount;
obj.groupID = item.groupProfile.groupID;
}
arr.push(obj)
}) })
list.data = arr;
}) })
// api.news.getMessageList({
// query: {
// userId: userinfo.value.id,
// }
// }).then(rs => {
// if (rs.code == 200) {
// let msg = JSON.parse(rs.msg);
// list.data = handleList(msg.SessionItem);
// return
// }
// util.alert({
// content: rs.msg,
// showCancel: false,
// })
// })
} }
/** /**
@ -130,27 +168,28 @@ function handleList(list) {
}, 800); }, 800);
return return
} }
if (list) {
list.forEach(item => {
item.MsgTime = handleDate(item.MsgTime)
list.forEach(item => { let type = item.Type == 1 ? `C2C${item.To_Account}` : `GROUP${item.GroupId}`;
item.MsgTime = handleDate(item.MsgTime) uni.$chat.getConversationProfile(type).then(rs => {
let res = rs.data.conversation;
let type = item.Type == 1 ? `C2C${item.To_Account}` : `GROUP${item.GroupId}`; item.chatText = res.lastMessage.messageForShow;
uni.$chat.getConversationProfile(type).then(rs => { item.unreadCount = res.unreadCount;
let res = rs.data.conversation; if (item.Type == 1) {
item.avatar = res.userProfile.avatar;
item.chatText = res.lastMessage.messageForShow; item.name = res.userProfile.nick;
item.unreadCount = res.unreadCount; } else if (item.Type == 2) {
if (item.Type == 1) { item.avatar = res.groupProfile.avatar;
item.avatar = res.userProfile.avatar; item.name = res.groupProfile.name;
item.name = res.userProfile.nick; item.num = res.groupProfile.memberCount;
} else if (item.Type == 2) { }
item.avatar = res.groupProfile.avatar;
item.name = res.groupProfile.name;
item.num = res.groupProfile.memberCount;
}
})
}) })
}) }
return list return list
} }
@ -178,15 +217,15 @@ function handleList(list) {
function handleChat(item) { function handleChat(item) {
let param = {}; let param = {};
// //
if (item.groupId == null) { if (item.type == 'C2C') {
param.type = 'C2C' param.type = 'C2C'
param.name = `${item.name}` param.name = `${item.name}`
param.msgId = `${item.To_Account}` param.msgId = `${item.userID}`
} else { } else {
// //
param.type = 'GROUP' param.type = 'GROUP'
param.name = `${item.name}` param.name = `${item.name}`
param.msgId = `${item.GroupId}` param.msgId = `${item.groupID}`
param.num = `${item.num}` param.num = `${item.num}`
} }
@ -216,7 +255,7 @@ function delMsg(item) {
return return
} }
let conversationId = item.Type == 1 ? `C2C${item.To_Account}` : `GROUP${item.GroupId}`; let conversationId = item.Type == 1 ? `C2C${item.userID}` : `GROUP${item.groupID}`;
uni.$chat.deleteConversation(conversationId).then(rs => { uni.$chat.deleteConversation(conversationId).then(rs => {
getList() getList()
@ -234,7 +273,7 @@ function setRead(item) {
return return
} }
let conversationId = item.Type == 1 ? `C2C${item.To_Account}` : `GROUP${item.GroupId}`; let conversationId = item.Type == 1 ? `C2C${item.userID}` : `GROUP${item.groupID}`;
uni.$chat.setMessageRead({ uni.$chat.setMessageRead({
conversationID: conversationId, conversationID: conversationId,
}).then(rs => { }).then(rs => {

View File

@ -226,7 +226,7 @@
color: #333; color: #333;
background-color: #F7F7F7; background-color: #F7F7F7;
border-radius: 10rpx; border-radius: 10rpx;
transition: .3s; // transition: .3s;
border: 2rpx solid #F7F7F7; border: 2rpx solid #F7F7F7;
.text {} .text {}
@ -244,7 +244,7 @@
// //
&.disabled { &.disabled {
background-color: F7F7F7; background-color: #F7F7F7;
.txt { .txt {
color: #999; color: #999;

View File

@ -36,7 +36,7 @@
screenHeight, screenHeight,
bottomSafeAreaHeight bottomSafeAreaHeight
} from '@/components/public/Mixins.js' } from '@/components/public/Mixins.js'
import JyCommonHead from '@/components/public/jy-common-head' // import JyCommonHead from '@/components/public/jy-common-head'
const PayUse = ref(false) const PayUse = ref(false)
// //

View File

@ -39,7 +39,7 @@
ref, ref,
inject inject
} from 'vue' } from 'vue'
import JyCommonHead from '@/components/public/jy-common-head' // import JyCommonHead from '@/components/public/jy-common-head'
import { import {
useStore useStore
} from 'vuex' } from 'vuex'

View File

@ -59,7 +59,7 @@
// //
function removeListener() { function removeListener() {
uni.$chat.off(TencentCloudChat.EVENT.GROUP_LIST_UPDATED); uni.$chat.off(TencentCloudChat.EVENT.GROUP_LIST_UPDATED,()=>{});
} }
// //

View File

@ -37,7 +37,7 @@ const menuList = reactive([
{ {
key: 'group', key: 'group',
name: '即时消息', name: '即时消息',
load: true, load: false,
}, { }, {
key: 'friend', key: 'friend',
name: '通讯录', name: '通讯录',
@ -68,6 +68,7 @@ const userinfo = computed(() => {
const menuCurrent = computed(() => { const menuCurrent = computed(() => {
return menuList[menuIndex.value] return menuList[menuIndex.value]
}) })
const footerMneuRef = ref()
onLoad(() => { onLoad(() => {
// //
@ -75,6 +76,11 @@ onLoad(() => {
// //
addListener() addListener()
//
uni.$on('updateNum', (val) => {
getNoRead()
})
}) })
onUnload(() => { onUnload(() => {
@ -82,6 +88,12 @@ onUnload(() => {
removeListener() removeListener()
}) })
function getNoRead() {
setTimeout(() => {
footerMneuRef.value.getReadNum();
}, 200)
}
// //
function addListener() { function addListener() {
uni.$chat.on(TencentCloudChat.EVENT.SDK_READY, imLoading); uni.$chat.on(TencentCloudChat.EVENT.SDK_READY, imLoading);
@ -95,7 +107,7 @@ function imLoading() {
// //
function removeListener() { function removeListener() {
// #ifdef APP // #ifdef APP
uni.$chat.off(TencentCloudChat.EVENT.SDK_READY); uni.$chat.off(TencentCloudChat.EVENT.SDK_READY,()=>{});
// #endif // #endif
} }
@ -201,7 +213,7 @@ function getUserInfos(userRecommend) {
<swiper class="swiper" :current="menuIndex" disable-touch="true"> <swiper class="swiper" :current="menuIndex" disable-touch="true">
<!-- 群组 --> <!-- 群组 -->
<swiper-item> <swiper-item>
<msgList v-if="menuList[0].load" :type="menuIndex" /> <msgList v-if="menuList[0].load" :type="menuIndex" @updateNum="updateNum" />
<view class="loading" v-else>正在加载</view> <view class="loading" v-else>正在加载</view>
</swiper-item> </swiper-item>
@ -213,13 +225,13 @@ function getUserInfos(userRecommend) {
<!-- 视频消息 --> <!-- 视频消息 -->
<swiper-item> <swiper-item>
<msgList v-if="menuList[2].load" :type="menuIndex" /> <msgList v-if="menuList[2].load" :type="menuIndex" @updateNum="updateNum" />
<view class="loading" v-else>正在加载</view> <view class="loading" v-else>正在加载</view>
</swiper-item> </swiper-item>
<!-- 商城消息 --> <!-- 商城消息 -->
<swiper-item> <swiper-item>
<msgList v-if="menuList[3].load" :type="menuIndex" /> <msgList v-if="menuList[3].load" :type="menuIndex" @updateNum="updateNum" />
</swiper-item> </swiper-item>
</swiper> </swiper>
</view> </view>

View File

@ -3,8 +3,8 @@ import {
} from 'vite'; } from 'vite';
import uni from '@dcloudio/vite-plugin-uni'; import uni from '@dcloudio/vite-plugin-uni';
// let target = 'http://91f.xyz:8080' let target = 'http://91f.xyz:8080'
let target = 'https://b433d23.r24.cpolar.top/' // let target = 'https://1e49a851.r24.cpolar.top/'
export default defineConfig({ export default defineConfig({
plugins: [uni()], plugins: [uni()],