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()
//
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>
<style lang="scss">

View File

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

View File

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

View File

@ -138,6 +138,12 @@ const showMenu = computed(() => {
//
const noReadNum = ref(0)
const getReadNum = () => {
getNoReadNum()
}
defineExpose({ getReadNum })
//
onMounted(() => {
//
@ -245,7 +251,7 @@ function getNoReadNum() {
<view class="option" :class="{ active: item.page === page }" v-if="item.type == 'option'">
<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 class="middle" v-else-if="item.type === 'middle'">
@ -351,15 +357,20 @@ $boderSize: 2rpx;
color: #999;
}
}
.option {
position: relative;
z-index: 1;
.pot {
position: absolute;
top: -16rpx;
right: -30rpx;
height: 24rpx;
/* #ifndef APP-NVUE */
min-width: 24rpx;
/* #endif */
line-height: 24rpx;
border-radius: 24rpx;
background: #FF6B17;
@ -367,7 +378,7 @@ $boderSize: 2rpx;
font-size: 20rpx;
padding: 4rpx;
text-align: center;
}
z-index: 11;
}
}

View File

@ -52,7 +52,7 @@
//
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() {
// #ifdef APP
uni.$chat.off(TencentCloudChat.EVENT.CONVERSATION_LIST_UPDATED);
// #endif
uni.$chat.off(TencentCloudChat.EVENT.CONVERSATION_LIST_UPDATED, () => { });
}
//
function getList() {
api.news.getMessageList({
query: {
userId: userinfo.value.id,
}
}).then(rs => {
if (rs.code == 200) {
// list.data = handleList(rs.data);
list.data = handleList(JSON.parse(rs.msg).SessionItem);
// sdk
let isReady = uni.$chat.isReady();
if (!isReady) {
setTimeout(function () {
getList();
}, 800);
return
}
util.alert({
content: rs.msg,
showCancel: false,
uni.$emit('updateNum', {})
uni.$chat.getConversationList().then(rs => {
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,7 +168,7 @@ function handleList(list) {
}, 800);
return
}
if (list) {
list.forEach(item => {
item.MsgTime = handleDate(item.MsgTime)
@ -151,6 +189,7 @@ function handleList(list) {
})
})
}
return list
}
@ -178,15 +217,15 @@ function handleList(list) {
function handleChat(item) {
let param = {};
//
if (item.groupId == null) {
if (item.type == 'C2C') {
param.type = 'C2C'
param.name = `${item.name}`
param.msgId = `${item.To_Account}`
param.msgId = `${item.userID}`
} else {
//
param.type = 'GROUP'
param.name = `${item.name}`
param.msgId = `${item.GroupId}`
param.msgId = `${item.groupID}`
param.num = `${item.num}`
}
@ -216,7 +255,7 @@ function delMsg(item) {
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 => {
getList()
@ -234,7 +273,7 @@ function setRead(item) {
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({
conversationID: conversationId,
}).then(rs => {

View File

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

View File

@ -36,7 +36,7 @@
screenHeight,
bottomSafeAreaHeight
} 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)
//

View File

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

View File

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

View File

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