This commit is contained in:
唐明明
2022-02-23 16:50:38 +08:00
16 changed files with 109 additions and 45 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@@ -62,10 +62,9 @@
actionMap: [], actionMap: [],
actionTitle: '', actionTitle: '',
currentUser: {}, currentUser: {},
avatarSize: 45, avatarSize: 40,
labelSize: 14, labelSize: 14,
iconSize: 14 iconSize: 14
} }
}, },
computed: { computed: {
@@ -76,7 +75,7 @@
} }
}, },
created() { created() {
this.avatarSize = utils.rpx2px(90) this.avatarSize = utils.rpx2px(84)
this.labelSize = utils.rpx2px(24) this.labelSize = utils.rpx2px(24)
this.iconSize = utils.rpx2px(26) this.iconSize = utils.rpx2px(26)
}, },
@@ -277,7 +276,6 @@
border-radius: 0 8rpx 0 0; border-radius: 0 8rpx 0 0;
position: relative; position: relative;
width: 84rpx; width: 84rpx;
height: 84rpx;
overflow: hidden; overflow: hidden;
.admin { .admin {

View File

@@ -1,6 +1,10 @@
<template> <template>
<view class=""> <view class="">
<view class="notify" v-if="message.objectName === 'RC:GrpNtf'">{{ message.content.message }}</view> <view class="notify" v-if="message.objectName === 'RC:GrpNtf'">
{{ message.content.message }}
<text class="link" @click="toAnnounce(message.content.extra)"
v-if="message.content.operation == 'ANNOUNCEMENT'">点击查看 </text>
</view>
<view class="notify" v-else-if="message.objectName === 'RC:RcNtf'"> <view class="notify" v-else-if="message.objectName === 'RC:RcNtf'">
{{ contact(message.senderUserId).name }} 撤回了一条消息 {{ contact(message.senderUserId).name }} 撤回了一条消息
</view> </view>
@@ -75,6 +79,19 @@
}) })
} }
}, },
// 跳转群公告
toAnnounce(targetId) {
if (targetId) {
uni.navigateTo({
url: '/pages/im/group/announceCreate?targetId=' + this.targetId
})
} else {
uni.showToast({
icon: 'none',
title: '旧版本,无链接'
})
}
},
// 撤回消息测试 // 撤回消息测试
backMessage() { backMessage() {
if (this.$store.getters.sender.userId != this.message.senderUserId) { if (this.$store.getters.sender.userId != this.message.senderUserId) {
@@ -118,6 +135,11 @@
text-align: center; text-align: center;
font-size: 24rpx; font-size: 24rpx;
color: #666; color: #666;
.link {
color: blue;
margin-left: 10rpx;
}
} }
.cell-item { .cell-item {

View File

@@ -30,7 +30,7 @@
<u-icon name="arrow-right" color="#eee" size="16" /> <u-icon name="arrow-right" color="#eee" size="16" />
</view> </view>
<view class="item u-border-bottom"> <view class="item u-border-bottom">
<label>聊天免打扰</label> <label>消息免打扰</label>
<u-switch size="22" v-model="status" activeColor="#34CE98" @change="setStatus"></u-switch> <u-switch size="22" v-model="status" activeColor="#34CE98" @change="setStatus"></u-switch>
</view> </view>
<view class="item"> <view class="item">

View File

@@ -2,7 +2,7 @@
<view class="pending"> <view class="pending">
<u-sticky> <u-sticky>
<view class="header-search" @click="$Router.push({ name: 'SearchFriend' })"> <view class="header-search" @click="$Router.push({ name: 'SearchFriend' })">
<u-search placeholder="输入手机号码搜索" height="74" searchIcon="search" inputAlign="center" bgColor="white" <u-search placeholder="输入手机号码搜索" searchIcon="search" inputAlign="center" bgColor="white"
:disabled="true" :show-action="false" /> :disabled="true" :show-action="false" />
</view> </view>
</u-sticky> </u-sticky>

View File

@@ -11,14 +11,16 @@
<!-- 搜索 --> <!-- 搜索 -->
<u-sticky> <u-sticky>
<view class="header-search"> <view class="header-search">
<u-search placeholder="输入用户账号、手机号" height="74" searchIcon="search" @custom="search" v-model="searchValue" @search="search" bgColor="#f9f9f9" :focus="focused" /> <u-search placeholder="输入用户账号、手机号" searchIcon="search" @custom="search" v-model="searchValue"
@search="search" bgColor="#f9f9f9" :focus="focused" />
</view> </view>
</u-sticky> </u-sticky>
<block v-if="searchResult.length > 0"> <block v-if="searchResult.length > 0">
<applyFriend :lists="searchResult" :isApply="true" @action="action" /> <applyFriend :lists="searchResult" :isApply="true" @action="action" />
</block> </block>
<view class="no-lists" v-else> <view class="no-lists" v-else>
<u-image class="cover" radius="4" width="400rpx" height="400rpx" :src="require('@/static/imgs/no-search.png')" :lazy-load="true" /> <u-image class="cover" radius="4" width="400rpx" height="400rpx"
:src="require('@/static/imgs/no-search.png')" :lazy-load="true" />
<span>暂无匹配内容~</span> <span>暂无匹配内容~</span>
</view> </view>
</view> </view>
@@ -43,11 +45,11 @@
}, },
methods: { methods: {
search() { search() {
// friendship: '' 没有好友关系 // friendship: '' 没有好友关系
// accepted 好友 // accepted 好友
// pending 申请中 // pending 申请中
// denied 拒绝 // denied 拒绝
// blocked 黑名单 // blocked 黑名单
searchFriend(this.searchValue) searchFriend(this.searchValue)
.then(res => { .then(res => {
this.searchResult = res; this.searchResult = res;
@@ -60,9 +62,9 @@
}); });
}); });
}, },
action(e) { action(e) {
uni.navigateTo({ uni.navigateTo({
url: '/pages/im/friends/info?targetId=' + e.item.targetId url: '/pages/im/friends/info?targetId=' + e.item.targetId
}) })
} }
} }

