图片消息发送

This commit is contained in:
2022-02-07 17:22:09 +08:00
parent d27e8c4f58
commit 9b6cb99541
9 changed files with 221 additions and 162 deletions

View File

@@ -5,7 +5,7 @@
export default { export default {
onLaunch: function() { onLaunch: function() {
im.initIm('lmxuhwaglu76d') im.initIm('lmxuhwaglu76d')
// return return
//#ifdef APP-PLUS //#ifdef APP-PLUS
// 获取系统版本号 // 获取系统版本号
getVersions({ getVersions({

View File

@@ -22,7 +22,9 @@
"Payment" : {}, "Payment" : {},
"Share" : {}, "Share" : {},
"SQLite" : {}, "SQLite" : {},
"VideoPlayer" : {} "VideoPlayer" : {},
"Geolocation" : {},
"Fingerprint" : {}
}, },
/* */ /* */
"distribute" : { "distribute" : {
@@ -78,7 +80,17 @@
} }
}, },
"ad" : {}, "ad" : {},
"push" : {} "push" : {},
"geolocation" : {
"amap" : {
"__platform__" : [ "android" ],
"appkey_ios" : "",
"appkey_android" : "05b7f32ca9c897c8b63c505d92cd654b"
},
"system" : {
"__platform__" : [ "android" ]
}
}
}, },
"icons" : { "icons" : {
"android" : { "android" : {

View File

@@ -1,10 +1,10 @@
<template> <template>
<view class="sent--popups" v-if="show"> <view class="sent--popups u-border-top" v-if="show">
<view class="sent--popups--item" @click="onPopupsItem('picture')"> <view class="sent--popups--item" @click="onPopupsItem('picture')">
<image class="sent--popups--icon" src="@/static/icon/popups-icon-00.png" mode="widthFix"></image> <image class="sent--popups--icon" src="@/static/icon/popups-icon-00.png" mode="widthFix"></image>
<text class="sent--popups--text">相册</text> <text class="sent--popups--text">相册</text>
</view> </view>
<view class="sent--popups--item" @click="onPopupsItem('film')"> <view class="sent--popups--item" @click="onPopupsItem('camera')">
<image class="sent--popups--icon" src="@/static/icon/popups-icon-01.png" mode="widthFix"></image> <image class="sent--popups--icon" src="@/static/icon/popups-icon-01.png" mode="widthFix"></image>
<text class="sent--popups--text">拍摄</text> <text class="sent--popups--text">拍摄</text>
</view> </view>
@@ -24,91 +24,138 @@
<image class="sent--popups--icon" src="@/static/icon/popups-icon-05.png" mode="widthFix"></image> <image class="sent--popups--icon" src="@/static/icon/popups-icon-05.png" mode="widthFix"></image>
<text class="sent--popups--text">文件</text> <text class="sent--popups--text">文件</text>
</view> </view>
<u-action-sheet :actions="callActions" cancelText="取消" @close="callShow = false" @select="singleCall"
:show="callShow">
</u-action-sheet>
</view> </view>
</template> </template>
<script> <script>
import im from '@/utils/im/index.js'
export default { export default {
data() { data() {
return { return {
callActions: [{
}; type: 0,
name: '语音通话'
}, },
props:{ {
type: 1,
name: '视频通话'
}
],
callShow: false
}
},
props: {
show: { show: {
type: Boolean, type: Boolean,
default: false default: false
},
conversationType: {
type: Number,
default: 0
},
targetId: {
type: String,
default: ''
} }
}, },
methods:{ methods: {
onPopupsItem(type){ singleCall(e) {
switch (type){ uni.showToast({
icon: 'none',
title: '功能正在开发中'
})
// CallLib.startSingleCall(this.targetId, e.type, '');
// uni.redirectTo({
// url: '/pages/im/private/call?targetId=' + this.targetId + '&mediaType=' + e.type
// })
},
onPopupsItem(type) {
switch (type) {
case 'picture': case 'picture':
uni.chooseImage({ uni.chooseImage({
count: 9, count: 9,
sourceType: ['album'], sourceType: ['album'],
success: res => { success: res => {
this.onSentValue(type, res.tempFilePaths) im.sentImage(this.conversationType, this.targetId, res.tempFilePaths[0], (
res) => {
this.success()
})
} }
}) })
break; break;
case 'film': case 'camera':
uni.chooseImage({ uni.chooseImage({
sourceType: ['camera'], sourceType: ['camera'],
success: res => { success: res => {
this.onSentValue(type, res.tempFilePaths) im.sentImage(this.conversationType, this.targetId, res.tempFilePaths[0], (
res) => {
this.success()
})
} }
}) })
break; break;
case 'video': case 'video':
this.onSentValue(type, {}) this.callShow = true
break; break;
case 'location': case 'location':
uni.chooseLocation({ uni.showToast({
success: res=> { icon: 'none',
this.onSentValue(type, { title: '功能正在开发中'
address: res.address,
longitude: res.longitude,
latitude: res.latitude,
name: res.name
})
}
}) })
// uni.chooseLocation({
// success: res => {
// console.log(res);
// this.success()
// }
// })
break; break;
case 'redpacket': case 'redpacket':
console.log('红包') uni.showToast({
icon: 'none',
title: '功能正在开发中'
})
break; break;
case 'file': case 'file':
console.log('文件选择') uni.showToast({
icon: 'none',
title: '功能正在开发中'
})
break; break;
} }
}, },
// 处理返回 // 处理返回
onSentValue(type, value){ success() {
this.$emit('onVlaue', { type, value }) this.$emit('success')
this.show = false
} }
} }
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.sent--popups{ .sent--popups {
background: white; background: white;
padding: 30rpx 15rpx; padding: 30rpx 15rpx;
flex-wrap: wrap; flex-wrap: wrap;
flex-direction: row; flex-direction: row;
&--item{
&--item {
width: 150rpx; width: 150rpx;
margin: 15rpx; margin: 15rpx;
} }
&--text{
&--text {
text-align: center; text-align: center;
font-size: 26rpx; font-size: 26rpx;
color: #555; color: #555;
padding-top: 15rpx; padding-top: 15rpx;
} }
&--icon{
&--icon {
width: 110rpx; width: 110rpx;
height: 110rpx; height: 110rpx;
margin: 0 20rpx; margin: 0 20rpx;

View File

@@ -7,7 +7,7 @@
<script> <script>
import im from '@/utils/im/index.js' import im from '@/utils/im/index.js'
import * as RongIMLib from "@/uni_modules/RongCloud-IMWrapper/js_sdk/index" import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
export default { export default {
props: { props: {

View File

@@ -13,7 +13,7 @@
<script> <script>
import im from '@/utils/im/index.js' import im from '@/utils/im/index.js'
import permision from "@/utils/permission.js" import permision from '@/utils/permission.js'
export default { export default {
props: { props: {

View File

@@ -1,6 +1,6 @@
<template> <template>
<view class="im--img" :class="guest ? 'right': 'left'"> <view class="im--img" :class="guest ? 'right': 'left'">
<image class="src" :src="msg" @click="openImg" mode="widthFix"></image> <image class="src" :src="msg.thumbnail" @click="previewImage" mode="widthFix"></image>
</view> </view>
</template> </template>
@@ -9,8 +9,8 @@
name: 'showImage', name: 'showImage',
props: { props: {
msg: { msg: {
type: String, type: Object,
default: 'https://images.pexels.com/photos/9024609/pexels-photo-9024609.jpeg' default: {}
}, },
guest: { guest: {
type: Boolean, type: Boolean,
@@ -18,9 +18,11 @@
} }
}, },
methods: { methods: {
openImg() { previewImage() {
uni.previewImage({ uni.previewImage({
urls: [this.msg], urls: [
this.msg.remote
],
current: 1 current: 1
}) })
} }

View File

@@ -1,6 +1,6 @@
<template> <template>
<view class="im--box"> <view class="im--box">
<text class="im--text" :class="guest ? 'right': 'left'">{{msg}}</text> <text class="im--text" :class="guest ? 'right': 'left'">{{ msg.content }}</text>
</view> </view>
</template> </template>
@@ -14,8 +14,8 @@
}, },
props: { props: {
msg: { msg: {
type: String, type: Object,
default: '' default: {}
}, },
guest: { guest: {
type: Boolean, type: Boolean,

View File

@@ -13,9 +13,9 @@
<show-voice v-if="item.objectName === 'RC:HQVCMsg'" :guest="item.messageDirection == 1" <show-voice v-if="item.objectName === 'RC:HQVCMsg'" :guest="item.messageDirection == 1"
:msg="item.content" /> :msg="item.content" />
<show-image v-if="item.objectName === 'RC:ImgMsg'" :guest="item.messageDirection == 1" <show-image v-if="item.objectName === 'RC:ImgMsg'" :guest="item.messageDirection == 1"
:msg="item.content.content" /> :msg="item.content" />
<show-text v-if="item.objectName === 'RC:TxtMsg'" :guest="item.messageDirection == 1" <show-text v-if="item.objectName === 'RC:TxtMsg'" :guest="item.messageDirection == 1"
:msg="item.content.content" /> :msg="item.content" />
<view class="state" v-if="item.messageDirection == 1"> <view class="state" v-if="item.messageDirection == 1">
<text class="state-text">{{ item.sentStatus == 50 ? '已读': '未读'}}</text> <text class="state-text">{{ item.sentStatus == 50 ? '已读': '未读'}}</text>
</view> </view>
@@ -32,21 +32,25 @@
<image class="msg-type-icon" src="@/static/icon/msg-icon.png" v-if="chatType === 1" mode="widthFix"> <image class="msg-type-icon" src="@/static/icon/msg-icon.png" v-if="chatType === 1" mode="widthFix">
</image> </image>
</view> </view>
<sent-voice v-if="chatType === 0" :conversationType="conversationType" :targetId="targetId" @success="getMessageList" /> <sent-voice v-if="chatType === 0" :conversationType="conversationType" :targetId="targetId"
<sent-text v-if="chatType === 1" :conversationType="conversationType" :targetId="targetId" @success="getMessageList" /> @success="getMessageList" />
<sent-text v-if="chatType === 1" :conversationType="conversationType" :targetId="targetId"
@success="getMessageList" />
<view class="msg-type msg-push" @click="showPopups = !showPopups"> <view class="msg-type msg-push" @click="showPopups = !showPopups">
<image class="msg-type-icon" src="@/static/icon/popups-icon.png"></image> <image class="msg-type-icon" src="@/static/icon/popups-icon.png"></image>
</view> </view>
</view> </view>
<!-- 弹出层 --> <!-- 弹出层 -->
<u-line v-if="showPopups" color="#f5f5f5"></u-line> <sent-popups :show="showPopups" :conversationType="conversationType" :targetId="targetId"
<sent-popups :show="showPopups" @onVlaue="onValue"></sent-popups> @success="() => {showPopups = false, getMessageList()}"></sent-popups>
</view> </view>
</template> </template>
<script> <script>
import { timeCustomCN } from '@/utils/filters.js' import {
import * as RongIMLib from "@/uni_modules/RongCloud-IMWrapper/js_sdk/index" timeCustomCN
} from '@/utils/filters.js'
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'
import showVoice from '../components/showVoice' import showVoice from '../components/showVoice'
import showImage from '../components/showImage' import showImage from '../components/showImage'
@@ -68,7 +72,7 @@
userId: '', userId: '',
portraitUrl: '' portraitUrl: ''
}, },
chatType: 1 ,// 0 语音1 文本 chatType: 1, // 0 语音1 文本
showPopups: false showPopups: false
} }
}, },
@@ -133,7 +137,7 @@
10, 10,
true, true,
(messages) => { (messages) => {
console.log(messages); console.log('获取到的消息', messages);
this.messages = messages.reverse() this.messages = messages.reverse()
this.scrollBottom() this.scrollBottom()
}) })
@@ -153,11 +157,6 @@
animated: false animated: false
}) })
}, 50) }, 50)
},
// 上传文件信息
onValue(e){
this.showPopups = false
console.log(e)
} }
} }
} }

View File

@@ -107,14 +107,13 @@ const sentVoice = (conversationType, targetId, voiceUrl, time, callback) => {
}) })
} }
const sentImage = (conversationType, targetId, imageUrl, time, callback) => { const sentImage = (conversationType, targetId, imageUrl, callback) => {
const msg = { const msg = {
conversationType: conversationType, conversationType: conversationType,
targetId: String(targetId), targetId: String(targetId),
content: { content: {
objectName: 'RC:ImgMsg', objectName: 'RC:ImgMsg',
local: 'file:///' + plus.io.convertLocalFileSystemURL(imageUrl), local: 'file:///' + plus.io.convertLocalFileSystemURL(imageUrl)
duration: time
} }
} }
RongIMLib.sendMediaMessage(msg, { RongIMLib.sendMediaMessage(msg, {