@@ -112,6 +123,14 @@
+
+
+
+
+ {{cur_user_name}}
+
+
+
@@ -142,6 +161,8 @@ export default {
filteredUsers: [], // 过滤后的用户列表
to_user_id:0,
cur_user_id:0,
+ cur_group_id:0,
+ msg_type:1,
searchName: '', // 搜索框内容
history_cnt: 1,
@@ -181,6 +202,47 @@ export default {
this.history_cnt++
this.handleGetMessage(this.cur_user_id);
},
+ async handleGetGroupMessage(id){
+ this.cur_group_id=id;
+ this.cur_user_id=0;
+ this.to_user_id=0;
+ this.msg_type=2;
+ let result={}
+ try {
+ let req={
+ token: localStorage.getItem("token"),
+ ip: localStorage.getItem("ip"),
+ userId: localStorage.getItem("userId"),
+ username: localStorage.getItem("username"),
+ group_id:id,
+ index:this.history_cnt,
+ type:2,
+ }
+ result = await getMessageService(req);
+ } catch (e) {
+ console.log(e);
+ }
+ let data = result.data;
+ if(data === undefined || data === null){
+ ElMessage({
+ message: "无消息!",
+ type: "error",
+ })
+ this.MsgList=[]
+ return;
+ }
+ data.sort((a, b) => {
+ const dateA = new Date(a.CreatedAt);
+ const dateB = new Date(b.CreatedAt);
+
+ // 返回时间差,用于排序
+ return dateA - dateB;
+ });
+ this.MsgList=data;
+ if(this.history_cnt <=2){
+ this.scrollToBottom();
+ }
+ },
async handleGetMessage(id){
let result = {};
if(this.to_user_id!=id){
@@ -188,6 +250,8 @@ export default {
}
this.to_user_id=id;
this.cur_user_id=id;
+ this.cur_group_id=0;
+ this.msg_type=1;
console.log("uid:",this.uid,"\tcur_user_id:",this.cur_user_id)
for(let i=0; i
+import axios from "axios";
+import { inject } from "vue";
+import { getGroupListService } from "@/api/group.js";
+import { restartDeviceService } from "@/api/device.js";
+import { addDeviceService } from "@/api/device.js";
+import { deleteDeviceService } from "@/api/device.js";
+import { getFriendListService } from "@/api/chat.js";
+import { addGroupService} from "@/api/chat.js";
+import {sendMessageService} from "@/api/chat.js";
+import { updateDeviceService } from "@/api/device.js";
+import router from "@/router/index.js";
+import { ElMessage } from 'element-plus';
+
+export default {
+ data() {
+ return {
+ ip: "",
+ FriendsTableIsDisplay:false,
+ tableData: [],
+ group_id:0,
+ tokenData: {
+ token: localStorage.getItem("token"),
+ ip: localStorage.getItem("ip"),
+ userId: localStorage.getItem("userId"),
+ username: localStorage.getItem("username"),
+ },
+ addDialogVisible: false,
+ updateDialogVisible: false,
+ searchForm: {
+ hour: 0,
+ entrydate: [],
+ },
+ addForm: {
+ group_name: "",
+ group_info: "",
+ group_type: "",
+ group_icon:"",
+ auth_id: -1,
+ token: localStorage.getItem("token"),
+ },
+ updateForm: {
+ id:0,
+ device_name: "",
+ device_ip: "",
+ device_status: "",
+ device_info: "",
+ device_location: "",
+ device_type: "",
+ auth_id: -1,
+ token: localStorage.getItem("token"),
+ },
+ };
+ },
+
+ // methods 是一些用来更改状态与触发更新的函数
+ // 它们可以在模板中作为事件处理器绑定
+ methods: {
+ async getGroupList() {
+ let result = {};
+ try {
+ result = await getGroupListService(this.tokenData);
+ } catch (e) {
+ console.log(e);
+ }
+ let data = result.data;
+
+ // for(let d in data){
+ // let res = JSON.parse(d);
+ // console.log("res=",res);
+ // this.tableData.push(res);
+ // }
+ // console.log(this.tableData);
+
+ this.tableData = data;
+ },
+ onSubmit() {
+ getGroupList({ token: token });
+ },
+ handleSizeChange() {
+ alert("每页记录数变化" + val);
+ },
+ handleCurrentChange() {
+ alert("页码发生变化" + val);
+ },
+ //获取好友列表
+ async displayFriends(index){
+ this.group_id = this.tableData[index].ID;
+ let result ={}
+ try{
+ result = await getFriendListService(this.tokenData);
+ if(result.code ===0){
+ this.FriendsGList = result.data.friends;
+ this.GroupList=result.data.groups;
+ this.FriendsTableIsDisplay = true;
+ }else{
+ ElMessage.error("获取好友列表失败");
+ }
+ }catch(e){
+ console.log(e);
+ }
+ },
+
+ //设置设备重启
+ async inviteUser(index) {
+ var id = this.tableData[index].ID;
+ var restart_data = {
+ id: id,
+ option: "one",
+ ip: this.ip,
+ userId: this.tokenData.userId,
+ token: this.tokenData.token,
+ };
+ try {
+ var d_re = await restartDeviceService(restart_data);
+ if (d_re.code == 0) {
+ //alert("重启成功");
+ ElMessage.success('重启成功');
+ } else {
+ alert("操作失败");
+ ElMessage.fail('操作失败');
+ }
+ } catch (e) {
+ console.log(e);
+ }
+ },
+ playRealVp(index) {
+ var id = this.tableData[index].ID;
+ localStorage.setItem("realvp_device_id", id);
+ router.push("/deviceRealVP");
+ },
+ async deleteDevice(index) {
+ var id = this.tableData[index].ID;
+ var delete_data = {
+ id: id,
+ userId: this.tokenData.userId,
+ token: this.tokenData.token,
+ };
+ try {
+ var d_re = await deleteGroupService(delete_data);
+ if (d_re.code == 0) {
+ //alert("删除成功");
+ ElMessage.success('删除成功');
+ //刷新页面
+ this.getGroupList();
+ } else {
+ //alert("操作失败");
+ ElMessage.fail("操作失败");
+ }
+ } catch (e) {
+ console.log(e);
+ }
+ },
+ async updateButtonDevice(index) {
+ var id = this.tableData[index].ID;
+ this.group_id = id;
+ this.updateForm.device_name = this.tableData[index].DeviceName;
+ this.updateForm.device_ip = this.tableData[index].DeviceIP;
+ this.updateForm.device_status = this.tableData[index].DeviceStatus;
+ this.updateForm.device_info = this.tableData[index].DeviceInfo;
+ this.updateForm.device_location = this.tableData[index].DeviceLocation;
+ this.updateForm.device_type = this.tableData[index].DeviceType;
+ this.updateForm.auth_id = this.tableData[index].AuthID;
+ this.updateForm.id = id;
+ this.updateDialogVisible= true;
+ },
+ async addGroup() {
+ this.addDialogVisible = false;
+ let result = {};
+ try {
+ result = await addGroupService(this.addForm);
+ if (result.code == 0) {
+ ElMessage.success("添加成功");
+ } else {
+ //alert("添加失败");
+ ElMessage.error("添加失败")
+ }
+ } catch (e) {
+ console.log(e);
+ }
+ },
+ async updateGroup() {
+ this.updateDialogVisible = false;
+ let result = {};
+ try {
+ result = await updateGroupService(this.updateForm);
+ if (result.code == 0) {
+ //alert("修改成功");
+ ElMessage.success("修改成功");
+ this.getGroupList()
+ } else {
+ alert("修改失败");
+ }
+ } catch (e) {
+ console.log(e);
+ }
+ },
+ async restartAllDevice() {
+ var restart_data = {
+ id: id,
+ ip: this.ip,
+ option: "all",
+ userId: this.tokenData.userId,
+ token: this.tokenData.token,
+ };
+ try {
+ var d_re = await restartDeviceService(restart_data);
+ if (d_re.code == 0) {
+ //alert("重启成功");
+ ElMessage.success("重启成功");
+ } else {
+ alert("操作失败");
+ }
+ } catch (e) {
+ console.log(e);
+ }
+ },
+ async inviteFriendAddGroup(index){
+ var id = this.FriendsGList[index].id;
+ let req={
+ token: localStorage.getItem("token"),
+ ip: localStorage.getItem("ip"),
+ userId: localStorage.getItem("userId"),
+ username: localStorage.getItem("username"),
+ from_user_id:localStorage.getItem("userId"),
+ to_user_id:id,
+ group_id:this.group_id,
+ msg:this.currentMsg,
+ type:6,
+ }
+ try {
+ var d_re = await sendMessageService(req);
+ if (d_re.code == 0) {
+ //alert("邀请成功");
+ ElMessage.success("邀请成功");
+ } else {
+ //alert("操作失败");
+ ElMessage.error("操作失败:"+d_re.error);
+ }
+ } catch (e) {
+ console.log(e);
+ }
+ },
+ async getIpClient() {
+ try {
+ const response = await axios.get("https://ipinfo.io/json");
+ this.ip = response.data.ip;
+ localStorage.setItem("ip", this.ip);
+ //console.log(response);
+ } catch (error) {
+ console.error(error);
+ }
+ },
+ handleMenuSelect(val) {
+ router.push(val);
+ },
+ toVideoList() {
+ router.push("/videoList");
+ },
+ // 修改条纹颜色
+ tableRowClassName({ row, rowIndex }) {
+ if (row.human === 1) {
+ return {
+ background: "#488aff",
+ };
+ } else {
+ return "";
+ }
+ },
+ },
+
+ // 生命周期钩子会在组件生命周期的各个不同阶段被调用
+ // 例如这个函数就会在组件挂载完成后被调用
+ async mounted() {
+ let now = new Date();
+ if (localStorage.getItem("token") === null) {
+ router.push("/login");
+ }
+ // console.log("mounted");
+ await this.getIpClient();
+ this.getGroupList();
+ },
+};
+
+
+
+
+ 视频列表
+ 设备管理
+ 用户
+ 集成部署
+
+ 群组
+
+
+
+
+
+ 建群
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 邀请
+
+
+
+
+
+
+
+ :row-style="this.tableRowClassName"
+
+
+
+
+
+
+
+
+ 邀请
+ 修改
+ 删除
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/views/UserList.vue b/src/views/UserList.vue
index c7a1937..b91beb6 100644
--- a/src/views/UserList.vue
+++ b/src/views/UserList.vue
@@ -3,6 +3,8 @@ import axios from "axios";
import { SearchUserService } from "@/api/user.js";
import { getFriendReqService } from "@/api/user.js";
import {acceptInviteService } from "@/api/user.js";
+import {GetUserInfoService} from "@/api/user.js";
+import {DelFGService} from "@/api/user.js";
import router from "@/router/index.js";
import Cookies from "js-cookie";
import { getFriendListService } from "@/api/chat.js";
@@ -14,8 +16,10 @@ export default {
ip: "",
tableData: [],
search_id: 2002,
+ UserUpdateForm:{},
keyword: "",
FriendsRequestIsDisplay:false,
+ updateDialogVisible: false,
FriendsGRequestList:[],
FriendsTableIsDisplay:false,
FriendsGList:[],
@@ -106,12 +110,12 @@ export default {
var name = this.FriendsGList[index].name;
let result ={}
try{
- result =await sendMessageService({
+ result =await DelFGService({
token: localStorage.getItem("token"),
from_user_id: localStorage.getItem("userId"),
to_user_id: id,
msg: "删除好友",
- type: 5,
+ type: 1,
});
if(result.code ===0){
ElMessage.success("删除好友成功");
@@ -177,22 +181,24 @@ export default {
alert("页码发生变化" + val);
},
- //设置设备重启
- async startChat(index) {
- var id = this.tableData[index].ID;
- var name = this.tableData[index].Name;
- // var user_data = {
- // to_user_id: id,
- // to_user_name: this.tableData[index].Name,
- // };
- //转到聊天页面
- if(id == localStorage.getItem("userId")){
- alert("不能和自己聊天");
- return;
+ async displayMyInfo() {
+ let result = {};
+ try{
+ //获取用户信息
+ result = await GetUserInfoService(this.tokenData)
+ if(result.code ===0){
+ this.UserUpdateForm.id = result.data.ID;
+ this.UserUpdateForm.name = result.data.Name;
+ this.UserUpdateForm.email = result.data.Email;
+ this.UserUpdateForm.age = result.data.Age;
+ this.UserUpdateForm.role = result.data.Role;
+ this.UserUpdateForm.gender = result.data.Gender;
+ this.UserUpdateForm.create_time = result.data.CreatedAt;
+ }
+ }catch(e){
+ console.log(e);
}
- localStorage.setItem("to_user_id", id);
- localStorage.setItem("to_user_name", name);
- router.push("/im");
+ this.updateDialogVisible= true;
},
handleMenuSelect(val) {
@@ -252,6 +258,7 @@ export default {
@click.prevent="handleMenuSelect('/cid')"
>集成部署
+
用户搜索列表好友请求
-
+
+ 我的信息
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
聊天
+ 群组