This commit is contained in:
2022-02-11 15:24:10 +08:00
parent efcfa00545
commit 35cb716299
4 changed files with 132 additions and 65 deletions

View File

@@ -369,7 +369,6 @@
"path": "pages/im/index", "path": "pages/im/index",
"name": "IM", "name": "IM",
"style": { "style": {
"navigationBarBackgroundColor": "#FFFFFF",
"navigationStyle": "custom" "navigationStyle": "custom"
} }
}, },
@@ -411,24 +410,21 @@
"path": "pages/im/friends/pending", "path": "pages/im/friends/pending",
"name": "imFriendsPending", "name": "imFriendsPending",
"style": { "style": {
"navigationBarTitleText": "新朋友", "navigationBarTitleText": "新朋友"
"navigationBarBackgroundColor": "#F3F6FB"
} }
}, },
{ {
"path": "pages/im/friends/search", "path": "pages/im/friends/search",
"name": "SearchFriend", "name": "SearchFriend",
"style": { "style": {
"navigationBarTitleText": "好友搜索", "navigationBarTitleText": "好友搜索"
"navigationBarBackgroundColor": "#F3F6FB"
} }
}, },
{ {
"path": "pages/im/friends/info", "path": "pages/im/friends/info",
"name": "imFriendsInfo", "name": "imFriendsInfo",
"style": { "style": {
"navigationBarTitleText": "用户资料", "navigationBarTitleText": "用户资料"
"navigationBarBackgroundColor": "#FFFFFF"
} }
}, },
{ {
@@ -480,7 +476,7 @@
"path": "pages/im/group/info", "path": "pages/im/group/info",
"name": "imGroupInfo", "name": "imGroupInfo",
"style": { "style": {
"navigationBarTitleText": "群信息" "navigationBarTitleText": "群信息"
} }
}, },
{ {
@@ -494,14 +490,14 @@
"path": "pages/im/group/users", "path": "pages/im/group/users",
"name": "imGroupUsers", "name": "imGroupUsers",
"style": { "style": {
"navigationBarTitleText": "群成员" "navigationBarTitleText": "群成员"
} }
}, },
{ {
"path": "pages/im/group/announcement", "path": "pages/im/group/announcement",
"name": "imGroupAnnouncement", "name": "imGroupAnnouncement",
"style": { "style": {
"navigationBarTitleText": "群公告", "navigationBarTitleText": "群公告",
"app-plus": { "app-plus": {
"titleNView": { "titleNView": {
"type": "default", "type": "default",
@@ -519,7 +515,7 @@
"path": "pages/im/group/announceCreate", "path": "pages/im/group/announceCreate",
"name": "imGroupAnnouncementCreate", "name": "imGroupAnnouncementCreate",
"style": { "style": {
"navigationBarTitleText": "发布群公告" "navigationBarTitleText": "发布群公告"
} }
}, },
{ {

View File

@@ -106,7 +106,6 @@
} }
}, },
onLoad(e) { onLoad(e) {
console.log(e);
this.targetId = e.targetId this.targetId = e.targetId
getFriendInfo(e.targetId).then(res => { getFriendInfo(e.targetId).then(res => {
this.userInfo = res this.userInfo = res
@@ -128,7 +127,7 @@
if (code == 0) { if (code == 0) {
this.isTop = conversation.isTop this.isTop = conversation.isTop
} }
}); })
}, },
methods: { methods: {
copyAddress() { copyAddress() {

View File

@@ -1,45 +1,44 @@
<template> <template>
<view> <view class="container">
<view class="members"> <view class="members u-border-bottom">
<view class="users"> <view class="users">
<view class="user" v-for="(item, index) in members" :key="index" @click="toUser(item)"> <view class="user" v-for="(item, index) in members" :key="index" @click="toUser(item)">
<u-avatar size="44" shape="square" :src="item.portraitUrl"></u-avatar> <u-avatar size="44" shape="square" :src="item.portraitUrl"></u-avatar>
<text class="name">{{ item.name }}</text> <view class="name">{{ item.name }}</view>
</view> </view>
<view class="user"> <view class="user">
<u-avatar @click="inviteUser" size="44" shape="square" icon="plus" bg-color="#eeeeee" <u-avatar @click="inviteUser" size="44" shape="square" icon="plus" bg-color="#eeeeee"
color="#999999"></u-avatar> color="#999999"></u-avatar>
<text class="name">邀请用户</text> <view class="name">邀请用户</view>
</view> </view>
</view>
<view class="">
<text @click="loadMore" class="loadmore">查看更多群成员</text>
</view>
</view>
<u-cell-group>
<u-cell isLink title="群公告" :label="announcement" @click="toAnnouncement"></u-cell>
<u-cell isLink title="聊天置顶"></u-cell>
<u-cell isLink title="免打扰"></u-cell>
</u-cell-group>
<u-cell-group v-if="group.is_owner">
<u-cell isLink title="修改群聊名称" :value="group.name"></u-cell>
<u-cell isLink title="修改群头像"></u-cell>
</u-cell-group>
<view class="actions u-border-top">
<view class="action u-border-bottom" @click="onClean">
<text>清空聊天记录</text>
</view>
<view class="action u-border-bottom" v-if="group.is_owner" @click="onDismiss">
<text>解散群聊</text>
</view> </view>
<view class="action u-border-bottom" v-else @click="onQuite">
<text>删除并退出</text> <view @click="loadMore" class="loadmore">查看更多群成员</view>
</view>
</view> </view>
<u-cell-group class="cells">
<u-cell isLink title="群公告" :label="announcement" @click="toAnnouncement"></u-cell>
<u-cell title="聊天置顶">
<u-switch slot="value" size="20" v-model="isTop" activeColor="#34CE98" @change="setTop"></u-switch>
</u-cell>
<u-cell title="免打扰">
<u-switch slot="value" size="20" v-model="status" activeColor="#34CE98" @change="setStatus"></u-switch>
</u-cell>
</u-cell-group>
<u-cell-group class="cells" v-if="group.is_owner">
<u-cell isLink title="修改群聊名称" :value="group.name" @click="onGroupName"></u-cell>
<u-cell isLink title="修改群头像">
<u-avatar slot="value" size="24" shape="square" :src="group.cover"></u-avatar>
</u-cell>
</u-cell-group>
<view class="cells actions u-border-top">
<view class="action u-border-bottom" @click="onClean">清空聊天记录</view>
<view class="action u-border-bottom" v-if="group.is_owner" @click="onDismiss">解散群聊</view>
<view class="action u-border-bottom" v-else @click="onQuite">删除并退出</view>
</view>
</view> </view>
</template> </template>
@@ -47,25 +46,60 @@
import { import {
getGroupInfo getGroupInfo
} from '@/apis/interfaces/im.js' } from '@/apis/interfaces/im.js'
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
export default { export default {
data() { data() {
return { return {
targetId: '', targetId: '',
group: {}, group: {},
conversationType: 3,
announcement: '', announcement: '',
members: [] members: [],
status: false,
isTop: false,
} }
}, },
onLoad(e) { onLoad(e) {
this.targetId = e.targetId this.targetId = e.targetId
getGroupInfo(this.targetId).then(res => { getGroupInfo(this.targetId).then(res => {
this.group = res.group this.group = res.group
console.log(this.group);
this.announcement = res.announcement this.announcement = res.announcement
this.members = res.members this.members = res.members
}) })
RongIMLib.getConversationNotificationStatus(this.conversationType, this.targetId, ({
status
}) => {
this.status = !Boolean(status)
})
RongIMLib.getConversation(this.conversationType, this.targetId, ({
code,
conversation
}) => {
if (code == 0) {
this.isTop = conversation.isTop
}
})
}, },
methods: { methods: {
setStatus() {
RongIMLib.setConversationNotificationStatus(this.conversationType, this.targetId, this.status,
({
status
}) => {
this.status = !Boolean(status)
})
},
setTop() {
RongIMLib.setConversationToTop(this.conversationType, this.targetId, this.isTop, (res) => {
RongIMLib.getConversation(this.conversationType, this.targetId, ({
conversation
}) => {
this.isTop = conversation.isTop
})
})
},
toUser(item) { toUser(item) {
uni.navigateTo({ uni.navigateTo({
url: '/pages/im/friends/info?targetId=' + item.targetId url: '/pages/im/friends/info?targetId=' + item.targetId
@@ -83,21 +117,53 @@
uni.navigateTo({ uni.navigateTo({
url: '/pages/im/group/announcement?targetId=' + this.targetId url: '/pages/im/group/announcement?targetId=' + this.targetId
}) })
}, },
onClean() { onGroupName() {
}, },
onDismiss() { onClean() {
uni.showModal({
}, title: '清空聊天记录',
onQuite() { content: '清空聊天记录,只会清空本地的记录,其他成员不会变化',
success: (res) => {
if (res.confirm) {
RongIMLib.deleteMessages(3, this.targetId, () => {
uni.showToast({
icon: 'none',
title: '清空成功'
})
})
}
}
})
},
onDismiss() {
uni.showToast({
icon: 'none',
title: '开发中'
})
},
onQuite() {
uni.showToast({
icon: 'none',
title: '开发中'
})
} }
} }
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.container {
min-height: 100vh;
background: $window-color;
}
.cells {
margin-top: $padding;
background-color: white;
}
.members { .members {
background-color: white; background-color: white;
padding-bottom: 40rpx; padding-bottom: 40rpx;
@@ -115,12 +181,14 @@
justify-content: center; justify-content: center;
align-items: center; align-items: center;
.name { .name {
width: 126rpx; width: 126rpx;
text-align: center; text-align: center;
font-size: 28rpx; font-size: 28rpx;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap;
word-break: break-word;
} }
} }
} }
@@ -134,10 +202,12 @@
.actions { .actions {
margin-top: $padding; margin-top: $padding;
text-align: center;
.action { .action {
padding: $padding;
color: $text-price; color: $text-price;
justify-content: center; justify-content: center;
} }
} }
</style> </style>

View File

@@ -3,7 +3,7 @@
<view class="users"> <view class="users">
<view class="user" v-for="(item, index) in members" :key="index" @click="toUser(item)"> <view class="user" v-for="(item, index) in members" :key="index" @click="toUser(item)">
<u-avatar size="44" shape="square" :src="item.portraitUrl"></u-avatar> <u-avatar size="44" shape="square" :src="item.portraitUrl"></u-avatar>
<text class="name">{{ item.name }}</text> <view class="name">{{ item.name }}</view>
</view> </view>
</view> </view>
</view> </view>
@@ -59,12 +59,14 @@
justify-content: center; justify-content: center;
align-items: center; align-items: center;
.name { .name {
width: 126rpx; width: 126rpx;
text-align: center; text-align: center;
font-size: 28rpx; font-size: 28rpx;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap;
word-break: break-word;
} }
} }
} }