This commit is contained in:
parent
46f55d8b0e
commit
a0925a4ec7
|
@ -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">
|
||||
|
|
|
@ -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: {
|
||||
|
|
|
@ -1427,6 +1427,7 @@ const util = {
|
|||
uni.$emit('login')
|
||||
|
||||
setTimeout(() => {
|
||||
util.loginTencent(userinfo)
|
||||
uni.reLaunch({
|
||||
url: '/pages/index/index'
|
||||
})
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
|
||||
// 移除监听
|
||||
function removeListener() {
|
||||
uni.$chat.off(TencentCloudChat.EVENT.FRIEND_LIST_UPDATED);
|
||||
uni.$chat.off(TencentCloudChat.EVENT.FRIEND_LIST_UPDATED,()=>{});
|
||||
}
|
||||
|
||||
// 获取群组列表
|
||||
|
|
|
@ -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 => {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
// 我是关闭服务
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
|
||||
// 移除监听
|
||||
function removeListener() {
|
||||
uni.$chat.off(TencentCloudChat.EVENT.GROUP_LIST_UPDATED);
|
||||
uni.$chat.off(TencentCloudChat.EVENT.GROUP_LIST_UPDATED,()=>{});
|
||||
}
|
||||
|
||||
// 获取群组列表
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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()],
|
||||
|
|
Loading…
Reference in New Issue