This commit is contained in:
2022-02-22 16:51:20 +08:00
13 changed files with 178 additions and 101 deletions

View File

@@ -88,9 +88,9 @@ const searchFriend = (value) => {
const pedingFriend = (recipient, message) => {
return request({
method: 'POST',
url: 'im/friends/' + recipient,
data: {
message
url: 'im/friends/' + recipient,
data: {
message
}
})
}
@@ -120,7 +120,7 @@ const getGroupBase = (groupId) => {
})
}
const getGroupUsers = (groupId, limit) => {
const getGroupUsers = (groupId, limit) => {
limit = limit || 0
return request({
url: 'im/groups/' + groupId + '/users?limit=' + limit
@@ -141,9 +141,9 @@ const createGroupAnnouncement = (groupId, content) => {
content: content
}
})
}
}
// 查看该公告详情
const getGroupAnnouncement = (groupId, announcementId) => {
const getGroupAnnouncement = (groupId, announcementId) => {
return request({
method: 'GET',
url: 'im/groups/' + groupId + '/announcements/' + announcementId
@@ -155,12 +155,12 @@ const deleteGroupAnnouncement = (groupId, announcementId) => {
method: 'DELETE',
url: 'im/groups/' + groupId + '/announcements/' + announcementId
})
}
// 置顶群公告
const topGroupAnnouncement = (groupId, announcementId) => {
}
// 置顶群公告
const topGroupAnnouncement = (groupId, announcementId) => {
return request({
method: 'POST',
url: 'im/groups/' + groupId + '/announcements/' + announcementId+'/top',
url: 'im/groups/' + groupId + '/announcements/' + announcementId + '/top',
})
}
@@ -241,12 +241,13 @@ const removeGroupUser = (groupId, userId) => {
/**
* 邀请群成员
*/
const inviteGroupUser = (groupId, userIds) => {
const inviteGroupUser = (groupId, userIds, allowIds) => {
return request({
method: 'POST',
url: 'im/groups/' + groupId + '/invite',
data: {
userIds
userIds: userIds,
allowIds: allowIds
}
})
}
@@ -280,16 +281,16 @@ const transferGroupOwner = (groupId, userId) => {
url: 'im/groups/' + groupId + '/owner/' + userId
})
}
// 通过审核验证群成员
const groupMakeSure = (groupId,user) => {
const groupMakeSure = (groupId, user) => {
return request({
url:`im/groups/${groupId}/makesure/${user}`,
method:'POST'
url: `im/groups/${groupId}/makesure/${user}`,
method: 'POST'
})
}
}
export {
@@ -310,16 +311,16 @@ export {
getGroupInfo,
getGroupBase,
getGroupUsers,
getGroupAnnouncements,
getGroupAnnouncements,
getGroupAnnouncement,
createGroupAnnouncement,
deleteGroupAnnouncement,
deleteGroupAnnouncement,
topGroupAnnouncement,
searchGroup,
joinGroupPre,
joinGroup,
quitGroup,
dismissGroup,
dismissGroup,
inviteGroupUser,
removeGroupUser,
setGroupAdmin,

View File

@@ -11,7 +11,7 @@
</view>
<view class="name">{{ item.name }}</view>
</view>
<view class="user" v-if="isAdmin">
<view class="user" v-if="canInvite">
<u-avatar @click="inviteUser" :size="avatarSize" shape="square" icon="plus" bgColor="#f9f9f9"
color="#c7c7c7" />
<view class="name">邀请好友</view>
@@ -54,7 +54,8 @@
return {
users: [],
isOwner: false,
isAdmin: false,
isAdmin: false,
canInvite:false,// 是否可以开启邀请
adminUid: 0,
members: 0,
actionShow: false,
@@ -63,6 +64,8 @@
currentUser: {},
avatarSize: 45,
labelSize: 14,
iconSize: 14
}
},
computed: {
@@ -72,14 +75,15 @@
}
}
},
created() {
this.avatarSize = utils.rpx2px(84)
this.labelSize = utils.rpx2px(24)
this.iconSize = utils.rpx2px(26)
created() {
this.avatarSize = utils.rpx2px(90)
this.labelSize = utils.rpx2px(24)
this.iconSize = utils.rpx2px(26)
},
mounted() {
this.initGroupInfo()
getGroupUsers(this.targetId, this.count).then(res => {
getGroupUsers(this.targetId, this.count).then(res => {
console.log("res..",res)
this.users = res
res.map(item => {
this.$store.dispatch('updateContact', item)
@@ -92,7 +96,8 @@
this.isOwner = res.is_owner
this.isAdmin = res.is_admin
this.adminUid = res.user_id
this.members = res.members
this.members = res.members
this.canInvite = res.can_invite
})
},
initUsers() {

View File

@@ -100,7 +100,8 @@
<style scoped lang="scss">
.send--voice {
.voice {
.voice {
display: flex;
background: $window-color;
height: 70rpx;
line-height: 70rpx;
@@ -109,14 +110,14 @@
width: 500rpx;
border-radius: 10rpx;
margin-right: 15rpx;
.button {
font-size: 30rpx;
color: #333;
}
}
.modal {
.modal {
display: flex;
background: rgba(0, 0, 0, .6);
position: fixed;
height: 200rpx;
@@ -128,7 +129,6 @@
flex-direction: column;
align-items: center;
justify-content: center;
.icon {
width: 88rpx;
height: 88rpx;

View File

@@ -3,8 +3,8 @@
<view class="name" v-if="isGroup && isRemote">{{ contact(message.senderUserId).name }}</view>
<view class="msg--voice">
<view :class="['voice', isRemote ? 'left': 'right', {'onPlay': onPlay}]" :style="{width: width + 'rpx'}" @click="startPlay">
<image v-if="isRemote" class="icon" src="@/static/icon/audio_green.png" mode="widthFix"></image>
<image v-else class="icon" src="@/static/icon/audio_white.png" mode="widthFix"></image>
<image v-if="isRemote" class="icon" :class="{ 'videoFlicker' : onPlay && msgId == message.messageId }" src="@/static/icon/audio_green.png" mode="widthFix"></image>
<image v-else class="icon" :class="{ 'videoFlicker' : onPlay && msgId == message.messageId }" src="@/static/icon/audio_white.png" mode="widthFix"></image>
<text class="duration">{{ duration }}"</text>
</view>
<u-badge isDot :show="message.content.local =='' && isRemote" />
@@ -27,12 +27,13 @@
isGroup: {
type: Boolean,
default: false
}
}
},
data() {
return {
onPlay: false,
innerAC: null,
msgId : null
}
},
computed: {
@@ -62,7 +63,12 @@
this.stopPlay()
}
})
},
},
created() {
console.log(this.message.messageId)
},
methods: {
// 播放语音消息
startPlay() {
@@ -91,15 +97,17 @@
})
}
},
playVoice(path) {
playVoice(path) {
console.log('准备播放', this.message.content);
this.innerAC = uni.createInnerAudioContext()
this.innerAC.src = path
this.innerAC.autoplay = false
this.innerAC.onCanplay(res => {
this.innerAC.autoplay = false
this.msgId = this.message.messageId
this.innerAC.onCanplay(res => {
this.innerAC.play()
})
this.innerAC.onPlay(res => {
})
this.innerAC.onPlay(res => {
this.onPlay = true
uni.$emit('onVoiceMessagePlay', this.message.messageId)
})
@@ -109,10 +117,11 @@
this.innerAC.onStop(() => {
this.onPlay = false
this.innerAC.destroy()
this.innerAC = null
this.innerAC = null
this.msgId = null
uni.$emit('onVoiceMessageStop', this.message.messageId)
})
this.innerAC.onError(err => {
this.innerAC.onError(err => {
uni.showToast({
icon: 'none',
title: '语音播放失败'
@@ -127,7 +136,25 @@
}
}
}
</script>
</script>
<style>
@keyframes playFlicker{
0%{
opacity: 1;
}
50%{
opacity: .5;
}
100%{
opacity: 1;
}
}
.videoFlicker{
animation: playFlicker 1s infinite;
}
</style>
<style scoped lang="scss">
.name {

View File

@@ -12,8 +12,8 @@
</view>
<block v-if="friends.length > 0">
<u-index-item v-for="(item, fkey) in friends" :key="fkey">
<u-index-anchor :text="indexs[fkey]" bgColor="#ededed" height="20" size="12" color="#666"
style="padding:10rpx 30rpx" />
<u-index-anchor :text="indexs[fkey]" bgColor="#f9f9f9" height="20" size="12" color="#666"
class="anchor" />
<view v-for="(friendItem, index) in item" :key="index" class="friend-flex"
@click="toFriend(friendItem.targetId)">
<u-avatar class="avatar-img" size="40" shape="square"
@@ -37,8 +37,8 @@
getFriendsLetter
} from '@/apis/interfaces/im';
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
import im from '@/utils/im/index.js'
import im from '@/utils/im/index.js'
export default {
data() {
return {
@@ -87,9 +87,9 @@
// 新朋友
toPending() {
// if (this.pendingCount > 0) {
uni.navigateTo({
url: '/pages/im/friends/pending'
});
uni.navigateTo({
url: '/pages/im/friends/pending'
});
// } else {
// uni.showToast({
// title: ` 暂无好友申请 ~ `,
@@ -114,6 +114,12 @@
height: 70vh;
}
.anchor {
background-color: #f9f9f9 !important;
padding: 10rpx 30rpx;
border-bottom: none !important;
}
// 好友列表
.friend-flex {
position: relative;
@@ -127,6 +133,8 @@
box-shadow: 0 0 20rpx rgba($color: $main-color, $alpha: 0.2);
}
.info {
flex: 1;
margin-left: $padding;

View File

@@ -30,8 +30,6 @@
this.targetId = e.targetId
if (e.type) {
this.type = e.type
console.log(this.type)
}
if (e.aId) {
this.aId = e.aId
@@ -46,8 +44,6 @@
})
})
}
},
computed: {
disabled() {

View File

@@ -182,8 +182,9 @@
.item {
background-color: #fff;
padding: $padding $padding + 10;
border-bottom: $padding solid #f9f9f9;
padding: $padding $padding + 10 10rpx $padding + 10;
border-bottom: $padding solid #f9f9f9;
.user {
display: flex;
@@ -192,7 +193,8 @@
align-items: center;
box-sizing: border-box;
font-size: $title-size-m;
color: $text-gray-m;
color: $text-gray-m;
padding: 10rpx;
.name {
padding-left: 10rpx;
@@ -207,12 +209,14 @@
font-size: $title-size;
color: $text-color;
max-width: 100%;
margin-bottom: $padding;
margin-bottom: 10rpx;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
overflow: hidden;
line-height: 1.5;
line-height: 1.5;
border-bottom: solid 1rpx #F9F9F9;
padding-bottom: 20rpx;
span {
color: #fff;

View File

@@ -144,6 +144,10 @@
im.setNotifyBadge()
}
}
},
onHide() {
// console.log(JSON.stringify(this.$refs))
this.$refs.voice.stopPlay()
}
}
</script>

View File

@@ -98,7 +98,7 @@
font-size: $title-size;
color: $text-gray;
background-color: #fff;
padding: 10rpx $padding $padding $padding;
padding: 10rpx $padding 20rpx $padding;
font-weight: normal;
}
}

View File

@@ -5,9 +5,8 @@
</view>
<u-cell-group class="cells" :border="false">
<u-cell :border="false" class="u-border-bottom" isLink title="群公告"
@click="toAnnouncement" >
<view slot="label" class="announcement-label "> {{announcement}} </view>
<u-cell :border="false" class="u-border-bottom" isLink title="群公告" @click="toAnnouncement">
<view slot="label" class="announcement-label "> {{announcement}} </view>
</u-cell>
<u-cell :border="false" class="u-border-bottom" isLink title="二维码" @click="showGroupQrCode" />
<u-cell :border="false" class="u-border-bottom" v-if="group.can_makesure" isLink title="群聊邀请确认"
@@ -107,8 +106,8 @@
})
this.initData()
uni.$on('groupAnnouncementCreated', this.initData)
uni.$on('groupInvitedUser', this.updateUserList)
uni.$on('updateAnnouncement',this.initData)
uni.$on('groupInvitedUser', this.updateUserList)
uni.$on('updateAnnouncement', this.initData)
},
onUnload() {
uni.$off('groupAnnouncementCreated')
@@ -258,8 +257,11 @@
}
return item
})
this.initData()
this.joinType = e.name
this.$nextTick(() => {
this.$refs.userList.initGroupInfo()
this.initData()
})
this.showActions = false
}).catch(err => {
console.log(err);
@@ -340,19 +342,20 @@
.cells {
margin-top: $padding;
background-color: white;
.announcement-label{
font-size: $title-size-m + 2;
padding-top: 10rpx;
color: $text-gray-m;
overflow: hidden;
width: 620rpx;
display: inline-block;
overflow:hidden;
text-overflow:ellipsis;
display:-webkit-box;
-webkit-box-orient:vertical;
-webkit-line-clamp:3;
background-color: white;
.announcement-label {
font-size: $title-size-m + 2;
padding-top: 10rpx;
color: $text-gray-m;
overflow: hidden;
width: 620rpx;
display: inline-block;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
}
}

View File

@@ -8,8 +8,8 @@
<u-index-list :index-list="indexs" inactiveColor="#666" activeColor="#34CE98">
<u-checkbox-group v-if="friends.length > 0" v-model="checkboxValue" placement="column">
<u-index-item v-for="(item, fkey) in friends" :key="fkey">
<u-index-anchor :text="indexs[fkey]" v-if="indexs[fkey]" bgColor="#ededed" height="20" size="12"
color="#666" style="padding:10rpx 30rpx" />
<u-index-anchor :text="indexs[fkey]" v-if="indexs[fkey]" bgColor="#f9f9f9f" height="20" size="12"
color="#666" style="border:none !important;padding: 10rpx 30rpx;background-color: #f9f9f9 !important;" />
<view v-for="(friendItem, index) in item" :key="index" class="friend-flex"
@click="addContact(friendItem.targetId)">
<u-checkbox :name="friendItem.targetId" shape="circle" activeColor="#34ce98"
@@ -101,7 +101,8 @@
this.orignalIndexs = res.indexList
})
getGroupUsers(this.targetId).then(res => {
res.map(res => {
res.map(res => {
console.log(res)
this.checkboxValue.push(String(res.targetId))
this.selectValue.push(String(res.targetId))
})
@@ -121,8 +122,17 @@
}
},
onInvite() {
inviteGroupUser(this.targetId, this.checkboxValue).then(res => {
onInvite() {
console.log(this.checkboxValue,'userIds.....')
console.log(this.selectValue,'userIds.....')
let userIds = []
this.checkboxValue.filter(item=>{
if(!utils.inArray(item, this.selectValue)){
userIds.push(item)
}
})
// console.log(userIds)
inviteGroupUser(this.targetId, this.checkboxValue,userIds).then(res => {
uni.navigateBack({
delta: 1,
animationType: 'pop-out',

View File

@@ -3,19 +3,19 @@
<view class="reviewed">
<block v-if="pendings.length > 0">
<view class="reviewed-item" v-for="(item, index) in pendings" :key="index">
<u-avatar class="avatar"
:src="JSON.parse(item.latestMessage.extra).portraitUrl || require('@/static/user/cover.png')"
<u-avatar class="avatar"
:src="JSON.parse(item.content.extra).portraitUrl || require('@/static/user/cover.png')"
shape="square" size="46" />
<view style="flex:1;" v-if="item.latestMessage.operation == 'GroupPending'">
<view class="nickname">{{ JSON.parse(item.latestMessage.extra).name }} 申请加入群聊</view>
<view> 申请原因{{ item.latestMessage.message }}</view>
<view style="flex:1;" v-if="item.content.operation == 'GroupPending'">
<view class="nickname">{{ JSON.parse(item.content.extra).name }} 申请加入群聊</view>
<view> 申请原因{{ item.content.message }}</view>
</view>
<view style="flex:1;" v-if="item.latestMessage.operation == 'GroupInvite'">
<view style="flex:1;" v-if="item.content.operation == 'GroupInvite'">
<view class="nickname">
<text>{{ contact(item.latestMessage.sourceUserId )}}</text>想邀请<span>{{ JSON.parse(item.latestMessage.extra).name }}</span>加入群聊
<text>{{ contact(item.content.sourceUserId).name }}</text>想邀请<span>{{ JSON.parse(item.content.extra).name }}</span>加入群聊
</view>
</view>
<view class="sure" @click="sure(item.latestMessage.targetUserId,item.latestMessageId)"> 通过 </view>
<view class="sure" @click="sure(item.content.targetUserId,item.messageId)"> 通过 </view>
</view>
</block>
@@ -81,11 +81,26 @@
})
}).catch(err => {
uni.showToast({
title: err.message,
icon: 'none',
mask: true,
duration: 2000
// uni.showToast({
// title: err.message,
// icon: 'none',
// mask: true,
// duration: 2000
// })
RongIMLib.deleteMessagesByIds([latestMessageId], ({
code
}) => {
console.log('code', code)
if (code == 0) {
uni.showToast({
title:err.message,
icon: 'none',
mask: true,
duration: 2000
})
this.getList()
uni.$emit('groupInvitedUser')
}
})
})
// 直接调用通过或拒绝的接口
@@ -138,7 +153,6 @@
}
}
.no-lists {
padding-top: $padding * 5;
display: flex;

View File

@@ -4,7 +4,7 @@
<view class="info-box">
<image src="@/static/user/user_back.png" mode="aspectFill" />
<view class="user-flex">
<image class="cover" @click="$Router.push({ name: 'Setting' })"
<image class="cover" @click="goSetting"
:src="userInfo.avatar || require('@/static/user/cover.png')" mode="aspectFill" />
<view class="user-content">
<block v-if="$store.state.token != ''">
@@ -233,6 +233,11 @@
params
});
}
},
goSetting(){
if (this.isLogin()) {
this.$Router.push({ name: 'Setting' })
}
},
// 检查登录
isLogin() {