修复群组查询,设备查询
This commit is contained in:
parent
a4d11ecf9e
commit
8a306bdee2
|
|
@ -15,6 +15,20 @@ export const getFriendListService = (data) => {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getGroupFriendListService = (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_req_user', params, {
|
||||||
|
headers: {
|
||||||
|
'token': data.token, // 将 token 替换为您的令牌值
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
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) {
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,17 @@ export const acceptInviteService =(Data)=> {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
export const rejectInviteService =(Data)=> {
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
for (let key in Data) {
|
||||||
|
params.append(key, Data[key])
|
||||||
|
}
|
||||||
|
return request.post('/im/reject_invite', params, {
|
||||||
|
headers: {
|
||||||
|
'token': Data.token, // 将 token 替换为您的令牌值
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export const SearchUserService = (Data) => {
|
export const SearchUserService = (Data) => {
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
|
|
|
||||||
|
|
@ -150,6 +150,7 @@ export default {
|
||||||
result = await addDeviceService(this.addForm);
|
result = await addDeviceService(this.addForm);
|
||||||
if (result.code == 0) {
|
if (result.code == 0) {
|
||||||
ElMessage.success("添加成功");
|
ElMessage.success("添加成功");
|
||||||
|
this.getDeviceList()
|
||||||
} else {
|
} else {
|
||||||
//alert("添加失败");
|
//alert("添加失败");
|
||||||
ElMessage.error("添加失败")
|
ElMessage.error("添加失败")
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,9 @@ import { inject } from "vue";
|
||||||
import { getGroupListService } from "@/api/group.js";
|
import { getGroupListService } from "@/api/group.js";
|
||||||
import { restartDeviceService } from "@/api/device.js";
|
import { restartDeviceService } from "@/api/device.js";
|
||||||
import { addDeviceService } from "@/api/device.js";
|
import { addDeviceService } from "@/api/device.js";
|
||||||
|
import {sendMessageService } from "@/api/chat.js";
|
||||||
|
import {getGroupFriendListService } from "@/api/chat.js";
|
||||||
|
import {acceptInviteService } 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 { addGroupService} from "@/api/chat.js";
|
import { addGroupService} from "@/api/chat.js";
|
||||||
|
|
@ -33,6 +36,7 @@ export default {
|
||||||
hour: 0,
|
hour: 0,
|
||||||
entrydate: [],
|
entrydate: [],
|
||||||
},
|
},
|
||||||
|
add_groups:[],
|
||||||
addForm: {
|
addForm: {
|
||||||
group_name: "",
|
group_name: "",
|
||||||
group_info: "",
|
group_info: "",
|
||||||
|
|
@ -58,12 +62,27 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
async getGroupList() {
|
async getGroupList() {
|
||||||
let result = {};
|
let result = {};
|
||||||
|
let add_res ={};
|
||||||
try {
|
try {
|
||||||
result = await getGroupListService(this.tokenData);
|
result = await getGroupListService(this.tokenData);
|
||||||
|
add_res = await getFriendListService(this.tokenData);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
let data = result.data;
|
let data = result.data;
|
||||||
|
let m ={};
|
||||||
|
for(let i=0;i<data.length;i++){
|
||||||
|
m[data[i].ID] = data[i];
|
||||||
|
}
|
||||||
|
let add_resu = add_res.data.groups;
|
||||||
|
let temp =[];
|
||||||
|
for(let i=0;i<add_resu.length;i++){
|
||||||
|
if(m[add_resu[i].ID] === undefined){
|
||||||
|
temp.push(add_resu[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.add_groups = temp;
|
||||||
|
|
||||||
|
|
||||||
// for(let d in data){
|
// for(let d in data){
|
||||||
// let res = JSON.parse(d);
|
// let res = JSON.parse(d);
|
||||||
|
|
@ -165,6 +184,7 @@ export default {
|
||||||
result = await addGroupService(this.addForm);
|
result = await addGroupService(this.addForm);
|
||||||
if (result.code == 0) {
|
if (result.code == 0) {
|
||||||
ElMessage.success("添加成功");
|
ElMessage.success("添加成功");
|
||||||
|
this.getGroupList();
|
||||||
} else {
|
} else {
|
||||||
//alert("添加失败");
|
//alert("添加失败");
|
||||||
ElMessage.error("添加失败")
|
ElMessage.error("添加失败")
|
||||||
|
|
@ -181,7 +201,7 @@ export default {
|
||||||
if (result.code == 0) {
|
if (result.code == 0) {
|
||||||
//alert("修改成功");
|
//alert("修改成功");
|
||||||
ElMessage.success("修改成功");
|
ElMessage.success("修改成功");
|
||||||
this.getGroupList()
|
this.getGroupList();
|
||||||
} else {
|
} else {
|
||||||
alert("修改失败");
|
alert("修改失败");
|
||||||
}
|
}
|
||||||
|
|
@ -229,7 +249,7 @@ export default {
|
||||||
async displayGroupReq(){
|
async displayGroupReq(){
|
||||||
let result ={}
|
let result ={}
|
||||||
try{
|
try{
|
||||||
result =await getGroupReqService(this.tokenData)
|
result =await getGroupFriendListService(this.tokenData)
|
||||||
if(result.code ===0){
|
if(result.code ===0){
|
||||||
this.GroupRequestList = result.data;
|
this.GroupRequestList = result.data;
|
||||||
this.GroupRequestIsDisplay = true;
|
this.GroupRequestIsDisplay = true;
|
||||||
|
|
@ -241,10 +261,33 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
//退出群聊
|
||||||
|
async DelFriendsOrGroup(index){
|
||||||
|
var id = this.add_groups[index].ID;
|
||||||
|
|
||||||
|
let result ={}
|
||||||
|
try{
|
||||||
|
result =await DelFGService({
|
||||||
|
token: localStorage.getItem("token"),
|
||||||
|
from_user_id: localStorage.getItem("userId"),
|
||||||
|
to_user_id: id,
|
||||||
|
group_id: id,
|
||||||
|
msg: "退出群聊",
|
||||||
|
type: 2,
|
||||||
|
});
|
||||||
|
if(result.code ===0){
|
||||||
|
ElMessage.success("退出群聊成功");
|
||||||
|
this.getGroupList();
|
||||||
|
}else{
|
||||||
|
ElMessage.error("退出群聊失败");
|
||||||
|
}
|
||||||
|
}catch(e){
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
},
|
||||||
async AcceptFriendsOrGroup(index){
|
async AcceptFriendsOrGroup(index){
|
||||||
var id = this.GroupRequestList[index].id;
|
var id = this.GroupRequestList[index].id;
|
||||||
var im_id = this.GroupRequestList[index].im_id;
|
var im_id = this.GroupRequestList[index].im_id;
|
||||||
var name = this.FriendsGRequestList[index].name;
|
|
||||||
let result ={}
|
let result ={}
|
||||||
try{
|
try{
|
||||||
result =await acceptInviteService({
|
result =await acceptInviteService({
|
||||||
|
|
@ -257,10 +300,10 @@ export default {
|
||||||
type: 4,
|
type: 4,
|
||||||
});
|
});
|
||||||
if(result.code ===0){
|
if(result.code ===0){
|
||||||
ElMessage.success("接受好友请求成功");
|
ElMessage.success("接受请求成功");
|
||||||
this.displayFriendReq()
|
this.displayGroupReq();
|
||||||
}else{
|
}else{
|
||||||
ElMessage.error("接受好友请求失败");
|
ElMessage.error("接受请求失败");
|
||||||
}
|
}
|
||||||
}catch(e){
|
}catch(e){
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
|
@ -329,6 +372,14 @@ export default {
|
||||||
<el-main>
|
<el-main>
|
||||||
<!-- 表单 -->
|
<!-- 表单 -->
|
||||||
<el-form :inline="true" :model="tokenData" class="demo-form-inline">
|
<el-form :inline="true" :model="tokenData" class="demo-form-inline">
|
||||||
|
<el-form-item>
|
||||||
|
<el-button
|
||||||
|
class="el-button--danger"
|
||||||
|
type="primary"
|
||||||
|
@click="getGroupList()"
|
||||||
|
>查询</el-button
|
||||||
|
>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" @click="addDialogVisible = true"
|
<el-button type="primary" @click="addDialogVisible = true"
|
||||||
>建群</el-button
|
>建群</el-button
|
||||||
|
|
@ -500,6 +551,9 @@ export default {
|
||||||
</el-table>
|
</el-table>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
|
<h>
|
||||||
|
我建的群组
|
||||||
|
</h>
|
||||||
<!-- 表格 :row-style="this.tableRowClassName"-->
|
<!-- 表格 :row-style="this.tableRowClassName"-->
|
||||||
<el-table :data="tableData" width="100%" border>
|
<el-table :data="tableData" width="100%" border>
|
||||||
:row-style="this.tableRowClassName"
|
:row-style="this.tableRowClassName"
|
||||||
|
|
@ -553,6 +607,53 @@ export default {
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
<br />
|
||||||
|
|
||||||
|
<h>
|
||||||
|
我加入的群组列表
|
||||||
|
</h>
|
||||||
|
|
||||||
|
<!-- 表格 :row-style="this.tableRowClassName"-->
|
||||||
|
<el-table :data="add_groups" width="100%" border>
|
||||||
|
:row-style="this.tableRowClassName"
|
||||||
|
<el-table-column prop="ID" label="id" width="80"></el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
prop="GroupName"
|
||||||
|
label="名称"
|
||||||
|
width="100"
|
||||||
|
></el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
prop="GroupInfo"
|
||||||
|
label="描述"
|
||||||
|
width="180"
|
||||||
|
></el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
prop="GroupType"
|
||||||
|
label="类型"
|
||||||
|
width="120"
|
||||||
|
></el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
prop="CreatedAt"
|
||||||
|
label="创建时间"
|
||||||
|
width="120"
|
||||||
|
></el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
prop="UpdatedAt"
|
||||||
|
label="更新时间"
|
||||||
|
width="120"
|
||||||
|
></el-table-column>
|
||||||
|
<el-table-column label="操作" width="350">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
size="mini"
|
||||||
|
@click.prevent="DelFriendsOrGroup(scope.$index)"
|
||||||
|
>退出群聊</el-button
|
||||||
|
>
|
||||||
|
<!-- <el-button type="danger" size="mini">删除</el-button> -->
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<!-- 分页条 -->
|
<!-- 分页条 -->
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import axios from "axios";
|
||||||
import { SearchUserService } from "@/api/user.js";
|
import { SearchUserService } from "@/api/user.js";
|
||||||
import { getFriendReqService } from "@/api/user.js";
|
import { getFriendReqService } from "@/api/user.js";
|
||||||
import {acceptInviteService } from "@/api/user.js";
|
import {acceptInviteService } from "@/api/user.js";
|
||||||
|
import { rejectInviteService } from "@/api/user.js";
|
||||||
import { addGroupRequestService } from "@/api/user.js";
|
import { addGroupRequestService } from "@/api/user.js";
|
||||||
import {GetUserInfoService} from "@/api/user.js";
|
import {GetUserInfoService} from "@/api/user.js";
|
||||||
import {DelFGService} from "@/api/user.js";
|
import {DelFGService} from "@/api/user.js";
|
||||||
|
|
@ -144,14 +145,15 @@ export default {
|
||||||
try{
|
try{
|
||||||
|
|
||||||
result = await addGroupRequestService(req);
|
result = await addGroupRequestService(req);
|
||||||
|
console.log(result.code);
|
||||||
if(result.code === 0){
|
if(result.code === 0){
|
||||||
ElMessage.success("请求发送成功");
|
ElMessage.success("请求发送成功");
|
||||||
}else{
|
}else{
|
||||||
ElMessage.error("操作失败:",result.error);
|
ElMessage.error("操作失败已有请求或者已经是群组成员");
|
||||||
}
|
}
|
||||||
|
|
||||||
}catch(e){
|
}catch(e){
|
||||||
console.log(e);
|
ElMessage.error("操作失败已有请求或者已经是群组成员");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -183,6 +185,31 @@ export default {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async RefuseFriendsOrGroup(index){
|
||||||
|
var id = this.FriendsGRequestList[index].id;
|
||||||
|
var im_id = this.FriendsGRequestList[index].im_id;
|
||||||
|
var name = this.FriendsGRequestList[index].name;
|
||||||
|
let result ={}
|
||||||
|
try{
|
||||||
|
result =await rejectInviteService({
|
||||||
|
token: localStorage.getItem("token"),
|
||||||
|
id: im_id,
|
||||||
|
from_user_id: localStorage.getItem("userId"),
|
||||||
|
to_user_id: id,
|
||||||
|
msg: "拒绝好友请求",
|
||||||
|
index: 1,
|
||||||
|
type: 4,
|
||||||
|
});
|
||||||
|
if(result.code ===0){
|
||||||
|
ElMessage.success("拒绝请求成功");
|
||||||
|
this.displayFriendReq()
|
||||||
|
}else{
|
||||||
|
ElMessage.error("拒绝请求失败");
|
||||||
|
}
|
||||||
|
}catch(e){
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
//获取好友请求列表
|
//获取好友请求列表
|
||||||
async displayFriendReq(){
|
async displayFriendReq(){
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue