通讯录-接口联调-发消息功能暂时搁置

main
ysn 3 days ago
parent 01f1e1f411
commit 21496dbc4f
  1. 16
      src/api/addressBook/index.js
  2. 33
      src/api/contacts/index.js
  3. 1
      src/store/modules/user.js
  4. 57
      src/views/contacts/index.vue

@ -1,16 +0,0 @@
import request from '@/utils/request'
export function getAddrBook(data) {
return request({
url: '/api/v1/groups/list',
method: 'post',
data
})
}
export function listUsers(data) {
return request({
url: '/api/v1/groups/list-user',
method: 'post',
data
})
}

@ -0,0 +1,33 @@
import request from '@/utils/request'
// 获取常用联系人
export function getMessagesLatestContacts(data) {
return request({
url: '/messages/latest-contacts',
method: 'post',
data
})
}
// 获取群组列表(包含用户)
export function getGroupsList(data) {
return request({
url: '/groups/list',
method: 'post',
data
})
}
// 获取群组列表(包含用户)
export function getGroupsListUser(data) {
return request({
url: '/groups/list-user',
method: 'post',
data
})
}
// 搜索用户
export function searchUsers(data) {
return request({
url: '/users/search',
method: 'post',
data
})
}

@ -55,7 +55,6 @@ const user = {
Login({ commit }, userInfo) {
return new Promise((resolve, reject) => {
login(userInfo).then(res => {
console.log(res)
setToken(res.data.token)
commit('SET_TOKEN', res.data.token)
store.dispatch('lock/unlockScreen')

@ -11,13 +11,14 @@
<span>常用联系人</span>
</div>
<div class="latest-contacts">
<i class="el-icon-office-building" />
<span>组织架构</span>
</div>
<el-tree
ref="orgTree"
:data="treeData"
:props="treeProps"
:default-expanded-keys="expandedKeys"
default-expand-all
:highlight-current="true"
node-key="id"
@node-click="handleNodeClick"
@ -127,7 +128,7 @@
</div>
<div class="action-section">
<el-button
type="success"
type="primary"
icon="el-icon-chat-dot-round"
@click="sendMessage"
>
@ -144,10 +145,14 @@
<script>
import EventBus from "@/utils/eventBus";
import { getAddrBook, listUsers } from "@/api/addressBook/index.js";
import { getLatestContacts, searchUsers } from "@/api/message/index.js";
import {
getMessagesLatestContacts,
getGroupsList,
getGroupsListUser,
searchUsers,
} from "@/api/contacts/index.js";
export default {
name: "AddressBook",
name: "Contacts",
filters: {
avatarFilter(avatar) {
if (!avatar) return "";
@ -187,34 +192,15 @@ export default {
},
},
mounted() {
this.initUserInfo();
//
this.showLatestContacts();
this.fetchOrgTree();
},
methods: {
// Qt SetCurDetailInfo
initUserInfo() {
const info = this.currentUserInfo;
if (info) {
this.currentUser = {
id: info.id,
name: info.name,
role: info.role,
phone: info.phone,
status: info.status,
email: info.email,
group: info.group,
full_group: info.full_group || info.group,
avatar: info.avatar,
online: info.status === 0,
};
this.userGroupId = info.group_id || info.grp_id;
}
},
// Qt Cmd_addr_book_addr POST body
async fetchOrgTree() {
try {
const res = await getAddrBook();
const res = await getGroupsList();
const list = res.data?.list || [];
this.treeData = this.buildTree(list);
//
@ -294,9 +280,7 @@ export default {
async fetchMembers(groupId) {
this.loading = true;
try {
const res = await listUsers({
group_id: groupId,
});
const res = await getGroupsListUser({ group_id: groupId });
const list = res.data?.list || [];
// Qt 线线 memberList computed
this.memberList = list.map((item) => ({
@ -311,6 +295,11 @@ export default {
avatar: item.avatar,
online: item.online === 1 || item.online === true,
}));
//
if (this.memberList.length > 0) {
this.handleMemberClick(this.memberList[0]);
}
console.log(this.memberList, "组成员");
} catch (e) {
console.error("获取成员列表失败", e);
this.memberList = [];
@ -334,10 +323,10 @@ export default {
async fetchLatestContacts() {
this.loading = true;
try {
const res = await getLatestContacts({
const res = await getMessagesLatestContacts({
scene: 1,
page: 1,
// size: 65535,
size: 65535,
});
const list = res.data?.list || [];
this.memberList = list.map((item) => ({
@ -352,6 +341,10 @@ export default {
avatar: item.avatar,
online: item.online === 1 || item.online === true,
}));
//
if (this.memberList.length > 0) {
this.handleMemberClick(this.memberList[0]);
}
} catch (e) {
console.error("获取最近联系人失败", e);
this.memberList = [];

Loading…
Cancel
Save