This commit is contained in:
cansnow
2026-02-09 07:29:02 +08:00
parent 2860c46ec1
commit 6720c15e30
19 changed files with 996 additions and 207 deletions
@@ -67,7 +67,9 @@
import SimpleEditor from "./SimpleEditor";
import ChatingActionBar from "./ChatingActionBar";
import Recoder from "./Recoder";
import {upload} from "@/api/login.js"
import IM from "@/util/im.js";
import permision from "@/js_sdk/wa-permission/permission.js"
const needClearTypes = [MessageType.TextMessage];
const rtcChoose = [
@@ -177,8 +179,12 @@
if (needClearTypes.includes(message.contentType)) {
this.$refs.customEditor.clear();
}
let method = IMMethods.SendMessage;
if([MessageType.PictureMessage,MessageType.VoiceMessage,MessageType.VideoMessage,MessageType.FileMessage].includes(message.contentType)){
method = IMMethods.SendMessageNotOss;
}
this.$emit("scrollToBottom");
IMSDK.asyncApi(IMMethods.SendMessage, IMSDK.uuid(), {
IMSDK.asyncApi(method, IMSDK.uuid(), {
recvID: user_id,
groupID: group_id,
message,
@@ -211,7 +217,6 @@
});
},
recordAudioMsg(){
if (uni.getSystemInfoSync().platform == "android") {
permission.requestAndroid("android.permission.RECORD_AUDIO"); //Android请求录音权限
} else {
@@ -281,36 +286,15 @@
sendMediaMesage(paths) {
const _this = this;
paths.forEach(async (item) => {
console.log(item);
try {
let message = null;
if(item.search('.mp4')>0){
const realVideoPath = await getPurePath(item);
console.log('处理后的可用路径', realVideoPath);
const info = await getVideoInfo(realVideoPath);
//const cover = await getVideoCover(item);
const res1 = await IMSDK.getVideoCover(item);
//console.log(res1.path);
const videoParams = {
videoPath: realVideoPath,
videoType: "mp4",
duration: info.duration,
snapshotPath: getPurePath(res1.path),
//snapshotPath: getPurePath(cover),
};
console.log('videoParams', videoParams);
message = await IMSDK.asyncApi(
IMMethods.CreateVideoMessageFromFullPath,
IMSDK.uuid(),
videoParams
);
message = await IM.createVideoMessage(item);
}else{
message = await IMSDK.asyncApi(
IMMethods.CreateImageMessageFromFullPath,
IMSDK.uuid(),
getPurePath(item)
);
message = await IM.createImageMessage(item);
}
//console.log(message);
console.log(message);
if(message){
_this.sendMessage(message,_this.storeCurrentConversation.userID,_this.storeCurrentConversation.groupID);
}
@@ -401,6 +385,31 @@
break;
}
},
pickMedia(){
const _this = this;
plus.gallery.pick(({files})=>{
console.log(files);
_this.sendMediaMesage(files);
}, (error )=>{
console.log(error);
}, {
animation:true,
confirmText:"确定",
//crop:null,
editable:true,
filename:"_doc/",
//filter:"none",//image,none,video
filter:"image",
maximum:9,
multiple:true,
permissionAlert:true,
//popover:{},
//selected:[""],
onmaxed(){
console.log("超出最大选择数");
},
});
},
onUserEvent(e){
const _this = this;
switch(e.type){
@@ -455,33 +464,8 @@
return ;
}
if(e.source == "album"){
// IMSDK.pickFile().then(res=>{
// console.log(res);
// }).catch(e=>{
// console.log(e);
// });
// return;
plus.gallery.pick(({files})=>{
_this.sendMediaMesage(files);
}, (error )=>{
console.log(error);
}, {
animation:true,
confirmText:"确定",
//crop:null,
editable:true,
filename:"_doc/",
filter:"none",
maximum:9,
multiple:true,
permissionAlert:true,
//popover:{},
//selected:[""],
onmaxed(){
console.log("超出最大选择数");
},
});
}
_this.pickMedia();
}
break;
case "prepend_call_message":
this.actionSheetMenu = [...rtcChoose];
@@ -1,14 +1,13 @@
<template>
<view>
<view class="video_message_container" @click="clickMediaItem">
<view class="video_message_container">
<u--image
:showLoading="true"
:src="src"
:width="imgWidth"
:height="maxHeight"
mode="widthFix"
@load="onLoaded"
@click="clickMediaItem">
@load="onLoaded" >
<template v-slot:loading>
<u-loading-icon color="red"></u-loading-icon>
</template>
@@ -21,8 +20,8 @@
</view>
<text class="progress-text">{{ videoDownloadProgress }}%</text>
</view>
<u-icon v-else-if="videoExists" class="play_icon" name="play-circle" size="48" color="#fff"></u-icon>
<uni-icons v-else class="play_icon" type="cloud-download" size="48" color="#fff"></uni-icons>
<u-icon v-else-if="videoExists" class="play_icon" name="play-circle" size="48" color="#ccc"></u-icon>
<uni-icons v-else class="play_icon" type="cloud-download" size="48" color="#ccc"></uni-icons>
</view>
</view>
<!-- 视频播放器组件 -->
@@ -116,23 +115,17 @@
},
methods: {
async init(){
const self = this;
const _this = this;
console.log(this.message?.videoElem,this.conversationID);
const snapshotUrl = this.message?.videoElem?.snapshotUrl;
self.coverDownloading = true;
_this.coverDownloading = true;
//console.log(snapshotUrl);
util.cacheFile(snapshotUrl,`${this.conversationID}`).then((fn)=>{
self.coverDownloading = false;
self.src = fn;
_this.coverDownloading = false;
_this.src = fn;
//console.log(fn);
});
},
clickMediaItem() {
uni.previewImage({
current: 0,
urls: [this.message.videoElem?.snapshotUrl],
indicator: "none",
});
_this.videoExists = util.fileExsit(util.getCachePath(_this.message?.videoElem?.videoUrl,`${_this.conversationID}`));
},
async onLoaded() {
this.loadingWidth = "auto";
@@ -1,8 +1,8 @@
<template>
<view v-if="isNoticeMessage" class="notice_message_container" style="margin: 0 auto;" :id="`auchor${source.clientMsgID}`">
<view v-if="isNoticeMessage" class="notice_message_container" :id="`auchor${source.clientMsgID}`">
<text>{{ getNoticeContent }}</text>
</view>
<view v-else-if="source.contentType == 1519" class="notice_message_container" style="margin: 0 auto;" :id="`auchor${source.clientMsgID}`">
<view v-else-if="source.contentType == 1519" class="notice_message_container" :id="`auchor${source.clientMsgID}`">
<text @click="toAnnouncement">{{ announcementElem.opUser.nickname }}更新了群公告</text>
</view>
<view v-else class="message_wrapper">
@@ -282,7 +282,7 @@
margin-bottom: 6rpx;
}
.message_content_wrap_shadow {
box-shadow: 0px 0px 2px rgba(0,0,0,0.1);
box-shadow: 0px 0px 0px rgba(0,0,0,0.1);
}
.message_content_wrap {
@include vCenterBox();
@@ -345,7 +345,7 @@
// text-align: end;
align-items: flex-end;
.message_content_wrap_shadow {
box-shadow: 0px 0px 2px #95e261;
box-shadow: 0px 0px 0px #95e261;
}
.message_content_wrap {
flex-direction: row-reverse;
@@ -375,10 +375,14 @@
.notice_message_container {
@include ellipsisWithLine(2);
text-align: center;
margin: 24rpx 48rpx;
padding: 24rpx 48rpx;
word-break: break-word;
// font-size: 24rpx;
font-size: 0.85rem;
text-align: center;
color: #999;
width: 100%;
box-sizing: border-box;
position: relative;
}