From f9e2819cc7300352471e274a5ce2716ec619cfbe Mon Sep 17 00:00:00 2001 From: Jason Date: Fri, 28 Jan 2022 11:24:10 +0800 Subject: [PATCH] =?UTF-8?q?IM=E7=9A=84=E9=93=BE=E6=8E=A5=E5=92=8C=E6=96=AD?= =?UTF-8?q?=E5=BC=80=E6=97=B6=E6=9C=BA=E8=B0=83=E6=95=B4=EF=BC=8CAPP?= =?UTF-8?q?=E6=89=93=E5=BC=80=E8=87=AA=E5=8A=A8=E5=88=A4=E6=96=AD=E7=99=BB?= =?UTF-8?q?=E5=BD=95=EF=BC=8C=E9=93=BE=E6=8E=A5=E3=80=82=E9=80=80=E5=87=BA?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E5=90=8E=E6=96=AD=E5=BC=80=E9=93=BE=E6=8E=A5?= =?UTF-8?q?=20=E6=96=B0=E6=9C=8B=E5=8F=8B=E6=95=B0=E9=87=8F=E6=8F=90?= =?UTF-8?q?=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apis/interfaces/im.js | 38 +- manifest.json | 1 + pages/im/friends/index.vue | 26 +- pages/im/index.vue | 8 +- pages/user/index.vue | 993 ++++++++++++++++++++----------------- public/userAuth.js | 249 +++++----- utils/im/index.js | 28 +- 7 files changed, 728 insertions(+), 615 deletions(-) diff --git a/apis/interfaces/im.js b/apis/interfaces/im.js index b179e16..b6ff4d4 100644 --- a/apis/interfaces/im.js +++ b/apis/interfaces/im.js @@ -22,14 +22,14 @@ const getImToken = () => { url: 'im/token', }, true) } - -// 删除好友 -const deleteFriend = (targetId) => { - return request({ - method: 'DELETE', - url: 'im/friends/' + targetId, - }) -} + +// 删除好友 +const deleteFriend = (targetId) => { + return request({ + method: 'DELETE', + url: 'im/friends/' + targetId, + }) +} // 获取用户信息 const getUserInfo = (targetId) => { @@ -37,9 +37,9 @@ const getUserInfo = (targetId) => { url: 'im/userInfo/' + targetId, }) } - -/** - * 查看好友资料,附带好友关系 + +/** + * 查看好友资料,附带好友关系 */ const getFriendInfo = (userId) => { return request({ @@ -84,16 +84,26 @@ const pedingFriend = (recipient) => { url: 'im/friends/' + recipient }) } + +/** + * 好友申请数量 + */ +const getPendingCount = () => { + return request({ + url: 'im/friends/pending/count' + }) +} export { - getImToken, + getImToken, deleteFriend, getFriends, - getUserInfo, + getUserInfo, getFriendInfo, getPedings, resolveFriend, rejectFriend, searchFriend, - pedingFriend + pedingFriend, + getPendingCount } diff --git a/manifest.json b/manifest.json index c09ce08..c681adb 100644 --- a/manifest.json +++ b/manifest.json @@ -32,6 +32,7 @@ "", "", "", + "", "", "", "", diff --git a/pages/im/friends/index.vue b/pages/im/friends/index.vue index 1811ed5..db6c55e 100644 --- a/pages/im/friends/index.vue +++ b/pages/im/friends/index.vue @@ -4,7 +4,9 @@ - 新的朋友 + + 新的朋友 ({{ pendingCount }}) + @@ -22,7 +24,8 @@ - import { - getFriends + getFriends, + getPendingCount } from '@/apis/interfaces/im'; + export default { data() { return { indexs: [], - friends: [] + friends: [], + pendingCount: 0 }; }, onShow() { getFriends().then(res => { - this.indexs = res.indexList; - this.friends = res.itemArr; - }); + this.indexs = res.indexList + this.friends = res.itemArr + }) + getPendingCount().then(res => { + console.log(res); + this.pendingCount = res + }) }, - computed: {}, methods: { - // 扫码提示 showToast() { uni.showToast({ title: '群聊功能暂未开放,敬请期待', diff --git a/pages/im/index.vue b/pages/im/index.vue index 4be35a2..f6a32be 100644 --- a/pages/im/index.vue +++ b/pages/im/index.vue @@ -102,12 +102,8 @@ } }, onShow() { - if (this.$store.state.token !== '') { - getImToken().then(res => { - im.connect(res.token, res.userInfo, () => { - this.getConversationList() - }) - }) + if (this.$store.state.token !== '') { + this.getConversationList() } this.isShown = true }, diff --git a/pages/user/index.vue b/pages/user/index.vue index 84a04f2..91ff793 100644 --- a/pages/user/index.vue +++ b/pages/user/index.vue @@ -1,472 +1,531 @@ -