群成员管理,同意加入群功能
This commit is contained in:
parent
b795f89b86
commit
4f735d82f7
|
|
@ -29,6 +29,22 @@ export const getGroupFriendListService = (data) => {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getGroupUsersListService = (data) => {
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
for (let d in data) {
|
||||||
|
params.append(d, data[d]);
|
||||||
|
}
|
||||||
|
// request.headers["Content-Type"] = "application/json";
|
||||||
|
request.defaults.headers["token"] = data.token.value;
|
||||||
|
return request.post('/im/get_group_users_info', params, {
|
||||||
|
headers: {
|
||||||
|
'token': data.token, // 将 token <20><>换为您的令牌值
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export const getMessageService = (data) => {
|
export const getMessageService = (data) => {
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
for (let d in data) {
|
for (let d in data) {
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,10 @@ import { addDeviceService } from "@/api/device.js";
|
||||||
import {sendMessageService } from "@/api/chat.js";
|
import {sendMessageService } from "@/api/chat.js";
|
||||||
import {getGroupFriendListService } from "@/api/chat.js";
|
import {getGroupFriendListService } from "@/api/chat.js";
|
||||||
import {acceptInviteService } from "@/api/user.js";
|
import {acceptInviteService } from "@/api/user.js";
|
||||||
|
import { rejectInviteService } from "@/api/user.js";
|
||||||
import { deleteDeviceService } from "@/api/device.js";
|
import { deleteDeviceService } from "@/api/device.js";
|
||||||
import { getFriendListService } from "@/api/chat.js";
|
import { getFriendListService } from "@/api/chat.js";
|
||||||
|
import { getGroupUsersListService } from "@/api/chat.js";
|
||||||
import { addGroupService} from "@/api/chat.js";
|
import { addGroupService} from "@/api/chat.js";
|
||||||
import {DelFGService} from "@/api/user.js";
|
import {DelFGService} from "@/api/user.js";
|
||||||
import { updateDeviceService } from "@/api/device.js";
|
import { updateDeviceService } from "@/api/device.js";
|
||||||
|
|
@ -22,6 +24,7 @@ export default {
|
||||||
FriendsTableIsDisplay:false,
|
FriendsTableIsDisplay:false,
|
||||||
tableData: [],
|
tableData: [],
|
||||||
group_id:0,
|
group_id:0,
|
||||||
|
is_del_group_user:false,
|
||||||
GroupRequestIsDisplay : false,
|
GroupRequestIsDisplay : false,
|
||||||
GroupRequestList:[],
|
GroupRequestList:[],
|
||||||
tokenData: {
|
tokenData: {
|
||||||
|
|
@ -112,6 +115,7 @@ export default {
|
||||||
this.FriendsGList = result.data.friends;
|
this.FriendsGList = result.data.friends;
|
||||||
this.GroupList=result.data.groups;
|
this.GroupList=result.data.groups;
|
||||||
this.FriendsTableIsDisplay = true;
|
this.FriendsTableIsDisplay = true;
|
||||||
|
this.is_del_group_user=false;
|
||||||
}else{
|
}else{
|
||||||
ElMessage.error("获取好友列表失败");
|
ElMessage.error("获取好友列表失败");
|
||||||
}
|
}
|
||||||
|
|
@ -119,6 +123,27 @@ export default {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async displayGroupUsersInfo(index){
|
||||||
|
this.group_id = this.tableData[index].ID;
|
||||||
|
let result ={}
|
||||||
|
try{
|
||||||
|
let req={
|
||||||
|
token: this.tokenData.token,
|
||||||
|
group_id: this.group_id,
|
||||||
|
}
|
||||||
|
result = await getGroupUsersListService(req);
|
||||||
|
if(result.code ===0){
|
||||||
|
this.FriendsGList = result.data;
|
||||||
|
this.FriendsTableIsDisplay = true;
|
||||||
|
this.is_del_group_user=true;
|
||||||
|
|
||||||
|
}else{
|
||||||
|
ElMessage.error("获取群用户列表失败");
|
||||||
|
}
|
||||||
|
}catch(e){
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
//邀请好友加入群组
|
//邀请好友加入群组
|
||||||
async inviteUser(index) {
|
async inviteUser(index) {
|
||||||
|
|
@ -236,6 +261,33 @@ export default {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async delGroupUser(index){
|
||||||
|
var id = this.FriendsGList[index].id;
|
||||||
|
let req={
|
||||||
|
token: localStorage.getItem("token"),
|
||||||
|
from_user_id: localStorage.getItem("userId"),
|
||||||
|
to_user_id: id,
|
||||||
|
group_id: this.group_id,
|
||||||
|
msg: "踢出群聊",
|
||||||
|
type: 4,
|
||||||
|
}
|
||||||
|
if (id === parseInt(req.userId)){
|
||||||
|
ElMessage.error("不能删除自己,若自己要退出,请解散群聊!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
var d_re = await DelFGService(req);
|
||||||
|
if (d_re.code == 0) {
|
||||||
|
//alert("邀请成功");
|
||||||
|
ElMessage.success("删除成功");
|
||||||
|
} else {
|
||||||
|
//alert("操作失败");
|
||||||
|
ElMessage.error("操作失败:"+d_re.error);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
},
|
||||||
async getIpClient() {
|
async getIpClient() {
|
||||||
try {
|
try {
|
||||||
const response = await axios.get("https://ipinfo.io/json");
|
const response = await axios.get("https://ipinfo.io/json");
|
||||||
|
|
@ -249,7 +301,11 @@ export default {
|
||||||
async displayGroupReq(){
|
async displayGroupReq(){
|
||||||
let result ={}
|
let result ={}
|
||||||
try{
|
try{
|
||||||
result =await getGroupFriendListService(this.tokenData)
|
let req={
|
||||||
|
token:this.tokenData.token,
|
||||||
|
type:1
|
||||||
|
}
|
||||||
|
result =await getGroupFriendListService(req)
|
||||||
if(result.code ===0){
|
if(result.code ===0){
|
||||||
this.GroupRequestList = result.data;
|
this.GroupRequestList = result.data;
|
||||||
this.GroupRequestIsDisplay = true;
|
this.GroupRequestIsDisplay = true;
|
||||||
|
|
@ -295,9 +351,35 @@ export default {
|
||||||
id: im_id,
|
id: im_id,
|
||||||
from_user_id: localStorage.getItem("userId"),
|
from_user_id: localStorage.getItem("userId"),
|
||||||
to_user_id: id,
|
to_user_id: id,
|
||||||
|
group_id: this.GroupRequestList[index].group_id,
|
||||||
msg: "接受加入群组请求",
|
msg: "接受加入群组请求",
|
||||||
index: 1,
|
index: 1,
|
||||||
type: 4,
|
type: 2,
|
||||||
|
});
|
||||||
|
if(result.code ===0){
|
||||||
|
ElMessage.success("接受请求成功");
|
||||||
|
this.displayGroupReq();
|
||||||
|
}else{
|
||||||
|
ElMessage.error("接受请求失败");
|
||||||
|
}
|
||||||
|
}catch(e){
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async RefuseFriendsOrGroup(index){
|
||||||
|
var id = this.GroupRequestList[index].id;
|
||||||
|
var im_id = this.GroupRequestList[index].im_id;
|
||||||
|
let result ={}
|
||||||
|
try{
|
||||||
|
result =await rejectInviteService({
|
||||||
|
token: localStorage.getItem("token"),
|
||||||
|
id: im_id,
|
||||||
|
from_user_id: localStorage.getItem("userId"),
|
||||||
|
to_user_id: id,
|
||||||
|
group_id: this.GroupRequestList[index].group_id,
|
||||||
|
msg: "接受加入群组请求",
|
||||||
|
index: 1,
|
||||||
|
type: 2,
|
||||||
});
|
});
|
||||||
if(result.code ===0){
|
if(result.code ===0){
|
||||||
ElMessage.success("接受请求成功");
|
ElMessage.success("接受请求成功");
|
||||||
|
|
@ -480,7 +562,7 @@ export default {
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
<el-dialog
|
<el-dialog
|
||||||
title="用户好友"
|
title="成员列表"
|
||||||
width="40%"
|
width="40%"
|
||||||
v-model="FriendsTableIsDisplay"
|
v-model="FriendsTableIsDisplay"
|
||||||
center>
|
center>
|
||||||
|
|
@ -503,8 +585,16 @@ export default {
|
||||||
type="primary"
|
type="primary"
|
||||||
size="mini"
|
size="mini"
|
||||||
@click.prevent="inviteFriendAddGroup(scope.$index)"
|
@click.prevent="inviteFriendAddGroup(scope.$index)"
|
||||||
|
v-if="is_del_group_user === false"
|
||||||
>邀请</el-button
|
>邀请</el-button
|
||||||
>
|
>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
size="mini"
|
||||||
|
@click.prevent="delGroupUser(scope.$index)"
|
||||||
|
v-if="is_del_group_user === true"
|
||||||
|
>删除</el-button
|
||||||
|
>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
@ -529,9 +619,9 @@ export default {
|
||||||
width="180"
|
width="180"
|
||||||
></el-table-column>
|
></el-table-column>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
prop="age"
|
prop="group_id"
|
||||||
label="用户Age"
|
label="群id"
|
||||||
width="120"
|
width="180"
|
||||||
></el-table-column>
|
></el-table-column>
|
||||||
<el-table-column>
|
<el-table-column>
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
|
|
@ -591,6 +681,12 @@ export default {
|
||||||
@click.prevent="displayFriends(scope.$index)"
|
@click.prevent="displayFriends(scope.$index)"
|
||||||
>邀请</el-button
|
>邀请</el-button
|
||||||
>
|
>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
size="mini"
|
||||||
|
@click.prevent="displayGroupUsersInfo(scope.$index)"
|
||||||
|
>成员管理</el-button
|
||||||
|
>
|
||||||
<el-button
|
<el-button
|
||||||
type="primary"
|
type="primary"
|
||||||
size="mini"
|
size="mini"
|
||||||
|
|
|
||||||
|
|
@ -179,7 +179,7 @@ export default {
|
||||||
to_user_id: id,
|
to_user_id: id,
|
||||||
msg: "接受好友请求",
|
msg: "接受好友请求",
|
||||||
index: 1,
|
index: 1,
|
||||||
type: 4,
|
type: 1,
|
||||||
});
|
});
|
||||||
if(result.code ===0){
|
if(result.code ===0){
|
||||||
ElMessage.success("接受好友请求成功");
|
ElMessage.success("接受好友请求成功");
|
||||||
|
|
@ -224,7 +224,7 @@ export default {
|
||||||
to_user_id: id,
|
to_user_id: id,
|
||||||
msg: "拒绝好友请求",
|
msg: "拒绝好友请求",
|
||||||
index: 1,
|
index: 1,
|
||||||
type: 4,
|
type: 1,
|
||||||
});
|
});
|
||||||
if(result.code ===0){
|
if(result.code ===0){
|
||||||
ElMessage.success("拒绝请求成功");
|
ElMessage.success("拒绝请求成功");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue