..
This commit is contained in:
@@ -315,14 +315,15 @@ export {
|
|||||||
getGroupAnnouncement,
|
getGroupAnnouncement,
|
||||||
createGroupAnnouncement,
|
createGroupAnnouncement,
|
||||||
deleteGroupAnnouncement,
|
deleteGroupAnnouncement,
|
||||||
topGroupAnnouncement,
|
topGroupAnnouncement,
|
||||||
searchGroup,
|
searchGroup,
|
||||||
joinGroupPre,
|
joinGroupPre,
|
||||||
joinGroup,
|
joinGroup,
|
||||||
quitGroup,
|
quitGroup,
|
||||||
dismissGroup,
|
dismissGroup,
|
||||||
inviteGroupUser,
|
inviteGroupUser,
|
||||||
removeGroupUser,
|
removeGroupUser,
|
||||||
|
transferGroupOwner,
|
||||||
setGroupAdmin,
|
setGroupAdmin,
|
||||||
removeGroupAdmin,
|
removeGroupAdmin,
|
||||||
groupMakeSure, // 通过审核
|
groupMakeSure, // 通过审核
|
||||||
|
|||||||
BIN
pages/.DS_Store
vendored
BIN
pages/.DS_Store
vendored
Binary file not shown.
BIN
pages/im/.DS_Store
vendored
BIN
pages/im/.DS_Store
vendored
Binary file not shown.
@@ -104,7 +104,10 @@
|
|||||||
hideAction(item) {
|
hideAction(item) {
|
||||||
this.actionShow = false
|
this.actionShow = false
|
||||||
},
|
},
|
||||||
showAction(item) {
|
showAction(item) {
|
||||||
|
if (item.is_admin == 2) {
|
||||||
|
return
|
||||||
|
}
|
||||||
this.currentUser = item
|
this.currentUser = item
|
||||||
this.actionTitle = item.name
|
this.actionTitle = item.name
|
||||||
// 只有管理员以上才会弹窗
|
// 只有管理员以上才会弹窗
|
||||||
|
|||||||
@@ -72,11 +72,10 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|
||||||
.input {
|
.input {
|
||||||
background: #F3F6FB;
|
background: #F3F6FB;
|
||||||
height: 70rpx;
|
height: 70rpx;
|
||||||
width: 500rpx;
|
width: 460rpx;
|
||||||
border-radius: 10rpx;
|
border-radius: 10rpx;
|
||||||
margin-right: 15rpx;
|
margin-right: 15rpx;
|
||||||
padding: 0 20rpx;
|
padding: 0 20rpx;
|
||||||
|
|||||||
@@ -2,11 +2,17 @@
|
|||||||
<view class="send--voice">
|
<view class="send--voice">
|
||||||
<view class="voice" hover-class="chat-hover" @touchstart="startRecord" @touchend="stopRecord">
|
<view class="voice" hover-class="chat-hover" @touchstart="startRecord" @touchend="stopRecord">
|
||||||
<text class="button">按住说话</text>
|
<text class="button">按住说话</text>
|
||||||
</view>
|
</view>
|
||||||
<!-- 录音中提示 -->
|
<!-- 录音中 -->
|
||||||
<view class="modal" v-if="showRecordTip">
|
<view class="modal" v-if="showRecordTip">
|
||||||
<image class="icon" src="@/static/icon/record-icon.png" mode="widthFix"></image>
|
<image class="icon" src="@/static/icon/record-icon.png" mode="widthFix"></image>
|
||||||
<text class="text">录音中 {{recordTime}} s</text>
|
<text class="text">录音中 {{recordTime}} s</text>
|
||||||
|
</view>
|
||||||
|
<!-- 录音完成发送或取消 -->
|
||||||
|
<view class="lay" v-if="showConfirm">
|
||||||
|
<view class="item red" @click="()=> { this.mp3AudioSrc = null, this.showConfirm = false }">取消</view>
|
||||||
|
<view class="item" @click="startPlay">试听</view>
|
||||||
|
<view class="item greed" @click="this.senVoice">发送</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
@@ -32,23 +38,39 @@
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
showRecordTip: false,
|
showRecordTip: false,
|
||||||
|
showConfirm: false,
|
||||||
recordTime: 60,
|
recordTime: 60,
|
||||||
interval: 0,
|
interval: 0,
|
||||||
maxRecordTime: 60,
|
maxRecordTime: 60,
|
||||||
recorderManager: null
|
recorderManager: null,
|
||||||
|
mp3AudioSrc: null,
|
||||||
|
isBetaPlay: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
computed: {
|
||||||
|
sender() {
|
||||||
|
return this.$store.getters.sender
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
this.recorderManager = uni.getRecorderManager()
|
this.recorderManager = uni.getRecorderManager()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
onShowLay(){
|
||||||
|
// this.showRecordTip = true
|
||||||
|
uni.vibrateShort({
|
||||||
|
complete: com => {
|
||||||
|
console.log(com)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
// 检查安卓录制权限
|
// 检查安卓录制权限
|
||||||
async getAndroidPermission() {
|
async getAndroidPermission() {
|
||||||
return await permision.requestAndroidPermission('android.permission.RECORD_AUDIO')
|
return await permision.requestAndroidPermission('android.permission.RECORD_AUDIO')
|
||||||
},
|
},
|
||||||
// 录制语音消息
|
// 录制语音消息
|
||||||
startRecord() {
|
startRecord() {
|
||||||
this.getAndroidPermission().then(code => {
|
this.getAndroidPermission().then(code => {
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case 1:
|
case 1:
|
||||||
@@ -78,21 +100,63 @@
|
|||||||
},
|
},
|
||||||
// 结束录音
|
// 结束录音
|
||||||
stopRecord(e) {
|
stopRecord(e) {
|
||||||
if (!this.showRecordTip) return
|
if (!this.showRecordTip) return
|
||||||
this.recorderManager.stop()
|
// 延迟500毫秒结束录音
|
||||||
clearInterval(this.interval)
|
setTimeout(()=> {
|
||||||
// 监听录音结束
|
this.recorderManager.stop()
|
||||||
this.recorderManager.onStop(res => {
|
clearInterval(this.interval)
|
||||||
im.sentVoice(this.conversationType, this.targetId, res.tempFilePath, (this.maxRecordTime -
|
// 监听录音结束
|
||||||
this.recordTime), this.sender, () => {
|
this.recorderManager.onStop(res => {
|
||||||
setTimeout(() => {
|
console.log(res)
|
||||||
this.$emit('success')
|
this.mp3AudioSrc = res.tempFilePath
|
||||||
}, 500)
|
this.showConfirm = true
|
||||||
})
|
this.showRecordTip = false
|
||||||
this.recordTime = this.maxRecordTime
|
})
|
||||||
this.showRecordTip = false
|
},500)
|
||||||
})
|
},
|
||||||
},
|
// 发送语音消息
|
||||||
|
senVoice(){
|
||||||
|
if(this.mp3AudioSrc === null) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '发送失败, 暂无音频信息',
|
||||||
|
icon : 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
im.sentVoice(this.conversationType, this.targetId, this.mp3AudioSrc, (this.maxRecordTime -
|
||||||
|
this.recordTime), this.sender, () => {
|
||||||
|
this.recordTime = this.maxRecordTime
|
||||||
|
this.mp3AudioSrc = null
|
||||||
|
this.showConfirm = false
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$emit('success')
|
||||||
|
}, 500)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 试听语音
|
||||||
|
startPlay() {
|
||||||
|
let betaAudio = uni.createInnerAudioContext()
|
||||||
|
betaAudio.src = this.mp3AudioSrc;
|
||||||
|
// 在播放中
|
||||||
|
if(this.isBetaPlay){
|
||||||
|
betaAudio.stop()
|
||||||
|
betaAudio.onStop(() => {
|
||||||
|
this.isBetaPlay = false;
|
||||||
|
betaAudio.destroy()
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 监听音频播放中
|
||||||
|
betaAudio.play()
|
||||||
|
betaAudio.onPlay(() => {
|
||||||
|
this.isBetaPlay = true;
|
||||||
|
})
|
||||||
|
// 监听音频结束
|
||||||
|
betaAudio.onEnded(() => {
|
||||||
|
this.isBetaPlay = false;
|
||||||
|
betaAudio.destroy()
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -114,6 +178,37 @@
|
|||||||
font-size: 30rpx;
|
font-size: 30rpx;
|
||||||
color: #333;
|
color: #333;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
.lay{
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
bottom: 0;
|
||||||
|
z-index: 9;
|
||||||
|
background: rgba($color: #000000, $alpha: .5);
|
||||||
|
height: 100vh;
|
||||||
|
width: 100vw;
|
||||||
|
padding: 20vh 30rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-around;
|
||||||
|
align-items: flex-end;
|
||||||
|
flex-direction: row;
|
||||||
|
.item{
|
||||||
|
height: 140rpx;
|
||||||
|
width: 140rpx;
|
||||||
|
text-align: center;
|
||||||
|
line-height: 140rpx;
|
||||||
|
border-radius: 50%;
|
||||||
|
background-color: white;
|
||||||
|
&.red{
|
||||||
|
background: #e6576b;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
&.greed{
|
||||||
|
background: #34CE98;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal {
|
.modal {
|
||||||
|
|||||||
@@ -55,8 +55,7 @@ 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 = () => {
|
||||||
@@ -68,7 +67,7 @@ const imLibListeners = () => {
|
|||||||
// 添加消息监听函数
|
// 添加消息监听函数
|
||||||
IMLib.addReceiveMessageListener((res) => {
|
IMLib.addReceiveMessageListener((res) => {
|
||||||
const message = res.data.message
|
const message = res.data.message
|
||||||
console.error('[收到消息]', message)
|
console.error('[收到消息]',IMLib.ObjectName.GroupNotification, message)
|
||||||
checkContactExists(message)
|
checkContactExists(message)
|
||||||
if (utils.inArray(message.objectName, notifyMsgTypes)) {
|
if (utils.inArray(message.objectName, notifyMsgTypes)) {
|
||||||
onReceiveMessage(message)
|
onReceiveMessage(message)
|
||||||
@@ -83,7 +82,8 @@ const imLibListeners = () => {
|
|||||||
uni.$emit('onNewContactConversation', message)
|
uni.$emit('onNewContactConversation', message)
|
||||||
uni.$emit('onNewContactFriends', message)
|
uni.$emit('onNewContactFriends', message)
|
||||||
uni.$emit('onNewContactPendings', message)
|
uni.$emit('onNewContactPendings', message)
|
||||||
} else if (message.objectName === IMLib.ObjectName.GroupNotification) {
|
} else if (message.objectName === IMLib.ObjectName.GroupNotification) {
|
||||||
|
console.log('踢出用户',message);
|
||||||
// 解散群
|
// 解散群
|
||||||
if (message.content.operation === 'Dismiss') {
|
if (message.content.operation === 'Dismiss') {
|
||||||
IMLib.cleanHistoryMessages(message.conversationType, message.targetId, message.sentTime,
|
IMLib.cleanHistoryMessages(message.conversationType, message.targetId, message.sentTime,
|
||||||
@@ -93,7 +93,8 @@ const imLibListeners = () => {
|
|||||||
// 发布群解散的消息
|
// 发布群解散的消息
|
||||||
uni.$emit('onGroupDismiss')
|
uni.$emit('onGroupDismiss')
|
||||||
uni.$emit('onGroupDismiss_' + message.targetId)
|
uni.$emit('onGroupDismiss_' + message.targetId)
|
||||||
} else if (message.content.operation === 'REMOVE') {
|
} else if (message.content.operation === 'REMOVE') {
|
||||||
|
console.log('踢出', message.content);
|
||||||
// 要判断是否当前用户,然后把当前用户踢出到主页去, 删除聊天记录,会话列表
|
// 要判断是否当前用户,然后把当前用户踢出到主页去, 删除聊天记录,会话列表
|
||||||
if (message.content.extra == store.getters.sender.userId) {
|
if (message.content.extra == store.getters.sender.userId) {
|
||||||
IMLib.cleanHistoryMessages(message.conversationType, message.targetId, message.sentTime,
|
IMLib.cleanHistoryMessages(message.conversationType, message.targetId, message.sentTime,
|
||||||
|
|||||||
Reference in New Issue
Block a user