图片消息发送
This commit is contained in:
2
App.vue
2
App.vue
@@ -5,7 +5,7 @@
|
||||
export default {
|
||||
onLaunch: function() {
|
||||
im.initIm('lmxuhwaglu76d')
|
||||
// return
|
||||
return
|
||||
//#ifdef APP-PLUS
|
||||
// 获取系统版本号
|
||||
getVersions({
|
||||
|
||||
@@ -22,7 +22,9 @@
|
||||
"Payment" : {},
|
||||
"Share" : {},
|
||||
"SQLite" : {},
|
||||
"VideoPlayer" : {}
|
||||
"VideoPlayer" : {},
|
||||
"Geolocation" : {},
|
||||
"Fingerprint" : {}
|
||||
},
|
||||
/* 应用发布信息 */
|
||||
"distribute" : {
|
||||
@@ -78,7 +80,17 @@
|
||||
}
|
||||
},
|
||||
"ad" : {},
|
||||
"push" : {}
|
||||
"push" : {},
|
||||
"geolocation" : {
|
||||
"amap" : {
|
||||
"__platform__" : [ "android" ],
|
||||
"appkey_ios" : "",
|
||||
"appkey_android" : "05b7f32ca9c897c8b63c505d92cd654b"
|
||||
},
|
||||
"system" : {
|
||||
"__platform__" : [ "android" ]
|
||||
}
|
||||
}
|
||||
},
|
||||
"icons" : {
|
||||
"android" : {
|
||||
|
||||
@@ -1,119 +1,166 @@
|
||||
<template>
|
||||
<view class="sent--popups" v-if="show">
|
||||
<view class="sent--popups--item" @click="onPopupsItem('picture')">
|
||||
<image class="sent--popups--icon" src="@/static/icon/popups-icon-00.png" mode="widthFix"></image>
|
||||
<text class="sent--popups--text">相册</text>
|
||||
</view>
|
||||
<view class="sent--popups--item" @click="onPopupsItem('film')">
|
||||
<image class="sent--popups--icon" src="@/static/icon/popups-icon-01.png" mode="widthFix"></image>
|
||||
<text class="sent--popups--text">拍摄</text>
|
||||
</view>
|
||||
<view class="sent--popups--item" @click="onPopupsItem('video')">
|
||||
<image class="sent--popups--icon" src="@/static/icon/popups-icon-02.png" mode="widthFix"></image>
|
||||
<text class="sent--popups--text">视频通话</text>
|
||||
</view>
|
||||
<view class="sent--popups--item" @click="onPopupsItem('location')">
|
||||
<image class="sent--popups--icon" src="@/static/icon/popups-icon-03.png" mode="widthFix"></image>
|
||||
<text class="sent--popups--text">位置</text>
|
||||
</view>
|
||||
<view class="sent--popups--item" @click="onPopupsItem('redpacket')">
|
||||
<image class="sent--popups--icon" src="@/static/icon/popups-icon-04.png" mode="widthFix"></image>
|
||||
<text class="sent--popups--text">红包</text>
|
||||
</view>
|
||||
<view class="sent--popups--item" @click="onPopupsItem('file')">
|
||||
<image class="sent--popups--icon" src="@/static/icon/popups-icon-05.png" mode="widthFix"></image>
|
||||
<text class="sent--popups--text">文件</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
|
||||
};
|
||||
},
|
||||
props:{
|
||||
show: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
methods:{
|
||||
onPopupsItem(type){
|
||||
switch (type){
|
||||
case 'picture':
|
||||
uni.chooseImage({
|
||||
count: 9,
|
||||
sourceType: ['album'],
|
||||
success: res => {
|
||||
this.onSentValue(type, res.tempFilePaths)
|
||||
}
|
||||
})
|
||||
break;
|
||||
case 'film':
|
||||
uni.chooseImage({
|
||||
sourceType: ['camera'],
|
||||
success: res => {
|
||||
this.onSentValue(type, res.tempFilePaths)
|
||||
}
|
||||
})
|
||||
break;
|
||||
case 'video':
|
||||
this.onSentValue(type, {})
|
||||
break;
|
||||
case 'location':
|
||||
uni.chooseLocation({
|
||||
success: res=> {
|
||||
this.onSentValue(type, {
|
||||
address: res.address,
|
||||
longitude: res.longitude,
|
||||
latitude: res.latitude,
|
||||
name: res.name
|
||||
})
|
||||
}
|
||||
})
|
||||
break;
|
||||
case 'redpacket':
|
||||
console.log('红包')
|
||||
break;
|
||||
case 'file':
|
||||
console.log('文件选择')
|
||||
break;
|
||||
}
|
||||
},
|
||||
// 处理返回
|
||||
onSentValue(type, value){
|
||||
this.$emit('onVlaue', { type, value })
|
||||
this.show = false
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.sent--popups{
|
||||
background: white;
|
||||
padding: 30rpx 15rpx;
|
||||
flex-wrap: wrap;
|
||||
flex-direction: row;
|
||||
&--item{
|
||||
width: 150rpx;
|
||||
margin: 15rpx;
|
||||
}
|
||||
&--text{
|
||||
text-align: center;
|
||||
font-size: 26rpx;
|
||||
color: #555;
|
||||
padding-top: 15rpx;
|
||||
}
|
||||
&--icon{
|
||||
width: 110rpx;
|
||||
height: 110rpx;
|
||||
margin: 0 20rpx;
|
||||
border-radius: 20rpx;
|
||||
background: #F3F6FB;
|
||||
}
|
||||
}
|
||||
<template>
|
||||
<view class="sent--popups u-border-top" v-if="show">
|
||||
<view class="sent--popups--item" @click="onPopupsItem('picture')">
|
||||
<image class="sent--popups--icon" src="@/static/icon/popups-icon-00.png" mode="widthFix"></image>
|
||||
<text class="sent--popups--text">相册</text>
|
||||
</view>
|
||||
<view class="sent--popups--item" @click="onPopupsItem('camera')">
|
||||
<image class="sent--popups--icon" src="@/static/icon/popups-icon-01.png" mode="widthFix"></image>
|
||||
<text class="sent--popups--text">拍摄</text>
|
||||
</view>
|
||||
<view class="sent--popups--item" @click="onPopupsItem('video')">
|
||||
<image class="sent--popups--icon" src="@/static/icon/popups-icon-02.png" mode="widthFix"></image>
|
||||
<text class="sent--popups--text">视频通话</text>
|
||||
</view>
|
||||
<view class="sent--popups--item" @click="onPopupsItem('location')">
|
||||
<image class="sent--popups--icon" src="@/static/icon/popups-icon-03.png" mode="widthFix"></image>
|
||||
<text class="sent--popups--text">位置</text>
|
||||
</view>
|
||||
<view class="sent--popups--item" @click="onPopupsItem('redpacket')">
|
||||
<image class="sent--popups--icon" src="@/static/icon/popups-icon-04.png" mode="widthFix"></image>
|
||||
<text class="sent--popups--text">红包</text>
|
||||
</view>
|
||||
<view class="sent--popups--item" @click="onPopupsItem('file')">
|
||||
<image class="sent--popups--icon" src="@/static/icon/popups-icon-05.png" mode="widthFix"></image>
|
||||
<text class="sent--popups--text">文件</text>
|
||||
</view>
|
||||
|
||||
<u-action-sheet :actions="callActions" cancelText="取消" @close="callShow = false" @select="singleCall"
|
||||
:show="callShow">
|
||||
</u-action-sheet>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import im from '@/utils/im/index.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
callActions: [{
|
||||
type: 0,
|
||||
name: '语音通话'
|
||||
},
|
||||
{
|
||||
type: 1,
|
||||
name: '视频通话'
|
||||
}
|
||||
],
|
||||
callShow: false
|
||||
}
|
||||
},
|
||||
props: {
|
||||
show: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
conversationType: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
targetId: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
singleCall(e) {
|
||||
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':
|
||||
uni.chooseImage({
|
||||
count: 9,
|
||||
sourceType: ['album'],
|
||||
success: res => {
|
||||
im.sentImage(this.conversationType, this.targetId, res.tempFilePaths[0], (
|
||||
res) => {
|
||||
this.success()
|
||||
})
|
||||
}
|
||||
})
|
||||
break;
|
||||
case 'camera':
|
||||
uni.chooseImage({
|
||||
sourceType: ['camera'],
|
||||
success: res => {
|
||||
im.sentImage(this.conversationType, this.targetId, res.tempFilePaths[0], (
|
||||
res) => {
|
||||
this.success()
|
||||
})
|
||||
}
|
||||
})
|
||||
break;
|
||||
case 'video':
|
||||
this.callShow = true
|
||||
break;
|
||||
case 'location':
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '功能正在开发中'
|
||||
})
|
||||
// uni.chooseLocation({
|
||||
// success: res => {
|
||||
// console.log(res);
|
||||
// this.success()
|
||||
// }
|
||||
// })
|
||||
break;
|
||||
case 'redpacket':
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '功能正在开发中'
|
||||
})
|
||||
break;
|
||||
case 'file':
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '功能正在开发中'
|
||||
})
|
||||
break;
|
||||
}
|
||||
},
|
||||
// 处理返回
|
||||
success() {
|
||||
this.$emit('success')
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.sent--popups {
|
||||
background: white;
|
||||
padding: 30rpx 15rpx;
|
||||
flex-wrap: wrap;
|
||||
flex-direction: row;
|
||||
|
||||
&--item {
|
||||
width: 150rpx;
|
||||
margin: 15rpx;
|
||||
}
|
||||
|
||||
&--text {
|
||||
text-align: center;
|
||||
font-size: 26rpx;
|
||||
color: #555;
|
||||
padding-top: 15rpx;
|
||||
}
|
||||
|
||||
&--icon {
|
||||
width: 110rpx;
|
||||
height: 110rpx;
|
||||
margin: 0 20rpx;
|
||||
border-radius: 20rpx;
|
||||
background: #F3F6FB;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
<script>
|
||||
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 {
|
||||
props: {
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
<script>
|
||||
import im from '@/utils/im/index.js'
|
||||
import permision from "@/utils/permission.js"
|
||||
import permision from '@/utils/permission.js'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<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>
|
||||
</template>
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
name: 'showImage',
|
||||
props: {
|
||||
msg: {
|
||||
type: String,
|
||||
default: 'https://images.pexels.com/photos/9024609/pexels-photo-9024609.jpeg'
|
||||
type: Object,
|
||||
default: {}
|
||||
},
|
||||
guest: {
|
||||
type: Boolean,
|
||||
@@ -18,9 +18,11 @@
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
openImg() {
|
||||
previewImage() {
|
||||
uni.previewImage({
|
||||
urls: [this.msg],
|
||||
urls: [
|
||||
this.msg.remote
|
||||
],
|
||||
current: 1
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<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>
|
||||
</template>
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
},
|
||||
props: {
|
||||
msg: {
|
||||
type: String,
|
||||
default: ''
|
||||
type: Object,
|
||||
default: {}
|
||||
},
|
||||
guest: {
|
||||
type: Boolean,
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
<show-voice v-if="item.objectName === 'RC:HQVCMsg'" :guest="item.messageDirection == 1"
|
||||
:msg="item.content" />
|
||||
<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"
|
||||
:msg="item.content.content" />
|
||||
:msg="item.content" />
|
||||
<view class="state" v-if="item.messageDirection == 1">
|
||||
<text class="state-text">{{ item.sentStatus == 50 ? '已读': '未读'}}</text>
|
||||
</view>
|
||||
@@ -24,7 +24,7 @@
|
||||
</cell>
|
||||
<cell class="cell-footer" ref="chatBottom"></cell>
|
||||
</list>
|
||||
<!-- footer -->
|
||||
<!-- footer -->
|
||||
<view class="chat-footer">
|
||||
<view class="msg-type" @click="changeMessageType">
|
||||
<image class="msg-type-icon" src="@/static/icon/key-icon.png" v-if="chatType === 0" mode="widthFix">
|
||||
@@ -32,30 +32,34 @@
|
||||
<image class="msg-type-icon" src="@/static/icon/msg-icon.png" v-if="chatType === 1" mode="widthFix">
|
||||
</image>
|
||||
</view>
|
||||
<sent-voice v-if="chatType === 0" :conversationType="conversationType" :targetId="targetId" @success="getMessageList" />
|
||||
<sent-text v-if="chatType === 1" :conversationType="conversationType" :targetId="targetId" @success="getMessageList" />
|
||||
<view class="msg-type msg-push" @click="showPopups = !showPopups">
|
||||
<image class="msg-type-icon" src="@/static/icon/popups-icon.png"></image>
|
||||
<sent-voice v-if="chatType === 0" :conversationType="conversationType" :targetId="targetId"
|
||||
@success="getMessageList" />
|
||||
<sent-text v-if="chatType === 1" :conversationType="conversationType" :targetId="targetId"
|
||||
@success="getMessageList" />
|
||||
<view class="msg-type msg-push" @click="showPopups = !showPopups">
|
||||
<image class="msg-type-icon" src="@/static/icon/popups-icon.png"></image>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 弹出层 -->
|
||||
<u-line v-if="showPopups" color="#f5f5f5"></u-line>
|
||||
<sent-popups :show="showPopups" @onVlaue="onValue"></sent-popups>
|
||||
</view>
|
||||
<!-- 弹出层 -->
|
||||
<sent-popups :show="showPopups" :conversationType="conversationType" :targetId="targetId"
|
||||
@success="() => {showPopups = false, getMessageList()}"></sent-popups>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { timeCustomCN } from '@/utils/filters.js'
|
||||
import * as RongIMLib from "@/uni_modules/RongCloud-IMWrapper/js_sdk/index"
|
||||
import {
|
||||
timeCustomCN
|
||||
} from '@/utils/filters.js'
|
||||
import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index'
|
||||
import im from '@/utils/im/index.js'
|
||||
import showVoice from '../components/showVoice'
|
||||
import showImage from '../components/showImage'
|
||||
import showText from '../components/showText'
|
||||
import sentText from '../components/sentText'
|
||||
import sentVoice from '../components/sentVoice'
|
||||
import sentPopups from '../components/sentPopups'
|
||||
import sentPopups from '../components/sentPopups'
|
||||
|
||||
const ChatList = uni.requireNativePlugin('dom')
|
||||
const ChatList = uni.requireNativePlugin('dom')
|
||||
|
||||
export default {
|
||||
data() {
|
||||
@@ -68,7 +72,7 @@
|
||||
userId: '',
|
||||
portraitUrl: ''
|
||||
},
|
||||
chatType: 1 ,// 0 语音,1 文本
|
||||
chatType: 1, // 0 语音,1 文本
|
||||
showPopups: false
|
||||
}
|
||||
},
|
||||
@@ -77,7 +81,7 @@
|
||||
showImage,
|
||||
showText,
|
||||
sentText,
|
||||
sentVoice,
|
||||
sentVoice,
|
||||
sentPopups
|
||||
},
|
||||
onLoad(e) {
|
||||
@@ -125,15 +129,15 @@
|
||||
this.chatType = this.chatType === 1 ? 0 : 1
|
||||
},
|
||||
// 获取消息列表
|
||||
getMessageList() {
|
||||
getMessageList() {
|
||||
im.getMessageList(
|
||||
this.conversationType,
|
||||
this.targetId,
|
||||
new Date().getTime(),
|
||||
10,
|
||||
this.targetId,
|
||||
new Date().getTime(),
|
||||
10,
|
||||
true,
|
||||
(messages) => {
|
||||
console.log(messages);
|
||||
(messages) => {
|
||||
console.log('获取到的消息', messages);
|
||||
this.messages = messages.reverse()
|
||||
this.scrollBottom()
|
||||
})
|
||||
@@ -153,11 +157,6 @@
|
||||
animated: false
|
||||
})
|
||||
}, 50)
|
||||
},
|
||||
// 上传文件信息
|
||||
onValue(e){
|
||||
this.showPopups = false
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 = {
|
||||
conversationType: conversationType,
|
||||
targetId: String(targetId),
|
||||
content: {
|
||||
objectName: 'RC:ImgMsg',
|
||||
local: 'file:///' + plus.io.convertLocalFileSystemURL(imageUrl),
|
||||
duration: time
|
||||
local: 'file:///' + plus.io.convertLocalFileSystemURL(imageUrl)
|
||||
}
|
||||
}
|
||||
RongIMLib.sendMediaMessage(msg, {
|
||||
|
||||
Reference in New Issue
Block a user