From 8656ddef5545f9468d392df739024d2575154e2a Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 10 Feb 2022 16:46:23 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BE=A4=E7=BB=84=E8=81=8A=E5=A4=A9=E7=9A=84?= =?UTF-8?q?=E5=9F=BA=E7=A1=80=E5=8A=9F=E8=83=BD=EF=BC=8Cnvue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 12292 -> 12292 bytes apis/interfaces/im.js | 60 +----- pages.json | 62 +++++- pages/im/components/conversationGroup.vue | 156 -------------- ...sationPrivate.vue => conversationList.vue} | 32 +-- pages/im/components/messageCell.vue | 4 +- pages/im/friends/index.vue | 21 +- pages/im/friends/info.vue | 2 +- pages/im/group/chat.nvue | 34 ++- pages/im/group/create.nvue | 23 ++ pages/im/group/index.nvue | 79 +++++++ pages/im/group/info.nvue | 33 +++ pages/im/index.vue | 203 ++++++------------ pages/im/private/chat.nvue | 33 ++- router/index.js | 12 +- static/iconfont.css | 6 +- static/iconfont.ttf | Bin 3420 -> 3532 bytes store/modules/im.js | 23 +- utils/im/index.js | 11 +- 19 files changed, 361 insertions(+), 433 deletions(-) delete mode 100644 pages/im/components/conversationGroup.vue rename pages/im/components/{conversationPrivate.vue => conversationList.vue} (89%) create mode 100644 pages/im/group/create.nvue create mode 100644 pages/im/group/index.nvue create mode 100644 pages/im/group/info.nvue diff --git a/.DS_Store b/.DS_Store index 29b9dbd7ef013fcc859b955544c1dccf51fdc8b0..0dbc7d97abdbe05311290a6a5a073714cbc09913 100644 GIT binary patch delta 149 zcmZokXi3S_y1104lpGs{{Xg=$M9Alt;)thSbuLsVJcIw(FnCpRy@ivbK686h+SFO-H+ d-J3rONbyg6Ah?-Z;Wqo^@8WWsSu`Gj835X!Bi{f3 delta 188 zcmZokXi3;+{&uzn%cUV3}C>>2%#DHp)`z|wfTX76#r&!h1=|M mU@=aHN`^#+B8EH$J%${He1>F(Y|oth { return request({ @@ -92,62 +92,17 @@ const pedingFriend = (recipient) => { }) } -/** - * 好友申请数量 - */ -const getPendingCount = () => { +// 以下是群组相关业务的接口 +const getMyGroups = () => { return request({ - url: 'im/friends/pending/count' - }) -} - -/** - * 上传聊天附件 - * 图片 - * 语音 - * 视频 - */ -// 基础配置 -const config = { - apiUrl: 'http://api.zh.shangkelian.cn/api/', // 正式环境 - timeout: 60000 -} - -const uploadMessageFile = (file, type) => { - config.header = { - 'Accept': 'application/json', - 'Authorization': store.getters.getToken || '' - } - return new Promise((resolve, reject) => { - uni.uploadFile({ - url: config.apiUrl + 'im/upload', - filePath: file, - name: 'upload', - formData: { - type - }, - header: config.header || {}, - success: (res) => { - if (res.statusCode === 200) { - let updData = JSON.parse(res.data) - if (updData.status_code === 200) { - resolve(updData.data) - } else { - reject(updData) - } - } - }, - fail: (err) => { - console.log('ERR', err); - } - }) + url: 'im/groups' }) } export { getImToken, deleteFriend, - getFriends, + getFriends, getFriendsLetter, getUserInfo, getFriendInfo, @@ -156,6 +111,5 @@ export { rejectFriend, searchFriend, pedingFriend, - getPendingCount, - uploadMessageFile + getMyGroups } diff --git a/pages.json b/pages.json index 0918bda..baf22cd 100644 --- a/pages.json +++ b/pages.json @@ -373,6 +373,15 @@ "navigationStyle": "custom" } }, + { + "path": "pages/im/private/chat", + "style": { + "disableScroll": true, + "navigationBarTitleText": "聊天", + "enablePullDownRefresh": false, + "navigationBarBackgroundColor": "#F3F6FB" + } + }, { "path": "pages/im/private/call", "name": "imPrivateCall", @@ -431,13 +440,56 @@ "navigationBarTextStyle": "white" } }, + { + "path": "pages/im/group/index", + "name": "imGroups", + "style": { + "navigationBarTitleText": "我的群聊", + "app-plus": { + "titleNView": { + "type": "default", + "buttons": [{ + "float": "right", + "fontSrc": "/static/iconfont.ttf", + "text": "\ue60a", + "fontSize": "20px" + }] + } + } + } + }, { "path": "pages/im/group/chat", "name": "imGroupChat", "style": { - "navigationBarTitleText": "我的群聊" + "navigationBarTitleText": "群聊", + "app-plus": { + "titleNView": { + "type": "default", + "buttons": [{ + "float": "right", + "fontSrc": "/static/iconfont.ttf", + "text": "\ue607", + "fontSize": "20px" + }] + } + } } }, + { + "path": "pages/im/group/info", + "name": "imGroupInfo", + "style": { + "navigationBarTitleText": "群信息" + } + }, + { + "path": "pages/im/group/create", + "name": "imGroupCreate", + "style": { + "navigationBarTitleText": "创建群聊" + } + }, { "path": "pages/wallet/add", "name": "WalletAdd", @@ -548,14 +600,6 @@ "navigationBarBackgroundColor": "#34CE98", "navigationBarTextStyle": "white" } - }, { - "path": "pages/im/private/chat", - "style": { - "disableScroll": true, - "navigationBarTitleText": "聊天", - "enablePullDownRefresh": false, - "navigationBarBackgroundColor": "#F3F6FB" - } } ], "tabBar": { diff --git a/pages/im/components/conversationGroup.vue b/pages/im/components/conversationGroup.vue deleted file mode 100644 index 6e7d222..0000000 --- a/pages/im/components/conversationGroup.vue +++ /dev/null @@ -1,156 +0,0 @@ - - - - - diff --git a/pages/im/components/conversationPrivate.vue b/pages/im/components/conversationList.vue similarity index 89% rename from pages/im/components/conversationPrivate.vue rename to pages/im/components/conversationList.vue index eec0df9..cf3eeca 100644 --- a/pages/im/components/conversationPrivate.vue +++ b/pages/im/components/conversationList.vue @@ -18,8 +18,8 @@ + + diff --git a/pages/im/group/index.nvue b/pages/im/group/index.nvue new file mode 100644 index 0000000..2a836ff --- /dev/null +++ b/pages/im/group/index.nvue @@ -0,0 +1,79 @@ + + + + + diff --git a/pages/im/group/info.nvue b/pages/im/group/info.nvue new file mode 100644 index 0000000..6f021b8 --- /dev/null +++ b/pages/im/group/info.nvue @@ -0,0 +1,33 @@ + + + + + diff --git a/pages/im/index.vue b/pages/im/index.vue index a260de3..8ac9edb 100644 --- a/pages/im/index.vue +++ b/pages/im/index.vue @@ -5,20 +5,13 @@ - - 私聊 - - - - 群聊 - - + 聊聊 - + @@ -28,10 +21,7 @@ - - + @@ -48,26 +38,20 @@ import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index' import im from '@/utils/im/index.js' import userAuth from '@/public/userAuth' - import conversationPrivate from './components/conversationPrivate' - import conversationGroup from './components/conversationGroup' + import conversationList from './components/conversationList' export default { data() { return { - showType: 1, // 0 单聊,1 群聊 conversations: [], // 会话列表 - groupConversations: [], connection: 0, - privateUnread: 0, - groupUnread: 0, hasNewFriends: 0 } }, components: { - conversationPrivate, - conversationGroup + conversationList }, - onLoad() { + onLoad() { // 好友申请数量 this.checkNewFriendPending() uni.$on('onConnectionStatusChange', (status) => { @@ -75,50 +59,19 @@ }) uni.$on('onContactNotification', this.checkNewFriendPending) }, - onShow() { + onShow() { if (this.$store.state.token !== '') { - this.getPrivateConversationList() - this.getGroupConversationList() - } - - console.log('开始监听'); + this.getConversationList() + } // 监听新消息 - uni.$on('onReceivePrivateMessage', (msg) => { - this.getPrivateConversationList() - }) - uni.$on('onReceiveGroupMessage', (msg) => { - this.getGroupConversationList() - }) + uni.$on('onReceiveMessage', (msg) => { + this.getConversationList() + }) }, onHide() { - uni.$off('onReceivePrivateMessage') - uni.$off('onReceiveGroupMessage') - console.log('index 隐藏'); - }, - onNavigationBarButtonTap(e) { - if (e.index == 0) { - uni.showToast({ - title: '开发中暂未开放,敬请期待', - icon: 'none' - }) - } - if (e.index == 1) { - if (this.toLogin()) { - this.$Router.push({ - name: 'imFriends' - }) - } - } + uni.$off('onReceiveMessage') }, methods: { - showPrivate() { - console.log('切换到单聊'); - this.showType = 0 - }, - showGroup() { - console.log('切换到群聊'); - this.showType = 1 - }, checkNewFriendPending() { // 获取是否有新的好友申请 RongIMLib.getConversationList([RongIMLib.ConversationType.SYSTEM], 1000, 0, (res) => { @@ -139,41 +92,16 @@ return true }, // 获取私聊的会话列表 - getPrivateConversationList() { + getConversationList() { const count = 1000 const timestamp = 0 - RongIMLib.getConversationList([RongIMLib.ConversationType.PRIVATE], count, timestamp, (res) => { + RongIMLib.getConversationList([1, 3], count, timestamp, (res) => { if (res.code === 0) { this.conversations = res.conversations + console.log(res.conversations); } }) }, - // 获取群组会话列表 - getGroupConversationList() { - const count = 1000 - const timestamp = 0 - RongIMLib.getConversationList([RongIMLib.ConversationType.GROUP], count, timestamp, (res) => { - if (res.code === 0) { - this.groupConversations = res.conversations - } - }) - }, - // 点击按钮 - onNav(name, params) { - if (this.toLogin) { - if (name === '') { - uni.showToast({ - title: '开发中,敬请期待', - icon: 'none' - }) - return - } - this.$Router.push({ - name, - params - }) - } - }, // 调起扫码 scanQrCode() { uni.scanCode({ @@ -186,62 +114,17 @@ } } }) + }, + toFriendList() { + uni.navigateTo({ + url: '/pages/im/friends/index' + }) } } }