diff --git a/src/api/addressBook/index.js b/src/api/addressBook/index.js
new file mode 100644
index 0000000..53bd0a0
--- /dev/null
+++ b/src/api/addressBook/index.js
@@ -0,0 +1,28 @@
+import request from '@/service/index.js'
+
+// 查询用户是否需要添加好友
+export const ServeCheckFriend = (data) => {
+ return request({
+ url: '/api/v1/contact/friend/check',
+ method: 'POST',
+ data,
+ })
+}
+
+// 主动添加好友(单向好友)
+export const ServeAddFriend = (data) => {
+ return request({
+ url: '/api/v1/contact/friend/add',
+ method: 'POST',
+ data,
+ })
+}
+
+// 查询我的好友列表
+export const ServeQueryFriendsList = (data) => {
+ return request({
+ url: '/api/v1/contact/friend/list',
+ method: 'POST',
+ data,
+ })
+}
diff --git a/src/pages/addressBook/index.vue b/src/pages/addressBook/index.vue
index b13cdfd..2d9e243 100644
--- a/src/pages/addressBook/index.vue
+++ b/src/pages/addressBook/index.vue
@@ -48,13 +48,170 @@
class="tabs-panes-each address-book-company"
v-if="state.addressBookActiveTab === 'company'"
>
- companycompany
+
+ {{ state.myCompany }}
+
+
+
+
+
+
+
+ {{ item.nickname }}
+
+
+ {{ item.job_num }}
+
+
+
+
+
+
+
+ {{ postionItem.position_name }}
+
+
+
+
+
+
+
+ {{ postionItem.position_name }}
+
+
+
+
+
+
+
+
+
- friendsfriends
+
+
+
+
+
+
+ {{ item.nickname }}
+
+
+ {{ item.job_num }}
+
+
+
+
+
+
+
+
+ {{ postionItem.position_name }}
+
+
+
+
+
+
+
+ {{ postionItem.position_name }}
+
+
+
+
+
+
+
+
+
+
+ {{ item.company_name }}
+
+
+
{
@@ -160,6 +327,7 @@ onMounted(() => {
},
]
handleSetWebviewStyle()
+ getMyContractList()
})
//输入搜索内容
@@ -172,6 +340,76 @@ const updateAddressBookTab = (e) => {
state.addressBookActiveTab = e
}
+//获取“组织架构”通讯录列表
+const getMyContractList = () => {
+ let params = {
+ type: 'addressBook', //查我的通讯录的时候写死addressBook
+ page: state.myContractListPage,
+ page_size: state.myContractListPageSize,
+ name: searchVal.value,
+ }
+ console.error(params)
+ ServeQueryFriendsList(params)
+ .then((res) => {
+ console.log(res)
+ if (res?.code === 200) {
+ state.myCompany = res.data?.company_name
+ if (state.myContractListPage === 1) {
+ state.myContractList = res.data?.user_list || []
+ } else {
+ state.myContractList = state.myContractList.concat(
+ res.data?.user_list || [],
+ )
+ }
+ if (state.myContractList.length < res.data?.count) {
+ state.hasMoreContracts = true
+ } else {
+ state.hasMoreContracts = false
+ }
+ }
+ })
+ .catch((err) => {})
+}
+
+//获取“我的好友”列表
+const getMyFriendsList = () => {
+ let params = {
+ type: 'myFriends', //查我得好友的时候写死myFriends
+ page: state.myFriendsListPage,
+ page_size: state.myFriendsListPageSize,
+ name: searchVal.value,
+ }
+ console.error(params)
+ ServeQueryFriendsList(params)
+ .then((res) => {
+ console.log(res)
+ if (res?.code === 200) {
+ if (state.myFriendsListPage === 1) {
+ state.myFriendsList = res.data?.user_list || []
+ } else {
+ state.myFriendsList = state.myFriendsList.concat(
+ res.data?.user_list || [],
+ )
+ }
+ if (state.myFriendsList.length < res.data?.count) {
+ state.hasMoreFriends = true
+ } else {
+ state.hasMoreFriends = false
+ }
+ }
+ })
+ .catch((err) => {})
+}
+
+//点击进入用户详情页面
+const toUserDetail = (userInfo) => {
+ uni.navigateTo({
+ url:
+ '/pages/dialog/dialogDetail/userDetail??erpUserId=' +
+ userInfo.erp_user_id,
+ })
+}
+
//获取“我的群组”列表
const getMyGroupsList = () => {
let params = {
@@ -179,7 +417,6 @@ const getMyGroupsList = () => {
page_size: state.myGroupsListPageSize,
group_name: searchVal.value,
}
- console.error(params)
ServeUserGroupChatList(params)
.then((res) => {
console.log(res)
@@ -201,7 +438,13 @@ const getMyGroupsList = () => {
//加载更多数据
const doLoadMore = (e) => {
- if (state.addressBookActiveTab === 'groups' && state.hasMoreGroups) {
+ if (state.addressBookActiveTab === 'company' && state.hasMoreContracts) {
+ state.myContractListPage += 1
+ getMyContractList()
+ } else if (state.addressBookActiveTab === 'friends' && state.hasMoreFriends) {
+ state.myFriendsListPage += 1
+ getMyFriendsList()
+ } else if (state.addressBookActiveTab === 'groups' && state.hasMoreGroups) {
state.myGroupsListPage += 1
getMyGroupsList()
}
@@ -229,7 +472,6 @@ const getSessionId = (talk_type, receiver_id) => {
//点击跳转进入我的指定群聊
const toGroupChat = async (groupInfo) => {
- console.error(groupInfo)
let talk_type = 2
let receiver_id = groupInfo.id
const sessionId = await getSessionId(talk_type, receiver_id)
@@ -275,7 +517,17 @@ const groupTypeMapping = {
watch(
() => state.addressBookActiveTab,
(newVal) => {
- if (newVal === 'groups') {
+ if (newVal === 'company') {
+ state.myContractListPage = 1
+ state.myContractList = []
+ getMyContractList()
+ } else if (newVal === 'friends') {
+ state.myFriendsListPage = 1
+ state.myFriendsList = []
+ getMyFriendsList()
+ } else if (newVal === 'groups') {
+ state.myGroupsListPage = 1
+ state.myGroupsList = []
getMyGroupsList()
}
},
@@ -284,9 +536,17 @@ watch(
watch(
() => searchVal.value,
(newVal) => {
- state.myGroupsListPage = 1
- state.myGroupsList = []
- if (state.addressBookActiveTab === 'groups') {
+ if (newVal === 'company') {
+ state.myContractListPage = 1
+ state.myContractList = []
+ getMyContractList()
+ } else if (state.addressBookActiveTab === 'friends') {
+ state.myFriendsListPage = 1
+ state.myFriendsList = []
+ getMyFriendsList()
+ } else if (state.addressBookActiveTab === 'groups') {
+ state.myGroupsListPage = 1
+ state.myGroupsList = []
getMyGroupsList()
}
},
@@ -343,9 +603,123 @@ watch(
align-items: flex-start;
justify-content: center;
}
- .address-book-company {
- }
+ .address-book-company,
.address-book-friends {
+ .address-book-company-name {
+ margin: 0 0 -16rpx;
+ span {
+ font-size: 26rpx;
+ font-weight: 400;
+ line-height: 1;
+ color: #999;
+ }
+ }
+ .members-list-each {
+ display: flex;
+ flex-direction: column;
+ align-items: flex-start;
+ justify-content: center;
+ background-color: #fff;
+ width: 100%;
+ padding: 24rpx;
+ border-radius: 8rpx;
+
+ .members-info {
+ display: flex;
+ flex-direction: row;
+ align-items: flex-start;
+ justify-content: flex-start;
+ gap: 16rpx;
+
+ .members-info-area {
+ display: flex;
+ flex-direction: row;
+ align-items: flex-start;
+ justify-content: flex-start;
+ gap: 16rpx;
+
+ .members-info-basic {
+ display: flex;
+ flex-direction: column;
+ align-items: flex-start;
+ justify-content: center;
+
+ .members-name {
+ font-size: 30rpx;
+ font-weight: 500;
+ width: 150rpx;
+ word-break: break-all;
+ }
+
+ .members-jobNum {
+ font-size: 26rpx;
+ font-weight: 400;
+ color: #999;
+ word-break: break-all;
+ margin: 10rpx 0 0;
+ }
+
+ .members-company {
+ font-size: 24rpx;
+ font-weight: 400;
+ line-height: 1;
+ color: #999;
+ }
+ }
+ .members-positions-area {
+ .members-positions {
+ display: flex;
+ flex-direction: row;
+ align-items: center;
+ justify-content: flex-start;
+ flex-wrap: wrap;
+ gap: 10rpx;
+ padding: 4rpx 0 0;
+ max-height: 84rpx;
+ overflow: hidden;
+ -webkit-box-orient: vertical;
+ -webkit-line-clamp: 2;
+ line-clamp: 2;
+
+ .members-positions-each {
+ background-color: #eee9f8;
+ line-height: 1;
+ font-size: 24rpx;
+ padding: 4rpx 16rpx;
+ color: #46299d;
+ }
+ }
+ .members-positions-popover-box {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ gap: 10rpx 0;
+
+ .members-positions-popover {
+ background-color: #eee9f8;
+ line-height: 1;
+ font-size: 24rpx;
+ padding: 8rpx 16rpx;
+ color: #46299d;
+ width: 100%;
+ }
+ }
+ }
+ }
+ }
+ .company-infos {
+ margin: 0 0 0 88rpx;
+ .company-each {
+ span {
+ font-size: 24rpx;
+ font-weight: 400;
+ line-height: 1;
+ color: #999;
+ }
+ }
+ }
+ }
}
.address-book-groups {
.groups-list-each {
diff --git a/src/pages/dialog/dialogDetail/userDetail.vue b/src/pages/dialog/dialogDetail/userDetail.vue
index 5635fb4..97b59d5 100644
--- a/src/pages/dialog/dialogDetail/userDetail.vue
+++ b/src/pages/dialog/dialogDetail/userDetail.vue
@@ -116,6 +116,7 @@ const talkStore = useTalkStore()
const userStore = useUserStore()
import { getUserInfoByClickAvatar } from '@/api/user/index'
+import { ServeCheckFriend, ServeAddFriend } from '@/api/addressBook/index'
import { useI18n } from 'vue-i18n'
const { t } = useI18n()
@@ -150,6 +151,7 @@ const getUserInfo = () => {
console.log(data)
if (code == 200) {
state.userInfo = data
+ checkNeedAddFriend()
let department = ''
let post = ''
if (data?.erp_dept_position?.length > 0) {
@@ -245,13 +247,41 @@ const doPhoneCall = () => {
//检查是否可以发送消息,如果不可以要先添加好友
const checkSendPermission = () => {
- if(state.canSendMsg){
+ if (state.canSendMsg) {
toTalkUser()
} else {
- message.success(t('addressBook.message.addSuccess') + ' !')
- state.canSendMsg = true
+ doAddFriend()
}
}
+
+//校验是否需要加好友
+const checkNeedAddFriend = () => {
+ let params = {
+ receiver_id: state.userInfo.sys_id, //聊天的用户id
+ talk_type: 1,
+ }
+ ServeCheckFriend(params).then((res) => {
+ console.log(res)
+ if (res?.code === 200) {
+ state.canSendMsg = res.data?.is_friend || false
+ }
+ })
+}
+
+//主动加好友(单向好友)
+const doAddFriend = () => {
+ let params = {
+ receiver_id: state.userInfo.sys_id, //聊天的用户id
+ talk_type: 1,
+ }
+ ServeAddFriend(params).then((res) => {
+ console.log(res)
+ if (res?.code === 200) {
+ message.success(t('addressBook.message.addSuccess') + ' !')
+ state.canSendMsg = true
+ }
+ })
+}