13
This commit is contained in:
@@ -0,0 +1,333 @@
|
||||
<template>
|
||||
<view class="map_page">
|
||||
<uni-nav-bar
|
||||
left-icon="back"
|
||||
@clickLeft="back"
|
||||
statusBar
|
||||
fixed
|
||||
backgroundColor="transparent"
|
||||
>
|
||||
<template slot="right">
|
||||
<u-button type="primary" @click="confirm">确定</u-button>
|
||||
</template>
|
||||
</uni-nav-bar>
|
||||
<map
|
||||
ref="map"
|
||||
class="map_containter"
|
||||
:latitude="mapCenter.lat"
|
||||
:longitude="mapCenter.lng"
|
||||
:scale="scale"
|
||||
@regionchange="onMapRegionChange"
|
||||
show-location
|
||||
>
|
||||
<!-- 中心点marker -->
|
||||
<cover-view class="center_marker">
|
||||
<cover-image src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30' viewBox='0 0 30 30'%3E%3Ccircle cx='15' cy='15' r='12' fill='%23FF4444' opacity='0.8'/%3E%3Ccircle cx='15' cy='15' r='8' fill='%23FFFFFF'/%3E%3C/svg%3E"></cover-image>
|
||||
</cover-view>
|
||||
</map>
|
||||
|
||||
<!-- 加载提示 -->
|
||||
<view v-if="isLoading" class="loading_overlay">
|
||||
<uni-load-more status="loading" content-text="加载中"></uni-load-more>
|
||||
</view>
|
||||
|
||||
<!-- 地址信息展示 -->
|
||||
<view class="address_info">
|
||||
<view class="address_title">位置信息</view>
|
||||
<view class="address_text">{{ currentAddress || '加载中...' }}</view>
|
||||
<view class="coordinates">
|
||||
经度: {{ mapCenter.lng.toFixed(6) }} | 纬度: {{ mapCenter.lat.toFixed(6) }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
// 地图中心点
|
||||
mapCenter: {
|
||||
lng: 116.397128,
|
||||
lat: 39.916527
|
||||
},
|
||||
// 初始中心点(用于比较)
|
||||
initialCenter: {
|
||||
lng: 116.397128,
|
||||
lat: 39.916527
|
||||
},
|
||||
// 地图缩放级别
|
||||
scale: 16,
|
||||
// 当前地址
|
||||
currentAddress: '北京市朝阳区',
|
||||
// 选中的位置数据
|
||||
selectedPoint: null,
|
||||
// 是否正在加载
|
||||
isLoading: false,
|
||||
// 地图对象
|
||||
mapContext: null,
|
||||
// 地址解析延迟器
|
||||
addressTimer: null,
|
||||
// 高德地图API key(需要替换为实际的key)
|
||||
aMapKey: ''
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.initMap();
|
||||
},
|
||||
beforeDestroy() {
|
||||
// 清理定时器
|
||||
if (this.addressTimer) {
|
||||
clearTimeout(this.addressTimer);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* 初始化地图
|
||||
*/
|
||||
initMap() {
|
||||
this.mapContext = uni.createMapContext('map', this);
|
||||
// 获取当前位置权限
|
||||
this.getCurrentLocation();
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取当前位置
|
||||
*/
|
||||
getCurrentLocation() {
|
||||
uni.getLocation({
|
||||
type: 'gcj02',
|
||||
success: (res) => {
|
||||
this.mapCenter = {
|
||||
lng: res.longitude,
|
||||
lat: res.latitude
|
||||
};
|
||||
this.initialCenter = {
|
||||
lng: res.longitude,
|
||||
lat: res.latitude
|
||||
};
|
||||
// 获取地址
|
||||
this.getAddressFromCoordinates(res.longitude, res.latitude);
|
||||
},
|
||||
fail: (err) => {
|
||||
// 权限拒绝或失败,使用默认位置
|
||||
console.log('获取位置失败,使用默认位置', err);
|
||||
this.getAddressFromCoordinates(this.mapCenter.lng, this.mapCenter.lat);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 地图区域变化时触发
|
||||
*/
|
||||
onMapRegionChange(e) {
|
||||
if (e.type === 'end') {
|
||||
// 获取地图中心点坐标
|
||||
this.mapContext.getCenterLocation({
|
||||
success: (res) => {
|
||||
this.mapCenter = {
|
||||
lng: res.longitude,
|
||||
lat: res.latitude
|
||||
};
|
||||
// 延迟获取地址,避免频繁调用
|
||||
this.debounceGetAddress();
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log('获取地图中心点失败', err);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 防抖获取地址
|
||||
*/
|
||||
debounceGetAddress() {
|
||||
if (this.addressTimer) {
|
||||
clearTimeout(this.addressTimer);
|
||||
}
|
||||
this.addressTimer = setTimeout(() => {
|
||||
this.getAddressFromCoordinates(this.mapCenter.lng, this.mapCenter.lat);
|
||||
}, 500);
|
||||
},
|
||||
|
||||
/**
|
||||
* 根据坐标获取地址(使用高德地图API)
|
||||
*/
|
||||
getAddressFromCoordinates(lng, lat) {
|
||||
// 方法1:使用高德地图逆地理编码API
|
||||
// 注意:需要在高德地图申请API key
|
||||
const aMapUrl = `https://restapi.amap.com/v3/geocode/regeo?location=${lng},${lat}&key=YOUR_AMAP_KEY`;
|
||||
|
||||
// 这里使用本地模拟,实际项目中应该调用真实API
|
||||
this.simulateAddressLookup(lng, lat);
|
||||
},
|
||||
|
||||
/**
|
||||
* 模拟地址查询(实际项目应调用真实的地理编码API)
|
||||
*/
|
||||
simulateAddressLookup(lng, lat) {
|
||||
// 简单的地址模拟逻辑
|
||||
const addresses = [
|
||||
'北京市朝阳区建国路88号',
|
||||
' 北京市东城区天安门广场',
|
||||
'上海市浦东新区陆家嘴环路1088号',
|
||||
'深圳市福田区中心区',
|
||||
'杭州市上城区武林路'
|
||||
];
|
||||
|
||||
// 根据坐标返回对应的地址(这里是随机模拟)
|
||||
const index = Math.floor((lng + lat) % addresses.length);
|
||||
this.currentAddress = addresses[index] || `经度: ${lng.toFixed(6)}, 纬度: ${lat.toFixed(6)}`;
|
||||
},
|
||||
|
||||
/**
|
||||
* 确定位置按钮点击
|
||||
*/
|
||||
confirm() {
|
||||
const _this = this;
|
||||
|
||||
// 验证是否有有效的位置数据
|
||||
if (!this.mapCenter.lng || !this.mapCenter.lat) {
|
||||
uni.showToast({
|
||||
title: '位置数据无效',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 保存选中的位置
|
||||
_this.selectedPoint = {
|
||||
lng: this.mapCenter.lng,
|
||||
lat: this.mapCenter.lat,
|
||||
address: this.currentAddress
|
||||
};
|
||||
|
||||
// 通过事件通道返回数据给父页面
|
||||
const eventChannel = this.getOpenerEventChannel();
|
||||
eventChannel.emit('onConfirm', {
|
||||
lng: this.mapCenter.lng,
|
||||
lat: this.mapCenter.lat,
|
||||
address: this.currentAddress
|
||||
});
|
||||
|
||||
// 显示成功提示
|
||||
uni.showToast({
|
||||
title: '位置已确定',
|
||||
icon: 'success',
|
||||
duration: 1500
|
||||
});
|
||||
|
||||
// 延迟返回,让用户看到提示
|
||||
setTimeout(() => {
|
||||
uni.navigateBack();
|
||||
}, 1500);
|
||||
},
|
||||
|
||||
/**
|
||||
* 返回上一页
|
||||
*/
|
||||
back() {
|
||||
uni.navigateBack();
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.map_page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
width: 100vw;
|
||||
background: #fff;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
|
||||
.map_containter {
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
// 中心点marker样式
|
||||
.center_marker {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
margin-left: -15px;
|
||||
margin-top: -15px;
|
||||
z-index: 100;
|
||||
pointer-events: none;
|
||||
|
||||
cover-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
animation: bounce 1.5s ease-in-out infinite;
|
||||
}
|
||||
}
|
||||
|
||||
// 加载覆盖层
|
||||
.loading_overlay {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: rgba(0, 0, 0, 0.3);
|
||||
z-index: 200;
|
||||
}
|
||||
|
||||
// 地址信息展示框
|
||||
.address_info {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background: rgba(255, 255, 255, 0.95);
|
||||
backdrop-filter: blur(10px);
|
||||
padding: 12px 16px;
|
||||
z-index: 99;
|
||||
border-top: 1px solid #e5e5e5;
|
||||
box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
|
||||
|
||||
.address_title {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.address_text {
|
||||
color: #333;
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
word-break: break-word;
|
||||
margin-bottom: 6px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.coordinates {
|
||||
color: #666;
|
||||
font-size: 12px;
|
||||
font-family: monospace;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 跳动动画
|
||||
@keyframes bounce {
|
||||
0%, 100% {
|
||||
transform: scale(1);
|
||||
opacity: 1;
|
||||
}
|
||||
50% {
|
||||
transform: scale(1.2);
|
||||
opacity: 0.8;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -15,7 +15,7 @@
|
||||
</view>
|
||||
</view>
|
||||
<u-row class="action_row" v-else>
|
||||
<u-col v-for="item in actionList" :key="item.idx" @click="actionClick(item)" span="3">
|
||||
<u-col v-for="(item,idx) in actionList" :key="idx" @click="actionClick(item)" span="3">
|
||||
<view class="action_item">
|
||||
<image class="img" :src="item.icon" alt="" srcset="" />
|
||||
<text class="action_item_title">{{ item.title }}</text>
|
||||
@@ -28,10 +28,11 @@
|
||||
<script>
|
||||
import {ChatingFooterActionTypes,} from "@/constant";
|
||||
import emojis from "@/common/emojis.js"
|
||||
import chating_action_image from "@/static/images/chating_action_image.png";
|
||||
import chating_action_camera from "@/static/images/chating_action_camera.png";
|
||||
import chating_action_call from "@/static/images/chating_action_call.png";
|
||||
import chating_action_location from "@/static/images/chating_action_location.png";
|
||||
import chating_action_image_img from "@/static/images/chat/action_bar/image.png";
|
||||
import chating_action_camera_img from "@/static/images/chat/action_bar/camera.png";
|
||||
import chating_action_call_img from "@/static/images/chat/action_bar/call.png";
|
||||
import chating_action_location_img from "@/static/images/chat/action_bar/location.png";
|
||||
import chating_action_file_img from "@/static/images/chat/action_bar/file.png";
|
||||
|
||||
export default {
|
||||
props:{
|
||||
@@ -50,37 +51,36 @@
|
||||
emojiList:emojis,
|
||||
actionList: [
|
||||
{
|
||||
idx: 0,
|
||||
type: ChatingFooterActionTypes.Album,
|
||||
title: "照片",
|
||||
icon: chating_action_image,
|
||||
icon: chating_action_image_img,
|
||||
},
|
||||
{
|
||||
idx: 1,
|
||||
type: ChatingFooterActionTypes.Camera,
|
||||
title: "拍摄",
|
||||
icon: chating_action_camera,
|
||||
icon: chating_action_camera_img,
|
||||
},
|
||||
{
|
||||
idx: 2,
|
||||
type: ChatingFooterActionTypes.Video,
|
||||
type: ChatingFooterActionTypes.Call,
|
||||
title: "视频通话",
|
||||
icon: chating_action_call,
|
||||
icon: chating_action_call_img,
|
||||
},
|
||||
{
|
||||
idx: 3,
|
||||
type: ChatingFooterActionTypes.Location,
|
||||
title: "位置",
|
||||
icon: chating_action_location,
|
||||
icon: chating_action_location_img,
|
||||
},
|
||||
// {
|
||||
// idx: 0,
|
||||
// type: "File",
|
||||
// title: "文件",
|
||||
// icon: chating_action_file_img,
|
||||
// },
|
||||
// {
|
||||
// type: ChatingFooterActionTypes.Album,
|
||||
// title: "红包",
|
||||
// icon: chating_action_image,
|
||||
// },
|
||||
// {
|
||||
// idx: 0,
|
||||
// type: ChatingFooterActionTypes.Album,
|
||||
// title: "转账",
|
||||
// icon: chating_action_image,
|
||||
@@ -98,21 +98,24 @@
|
||||
this.$emit("onUserEvent",{type:"clearSendStr"});
|
||||
},
|
||||
async emojiClick(emoji){
|
||||
this.$emit("prepareMediaMessage", 'emoji',emoji);
|
||||
this.$emit("onUserEvent", {type:'insertEmoji', emoji:emoji});
|
||||
},
|
||||
async actionClick(action) {
|
||||
switch (action.type) {
|
||||
case ChatingFooterActionTypes.Video:
|
||||
this.$emit("prepareMediaMessage", action.type);
|
||||
break;
|
||||
case ChatingFooterActionTypes.Album:
|
||||
this.$emit("prepareMediaMessage", action.type);
|
||||
this.$emit("onUserEvent",{type:"prepend_image_message",source:"album"});
|
||||
break;
|
||||
case ChatingFooterActionTypes.Camera:
|
||||
this.$emit("prepareMediaMessage", action.type);
|
||||
this.$emit("onUserEvent",{type:"prepend_image_message",source:"camera"});
|
||||
break;
|
||||
case ChatingFooterActionTypes.Call:
|
||||
this.$emit("onUserEvent",{type:"prepend_call_message"});
|
||||
break;
|
||||
case "File":
|
||||
this.$emit("onUserEvent",{type:"prepend_file_message"});
|
||||
break;
|
||||
case ChatingFooterActionTypes.Location:
|
||||
this.$emit("prepareMediaMessage", action.type);
|
||||
this.$emit("onUserEvent",{type:"prepend_location_message"});
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -29,16 +29,14 @@
|
||||
<button class="send_btn" type="primary" v-show="hasContent" @touchend.prevent="sendTextMessage">发送</button>
|
||||
</view>
|
||||
</view>
|
||||
<chating-action-bar :isEmoji="isEmoji"
|
||||
@sendMessage="sendMessage($event,storeCurrentConversation.userID,storeCurrentConversation.groupID)"
|
||||
@prepareMediaMessage="prepareMediaMessage"
|
||||
<chating-action-bar
|
||||
:isEmoji="isEmoji"
|
||||
@onUserEvent="onUserEvent"
|
||||
v-show="actionBarVisible" />
|
||||
<u-action-sheet :safeAreaInsetBottom="true" round="12" :actions="actionSheetMenu" @select="selectClick"
|
||||
:closeOnClickOverlay="true" :closeOnClickAction="true" :show="showActionSheet"
|
||||
@close="showActionSheet = false">
|
||||
</u-action-sheet>
|
||||
|
||||
<!-- 录音动画 -->
|
||||
<!-- #ifdef APP-PLUS -->
|
||||
<view class="voice_an" v-if="recording">
|
||||
@@ -61,7 +59,7 @@
|
||||
|
||||
<script>
|
||||
import {mapGetters,mapActions} from "vuex";
|
||||
import {getPurePath,html2Text} from "@/util/common";
|
||||
import {getPurePath,html2Text,getVideoCover,getVideoInfo} from "@/util/common";
|
||||
import {offlinePushInfo} from "@/util/imCommon";
|
||||
import {ChatingFooterActionTypes,UpdateMessageTypes,} from "@/constant";
|
||||
import IMSDK, {IMMethods,MessageStatus,MessageType,} from "openim-uniapp-polyfill";
|
||||
@@ -75,12 +73,12 @@
|
||||
const rtcChoose = [
|
||||
{
|
||||
name: "视频通话",
|
||||
type: ChatingFooterActionTypes.Video,
|
||||
type: 'video',
|
||||
idx: 0,
|
||||
},
|
||||
{
|
||||
name: "语言通话",
|
||||
type: ChatingFooterActionTypes.Voice,
|
||||
type: 'voice',
|
||||
idx: 1,
|
||||
},
|
||||
];
|
||||
@@ -109,6 +107,8 @@
|
||||
actionSheetMenu: [],
|
||||
showActionSheet: false,
|
||||
isInsertingEmoji: false, // 标记是否正在插入表情
|
||||
|
||||
fileSelectedArray:[]
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -163,12 +163,14 @@
|
||||
offlinePushInfo,
|
||||
})
|
||||
.then(({data}) => {
|
||||
console.log(data);
|
||||
this.updateOneMessage({
|
||||
message: data,
|
||||
isSuccess: true,
|
||||
});
|
||||
})
|
||||
.catch(({data,errCode,errMsg}) => {
|
||||
console.log(errCode,errMsg);
|
||||
uni.$u.toast(errMsg);
|
||||
this.updateOneMessage({
|
||||
message: data,
|
||||
@@ -227,136 +229,54 @@
|
||||
// SimpleEditor 返回的是纯文本,直接使用
|
||||
this.inputHtml = e.detail.value || e.detail.text || e.detail.html || "";
|
||||
},
|
||||
prepareMediaMessage(type,extra) {
|
||||
console.log(type,extra)
|
||||
if (type === ChatingFooterActionTypes.Video) {
|
||||
this.actionSheetMenu = [...rtcChoose];
|
||||
this.showActionSheet = true;
|
||||
}
|
||||
if (type === ChatingFooterActionTypes.Album) {
|
||||
this.chooseOrShotImage(["album"]).then((paths) =>
|
||||
this.batchCreateImageMesage(paths)
|
||||
);
|
||||
}
|
||||
if (type === ChatingFooterActionTypes.Camera) {
|
||||
this.chooseOrShotImage(["camera"]).then((paths) =>
|
||||
this.batchCreateImageMesage(paths)
|
||||
);
|
||||
}
|
||||
if (type === ChatingFooterActionTypes.Location) {
|
||||
uni.chooseLocation({
|
||||
complete(res) {
|
||||
console.log(res);
|
||||
},
|
||||
fail(res) {
|
||||
console.log(res);
|
||||
}
|
||||
//latitude:1,
|
||||
//longitude:1,
|
||||
})
|
||||
}
|
||||
if (type === "emoji") {
|
||||
//TODO 在光标处插入文字extra
|
||||
//editorContext.insertImage(
|
||||
// 标记正在插入表情(先设置标志,保护表情栏不被隐藏)
|
||||
this.isInsertingEmoji = true;
|
||||
|
||||
// 确保表情栏显示(只在真正需要时才更新状态,避免不必要的响应式触发)
|
||||
const wasVisible = this.actionBarVisible;
|
||||
const wasEmoji = this.isEmoji;
|
||||
|
||||
if (!wasVisible || !wasEmoji) {
|
||||
// 只有在需要时才更新状态,减少响应式触发
|
||||
if (!wasVisible) {
|
||||
this.actionBarVisible = true;
|
||||
}
|
||||
if (!wasEmoji) {
|
||||
this.isEmoji = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 直接插入文本,不等待 nextTick,减少延迟
|
||||
this.$refs.customEditor.insertText(extra,() =>{
|
||||
console.log("插入文字成功");
|
||||
// 延迟重置标志,确保其他事件不会隐藏表情栏
|
||||
setTimeout(() => {
|
||||
this.isInsertingEmoji = false;
|
||||
}, 300);
|
||||
},(err) => {
|
||||
console.log("插入文字失败", err);
|
||||
this.isInsertingEmoji = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// from comp
|
||||
batchCreateImageMesage(paths) {
|
||||
/*
|
||||
createAdvancedTextMessage
|
||||
createTextAtMessage
|
||||
createLocationMessage
|
||||
createTextMessage
|
||||
createCustomMessage
|
||||
createQuoteMessage
|
||||
createAdvancedQuoteMessage
|
||||
createCardMessage
|
||||
createImageMessage
|
||||
createImageMessage
|
||||
createImageMessageByURL
|
||||
createSoundMessage
|
||||
createSoundMessageFromFullPath
|
||||
createSoundMessageByURL
|
||||
createVideoMessage
|
||||
createVideoMessageFromFullPath
|
||||
createVideoMessageByURL
|
||||
createFileMessage
|
||||
createFileMessageFromFullPath
|
||||
createFileMessageByURL
|
||||
createMergerMessage
|
||||
createFaceMessage
|
||||
createForwardMessage
|
||||
*/
|
||||
paths.forEach(async (path) => {
|
||||
const message = await IMSDK.asyncApi(
|
||||
IMMethods.CreateImageMessageFromFullPath,
|
||||
IMSDK.uuid(),
|
||||
getPurePath(path)
|
||||
);
|
||||
this.sendMessage(message,this.storeCurrentConversation.userID,this.storeCurrentConversation.groupID);
|
||||
sendMediaMesage(paths) {
|
||||
const _this = this;
|
||||
paths.forEach(async (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 videoParams = {
|
||||
videoPath: realVideoPath,
|
||||
videoType: "mp4",
|
||||
duration: info.duration,
|
||||
snapshotPath: getPurePath(cover),
|
||||
};
|
||||
console.log('videoParams', videoParams);
|
||||
message = await IMSDK.asyncApi(
|
||||
IMMethods.CreateVideoMessageFromFullPath,
|
||||
IMSDK.uuid(),
|
||||
videoParams
|
||||
);
|
||||
}else{
|
||||
message = await IMSDK.asyncApi(
|
||||
IMMethods.CreateImageMessageFromFullPath,
|
||||
IMSDK.uuid(),
|
||||
getPurePath(item)
|
||||
);
|
||||
}
|
||||
console.log(message);
|
||||
if(message){
|
||||
_this.sendMessage(message,_this.storeCurrentConversation.userID,_this.storeCurrentConversation.groupID);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
},
|
||||
selectClick({idx}) {
|
||||
if (idx === 0) {
|
||||
uni.$u.toast('根据相关政策,暂时禁用视频通话');
|
||||
//发送视频通话
|
||||
// this.chooseOrShotImage(["album"]).then((paths) =>
|
||||
// this.batchCreateImageMesage(paths)
|
||||
// );
|
||||
} else {
|
||||
uni.$u.toast('根据相关政策,暂时禁用音频通话');
|
||||
//发送音频通话
|
||||
// this.chooseOrShotImage(["camera"]).then((paths) =>
|
||||
// this.batchCreateImageMesage(paths)
|
||||
// );
|
||||
}
|
||||
},
|
||||
chooseOrShotImage(sourceType) {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.chooseImage({
|
||||
count: 9,
|
||||
sizeType: ["compressed"],
|
||||
sourceType,
|
||||
success: function({tempFilePaths}) {
|
||||
resolve(tempFilePaths);
|
||||
},
|
||||
fail: function(err) {
|
||||
console.log(err);
|
||||
reject(err);
|
||||
},
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
// keyboard
|
||||
keyboardChangeHander({height}) {
|
||||
//console.log(height);
|
||||
@@ -503,6 +423,7 @@
|
||||
},
|
||||
/*-------------------------------------录音相关方法块 end---------------------------------------------------*/
|
||||
onUserEvent(e){
|
||||
const _this = this;
|
||||
switch(e.type){
|
||||
case "clearSendStr":
|
||||
this.$refs.customEditor.clear();
|
||||
@@ -510,8 +431,107 @@
|
||||
case "delSendStr":
|
||||
this.$refs.customEditor.delete();
|
||||
break;
|
||||
case "insertEmoji":
|
||||
//TODO 在光标处插入文字extra
|
||||
//editorContext.insertImage(
|
||||
// 标记正在插入表情(先设置标志,保护表情栏不被隐藏)
|
||||
this.isInsertingEmoji = true;
|
||||
|
||||
// 确保表情栏显示(只在真正需要时才更新状态,避免不必要的响应式触发)
|
||||
const wasVisible = this.actionBarVisible;
|
||||
const wasEmoji = this.isEmoji;
|
||||
|
||||
if (!wasVisible || !wasEmoji) {
|
||||
// 只有在需要时才更新状态,减少响应式触发
|
||||
if (!wasVisible) {
|
||||
this.actionBarVisible = true;
|
||||
}
|
||||
if (!wasEmoji) {
|
||||
this.isEmoji = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 直接插入文本,不等待 nextTick,减少延迟
|
||||
this.$refs.customEditor.insertText(e.emoji,() =>{
|
||||
console.log("插入文字成功");
|
||||
// 延迟重置标志,确保其他事件不会隐藏表情栏
|
||||
setTimeout(() => {
|
||||
this.isInsertingEmoji = false;
|
||||
}, 300);
|
||||
},(err) => {
|
||||
console.log("插入文字失败", err);
|
||||
this.isInsertingEmoji = false;
|
||||
});
|
||||
break;
|
||||
case "prepend_image_message":
|
||||
if(e.source == "camera"){
|
||||
var cmr = plus.camera.getCamera();
|
||||
cmr.captureImage((src) =>{
|
||||
_this.sendMediaMesage([plus.io.convertLocalFileSystemURL(src)]);
|
||||
}, (err) =>{
|
||||
console.log(err);
|
||||
}, {
|
||||
filename:"_doc/camera/"
|
||||
});
|
||||
return ;
|
||||
}
|
||||
if(e.source == "album"){
|
||||
plus.gallery.pick(({files})=>{
|
||||
_this.sendMediaMesage(files);
|
||||
}, (error )=>{
|
||||
reject(error);
|
||||
}, {
|
||||
animation:true,
|
||||
confirmText:"确定",
|
||||
//crop:null,
|
||||
editable:true,
|
||||
filename:"_doc/",
|
||||
filter:"none",
|
||||
maximum:9,
|
||||
multiple:true,
|
||||
permissionAlert:true,
|
||||
//popover:{},
|
||||
//selected:[""],
|
||||
onmaxed(){
|
||||
console.log("超出最大选择数");
|
||||
},
|
||||
});
|
||||
}
|
||||
break;
|
||||
case "prepend_call_message":
|
||||
this.actionSheetMenu = [...rtcChoose];
|
||||
this.showActionSheet = true;
|
||||
break;
|
||||
case "prepend_file_message":
|
||||
uni.chooseFile({
|
||||
count:9,
|
||||
multiple: true,
|
||||
success: (res) => {
|
||||
console.log('选择文件成功', res);
|
||||
//const filePaths = res.tempFiles.map(file => file.path);
|
||||
//_this.sendMediaMesage(filePaths);
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log('选择文件失败', err);
|
||||
}
|
||||
});
|
||||
break;
|
||||
case "prepend_location_message":
|
||||
uni.chooseLocation({
|
||||
complete(res) {
|
||||
console.log(res);
|
||||
},
|
||||
fail(res) {
|
||||
console.log(res);
|
||||
}
|
||||
//latitude:1,
|
||||
//longitude:1,
|
||||
});
|
||||
break;
|
||||
default:
|
||||
console.log(e);
|
||||
break;
|
||||
}
|
||||
console.log(e);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
<uni-icons class="selectedIcon" size="30" color="#07c160" type="checkbox-filled" v-if="selectClientMsgIDItems.indexOf(item.clientMsgID)>-1"></uni-icons>
|
||||
<uni-icons class="selectedIcon" size="30" color="#ccc" type="circle" v-else></uni-icons>
|
||||
</template>
|
||||
<message-item-render
|
||||
@messageItemRender="messageItemRender"
|
||||
<MessageItemRender
|
||||
@userEvent="onUserMessageEvent"
|
||||
:source="item"
|
||||
:conversationID="storeCurrentConversation.conversationID"
|
||||
:isSender="item.sendID === storeCurrentUserID"
|
||||
/>
|
||||
<!-- :isActive="selectClientMsgIDItems.indexOf(item.clientMsgID)>-1" -->
|
||||
@@ -88,18 +88,6 @@
|
||||
},
|
||||
methods: {
|
||||
...mapActions("message", ["getHistoryMesageList"]),
|
||||
messageItemRender(clientMsgID) {
|
||||
if (
|
||||
this.initFlag &&
|
||||
clientMsgID ===
|
||||
this.storeHistoryMessageList[this.storeHistoryMessageList.length - 1]
|
||||
.clientMsgID
|
||||
) {
|
||||
this.initFlag = false;
|
||||
setTimeout(() => this.scrollToBottom(true), 200);
|
||||
this.checkInitHeight();
|
||||
}
|
||||
},
|
||||
async loadMessageList(isLoadMore = false) {
|
||||
this.messageLoadState.loading = true;
|
||||
const lastMsgID = this.storeHistoryMessageList[0]?.clientMsgID;
|
||||
@@ -192,6 +180,16 @@
|
||||
});
|
||||
},
|
||||
onUserMessageEvent(e,data){
|
||||
if(e.type == 'messageItemRender'){
|
||||
if (
|
||||
this.initFlag && data === this.storeHistoryMessageList[this.storeHistoryMessageList.length - 1].clientMsgID
|
||||
) {
|
||||
this.initFlag = false;
|
||||
setTimeout(() => this.scrollToBottom(true), 200);
|
||||
this.checkInitHeight();
|
||||
}
|
||||
return ;
|
||||
}
|
||||
this.$emit('userEvent',e,data)
|
||||
},
|
||||
empty(){}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<template>
|
||||
<view class="at_text_message_container bg_container">
|
||||
消息
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "AtTextMessageRender",
|
||||
components: {},
|
||||
props: {
|
||||
message: Object,
|
||||
conversationID:String,
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
methods: {
|
||||
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -0,0 +1,24 @@
|
||||
<template>
|
||||
<view class="card_message_container bg_container">
|
||||
消息
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "CardMessageRender",
|
||||
components: {},
|
||||
props: {
|
||||
message: Object,
|
||||
conversationID:String,
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
methods: {
|
||||
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -0,0 +1,24 @@
|
||||
<template>
|
||||
<view class="custom_message_container bg_container">
|
||||
消息
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "CustomMessageRender",
|
||||
components: {},
|
||||
props: {
|
||||
message: Object,
|
||||
conversationID:String,
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
methods: {
|
||||
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -1,17 +1,17 @@
|
||||
<template>
|
||||
<view class="text_message_container bg_container">
|
||||
<view> [暂未支持的消息类型] </view>
|
||||
</view>
|
||||
<view class="text_message_container bg_container">
|
||||
<view> [暂未支持的消息类型] </view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "ErrorMessagegRender",
|
||||
components: {},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
};
|
||||
export default {
|
||||
name: "ErrorMessagegRender",
|
||||
components: {},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -0,0 +1,103 @@
|
||||
<template>
|
||||
<view class="face_message_container bg_container">
|
||||
<u--image
|
||||
:showLoading="true"
|
||||
width="120"
|
||||
:height="maxHeight"
|
||||
mode="widthFix"
|
||||
v-if="src"
|
||||
:src="src"
|
||||
@load="onLoaded"
|
||||
@click="clickMediaItem">
|
||||
<template v-slot:loading>
|
||||
<u-loading-icon color="red"></u-loading-icon>
|
||||
</template>
|
||||
</u--image>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import util from "@/util"
|
||||
import md5 from "md5";
|
||||
export default {
|
||||
name: "FaceMessageRender",
|
||||
components: {},
|
||||
props: {
|
||||
message: Object,
|
||||
conversationID:String,
|
||||
},
|
||||
data() {
|
||||
//console.log(this.message);
|
||||
return {
|
||||
loadingWidth: "120px",
|
||||
maxHeight:'120px',
|
||||
src:"",
|
||||
coverCachePath:"",
|
||||
coverDownloading:false,
|
||||
coverExists:false,
|
||||
coverDownloadProgress:"",
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
getImgUrl() {
|
||||
return (
|
||||
this.message.FaceElem?.data ??
|
||||
this.message.FaceElem.index
|
||||
);
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.init();
|
||||
},
|
||||
methods: {
|
||||
async init(){
|
||||
const self = this;
|
||||
let url = "";
|
||||
// 如果有远程 snapshotUrl,则下载到 coverCachePath
|
||||
const snapshotUrl = this.message.FaceElem.data;
|
||||
const key = md5(snapshotUrl || '');
|
||||
this.coverCachePath = `_doc/${this.conversationID}/face_${key}.jpg`;
|
||||
if (typeof plus === 'undefined' || !this.coverCachePath) return;
|
||||
try {
|
||||
// 检查封面是否存在
|
||||
const coverExists = await util.fileExsit(self.coverCachePath);
|
||||
this.coverExists = !!coverExists;
|
||||
if (this.coverExists) {
|
||||
this.src = this.coverCachePath;
|
||||
return;
|
||||
}
|
||||
if (!snapshotUrl) {
|
||||
this.src="/static/images/sync_error.png";
|
||||
return;
|
||||
}
|
||||
this.coverDownloading = true;
|
||||
await new Promise((resolve, reject) => {
|
||||
util.downloadFile(snapshotUrl, self.coverCachePath, function(localPath) {
|
||||
self.coverDownloading = false;
|
||||
self.coverExists = true;
|
||||
resolve(localPath);
|
||||
}, function(err) {
|
||||
self.coverDownloading = false;
|
||||
reject(err);
|
||||
}, function(progress) {
|
||||
self.coverDownloadProgress = progress;
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
this.coverDownloading = false;
|
||||
}
|
||||
},
|
||||
onLoaded() {
|
||||
this.loadingWidth = "auto";
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.face_message_container {
|
||||
position: relative;
|
||||
border-radius: 16rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,24 @@
|
||||
<template>
|
||||
<view class="file_message_container bg_container">
|
||||
文件
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "FileMessageRender",
|
||||
components: {},
|
||||
props: {
|
||||
message: Object,
|
||||
conversationID:String,
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
methods: {
|
||||
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -0,0 +1,24 @@
|
||||
<template>
|
||||
<view class="location_message_container bg_container">
|
||||
消息
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "LocationMessageRender",
|
||||
components: {},
|
||||
props: {
|
||||
message: Object,
|
||||
conversationID:String,
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
methods: {
|
||||
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -0,0 +1,24 @@
|
||||
<template>
|
||||
<view class="markdown_message_container bg_container">
|
||||
消息
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "MarkdownMessageRender",
|
||||
components: {},
|
||||
props: {
|
||||
message: Object,
|
||||
conversationID:String,
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
methods: {
|
||||
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -1,81 +0,0 @@
|
||||
<template>
|
||||
<view class="media_message_container" @click="clickMediaItem">
|
||||
<u--image
|
||||
@load="onLoaded"
|
||||
:showLoading="true"
|
||||
width="120"
|
||||
:height="maxHeight"
|
||||
mode="widthFix"
|
||||
:src="getImgUrl"
|
||||
@click="clickMediaItem"
|
||||
>
|
||||
<template v-slot:loading>
|
||||
<u-loading-icon color="red"></u-loading-icon>
|
||||
</template>
|
||||
</u--image>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "",
|
||||
props: {
|
||||
message: Object,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loadingWidth: "120px",
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
getImgUrl() {
|
||||
return (
|
||||
this.message.pictureElem.snapshotPicture?.url ??
|
||||
this.message.pictureElem.sourcePath
|
||||
);
|
||||
},
|
||||
maxHeight() {
|
||||
const imageHeight = this.message.pictureElem.sourcePicture.height;
|
||||
const imageWidth = this.message.pictureElem.sourcePicture.width;
|
||||
const aspectRatio = imageHeight / imageWidth;
|
||||
return 120 * aspectRatio;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
clickMediaItem() {
|
||||
uni.previewImage({
|
||||
current: 0,
|
||||
urls: [this.message.pictureElem.sourcePicture.url],
|
||||
indicator: "none",
|
||||
});
|
||||
},
|
||||
onLoaded() {
|
||||
this.loadingWidth = "auto";
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.media_message_container {
|
||||
position: relative;
|
||||
border-radius: 16rpx;
|
||||
overflow: hidden;
|
||||
|
||||
.play_icon {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
.video_duration {
|
||||
position: absolute;
|
||||
bottom: 12rpx;
|
||||
right: 24rpx;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,24 @@
|
||||
<template>
|
||||
<view class="merge_message_container bg_container">
|
||||
消息
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "MergeMessageRender",
|
||||
components: {},
|
||||
props: {
|
||||
message: Object,
|
||||
conversationID:String,
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
methods: {
|
||||
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -0,0 +1,24 @@
|
||||
<template>
|
||||
<view class="oanotification_message_container bg_container">
|
||||
消息
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "OANotificationMessageRender",
|
||||
components: {},
|
||||
props: {
|
||||
message: Object,
|
||||
conversationID:String,
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
methods: {
|
||||
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -0,0 +1,124 @@
|
||||
<template>
|
||||
<view class="picture_message_container" @click="clickMediaItem">
|
||||
<u--image
|
||||
:showLoading="true"
|
||||
width="120"
|
||||
:height="maxHeight"
|
||||
mode="widthFix"
|
||||
v-if="src"
|
||||
:src="src"
|
||||
@load="onLoaded"
|
||||
@click="clickMediaItem">
|
||||
<template v-slot:loading>
|
||||
<u-loading-icon color="red"></u-loading-icon>
|
||||
</template>
|
||||
</u--image>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import util from "@/util"
|
||||
import md5 from "md5";
|
||||
export default {
|
||||
name: "PictureMessageContainer",
|
||||
props: {
|
||||
message: Object,
|
||||
conversationID:String,
|
||||
},
|
||||
data() {
|
||||
//console.log(this.message);
|
||||
return {
|
||||
loadingWidth: "120px",
|
||||
src:"",
|
||||
coverCachePath:"",
|
||||
coverDownloading:false,
|
||||
coverExists:false,
|
||||
coverDownloadProgress:"",
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
maxHeight() {
|
||||
const imageHeight = this.message.pictureElem.sourcePicture.height;
|
||||
const imageWidth = this.message.pictureElem.sourcePicture.width;
|
||||
const aspectRatio = imageHeight / imageWidth;
|
||||
return 120 * aspectRatio;
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.init();
|
||||
},
|
||||
methods: {
|
||||
async init(){
|
||||
const self = this;
|
||||
let url = "";
|
||||
// 如果有远程 snapshotUrl,则下载到 coverCachePath
|
||||
const snapshotUrl = (this.message.pictureElem.snapshotPicture?.url ?? this.message.pictureElem.sourcePath );
|
||||
const key = md5(snapshotUrl || '');
|
||||
this.coverCachePath = `_doc/${this.conversationID}/img_${key}.jpg`;
|
||||
if (typeof plus === 'undefined' || !this.coverCachePath) return;
|
||||
try {
|
||||
// 检查封面是否存在
|
||||
const coverExists = await util.fileExsit(self.coverCachePath);
|
||||
this.coverExists = !!coverExists;
|
||||
if (this.coverExists) {
|
||||
this.src = this.coverCachePath;
|
||||
return;
|
||||
}
|
||||
if (!snapshotUrl) {
|
||||
this.src="/static/images/sync_error.png";
|
||||
return;
|
||||
}
|
||||
this.coverDownloading = true;
|
||||
await new Promise((resolve, reject) => {
|
||||
util.downloadFile(snapshotUrl, self.coverCachePath, function(localPath) {
|
||||
self.coverDownloading = false;
|
||||
self.coverExists = true;
|
||||
resolve(localPath);
|
||||
}, function(err) {
|
||||
self.coverDownloading = false;
|
||||
reject(err);
|
||||
}, function(progress) {
|
||||
self.coverDownloadProgress = progress;
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
this.coverDownloading = false;
|
||||
}
|
||||
},
|
||||
clickMediaItem() {
|
||||
uni.previewImage({
|
||||
current: 0,
|
||||
urls: [this.message.pictureElem.sourcePicture.url],
|
||||
indicator: "none",
|
||||
});
|
||||
},
|
||||
onLoaded() {
|
||||
this.loadingWidth = "auto";
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.picture_message_container {
|
||||
position: relative;
|
||||
border-radius: 16rpx;
|
||||
overflow: hidden;
|
||||
|
||||
.play_icon {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
.video_duration {
|
||||
position: absolute;
|
||||
bottom: 12rpx;
|
||||
right: 24rpx;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,24 @@
|
||||
<template>
|
||||
<view class="quote_message_container bg_container">
|
||||
消息
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "QuoteMessageRender",
|
||||
components: {},
|
||||
props: {
|
||||
message: Object,
|
||||
conversationID:String,
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
methods: {
|
||||
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -0,0 +1,24 @@
|
||||
<template>
|
||||
<view class="stream_message_container bg_container">
|
||||
消息
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "StreamMessageRender",
|
||||
components: {},
|
||||
props: {
|
||||
message: Object,
|
||||
conversationID:String,
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
methods: {
|
||||
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -1,36 +1,33 @@
|
||||
<template>
|
||||
<view class="text_message_container bg_container">
|
||||
<mp-html
|
||||
:previewImg="false"
|
||||
:showImgMenu="false"
|
||||
:lazyLoad="false"
|
||||
selectable
|
||||
:content="getContent"
|
||||
/>
|
||||
</view>
|
||||
<view class="text_message_container bg_container">
|
||||
<mp-html :previewImg="false" :showImgMenu="false" :lazyLoad="false" selectable :content="getContent" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { parseBr } from "@/util/common";
|
||||
import {
|
||||
parseBr
|
||||
} from "@/util/common";
|
||||
|
||||
export default {
|
||||
name: "TextMessageRender",
|
||||
components: {},
|
||||
props: {
|
||||
message: Object,
|
||||
},
|
||||
computed: {
|
||||
getContent() {
|
||||
return parseBr(this.message.textElem?.content);
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
methods: {
|
||||
|
||||
},
|
||||
};
|
||||
export default {
|
||||
name: "TextMessageRender",
|
||||
components: {},
|
||||
props: {
|
||||
message: Object,
|
||||
conversationID:String,
|
||||
},
|
||||
computed: {
|
||||
getContent() {
|
||||
return parseBr(this.message.textElem?.content);
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
methods: {
|
||||
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -0,0 +1,24 @@
|
||||
<template>
|
||||
<view class="typing_message_container bg_container">
|
||||
消息
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "TypingMessageRender",
|
||||
components: {},
|
||||
props: {
|
||||
message: Object,
|
||||
conversationID:String,
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
methods: {
|
||||
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -0,0 +1,264 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="video_message_container" @click="clickMediaItem">
|
||||
<u--image
|
||||
:showLoading="true"
|
||||
:src="src"
|
||||
:width="imgWidth"
|
||||
:height="maxHeight"
|
||||
mode="widthFix"
|
||||
@load="onLoaded"
|
||||
@click="clickMediaItem">
|
||||
<template v-slot:loading>
|
||||
<u-loading-icon color="red"></u-loading-icon>
|
||||
</template>
|
||||
</u--image>
|
||||
<!-- 覆盖层:显示封面下载状态/视频下载入口/播放按钮 -->
|
||||
<view class="download-overlay" @click.stop="onOverlayClick">
|
||||
<view v-if="videoDownloading" class="progress-box">
|
||||
<view class="progress-bar">
|
||||
<view class="progress-fill" :style="{ width: videoDownloadProgress + '%' }"></view>
|
||||
</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>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 视频播放器组件 -->
|
||||
<videoPlayer :previewVideoFlag="previewVideoFlag" :previewVideoSrc="previewVideoSrc" @quitPlay="previewVideoFlag=false"></videoPlayer>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
/*
|
||||
{
|
||||
"clientMsgID": "d9a596f3e665e84559821a8aa5fb9f16",
|
||||
"serverMsgID": "76a56965a5fba40df213da2acb331517",
|
||||
"createTime": 1765413732786,
|
||||
"sendTime": 1765413733732,
|
||||
"sessionType": 1,
|
||||
"sendID": "100003",
|
||||
"recvID": "100004",
|
||||
"msgFrom": 100,
|
||||
"contentType": 104,
|
||||
"senderPlatformID": 2,
|
||||
"senderNickname": "131****2222",
|
||||
"senderFaceUrl": "/static/img/avatar.png",
|
||||
"seq": 22,
|
||||
"isRead": false,
|
||||
"status": 2,
|
||||
"videoElem": {
|
||||
"videoPath": "/storage/emulated/0/Movies/顺网云电脑 2025-10-21 04-26-04-converted.mp4",
|
||||
"videoUrl": "http://www.axzc.xyz/object/100003/msg_video_d9a596f3e665e84559821a8aa5fb9f16.mp4",
|
||||
"videoType": "mp4",
|
||||
"videoSize": 3751005,
|
||||
"duration": 44,
|
||||
"snapshotPath": "/storage/emulated/0/Android/data/hk.huisheng.im/apps/__UNI__CA458BA/doc/video_cover_2ea1c8ec.jpg",
|
||||
"snapshotSize": 36974,
|
||||
"snapshotUrl": "http://www.axzc.xyz/object/100003/msg_videoSnapshot_d9a596f3e665e84559821a8aa5fb9f16.jpg",
|
||||
"snapshotWidth": 1087,
|
||||
"snapshotHeight": 726
|
||||
},
|
||||
"attachedInfoElem": {
|
||||
"groupHasReadInfo": {
|
||||
"hasReadCount": 0,
|
||||
"groupMemberCount": 0
|
||||
},
|
||||
"isPrivateChat": false,
|
||||
"burnDuration": 0,
|
||||
"hasReadTime": 0,
|
||||
"isEncryption": false,
|
||||
"inEncryptStatus": false
|
||||
}
|
||||
}
|
||||
*/
|
||||
const imgWidth = 240;
|
||||
import md5 from "md5";
|
||||
import videoPlayer from "@/components/videoPlayer.vue";
|
||||
import util from "@/util"
|
||||
export default {
|
||||
name: "VideoMessageContainer",
|
||||
components: {
|
||||
videoPlayer,
|
||||
},
|
||||
props: {
|
||||
message: Object,
|
||||
conversationID:String,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loadingWidth: imgWidth+"px",
|
||||
imgWidth:imgWidth,
|
||||
isDownloading: false,
|
||||
downloadProgress: 0,
|
||||
coverDownloading: false,
|
||||
coverDownloadProgress: 0,
|
||||
videoDownloading: false,
|
||||
videoDownloadProgress: 0,
|
||||
coverExists: false,
|
||||
videoExists: false,
|
||||
coverCachePath:"",
|
||||
videoCachePath:"",
|
||||
previewVideoFlag: false,
|
||||
previewVideoSrc: "",
|
||||
src:"",
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
maxHeight() {
|
||||
const imageHeight = this.message.videoElem.snapshotHeight;
|
||||
const imageWidth = this.message.videoElem.snapshotWidth;
|
||||
const aspectRatio = imageHeight / imageWidth;
|
||||
return imgWidth * aspectRatio;
|
||||
}
|
||||
},
|
||||
async created(){
|
||||
this.init();
|
||||
},
|
||||
methods: {
|
||||
async init(){
|
||||
// 如果有远程 snapshotUrl,则下载到 coverCachePath
|
||||
const snapshotUrl = this.message?.videoElem?.snapshotUrl;
|
||||
const key = md5(this.message?.videoElem?.videoUrl || '');
|
||||
this.coverCachePath = `_doc/${this.conversationID}/cover_${key}.jpg`;
|
||||
this.videoCachePath = `_doc/${this.conversationID}/${key}.mp4`;
|
||||
const coverExists = await util.fileExsit(this.coverCachePath);
|
||||
|
||||
// 自动缓存封面到 this.coverCachePath
|
||||
const self = this;
|
||||
if (typeof plus === 'undefined' || !this.coverCachePath) return;
|
||||
try {
|
||||
// 检查封面是否存在
|
||||
const coverExists = await util.fileExsit(self.coverCachePath);
|
||||
this.coverExists = !!coverExists;
|
||||
// 同时检查视频缓存是否存在
|
||||
const vidExists = await util.fileExsit(self.videoCachePath);
|
||||
this.videoExists = !!vidExists;
|
||||
if (this.coverExists) {
|
||||
this.src = this.coverCachePath;
|
||||
return;
|
||||
}
|
||||
if (!snapshotUrl) {
|
||||
this.src="/static/images/sync_error.png";
|
||||
return;
|
||||
}
|
||||
this.coverDownloading = true;
|
||||
await new Promise((resolve, reject) => {
|
||||
util.downloadFile(snapshotUrl, self.coverCachePath, function(localPath) {
|
||||
self.coverDownloading = false;
|
||||
self.coverExists = true;
|
||||
resolve(localPath);
|
||||
}, function(err) {
|
||||
self.coverDownloading = false;
|
||||
reject(err);
|
||||
}, function(progress) {
|
||||
self.coverDownloadProgress = progress;
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
this.coverDownloading = false;
|
||||
}
|
||||
},
|
||||
clickMediaItem() {
|
||||
uni.previewImage({
|
||||
current: 0,
|
||||
urls: [this.message.videoElem?.snapshotUrl],
|
||||
indicator: "none",
|
||||
});
|
||||
},
|
||||
async onLoaded() {
|
||||
this.loadingWidth = "auto";
|
||||
},
|
||||
onOverlayClick() {
|
||||
// 点击覆盖层:如果视频已缓存则直接播放,否则开始下载
|
||||
if (this.videoExists) {
|
||||
this.playVideo(this.videoCachePath);
|
||||
return;
|
||||
}
|
||||
const url = this.message?.videoElem?.videoUrl || this.message?.videoElem?.videoPath;
|
||||
if (!url) {
|
||||
uni.showToast({ title: '无可下载的视频' });
|
||||
return;
|
||||
}
|
||||
this.videoDownloading = true;
|
||||
this.videoDownloadProgress = 0;
|
||||
util.downloadFile(url, this.videoCachePath, (localPath) => {
|
||||
this.videoDownloading = false;
|
||||
this.videoExists = true;
|
||||
this.playVideo(localPath);
|
||||
}, (err) => {
|
||||
this.videoDownloading = false;
|
||||
uni.showToast({ title: '下载失败' });
|
||||
}, (prog) => {
|
||||
this.videoDownloadProgress = prog;
|
||||
});
|
||||
},
|
||||
|
||||
playVideo(localPath) {
|
||||
if (!localPath) return;
|
||||
this.previewVideoSrc = localPath;
|
||||
this.previewVideoFlag = true;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.video_message_container {
|
||||
position: relative;
|
||||
border-radius: 16rpx;
|
||||
overflow: hidden;
|
||||
|
||||
.play_icon {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
.video_duration {
|
||||
position: absolute;
|
||||
bottom: 12rpx;
|
||||
right: 24rpx;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
.download-overlay {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: rgba(0,0,0,0.35);
|
||||
}
|
||||
.progress-box {
|
||||
width: 70%;
|
||||
max-width: 240px;
|
||||
text-align: center;
|
||||
}
|
||||
.progress-bar {
|
||||
width: 100%;
|
||||
height: 8px;
|
||||
background: rgba(255,255,255,0.25);
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.progress-fill {
|
||||
height: 100%;
|
||||
background: #4caf50;
|
||||
width: 0%;
|
||||
}
|
||||
.progress-text {
|
||||
display: block;
|
||||
color: #fff;
|
||||
margin-top: 8px;
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,24 @@
|
||||
<template>
|
||||
<view class="voice_message_container bg_container">
|
||||
消息
|
||||
</view>
|
||||
</template>v
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "VoiceMessageRender",
|
||||
components: {},
|
||||
props: {
|
||||
message: Object,
|
||||
conversationID:String,
|
||||
},
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
methods: {
|
||||
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -16,9 +16,7 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="message_content_wrap message_content_wrap_shadow" :id="`message_content_wrap_${source.clientMsgID}`" @longtap.stop.prevent="longtapEvent($event)">
|
||||
<text-message-render v-if="showTextRender" :message="source" />
|
||||
<media-message-render v-else-if="showMediaRender" :message="source" />
|
||||
<error-message-render v-else />
|
||||
<component :is="component" :message="source" :conversationID="conversationID"></component>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -35,20 +33,46 @@
|
||||
import {MessageStatus,MessageType,SessionType,} from "openim-uniapp-polyfill";
|
||||
import MyAvatar from "@/components/MyAvatar/index.vue";
|
||||
import TextMessageRender from "./TextMessageRender";
|
||||
import MediaMessageRender from "./MediaMessageRender";
|
||||
import PictureMessageRender from "./PictureMessageRender";
|
||||
import VoiceMessageRender from "./VoiceMessageRender";
|
||||
import VideoMessageRender from "./VideoMessageRender";
|
||||
import FileMessageRender from "./FileMessageRender";
|
||||
import AtTextMessageRender from "./AtTextMessageRender";
|
||||
import MergeMessageRender from "./MergeMessageRender";
|
||||
import CardMessageRender from "./CardMessageRender";
|
||||
import LocationMessageRender from "./LocationMessageRender";
|
||||
import CustomMessageRender from "./CustomMessageRender";
|
||||
import TypingMessageRender from "./TypingMessageRender";
|
||||
import QuoteMessageRender from "./QuoteMessageRender";
|
||||
import FaceMessageRender from "./FaceMessageRender";
|
||||
import MarkdownMessageRender from "./MarkdownMessageRender";
|
||||
import StreamMessageRender from "./StreamMessageRender";
|
||||
import OANotificationRender from "./OANotificationRender";
|
||||
|
||||
import ErrorMessageRender from "./ErrorMessageRender";
|
||||
import {noticeMessageTypes} from "@/constant";
|
||||
import {tipMessaggeFormat,formatMessageTime} from "@/util/imCommon";
|
||||
|
||||
const textRenderTypes = [MessageType.TextMessage];
|
||||
|
||||
const mediaRenderTypes = [MessageType.PictureMessage];
|
||||
import { ca } from "date-fns/locale";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
MyAvatar,
|
||||
TextMessageRender,
|
||||
MediaMessageRender,
|
||||
PictureMessageRender,
|
||||
VoiceMessageRender,
|
||||
VideoMessageRender,
|
||||
FileMessageRender,
|
||||
AtTextMessageRender,
|
||||
MergeMessageRender,
|
||||
CardMessageRender,
|
||||
LocationMessageRender,
|
||||
CustomMessageRender,
|
||||
TypingMessageRender,
|
||||
QuoteMessageRender,
|
||||
FaceMessageRender,
|
||||
MarkdownMessageRender,
|
||||
StreamMessageRender,
|
||||
OANotificationRender,
|
||||
ErrorMessageRender
|
||||
},
|
||||
props: {
|
||||
@@ -57,6 +81,7 @@
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
conversationID:String,
|
||||
isPreview: Boolean,
|
||||
isActive: Boolean,
|
||||
},
|
||||
@@ -67,6 +92,7 @@
|
||||
toolTipFlag: false,
|
||||
popPostion:"default",
|
||||
toolTipData: [],
|
||||
component:"ErrorMessageRender",
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -82,12 +108,6 @@
|
||||
formattedMessageTime() {
|
||||
return formatMessageTime(this.source.sendTime);
|
||||
},
|
||||
showTextRender() {
|
||||
return textRenderTypes.includes(this.source.contentType);
|
||||
},
|
||||
showMediaRender() {
|
||||
return mediaRenderTypes.includes(this.source.contentType);
|
||||
},
|
||||
getNoticeContent() {
|
||||
const isNoticeMessage = noticeMessageTypes.includes(
|
||||
this.source.contentType
|
||||
@@ -110,7 +130,26 @@
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.$emit("messageItemRender", this.source.clientMsgID);
|
||||
const MsgType2Components = {
|
||||
['type_'+MessageType.TextMessage] : "TextMessageRender",
|
||||
['type_'+MessageType.PictureMessage] : "PictureMessageRender",
|
||||
['type_'+MessageType.VoiceMessage] : "VoiceMessageRender",
|
||||
['type_'+MessageType.VideoMessage] : "VideoMessageRender",
|
||||
['type_'+MessageType.FileMessage] : "FileMessageRender",
|
||||
['type_'+MessageType.AtTextMessage] : "AtTextMessageRender",
|
||||
['type_'+MessageType.MergeMessage] : "MergeMessageRender",
|
||||
['type_'+MessageType.CardMessage] : "CardMessageRender",
|
||||
['type_'+MessageType.LocationMessage] : "LocationMessageRender",
|
||||
['type_'+MessageType.CustomMessage] : "CustomMessageRender",
|
||||
['type_'+MessageType.TypingMessage] : "TypingMessageRender",
|
||||
['type_'+MessageType.QuoteMessage] : "QuoteMessageRender",
|
||||
['type_'+MessageType.FaceMessage] : "FaceMessageRender",
|
||||
['type_'+MessageType.MarkdownMessage] : "MarkdownMessageRender",
|
||||
['type_'+MessageType.StreamMessage] : "StreamMessageRender",
|
||||
['type_'+MessageType.OANotification] : "OANotificationRender"
|
||||
};
|
||||
this.component = MsgType2Components['type_'+this.source.contentType] || "ErrorMessageRender";
|
||||
this.$emit('userEvent',{type:"messageItemRender"},this.source.clientMsgID);
|
||||
this.setSendingDelay();
|
||||
},
|
||||
methods: {
|
||||
|
||||
@@ -48,9 +48,7 @@
|
||||
return getConversationContent(parsedMessage);
|
||||
},
|
||||
latestMessageTime() {
|
||||
return this.source.latestMsgSendTime ?
|
||||
formatConversionTime(this.source.latestMsgSendTime) :
|
||||
"";
|
||||
return this.source.latestMsgSendTime ? formatConversionTime(this.source.latestMsgSendTime) : "";
|
||||
},
|
||||
isGroup() {
|
||||
return this.source.conversationType === SessionType.WorkingGroup;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<view class="page_container">
|
||||
<view class="user_page">
|
||||
<view class="uni-white-bg">
|
||||
<view class="self_info_row"></view>
|
||||
|
||||
@@ -112,7 +112,7 @@
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import '@/uni_modules/uni-scss/index.scss';
|
||||
.page_container {
|
||||
.user_page {
|
||||
background-color: #ececec;
|
||||
|
||||
.self_info_row {
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
<template>
|
||||
<view class="content">
|
||||
<uni-nav-bar title="发现" background-color="transparent"></uni-nav-bar>
|
||||
<view class="workbench_page">
|
||||
<uni-nav-bar
|
||||
title="发现"
|
||||
statusBar
|
||||
fixed
|
||||
background-color="transparent"></uni-nav-bar>
|
||||
<uni-list>
|
||||
<uni-list-item title="朋友圈"
|
||||
thumb="/static/images/workbench/01.png"
|
||||
@@ -71,10 +75,7 @@
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.content {padding-top: 36rpx;}
|
||||
</style>
|
||||
<style>
|
||||
page {
|
||||
.workbench_page {
|
||||
background-color: #ececec !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user