文件消息,地理位置消息
This commit is contained in:
@@ -3,12 +3,11 @@
|
|||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'tki-file-manager',
|
name: 'tki-file-manager',
|
||||||
props: {},
|
props: {},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
_openFile() {
|
_openFile() {
|
||||||
@@ -17,7 +16,7 @@ export default {
|
|||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: '提示',
|
title: '提示',
|
||||||
content: '仅支持Android平台',
|
content: '仅支持Android平台',
|
||||||
success: function (res) {}
|
success: function(res) {}
|
||||||
});
|
});
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -36,7 +35,7 @@ export default {
|
|||||||
fileIntent.addCategory(Intent.CATEGORY_OPENABLE);
|
fileIntent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||||
main.startActivityForResult(fileIntent, 1);
|
main.startActivityForResult(fileIntent, 1);
|
||||||
// 获取回调
|
// 获取回调
|
||||||
main.onActivityResult = function (requestCode, resultCode, data) {
|
main.onActivityResult = function(requestCode, resultCode, data) {
|
||||||
let Activity = plus.android.importClass("android.app.Activity");
|
let Activity = plus.android.importClass("android.app.Activity");
|
||||||
let ContentUris = plus.android.importClass("android.content.ContentUris");
|
let ContentUris = plus.android.importClass("android.content.ContentUris");
|
||||||
let Cursor = plus.android.importClass("android.database.Cursor");
|
let Cursor = plus.android.importClass("android.database.Cursor");
|
||||||
@@ -52,6 +51,7 @@ export default {
|
|||||||
let path = '';
|
let path = '';
|
||||||
if (resultCode == Activity.RESULT_OK) {
|
if (resultCode == Activity.RESULT_OK) {
|
||||||
let uri = data.getData()
|
let uri = data.getData()
|
||||||
|
|
||||||
if ("file" == uri.getScheme().toLowerCase()) { //使用第三方应用打开
|
if ("file" == uri.getScheme().toLowerCase()) { //使用第三方应用打开
|
||||||
path = uri.getPath();
|
path = uri.getPath();
|
||||||
return;
|
return;
|
||||||
@@ -68,6 +68,7 @@ export default {
|
|||||||
function getPath(context, uri) {
|
function getPath(context, uri) {
|
||||||
let isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
|
let isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
|
||||||
let scheme = uri.getScheme().toLowerCase()
|
let scheme = uri.getScheme().toLowerCase()
|
||||||
|
|
||||||
if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) {
|
if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) {
|
||||||
// ExternalStorageProvider
|
// ExternalStorageProvider
|
||||||
if (isExternalStorageDocument(uri)) {
|
if (isExternalStorageDocument(uri)) {
|
||||||
@@ -83,8 +84,8 @@ export default {
|
|||||||
}
|
}
|
||||||
// DownloadsProvider
|
// DownloadsProvider
|
||||||
else if (isDownloadsDocument(uri)) {
|
else if (isDownloadsDocument(uri)) {
|
||||||
let id = DocumentsContract.getDocumentId(uri);
|
let docId = DocumentsContract.getDocumentId(uri);
|
||||||
let split = id.split(":");
|
let split = docId.split(":");
|
||||||
return split[1]
|
return split[1]
|
||||||
// console.log(id)
|
// console.log(id)
|
||||||
// let contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), id);
|
// let contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), id);
|
||||||
@@ -122,7 +123,8 @@ export default {
|
|||||||
let res = null
|
let res = null
|
||||||
let proj = [MediaStore.Images.Media.DATA]
|
let proj = [MediaStore.Images.Media.DATA]
|
||||||
let cursor = contentResolver.query(uri, proj, null, null, null);
|
let cursor = contentResolver.query(uri, proj, null, null, null);
|
||||||
if (null != cursor && cursor.moveToFirst()) { ;
|
if (null != cursor && cursor.moveToFirst()) {
|
||||||
|
;
|
||||||
let column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
|
let column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
|
||||||
res = cursor.getString(column_index);
|
res = cursor.getString(column_index);
|
||||||
cursor.close();
|
cursor.close();
|
||||||
@@ -142,12 +144,15 @@ export default {
|
|||||||
return cursor.getString(column_index);
|
return cursor.getString(column_index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isExternalStorageDocument(uri) {
|
function isExternalStorageDocument(uri) {
|
||||||
return "com.android.externalstorage.documents" == uri.getAuthority() ? true : false
|
return "com.android.externalstorage.documents" == uri.getAuthority() ? true : false
|
||||||
}
|
}
|
||||||
|
|
||||||
function isDownloadsDocument(uri) {
|
function isDownloadsDocument(uri) {
|
||||||
return "com.android.providers.downloads.documents" == uri.getAuthority() ? true : false
|
return "com.android.providers.downloads.documents" == uri.getAuthority() ? true : false
|
||||||
}
|
}
|
||||||
|
|
||||||
function isMediaDocument(uri) {
|
function isMediaDocument(uri) {
|
||||||
return "com.android.providers.media.documents" == uri.getAuthority() ? true : false
|
return "com.android.providers.media.documents" == uri.getAuthority() ? true : false
|
||||||
}
|
}
|
||||||
@@ -157,7 +162,7 @@ export default {
|
|||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: '提示',
|
title: '提示',
|
||||||
content: '仅支持Android平台',
|
content: '仅支持Android平台',
|
||||||
success: function (res) {
|
success: function(res) {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -179,5 +184,5 @@ export default {
|
|||||||
// console.log("Request file system failed: " + e.message);
|
// console.log("Request file system failed: " + e.message);
|
||||||
// });
|
// });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -47,6 +47,7 @@
|
|||||||
"<uses-permission android:name=\"android.permission.INTERNET\"/>",
|
"<uses-permission android:name=\"android.permission.INTERNET\"/>",
|
||||||
"<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>",
|
"<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>",
|
||||||
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
|
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\"/>",
|
||||||
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
|
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
|
||||||
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
|
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
|
||||||
"<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>",
|
"<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>",
|
||||||
@@ -112,33 +113,33 @@
|
|||||||
},
|
},
|
||||||
"icons" : {
|
"icons" : {
|
||||||
"android" : {
|
"android" : {
|
||||||
"hdpi" : "",
|
"hdpi" : "unpackage/res/icons/72x72.png",
|
||||||
"xhdpi" : "",
|
"xhdpi" : "unpackage/res/icons/96x96.png",
|
||||||
"xxhdpi" : "",
|
"xxhdpi" : "unpackage/res/icons/144x144.png",
|
||||||
"xxxhdpi" : ""
|
"xxxhdpi" : "unpackage/res/icons/192x192.png"
|
||||||
},
|
},
|
||||||
"ios" : {
|
"ios" : {
|
||||||
"appstore" : "",
|
"appstore" : "unpackage/res/icons/1024x1024.png",
|
||||||
"ipad" : {
|
"ipad" : {
|
||||||
"app" : "",
|
"app" : "unpackage/res/icons/76x76.png",
|
||||||
"app@2x" : "",
|
"app@2x" : "unpackage/res/icons/152x152.png",
|
||||||
"notification" : "",
|
"notification" : "unpackage/res/icons/20x20.png",
|
||||||
"notification@2x" : "",
|
"notification@2x" : "unpackage/res/icons/40x40.png",
|
||||||
"proapp@2x" : "",
|
"proapp@2x" : "unpackage/res/icons/167x167.png",
|
||||||
"settings" : "",
|
"settings" : "unpackage/res/icons/29x29.png",
|
||||||
"settings@2x" : "",
|
"settings@2x" : "unpackage/res/icons/58x58.png",
|
||||||
"spotlight" : "",
|
"spotlight" : "unpackage/res/icons/40x40.png",
|
||||||
"spotlight@2x" : ""
|
"spotlight@2x" : "unpackage/res/icons/80x80.png"
|
||||||
},
|
},
|
||||||
"iphone" : {
|
"iphone" : {
|
||||||
"app@2x" : "",
|
"app@2x" : "unpackage/res/icons/120x120.png",
|
||||||
"app@3x" : "",
|
"app@3x" : "unpackage/res/icons/180x180.png",
|
||||||
"notification@2x" : "",
|
"notification@2x" : "unpackage/res/icons/40x40.png",
|
||||||
"notification@3x" : "",
|
"notification@3x" : "unpackage/res/icons/60x60.png",
|
||||||
"settings@2x" : "",
|
"settings@2x" : "unpackage/res/icons/58x58.png",
|
||||||
"settings@3x" : "",
|
"settings@3x" : "unpackage/res/icons/87x87.png",
|
||||||
"spotlight@2x" : "",
|
"spotlight@2x" : "unpackage/res/icons/80x80.png",
|
||||||
"spotlight@3x" : ""
|
"spotlight@3x" : "unpackage/res/icons/120x120.png"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
<text class="text">文件</text>
|
<text class="text">文件</text>
|
||||||
</view>
|
</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"
|
<u-action-sheet :actions="callActions" cancelText="取消" @close="callShow = false" @select="singleCall"
|
||||||
:show="callShow">
|
:show="callShow">
|
||||||
@@ -42,9 +42,9 @@
|
|||||||
mixins: [
|
mixins: [
|
||||||
imBase
|
imBase
|
||||||
],
|
],
|
||||||
components: [
|
components: {
|
||||||
tkiFileManager
|
tkiFileManager
|
||||||
],
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
callActions: [{
|
callActions: [{
|
||||||
@@ -74,10 +74,22 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
resultPath(path) {
|
sendFileMessage(path) {
|
||||||
|
if (path) {
|
||||||
im.sentFile(this.conversationType, this.targetId, path).then(res => {
|
im.sentFile(this.conversationType, this.targetId, path).then(res => {
|
||||||
console.log('发送文件', res);
|
this.success()
|
||||||
|
}).catch(err => {
|
||||||
|
uni.showToast({
|
||||||
|
icon: 'none',
|
||||||
|
title: '发送文件失败' + err
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
icon: 'none',
|
||||||
|
title: '选择文件失败'
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
singleCall(e) {
|
singleCall(e) {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
@@ -120,8 +132,10 @@
|
|||||||
break;
|
break;
|
||||||
case 'location':
|
case 'location':
|
||||||
uni.chooseLocation({
|
uni.chooseLocation({
|
||||||
success: (c) => {
|
success: (location) => {
|
||||||
console.log(c);
|
im.sentLocation(this.conversationType, this.targetId, location).then(() => {
|
||||||
|
this.success()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
break;
|
break;
|
||||||
@@ -133,11 +147,6 @@
|
|||||||
break;
|
break;
|
||||||
case 'file':
|
case 'file':
|
||||||
this.$refs.filemanager._openFile()
|
this.$refs.filemanager._openFile()
|
||||||
|
|
||||||
// uni.showToast({
|
|
||||||
// icon: 'none',
|
|
||||||
// title: '功能正在开发中'
|
|
||||||
// })
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
95
pages/im/components/show/showFile.vue
Normal file
95
pages/im/components/show/showFile.vue
Normal 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>
|
||||||
86
pages/im/components/show/showLocation.vue
Normal file
86
pages/im/components/show/showLocation.vue
Normal 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>
|
||||||
30
pages/im/components/show/showNormal.vue
Normal file
30
pages/im/components/show/showNormal.vue
Normal 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>
|
||||||
@@ -16,6 +16,9 @@
|
|||||||
<show-voice v-else-if="message.objectName === 'RC:HQVCMsg'" :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-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="">
|
<view v-else class="">
|
||||||
[未处理的消息类型 {{ message.objectName }}]
|
[未处理的消息类型 {{ message.objectName }}]
|
||||||
</view>
|
</view>
|
||||||
@@ -34,6 +37,8 @@
|
|||||||
import showImage from './show/showImage'
|
import showImage from './show/showImage'
|
||||||
import showText from './show/showText'
|
import showText from './show/showText'
|
||||||
import showCall from './show/showCall'
|
import showCall from './show/showCall'
|
||||||
|
import showFile from './show/showFile'
|
||||||
|
import showNormal from './show/showNormal'
|
||||||
import utils from '@/utils/index.js'
|
import utils from '@/utils/index.js'
|
||||||
import imBase from '../mixins/imBase.js'
|
import imBase from '../mixins/imBase.js'
|
||||||
|
|
||||||
@@ -45,7 +50,9 @@
|
|||||||
showCall,
|
showCall,
|
||||||
showVoice,
|
showVoice,
|
||||||
showImage,
|
showImage,
|
||||||
showText
|
showText,
|
||||||
|
showFile,
|
||||||
|
showNormal
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
message: {
|
message: {
|
||||||
|
|||||||
@@ -163,6 +163,7 @@
|
|||||||
10,
|
10,
|
||||||
false,
|
false,
|
||||||
(messages) => {
|
(messages) => {
|
||||||
|
console.log('获取最新消息', messages);
|
||||||
this.messages.unshift(...messages)
|
this.messages.unshift(...messages)
|
||||||
this.scrollBottom()
|
this.scrollBottom()
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -107,7 +107,7 @@
|
|||||||
conversations
|
conversations
|
||||||
}) => {
|
}) => {
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
console.log(conversations,',,,,,')
|
console.log('获取会话列表', conversations);
|
||||||
this.conversations = conversations
|
this.conversations = conversations
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -55,7 +55,8 @@ 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,
|
||||||
|
'RC:IWNormalMsg'
|
||||||
]
|
]
|
||||||
|
|
||||||
const imLibListeners = () => {
|
const imLibListeners = () => {
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ const getMessageList = (conversationType, targetId, timeStamp, count, isForward,
|
|||||||
'RC:CombineMsg',
|
'RC:CombineMsg',
|
||||||
'RC:GrpNtf',
|
'RC:GrpNtf',
|
||||||
'RC:InfoNtf',
|
'RC:InfoNtf',
|
||||||
'RC:RcNtf'
|
'RC:RcNtf',
|
||||||
|
'RC:IWNormalMsg'
|
||||||
]
|
]
|
||||||
|
|
||||||
RongIMLib.getHistoryMessagesByTimestamp(
|
RongIMLib.getHistoryMessagesByTimestamp(
|
||||||
@@ -184,10 +185,13 @@ const sentFile = (conversationType, targetId, fileUrl) => {
|
|||||||
targetId: String(targetId),
|
targetId: String(targetId),
|
||||||
content: {
|
content: {
|
||||||
objectName: 'RC:FileMsg',
|
objectName: 'RC:FileMsg',
|
||||||
local: 'file:///' + plus.io.convertLocalFileSystemURL(fileUrl),
|
local: plus.io.convertLocalFileSystemURL(fileUrl),
|
||||||
userInfo: store.getters.sender
|
userInfo: store.getters.sender
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('发送文件', msg);
|
||||||
|
|
||||||
RongIMLib.sendMediaMessage(msg, {
|
RongIMLib.sendMediaMessage(msg, {
|
||||||
success: (messageId) => {
|
success: (messageId) => {
|
||||||
resolve(messageId)
|
resolve(messageId)
|
||||||
@@ -201,6 +205,48 @@ const sentFile = (conversationType, targetId, fileUrl) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 发送地理位置
|
||||||
|
const sentLocation = (conversationType, targetId, location) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const msg = {
|
||||||
|
conversationType: conversationType,
|
||||||
|
targetId: String(targetId),
|
||||||
|
objectName: 'RC:LBSMsg',
|
||||||
|
content: {
|
||||||
|
customType: 2,
|
||||||
|
objectName: 'RC:LBSMsg',
|
||||||
|
customFields: {
|
||||||
|
name: location.name,
|
||||||
|
latitude: Number(location.latitude),
|
||||||
|
longitude: Number(location.longitude),
|
||||||
|
thumbnail: ''
|
||||||
|
},
|
||||||
|
userInfo: store.getters.sender,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RongIMLib.sendMessage(msg, ({
|
||||||
|
code,
|
||||||
|
messageId
|
||||||
|
}) => {
|
||||||
|
if (code === 0) {
|
||||||
|
if (conversationType == 3) {
|
||||||
|
RongIMLib.sendReadReceiptRequest(messageId, (res) => {
|
||||||
|
console.log('发送回执请求', res);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
resolve(messageId)
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
icon: 'none',
|
||||||
|
title: '发送失败' + code
|
||||||
|
})
|
||||||
|
reject(code)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
getMessageList,
|
getMessageList,
|
||||||
getPendingList,
|
getPendingList,
|
||||||
@@ -208,5 +254,6 @@ export default {
|
|||||||
sentText,
|
sentText,
|
||||||
sentVoice,
|
sentVoice,
|
||||||
sentImage,
|
sentImage,
|
||||||
sentFile
|
sentFile,
|
||||||
|
sentLocation
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user