成员管理的基础
This commit is contained in:
@@ -117,9 +117,10 @@ const getGroupBase = (groupId) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const getGroupUsers = (groupId) => {
|
const getGroupUsers = (groupId, limit) => {
|
||||||
|
limit = limit || 0
|
||||||
return request({
|
return request({
|
||||||
url: 'im/groups/' + groupId + '/users'
|
url: 'im/groups/' + groupId + '/users?limit=' + limit
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,6 +211,59 @@ const dismissGroup = (groupId) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除群成员
|
||||||
|
*/
|
||||||
|
const removeGroupUser = (groupId, userId) => {
|
||||||
|
return request({
|
||||||
|
method: 'DELETE',
|
||||||
|
url: 'im/groups/' + groupId + '/users/' + userId
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邀请群成员
|
||||||
|
*/
|
||||||
|
const inviteGroupUser = (groupId, userIds) => {
|
||||||
|
return request({
|
||||||
|
method: 'POST',
|
||||||
|
url: 'im/groups/' + groupId + '/invite',
|
||||||
|
data: {
|
||||||
|
userIds
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置群管理
|
||||||
|
*/
|
||||||
|
const setGroupAdmin = (groupId, userId) => {
|
||||||
|
return request({
|
||||||
|
method: 'POST',
|
||||||
|
url: 'im/groups/' + groupId + '/admin/' + userId
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除群管理
|
||||||
|
*/
|
||||||
|
const removeGroupAdmin = (groupId, userId) => {
|
||||||
|
return request({
|
||||||
|
method: 'DELETE',
|
||||||
|
url: 'im/groups/' + groupId + '/admin/' + userId
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转移群主
|
||||||
|
*/
|
||||||
|
const transferGroupOwner = (groupId, userId) => {
|
||||||
|
return request({
|
||||||
|
method: 'DELETE',
|
||||||
|
url: 'im/groups/' + groupId + '/owner/' + userId
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
getImToken,
|
getImToken,
|
||||||
deleteFriend,
|
deleteFriend,
|
||||||
@@ -235,5 +289,10 @@ export {
|
|||||||
joinGroupPre,
|
joinGroupPre,
|
||||||
joinGroup,
|
joinGroup,
|
||||||
quitGroup,
|
quitGroup,
|
||||||
dismissGroup
|
dismissGroup,
|
||||||
|
inviteGroupUser,
|
||||||
|
removeGroupUser,
|
||||||
|
setGroupAdmin,
|
||||||
|
removeGroupAdmin,
|
||||||
|
transferGroupOwner
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
<view class="container">
|
<view class="container">
|
||||||
<view class="members u-border-bottom">
|
<view class="members u-border-bottom">
|
||||||
<view class="users">
|
<view class="users">
|
||||||
<view class="user" v-for="(item, index) in users" :key="index" @click="toUser(item)"
|
<view :class="['user', {'active': item.targetId == currentUser.targetId}]"
|
||||||
|
v-for="(item, index) in users" :key="index" @click="toUser(item)"
|
||||||
@longpress="showUserActionSheet(item)">
|
@longpress="showUserActionSheet(item)">
|
||||||
<u-avatar size="44" shape="square" :src="item.portraitUrl">
|
<u-avatar size="44" shape="square" :src="item.portraitUrl">
|
||||||
</u-avatar>
|
</u-avatar>
|
||||||
@@ -71,7 +72,12 @@
|
|||||||
getGroupInfo,
|
getGroupInfo,
|
||||||
updateGroup,
|
updateGroup,
|
||||||
quitGroup,
|
quitGroup,
|
||||||
dismissGroup
|
removeGroupUser,
|
||||||
|
setGroupAdmin,
|
||||||
|
removeGroupAdmin,
|
||||||
|
dismissGroup,
|
||||||
|
transferGroupOwner,
|
||||||
|
getGroupUsers
|
||||||
} from '@/apis/interfaces/im.js'
|
} from '@/apis/interfaces/im.js'
|
||||||
import {
|
import {
|
||||||
uploads
|
uploads
|
||||||
@@ -133,18 +139,23 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.initData()
|
this.initData()
|
||||||
|
this.initUsers()
|
||||||
uni.$on('groupAnnouncementCreated', this.initData)
|
uni.$on('groupAnnouncementCreated', this.initData)
|
||||||
},
|
},
|
||||||
onUnload() {
|
onUnload() {
|
||||||
uni.$off('groupAnnouncementCreated')
|
uni.$off('groupAnnouncementCreated')
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
initUsers() {
|
||||||
|
getGroupUsers(this.targetId, 14).then(res => {
|
||||||
|
this.users = res
|
||||||
|
})
|
||||||
|
},
|
||||||
initData() {
|
initData() {
|
||||||
getGroupInfo(this.targetId).then(res => {
|
getGroupInfo(this.targetId).then(res => {
|
||||||
this.group = res.group
|
this.group = res.group
|
||||||
this.groupName = res.group.name
|
this.groupName = res.group.name
|
||||||
this.announcement = res.announcement
|
this.announcement = res.announcement
|
||||||
this.users = res.users
|
|
||||||
this.members = res.members
|
this.members = res.members
|
||||||
this.loaded = true
|
this.loaded = true
|
||||||
this.joinTypeMap = res.join_type_map.map(item => {
|
this.joinTypeMap = res.join_type_map.map(item => {
|
||||||
@@ -191,7 +202,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
inviteUser() {
|
inviteUser() {
|
||||||
|
uni.showToast({
|
||||||
|
icon: 'none',
|
||||||
|
title: '开发中'
|
||||||
|
})
|
||||||
},
|
},
|
||||||
loadMore() {
|
loadMore() {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
@@ -375,11 +389,54 @@
|
|||||||
this.showUserAction = false
|
this.showUserAction = false
|
||||||
},
|
},
|
||||||
handleUserAction(e) {
|
handleUserAction(e) {
|
||||||
|
switch (e.key) {
|
||||||
|
case 0:
|
||||||
|
removeGroupUser(this.targetId, this.currentUser.targetId).then(res => {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
title: e.name
|
title: '成员移除成功'
|
||||||
})
|
})
|
||||||
console.log(e);
|
}).catch(err => {
|
||||||
|
uni.showToast({
|
||||||
|
icon: 'none',
|
||||||
|
title: err.message
|
||||||
|
})
|
||||||
|
}).finally(() => {
|
||||||
|
this.initUsers()
|
||||||
|
})
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
setGroupAdmin(this.targetId, this.currentUser.targetId).then(res => {
|
||||||
|
uni.showToast({
|
||||||
|
icon: 'none',
|
||||||
|
title: '设置管理成功'
|
||||||
|
})
|
||||||
|
}).catch(err => {
|
||||||
|
uni.showToast({
|
||||||
|
icon: 'none',
|
||||||
|
title: err.message
|
||||||
|
})
|
||||||
|
}).finally(() => {
|
||||||
|
this.initUsers()
|
||||||
|
})
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
transferGroupOwner(this.targetId, this.currentUser.targetId).then(res => {
|
||||||
|
uni.showToast({
|
||||||
|
icon: 'none',
|
||||||
|
title: '群主转让成功'
|
||||||
|
})
|
||||||
|
}).catch(err => {
|
||||||
|
uni.showToast({
|
||||||
|
icon: 'none',
|
||||||
|
title: err.message
|
||||||
|
})
|
||||||
|
}).finally(() => {
|
||||||
|
this.initUsers()
|
||||||
|
this.initData()
|
||||||
|
})
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -415,6 +472,10 @@
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
background-color: $window-color;
|
||||||
|
}
|
||||||
|
|
||||||
.name {
|
.name {
|
||||||
color: $text-gray-m;
|
color: $text-gray-m;
|
||||||
width: 126rpx;
|
width: 126rpx;
|
||||||
|
|||||||
@@ -67,8 +67,10 @@
|
|||||||
updImgs(type) {
|
updImgs(type) {
|
||||||
uni.chooseImage({
|
uni.chooseImage({
|
||||||
crop: {
|
crop: {
|
||||||
width: 80,
|
quality: 100,
|
||||||
height: 80
|
width: 128,
|
||||||
|
height: 128,
|
||||||
|
resize: true
|
||||||
},
|
},
|
||||||
success: res => {
|
success: res => {
|
||||||
let path = res.tempFiles.map((val, index) => {
|
let path = res.tempFiles.map((val, index) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user