View File

@@ -1,11 +1,11 @@
<template> <template>
<view class="create"> <view class="create">
<view class="create-title">公告内容</view> <view class="create-title">公告内容</view>
<block v-if="type !== 'cheack'"> <block v-if="type !== 'check'">
<u--textarea v-model="content" count height="240" maxlength="240" placeholder="请输入公告内容" /> <u--textarea v-model="content" count height="240" maxlength="240" placeholder="请输入公告内容" />
<u-button type="primary" text="发布" :disabled="disabled" @click="onCreate" color="#34CE98" /> <u-button type="primary" text="发布" :disabled="disabled" @click="onCreate" color="#34CE98" />
</block> </block>
<block v-if="type === 'cheack'"> <block v-if="type === 'check'">
<view class="content-a"> {{content}} </view> <view class="content-a"> {{content}} </view>
</block> </block>
</view> </view>

View File

@@ -76,7 +76,7 @@
onNavigationBarButtonTap() { onNavigationBarButtonTap() {
if (this.isAdmin) { if (this.isAdmin) {
uni.navigateTo({ uni.navigateTo({
url: '/pages/im/group/announceCreate?targetId=' + this.targetId url: '/pages/im/group/announceCreate?type=check&targetId=' + this.targetId
}) })
} else { } else {
uni.showToast({ uni.showToast({
@@ -119,7 +119,7 @@
}, },
tabA(id) { tabA(id) {
uni.navigateTo({ uni.navigateTo({
url: '/pages/im/group/announceCreate?type=cheack&targetId=' + this.targetId + '&aId=' + id url: '/pages/im/group/announceCreate?type=check&targetId=' + this.targetId + '&aId=' + id
}) })
}, },
onTop(aId) { onTop(aId) {

View File

@@ -21,11 +21,11 @@
import sentMessageBar from '../components/sentMessageBar' import sentMessageBar from '../components/sentMessageBar'
import showMessageCell from '../components/showMessageCell' import showMessageCell from '../components/showMessageCell'
import utils from '@/utils/index.js' import utils from '@/utils/index.js'
import onGroupDismiss from '@/utils/im/onGroupDismiss.js' import onGroupDismiss from '@/utils/im/onGroupDismiss.js'
export default { export default {
mixins: [ mixins: [
onGroupDismiss onGroupDismiss
], ],
components: { components: {
sentMessageBar, sentMessageBar,
@@ -52,15 +52,12 @@
} }
} }
} }
},
onShow() {
this.initGroupInfo()
}, },
onLoad(e) { onLoad(e) {
this.targetId = e.targetId this.targetId = e.targetId
// 获取群成员数量
getGroupBase(this.targetId).then(res => {
uni.setNavigationBarTitle({
title: res.name + `(${res.members})`
})
})
// 获取历史消息列表 // 获取历史消息列表
this.getMessageList() this.getMessageList()
// 监听新消息 // 监听新消息
@@ -103,7 +100,8 @@
}) })
}, },
onUnload() { onUnload() {
uni.$off('onReceiveMessage_' + this.targetId) uni.$off('onReceiveMessage_' + this.targetId)
uni.$off('onUpdateProfile_' + this.targetId)
uni.$off('onRecallMessage') uni.$off('onRecallMessage')
uni.$off('onReceiptRequest') uni.$off('onReceiptRequest')
uni.$off('onReceiptResponse') uni.$off('onReceiptResponse')
@@ -114,6 +112,14 @@
}) })
}, },
methods: { methods: {
initGroupInfo() {
// 获取群信息,成员数量,设置标题
getGroupBase(this.targetId).then(res => {
uni.setNavigationBarTitle({
title: res.name + `(${res.members})`
})
})
},
onScroll(e) { onScroll(e) {
this.$refs.messageBar.onHidePopus() this.$refs.messageBar.onHidePopus()
}, },

View File

@@ -3,16 +3,15 @@
<block v-if="groups.length > 0"> <block v-if="groups.length > 0">
<view class="title"> 群聊 </view> <view class="title"> 群聊 </view>
<view v-for="(item, index) in groups" :key="index" class="friend-flex" @click="toGroup(item.targetId)"> <view v-for="(item, index) in groups" :key="index" class="friend-flex" @click="toGroup(item.targetId)">
<u-avatar size="38" shape="square" :src="contact(item.targetId).portraitUrl" /> <u-avatar size="36" shape="square" :src="item.portraitUrl !== ''?contact(item.targetId).portraitUrl :require('@/static/user/cover-s.png')" />
<view class="info"> <view class="info">
<view class="name">{{item.name}} <span class="total">10人</span></view> <view class="name">{{ item.name }} <span class="total">{{ item.members }} 成员</span></view>
</view> </view>
</view> </view>
<view class="group-count"> {{groups.length}}个群聊 </view> <view class="group-count"> {{ groups.length }}个群聊 </view>
</block> </block>
<view class="no-lists" v-else> <view class="no-lists" v-else>
<u-image class="cover" radius="4" width="400rpx" height="400rpx" <u-image class="cover" radius="4" width="400rpx" height="400rpx" :src="require('@/static/imgs/no-friend.png')" :lazy-load="true" />
:src="require('@/static/imgs/no-friend.png')" :lazy-load="true" />
<span>空空如也~</span> <span>空空如也~</span>
</view> </view>
<u-modal negativeTop="300" :show="createModal" title="创建群聊" showCancelButton @cancel="onHideModal" <u-modal negativeTop="300" :show="createModal" title="创建群聊" showCancelButton @cancel="onHideModal"
@@ -55,7 +54,8 @@
}, },
methods: { methods: {
initData() { initData() {
getMyGroups().then((res) => { getMyGroups().then((res) => {
console.log(res,'res...')
if (res.length > 0) { if (res.length > 0) {
this.bg = '#f9f9f9' this.bg = '#f9f9f9'
} else { } else {

View File

@@ -13,7 +13,7 @@
<u-cell :border="false" class="u-border-bottom" title="聊天置顶"> <u-cell :border="false" class="u-border-bottom" title="聊天置顶">
<u-switch slot="value" size="20" v-model="isTop" activeColor="#34CE98" @change="setTop" /> <u-switch slot="value" size="20" v-model="isTop" activeColor="#34CE98" @change="setTop" />
</u-cell> </u-cell>
<u-cell class="u-border-bottom" :border="false" title="免打扰"> <u-cell class="u-border-bottom" :border="false" title="消息免打扰">
<u-switch slot="value" size="20" v-model="status" activeColor="#34CE98" @change="setStatus" /> <u-switch slot="value" size="20" v-model="status" activeColor="#34CE98" @change="setStatus" />
</u-cell> </u-cell>
</u-cell-group> </u-cell-group>
@@ -34,7 +34,7 @@
</view> </view>
<u-modal negativeTop="300" :show="modalShow" title="修改群名称" showCancelButton @cancel="onHideModal" @confirm="onChangeGroupName"> <u-modal negativeTop="300" :show="modalShow" title="修改群名称" showCancelButton @cancel="onHideModal" @confirm="onChangeGroupName">
<view class="slot-content"> <u--input placeholder="群名称" border="surround" focus v-model="groupName" maxlength="14" /> </view> <view class="slot-content"> <u--input placeholder="群名称" border="surround" focus v-model="groupName" maxlength="12" /> </view>
</u-modal> </u-modal>
<u-modal :show="qrCodeShow" :title="group.name" @confirm="qrCodeShow = false"> <u-modal :show="qrCodeShow" :title="group.name" @confirm="qrCodeShow = false">

View File

@@ -22,7 +22,7 @@
<view class="no-lists" v-else> <view class="no-lists" v-else>
<u-image class="cover" radius="4" width="400rpx" height="400rpx" <u-image class="cover" radius="4" width="400rpx" height="400rpx"
:src="require('@/static/imgs/no-friend.png')" :lazy-load="true" /> :src="require('@/static/imgs/no-friend.png')" :lazy-load="true" />
<span> 暂无群聊申请数据~</span> <span>暂无群聊申请数据</span>
</view> </view>
</view> </view>
</template> </template>
@@ -82,7 +82,6 @@
uni.$emit('groupInvitedUser') uni.$emit('groupInvitedUser')
} }
}) })
}).catch(err => { }).catch(err => {
// uni.showToast({ // uni.showToast({
// title: err.message, // title: err.message,

BIN
static/.DS_Store vendored

Binary file not shown.

BIN
static/user/cover-s.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@@ -30,6 +30,7 @@ const onReceiveMessage = (message) => {
const checkContactExists = (message) => { const checkContactExists = (message) => {
if (!store.getters.contactIsExist(message.targetId)) { if (!store.getters.contactIsExist(message.targetId)) {
getUserInfo(message.targetId).then(res => { getUserInfo(message.targetId).then(res => {
console.log('targetId', res);
store.dispatch('initContact', res) store.dispatch('initContact', res)
}).catch(err => { }).catch(err => {
console.error('getUserInfo ERR', err) console.error('getUserInfo ERR', err)
@@ -37,6 +38,7 @@ const checkContactExists = (message) => {
} }
if (!store.getters.contactIsExist(message.senderUserId)) { if (!store.getters.contactIsExist(message.senderUserId)) {
getUserInfo(message.senderUserId).then(res => { getUserInfo(message.senderUserId).then(res => {
console.log('senderUserId', message.senderUserId, res);
store.dispatch('initContact', res) store.dispatch('initContact', res)
}).catch(err => { }).catch(err => {
console.error('getUserInfo ERR', err) console.error('getUserInfo ERR', err)
@@ -53,7 +55,8 @@ const notifyMsgTypes = [
IMLib.ObjectName.Location, IMLib.ObjectName.Location,
IMLib.ObjectName.Voice, IMLib.ObjectName.Voice,
IMLib.ObjectName.HQVoice, IMLib.ObjectName.HQVoice,
IMLib.ObjectName.Sight IMLib.ObjectName.Sight,
IMLib.ObjectName.GroupNotification
] ]
const imLibListeners = () => { const imLibListeners = () => {
@@ -69,7 +72,8 @@ const imLibListeners = () => {
checkContactExists(message) checkContactExists(message)
if (utils.inArray(message.objectName, notifyMsgTypes)) { if (utils.inArray(message.objectName, notifyMsgTypes)) {
onReceiveMessage(message) onReceiveMessage(message)
} else if (message.objectName === IMLib.ObjectName.ProfileNotification) { } else if (message.objectName === IMLib.ObjectName.ProfileNotification) {
uni.$emit('onUpdateProfile_' + message.targetId)
// 更新联系人信息 // 更新联系人信息
store.dispatch('updateContact', JSON.parse(message.content.data)) store.dispatch('updateContact', JSON.parse(message.content.data))
// 调用完更新之后,删除这条消息 // 调用完更新之后,删除这条消息
@@ -89,6 +93,19 @@ const imLibListeners = () => {
// 发布群解散的消息 // 发布群解散的消息
uni.$emit('onGroupDismiss') uni.$emit('onGroupDismiss')
uni.$emit('onGroupDismiss_' + message.targetId) uni.$emit('onGroupDismiss_' + message.targetId)
} else if (message.content.operation === 'REMOVE') {
// 要判断是否当前用户,然后把当前用户踢出到主页去, 删除聊天记录,会话列表
if (message.content.extra == store.getters.sender.userId) {
IMLib.cleanHistoryMessages(message.conversationType, message.targetId, message.sentTime,
false)
// 解散了就删了吧
IMLib.removeConversation(message.conversationType, message.targetId)
// 为了更新群列表
uni.$emit('onGroupDismiss')
uni.$emit('onGroupRemoveYou_' + message.targetId)
}
uni.$emit('onReceiveMessage_' + message.targetId, message)
// 这个是为了更新消息列表页的
} }
// 触发刷新会话列表 // 触发刷新会话列表
uni.$emit('onReceiveMessage', message) uni.$emit('onReceiveMessage', message)

View File

@@ -1,6 +1,13 @@
// 监听群解散的消息,直接跳转到会话列表页面 // 监听群解散的消息,直接跳转到会话列表页面
const onGroupDismiss = { const onGroupDismiss = {
data() {
return {
currentTargetId: ''
}
},
onLoad(e) { onLoad(e) {
this.currentTargetId = e.targetId
uni.$once('onGroupDismiss_' + e.targetId, () => { uni.$once('onGroupDismiss_' + e.targetId, () => {
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
@@ -10,6 +17,19 @@ const onGroupDismiss = {
url: '/pages/im/index' url: '/pages/im/index'
}) })
}) })
uni.$once('onGroupRemoveYou_' + e.targetId, () => {
uni.showToast({
icon: 'none',
title: '您已被移出群聊'
})
uni.switchTab({
url: '/pages/im/index'
})
})
},
onUnload() {
uni.$off('onGroupDismiss_' + this.currentTargetId)
uni.$off('onGroupRemoveYou_' + this.currentTargetId)
} }
} }