文件消息,地理位置消息

This commit is contained in:
2022-02-28 16:28:14 +08:00
parent 39b8f158c0
commit bce7822e51
11 changed files with 505 additions and 223 deletions

View File

@@ -25,7 +25,7 @@
<text class="text">文件</text>
</view>
<tki-file-manager ref="filemanager" @result="resultPath"></tki-file-manager>
<tki-file-manager ref="filemanager" @result="sendFileMessage"></tki-file-manager>
<u-action-sheet :actions="callActions" cancelText="取消" @close="callShow = false" @select="singleCall"
:show="callShow">
@@ -42,9 +42,9 @@
mixins: [
imBase
],
components: [
components: {
tkiFileManager
],
},
data() {
return {
callActions: [{
@@ -74,10 +74,22 @@
}
},
methods: {
resultPath(path) {
im.sentFile(this.conversationType, this.targetId, path).then(res => {
console.log('发送文件', res);
})
sendFileMessage(path) {
if (path) {
im.sentFile(this.conversationType, this.targetId, path).then(res => {
this.success()
}).catch(err => {
uni.showToast({
icon: 'none',
title: '发送文件失败' + err
})
})
} else {
uni.showToast({
icon: 'none',
title: '选择文件失败'
})
}
},
singleCall(e) {
uni.navigateTo({
@@ -120,8 +132,10 @@
break;
case 'location':
uni.chooseLocation({
success: (c) => {
console.log(c);
success: (location) => {
im.sentLocation(this.conversationType, this.targetId, location).then(() => {
this.success()
})
}
})
break;
@@ -133,11 +147,6 @@
break;
case 'file':
this.$refs.filemanager._openFile()
// uni.showToast({
// icon: 'none',
// title: '功能正在开发中'
// })
break;
}
},

View File

@@ -0,0 +1,95 @@
<template>
<view class="msg--file">
<message-state :message="message" :isGroup="isGroup" :isRemote="isRemote" />
<view class="">
<view class="name" v-if="isGroup && isRemote">{{ contact(message.senderUserId).name }}</view>
<view class="file" :class="isRemote ? 'left': 'right'">
<view class="img">
{{ content.fileType }}
{{ content.name }}
</view>
</view>
</view>
</view>
</template>
<!-- "content": {
"fileType": "jpg",
"remote": "https://rongcloud-spic.ronghub.com/Xl1PRVpHVldeRQAGVgEHAAcBBgYGBgcDAwMGMjA3MA%3D%3D.jpg?e=1661583313&token=livk5rb3__JZjCtEiMxXpQ8QscLxbNLehwhHySnX:t58hs4uvM1RFsBeKLTcDbVW-k5w=",
"size": 347062,
"objectName": "RC:FileMsg",
"name": "Screenshot_2022-02-25-14-44-55-886_io.zhhealth.app.jpg",
"local": "file:///storage/emulated/0/DCIM/Screenshots/Screenshot_2022-02-25-14-44-55-886_io.zhhealth.app.jpg",
"userInfo": {
"userId": "10051",
"name": "Jason.电信",
"extra": "",
"portraitUrl": "http://storage.zh.shangkelian.cn/uploads/2022/02/16/29b13f5301694721ad7acd8b8b67bbd9.jpg"
}
}, -->
<script>
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
import messageState from './messageState'
import imBase from '../../mixins/imBase.js'
export default {
mixins: [
imBase
],
props: {
message: {
type: Object,
default: () => {
return {}
}
},
isGroup: {
type: Boolean,
default: false
}
},
components: {
messageState
},
computed: {
isRemote() {
return this.message.messageDirection == 2
},
content() {
return this.message.content
}
}
}
</script>
<style lang="scss" scoped>
.msg--file {
display: flex;
align-items: flex-end;
.name {
font-size: 24rpx;
color: $text-gray-m;
}
.file {
.img {
width: 180rpx;
}
&.left {
.img {
border-radius: 0 10rpx 10rpx 10rpx;
}
}
&.right {
.img {
border-radius: 10rpx 0 10rpx 10rpx;
}
}
}
}
</style>

View File

@@ -0,0 +1,86 @@
<template>
<view class="msg--location">
<message-state :message="message" :isGroup="isGroup" :isRemote="isRemote" />
<view class="">
<view class="name" v-if="isGroup && isRemote">{{ contact(message.senderUserId).name }}</view>
<view class="location" :class="isRemote ? 'left': 'right'" @click="showLocation">
{{ content.customFields.name }}
{{ content.customFields.thumbnail }}
<!-- 缩略图在考虑是否要通过截图后自动截屏来操作 -->
</view>
</view>
</view>
</template>
<script>
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
import messageState from './messageState'
import imBase from '../../mixins/imBase.js'
export default {
mixins: [
imBase
],
name: 'showImage',
props: {
message: {
type: Object,
default: () => {
return {}
}
},
isGroup: {
type: Boolean,
default: false
}
},
components: {
messageState
},
computed: {
isRemote() {
return this.message.messageDirection == 2
},
content() {
return this.message.content
}
},
methods: {
showLocation() {
console.log(this.content.customFields.longitude, this.content.customFields.latitude)
}
}
}
</script>
<style scoped lang="scss">
.msg--location {
display: flex;
align-items: flex-end;
.name {
font-size: 24rpx;
color: $text-gray-m;
}
.location {
.image {
width: 180rpx;
}
&.left {
.image {
border-radius: 0 10rpx 10rpx 10rpx;
}
}
&.right {
.image {
border-radius: 10rpx 0 10rpx 10rpx;
}
}
}
}
</style>

View File

@@ -0,0 +1,30 @@
<template>
<view class="">
<show-location v-if="message.content.objectName == 'RC:LBSMsg'" :message="message" :isGroup="isGroup" />
</view>
</template>
<script>
import showLocation from './showLocation'
export default {
props: {
message: {
type: Object,
default: () => {
return {}
}
},
isGroup: {
type: Boolean,
default: false
}
},
components: {
showLocation
}
}
</script>
<style>
</style>

View File

@@ -15,7 +15,10 @@
<show-text v-if="message.objectName === 'RC:TxtMsg'" :message="message" :isGroup="isGroup" />
<show-voice v-else-if="message.objectName === 'RC:HQVCMsg'" :message="message" :isGroup="isGroup" />
<show-image v-else-if="message.objectName === 'RC:ImgMsg'" :message="message" :isGroup="isGroup" />
<show-call v-else-if="message.objectName === 'RC:InfoNtf'" :message="message" :isGroup="isGroup" />
<show-call v-else-if="message.objectName === 'RC:InfoNtf'" :message="message" :isGroup="isGroup" />
<show-file v-else-if="message.objectName === 'RC:FileMsg'" :message="message" :isGroup="isGroup" />
<show-normal v-else-if="message.objectName === 'RC:IWNormalMsg'" :message="message" :isGroup="isGroup" />
<view v-else class="">
[未处理的消息类型 {{ message.objectName }}]
</view>
@@ -34,6 +37,8 @@
import showImage from './show/showImage'
import showText from './show/showText'
import showCall from './show/showCall'
import showFile from './show/showFile'
import showNormal from './show/showNormal'
import utils from '@/utils/index.js'
import imBase from '../mixins/imBase.js'
@@ -45,8 +50,10 @@
showCall,
showVoice,
showImage,
showText
},
showText,
showFile,
showNormal
},
props: {
message: {
type: Object,

View File

@@ -163,6 +163,7 @@
10,
false,
(messages) => {
console.log('获取最新消息', messages);
this.messages.unshift(...messages)
this.scrollBottom()
})

View File

@@ -106,8 +106,8 @@
code,
conversations
}) => {
if (code === 0) {
console.log(conversations,',,,,,')
if (code === 0) {
console.log('获取会话列表', conversations);
this.conversations = conversations
}
})