IM,群组相关页面
This commit is contained in:
@@ -99,12 +99,29 @@ const getMyGroups = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取群信息,包含基础信息和 14 个用户
|
||||||
|
*/
|
||||||
const getGroupInfo = (groupId) => {
|
const getGroupInfo = (groupId) => {
|
||||||
return request({
|
return request({
|
||||||
url: 'im/groups/' + groupId
|
url: 'im/groups/' + groupId
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getGroupUsers = (groupId) => {
|
||||||
|
return request({
|
||||||
|
url: 'im/groups/' + groupId + '/users'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const getGroupAnnouncements = (groupId) => {
|
||||||
|
return request({
|
||||||
|
url: 'im/groups/' + groupId + '/announcements'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 创建群聊
|
||||||
|
*/
|
||||||
const createGroup = (data) => {
|
const createGroup = (data) => {
|
||||||
return request({
|
return request({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -113,6 +130,37 @@ const createGroup = (data) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const updateGroup = (groupId, data) => {
|
||||||
|
return request({
|
||||||
|
method: 'PUT',
|
||||||
|
url: 'im/groups/' + groupId,
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 搜索群聊
|
||||||
|
*/
|
||||||
|
const searchGroup = (name) => {
|
||||||
|
return request({
|
||||||
|
url: 'im/groups/search?name=' + name
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const joinGroup = (groupId) => {
|
||||||
|
return request({
|
||||||
|
method: 'POST',
|
||||||
|
url: 'im/groups/' + groupId + '/join'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const quitGroup = (groupId) => {
|
||||||
|
return request({
|
||||||
|
method: 'POST',
|
||||||
|
url: 'im/groups/' + groupId + '/quit'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
getImToken,
|
getImToken,
|
||||||
deleteFriend,
|
deleteFriend,
|
||||||
@@ -127,5 +175,11 @@ export {
|
|||||||
pedingFriend,
|
pedingFriend,
|
||||||
getMyGroups,
|
getMyGroups,
|
||||||
createGroup,
|
createGroup,
|
||||||
getGroupInfo
|
updateGroup,
|
||||||
|
getGroupInfo,
|
||||||
|
getGroupUsers,
|
||||||
|
getGroupAnnouncements,
|
||||||
|
searchGroup,
|
||||||
|
joinGroup,
|
||||||
|
quitGroup
|
||||||
}
|
}
|
||||||
|
|||||||
16
pages.json
16
pages.json
@@ -427,7 +427,7 @@
|
|||||||
"path": "pages/im/friends/info",
|
"path": "pages/im/friends/info",
|
||||||
"name": "imFriendsInfo",
|
"name": "imFriendsInfo",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "好友资料",
|
"navigationBarTitleText": "用户资料",
|
||||||
"navigationBarBackgroundColor": "#FFFFFF"
|
"navigationBarBackgroundColor": "#FFFFFF"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -490,6 +490,20 @@
|
|||||||
"navigationBarTitleText": "创建群聊"
|
"navigationBarTitleText": "创建群聊"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/im/group/users",
|
||||||
|
"name": "imGroupUsers",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "群成员"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/im/group/announcement",
|
||||||
|
"name": "imGroupAnnouncement",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "群公告"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/wallet/add",
|
"path": "pages/wallet/add",
|
||||||
"name": "WalletAdd",
|
"name": "WalletAdd",
|
||||||
|
|||||||
@@ -106,6 +106,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
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
|
||||||
|
|||||||
32
pages/im/group/announcement.nvue
Normal file
32
pages/im/group/announcement.nvue
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<template>
|
||||||
|
<view>
|
||||||
|
<view v-for="(item,index) in announcements" :key="index">
|
||||||
|
{{ item.content }}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
getGroupAnnouncements
|
||||||
|
} from '@/apis/interfaces/im.js'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
targetId: '',
|
||||||
|
announcements: []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onLoad(e) {
|
||||||
|
this.targetId = e.targetId
|
||||||
|
getGroupAnnouncements(this.targetId).then(res => {
|
||||||
|
this.announcements = res
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
|
||||||
|
</style>
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<list class="body" :show-scrollbar="false">
|
<list class="body" :show-scrollbar="false">
|
||||||
<cell class="cell" v-for="(item, index) in messages" :key="index">
|
<cell class="cell" v-for="(item, index) in messages" :key="index">
|
||||||
<view class="cell-item" :class="item.messageDirection == 1 ? 'right' : 'left'">
|
<view class="cell-item" :class="item.messageDirection == 1 ? 'right' : 'left'">
|
||||||
<u-avatar class="avatar" size="36" shape="square" :src="item.content.userInfo.portraitUrl" />
|
<u-avatar class="avatar" @click="toUser(item)" size="36" shape="square" :src="item.content.userInfo.portraitUrl" />
|
||||||
<view class="msg">
|
<view class="msg">
|
||||||
<show-voice v-if="item.objectName === 'RC:HQVCMsg'" :guest="item.messageDirection == 1"
|
<show-voice v-if="item.objectName === 'RC:HQVCMsg'" :guest="item.messageDirection == 1"
|
||||||
:msg="item.content" :name="item.content.userInfo.name" />
|
:msg="item.content" :name="item.content.userInfo.name" />
|
||||||
@@ -72,6 +72,12 @@
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
toUser(item) {
|
||||||
|
console.log(item);
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/im/friends/info?targetId=' + item.senderUserId
|
||||||
|
})
|
||||||
|
},
|
||||||
// 获取消息列表
|
// 获取消息列表
|
||||||
getMessageList() {
|
getMessageList() {
|
||||||
im.getMessageList(
|
im.getMessageList(
|
||||||
|
|||||||
@@ -1,24 +1,40 @@
|
|||||||
<template>
|
<template>
|
||||||
<view>
|
<view>
|
||||||
<view class="">
|
<view class="members">
|
||||||
|
<view class="users">
|
||||||
|
<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>
|
||||||
|
<text class="name">{{ item.name }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="user">
|
||||||
|
<u-avatar @click="inviteUser" size="44" shape="square" icon="plus" bg-color="#eeeeee" color="#999999"></u-avatar>
|
||||||
|
<text class="name">邀请用户</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
</view>
|
<view class="">
|
||||||
<view>
|
<text @click="loadMore" class="loadmore">查看更多群成员</text>
|
||||||
查看更多群成员
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
群聊名称
|
<u-cell-group>
|
||||||
群公告
|
<u-cell isLink title="群聊名称" :value="group.name"></u-cell>
|
||||||
|
<u-cell isLink title="群公告" :label="announcement"></u-cell>
|
||||||
|
<u-cell isLink title="聊天置顶"></u-cell>
|
||||||
|
<u-cell isLink title="免打扰"></u-cell>
|
||||||
|
</u-cell-group>
|
||||||
|
|
||||||
<view class="">
|
<view class="actions u-border-top">
|
||||||
置顶
|
<view class="u-border-bottom">
|
||||||
|
<text>清空聊天记录</text>
|
||||||
|
</view>
|
||||||
|
<view class="u-border-bottom">
|
||||||
|
<text>删除并退出</text>
|
||||||
|
</view>
|
||||||
|
<view class="u-border-bottom" v-if="group.is_owner">
|
||||||
|
<text>解散群聊</text>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="">
|
|
||||||
免打扰
|
|
||||||
</view>
|
|
||||||
清空聊天记录
|
|
||||||
删除并退出
|
|
||||||
解散群聊
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -32,21 +48,77 @@
|
|||||||
return {
|
return {
|
||||||
targetId: '',
|
targetId: '',
|
||||||
group: {},
|
group: {},
|
||||||
|
announcement: '',
|
||||||
members: []
|
members: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad(e) {
|
onLoad(e) {
|
||||||
this.targetId = e.targetId
|
this.targetId = e.targetId
|
||||||
getGroupInfo(this.targetId).then(res => {
|
getGroupInfo(this.targetId).then(res => {
|
||||||
this.info = res.group
|
this.group = res.group
|
||||||
|
this.announcement = res.announcement
|
||||||
this.members = res.members
|
this.members = res.members
|
||||||
}).catch(err => {
|
|
||||||
console.log(err);
|
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
toUser(item) {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/im/friends/info?targetId=' + item.targetId
|
||||||
|
})
|
||||||
|
},
|
||||||
|
inviteUser() {
|
||||||
|
|
||||||
|
},
|
||||||
|
loadMore() {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/im/group/users?targetId=' + this.targetId
|
||||||
|
})
|
||||||
|
},
|
||||||
|
toAnnouncement() {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/im/group/announcement?targetId=' + this.targetId
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style lang="scss" scoped>
|
||||||
|
.members {
|
||||||
|
background-color: white;
|
||||||
|
padding-bottom: 40rpx;
|
||||||
|
|
||||||
|
.users {
|
||||||
|
flex-direction: row;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
display: flex;
|
||||||
|
padding: 20rpx 0;
|
||||||
|
|
||||||
|
.user {
|
||||||
|
width: 126rpx;
|
||||||
|
margin-left: 20rpx;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
.name {
|
||||||
|
width: 126rpx;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 28rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.loadmore {
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: $text-gray-m;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.actions {
|
||||||
|
margin-top: $padding;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
68
pages/im/group/users.nvue
Normal file
68
pages/im/group/users.nvue
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
<template>
|
||||||
|
<view class="members">
|
||||||
|
<view class="users">
|
||||||
|
<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>
|
||||||
|
<text class="name">{{ item.name }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
getGroupUsers
|
||||||
|
} from '@/apis/interfaces/im.js'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
targetId: '',
|
||||||
|
members: []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onLoad(e) {
|
||||||
|
this.targetId = e.targetId
|
||||||
|
getGroupUsers(this.targetId).then(res => {
|
||||||
|
this.members = res
|
||||||
|
})
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
toUser(item) {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/im/friends/info?targetId=' + item.targetId
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.members {
|
||||||
|
background-color: white;
|
||||||
|
padding-bottom: 40rpx;
|
||||||
|
|
||||||
|
.users {
|
||||||
|
flex-direction: row;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
display: flex;
|
||||||
|
padding: 20rpx 0;
|
||||||
|
|
||||||
|
.user {
|
||||||
|
width: 126rpx;
|
||||||
|
margin-left: 20rpx;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
.name {
|
||||||
|
width: 126rpx;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 28rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -98,7 +98,6 @@
|
|||||||
RongIMLib.getConversationList([1, 3], count, timestamp, (res) => {
|
RongIMLib.getConversationList([1, 3], count, timestamp, (res) => {
|
||||||
if (res.code === 0) {
|
if (res.code === 0) {
|
||||||
this.conversations = res.conversations
|
this.conversations = res.conversations
|
||||||
console.log(res.conversations);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import {
|
|||||||
} from 'uni-simple-router';
|
} from 'uni-simple-router';
|
||||||
import store from '@/store/index'
|
import store from '@/store/index'
|
||||||
|
|
||||||
// #ifdef APP-NVUE
|
|
||||||
// CALL 页面,必须是nvue,但是NVUE 不支持webpack的 ROUTES 注入
|
// CALL 页面,必须是nvue,但是NVUE 不支持webpack的 ROUTES 注入
|
||||||
// https://github.com/SilurianYang/uni-read-pages/issues/20
|
// https://github.com/SilurianYang/uni-read-pages/issues/20
|
||||||
|
// #ifdef APP-NVUE
|
||||||
const ROUTES = [{
|
const ROUTES = [{
|
||||||
'path': '/pages/im/private/call',
|
'path': '/pages/im/private/call',
|
||||||
'name': 'imPrivateCall'
|
'name': 'imPrivateCall'
|
||||||
@@ -25,8 +25,13 @@ const ROUTES = [{
|
|||||||
},{
|
},{
|
||||||
'path': '/pages/im/group/create',
|
'path': '/pages/im/group/create',
|
||||||
'name': 'imGroupCreate'
|
'name': 'imGroupCreate'
|
||||||
|
},{
|
||||||
|
'path': '/pages/im/group/users',
|
||||||
|
'name': 'imGroupUsers'
|
||||||
|
},{
|
||||||
|
'path': '/pages/im/group/announcement',
|
||||||
|
'name': 'imGroupAnnouncement'
|
||||||
}]
|
}]
|
||||||
|
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
|
|||||||
Reference in New Issue
Block a user