13
@@ -0,0 +1,155 @@
|
||||
<template>
|
||||
<view class="map_container"></view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
map: null,
|
||||
centerMarker: null,
|
||||
currentPoint: null,
|
||||
currentAddress: '',
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.createMap();
|
||||
this.initializeMap();
|
||||
},
|
||||
methods: {
|
||||
createMap() {
|
||||
const mapId = "map_" + Math.random();
|
||||
const map = plus.maps.create(mapId, {
|
||||
zoom: 13,
|
||||
MapType: plus.maps.MapType.MAPTYPE_NORMAL,
|
||||
traffic: true,
|
||||
zoomControls: true,
|
||||
top: "0",
|
||||
left: "0",
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
position: "static",
|
||||
});
|
||||
|
||||
plus.webview.currentWebview().append(map);
|
||||
this.map = map;
|
||||
},
|
||||
|
||||
initializeMap() {
|
||||
const _this = this;
|
||||
|
||||
// 获取当前位置
|
||||
uni.getLocation({
|
||||
type: 'gcj02',
|
||||
success(res) {
|
||||
const point = new plus.maps.Point(res.longitude, res.latitude);
|
||||
_this.map.setCenter(point);
|
||||
_this.currentPoint = point;
|
||||
_this.addCenterMarker(point);
|
||||
_this.getAddressByPoint(point);
|
||||
_this.setupMapMoveListener();
|
||||
_this.map.show();
|
||||
},
|
||||
fail() {
|
||||
// 如果获取位置失败,使用默认位置
|
||||
const defaultPoint = new plus.maps.Point(116.4074, 39.9042);
|
||||
_this.map.setCenter(defaultPoint);
|
||||
_this.currentPoint = defaultPoint;
|
||||
_this.addCenterMarker(defaultPoint);
|
||||
_this.getAddressByPoint(defaultPoint);
|
||||
_this.setupMapMoveListener();
|
||||
_this.map.show();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
addCenterMarker(point) {
|
||||
// 移除旧的marker
|
||||
if (this.centerMarker) {
|
||||
this.map.removeOverlay(this.centerMarker);
|
||||
}
|
||||
|
||||
// 添加中心点marker
|
||||
this.centerMarker = new plus.maps.Marker(point);
|
||||
this.centerMarker.setIcon("/static/images/chat/marker.png");
|
||||
this.map.addOverlay(this.centerMarker);
|
||||
},
|
||||
|
||||
setupMapMoveListener() {
|
||||
const _this = this;
|
||||
|
||||
// 使用定时器轮询来检测地图位置变化
|
||||
// plus.maps 的 H5 版本可能不支持事件监听,通过定时器实现
|
||||
let lastCenter = this.map.getCenter ? this.map.getCenter() : null;
|
||||
|
||||
setInterval(() => {
|
||||
_this.map.getCurrentCenter((state, point) => {
|
||||
if (state !== 0 || !point) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 简单的位置变化检测
|
||||
if (!lastCenter ||
|
||||
lastCenter.getLng() !== point.getLng() ||
|
||||
lastCenter.getLat() !== point.getLat()) {
|
||||
|
||||
lastCenter = point;
|
||||
_this.updateCenterMarker();
|
||||
}
|
||||
});
|
||||
}, 500);
|
||||
},
|
||||
|
||||
updateCenterMarker() {
|
||||
const _this = this;
|
||||
|
||||
this.map.getCurrentCenter((state, point) => {
|
||||
if (state !== 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
_this.currentPoint = point;
|
||||
_this.addCenterMarker(point);
|
||||
_this.getAddressByPoint(point);
|
||||
});
|
||||
},
|
||||
|
||||
getAddressByPoint(point) {
|
||||
const _this = this;
|
||||
|
||||
// 简化处理:直接显示"位置已选择",不调用外部 API
|
||||
// 如果需要真实地址,可以在确认时调用服务端 API
|
||||
_this.currentAddress = '位置已选择';
|
||||
},
|
||||
|
||||
getCurrentCenter(callback) {
|
||||
const _this = this;
|
||||
|
||||
this.map.getCurrentCenter((state, point) => {
|
||||
if (state !== 0) {
|
||||
callback(state, null);
|
||||
return;
|
||||
}
|
||||
|
||||
// 直接返回当前数据,地址会异步更新
|
||||
callback(state, {
|
||||
point: point,
|
||||
lng: point.getLng(),
|
||||
lat: point.getLat(),
|
||||
address: _this.currentAddress || '位置已选择'
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.map_container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
@@ -1,18 +1,27 @@
|
||||
<template>
|
||||
<view>
|
||||
<u-mask :show="previewVideoFlag" :custom-style="customMaskStyle">
|
||||
<view @tap.stop class="playBox" :style="'height:'+(winHeight/10*9)+'px;width:'+(winWidth-20)+'px;'">
|
||||
<video :style="'height:'+(winHeight/10*8)+'px;width:'+(winWidth-20)+'px'"
|
||||
:controls="true" :show-fullscreen-btn="false" :autoplay="true"
|
||||
:src="previewVideoSrc" @ended="quitPlay()">
|
||||
<u-button hover-class="none" @click="quitPlay()">关闭</u-button>
|
||||
<u-overlay
|
||||
v-if="previewVideoFlag"
|
||||
:show="previewVideoFlag"
|
||||
opacity="1"
|
||||
:custom-style="customMaskStyle">
|
||||
<view @tap.stop
|
||||
class="playBox"
|
||||
style="height:100vh;width:100vw;">
|
||||
<video
|
||||
v-if="previewVideoFlag"
|
||||
:style="{height:videoHeight+'vw',width:'100vw'}"
|
||||
:controls="true"
|
||||
:show-fullscreen-btn="false"
|
||||
:autoplay="true"
|
||||
:src="previewVideoSrc"
|
||||
@ended="play_end">
|
||||
</video>
|
||||
<view class="quitBox">
|
||||
<u-button hover-class="none" @click="quitPlay()">关闭</u-button>
|
||||
<view class="quitBox" @click="quitPlay">
|
||||
<u-icon name="close-circle" color="#FFF" size="32"></u-icon>
|
||||
<cover-view class="icon"></cover-view>
|
||||
</view>
|
||||
</view>
|
||||
</u-mask>
|
||||
</view>
|
||||
</u-overlay>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -36,22 +45,40 @@
|
||||
display:"flex",
|
||||
flexDirection: "column",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
//paddingTop:'100rpx',
|
||||
border:'1px solid red',
|
||||
width:"100%",
|
||||
height:"100%",
|
||||
alignItems: "center"
|
||||
},
|
||||
videoHeight:100,
|
||||
winHeight:0,
|
||||
winWidth:0
|
||||
};
|
||||
},
|
||||
watch:{
|
||||
previewVideoSrc(nv,ov){
|
||||
const _this = this;
|
||||
console.log(nv,ov);
|
||||
if(nv && nv != ov){
|
||||
uni.getVideoInfo({
|
||||
src:nv,
|
||||
success(res) {
|
||||
_this.videoHeight = res.width/ res.height * 100;
|
||||
},
|
||||
complete(res) {
|
||||
console.log(res);
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
created:function(){
|
||||
this.winHeight=this.$u.sys().windowHeight;
|
||||
this.winWidth=this.$u.sys().windowWidth;
|
||||
},
|
||||
methods:{
|
||||
play_end(res){
|
||||
console.log(res);
|
||||
},
|
||||
quitPlay:function(){
|
||||
console.log('quit');
|
||||
this.$emit("quitPlay");
|
||||
}
|
||||
}
|
||||
@@ -64,8 +91,17 @@
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
}
|
||||
.quitBox{
|
||||
width: 100%;
|
||||
position: absolute;
|
||||
z-index: 9999;
|
||||
right: 5%;
|
||||
top: 10%;
|
||||
.icon{
|
||||
color: #fff;
|
||||
font-size: 32px;
|
||||
font-family: uicon-iconfont;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
export const ChatingFooterActionTypes = {
|
||||
Album: "Album",
|
||||
Camera: "Camera",
|
||||
Video: "Video",
|
||||
Voice: "Voice",
|
||||
Call: "Call",
|
||||
Location: "Location",
|
||||
Redpacket: "Redpacket",
|
||||
Transfer: "Transfer",
|
||||
};
|
||||
|
||||
export const ContactMenuTypes = {
|
||||
|
||||
@@ -338,6 +338,12 @@
|
||||
"style": {
|
||||
"navigationBarTitleText": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/common/map",
|
||||
"style": {
|
||||
"navigationBarTitleText": ""
|
||||
}
|
||||
}
|
||||
],
|
||||
"tabBar": {
|
||||
|
||||
@@ -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(
|
||||
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(path)
|
||||
getPurePath(item)
|
||||
);
|
||||
this.sendMessage(message,this.storeCurrentConversation.userID,this.storeCurrentConversation.groupID);
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -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>
|
||||
@@ -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,23 +1,20 @@
|
||||
<template>
|
||||
<view class="text_message_container bg_container">
|
||||
<mp-html
|
||||
:previewImg="false"
|
||||
:showImgMenu="false"
|
||||
:lazyLoad="false"
|
||||
selectable
|
||||
:content="getContent"
|
||||
/>
|
||||
<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,
|
||||
conversationID:String,
|
||||
},
|
||||
computed: {
|
||||
getContent() {
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 84 KiB |
@@ -1,3 +1,5 @@
|
||||
## 1.1.3(2025-12-03)
|
||||
- 修复: 腾讯云目录错误导致的上传错误问题
|
||||
## 1.1.2(2025-09-17)
|
||||
- 修复 设置readonly属性后内容插槽失效的问题。
|
||||
## 1.1.1(2025-09-03)
|
||||
|
||||
@@ -186,14 +186,14 @@
|
||||
},
|
||||
dir: {
|
||||
type: String,
|
||||
default: '/'
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
files: [],
|
||||
localValue: [],
|
||||
dirPath: '/'
|
||||
dirPath: ''
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "uni-file-picker",
|
||||
"displayName": "uni-file-picker 文件选择上传",
|
||||
"version": "1.1.2",
|
||||
"version": "1.1.3",
|
||||
"description": "文件选择上传组件,可以选择图片、视频等任意文件并上传到当前绑定的服务空间",
|
||||
"keywords": [
|
||||
"uni-ui",
|
||||
|
||||
@@ -8,4 +8,3 @@
|
||||
文件选择上传组件,可以选择图片、视频等任意文件并上传到当前绑定的服务空间
|
||||
|
||||
### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-file-picker)
|
||||
#### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839
|
||||
@@ -241,6 +241,7 @@ export const formatChooseData = (data, key = "nickname") => {
|
||||
};
|
||||
|
||||
export const getPurePath = (path) => {
|
||||
if(!path)return "";
|
||||
const prefix = "file://";
|
||||
const relativeRrefix = "_doc/";
|
||||
if (path.includes(prefix)) {
|
||||
@@ -303,3 +304,236 @@ export const checkLoginError = (error) => {
|
||||
return "操作失败";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// 删除本地文件,适配 plus 环境
|
||||
export const deleteLocalFile = (path) => {
|
||||
return new Promise((resolve) => {
|
||||
if (!path) return resolve();
|
||||
if (typeof plus === 'undefined') return resolve();
|
||||
|
||||
// 尝试直接用 resolveLocalFileSystemURL,如果失败再尝试加 file:// 前缀
|
||||
const tryRemove = (p) => {
|
||||
plus.io.resolveLocalFileSystemURL(p, function(entry) {
|
||||
entry.remove(function() {
|
||||
resolve();
|
||||
}, function(err) {
|
||||
console.log('deleteLocalFile remove error:', err);
|
||||
resolve();
|
||||
});
|
||||
}, function(err) {
|
||||
resolve(err);
|
||||
});
|
||||
};
|
||||
|
||||
tryRemove(path);
|
||||
});
|
||||
};
|
||||
export const getVideoCover = (videoPath, frameIndex, callback) => {
|
||||
// 兼容性:如果传入 callback,则函数立即返回空串,并在回调中返回路径;
|
||||
// 如果不传 callback,则返回 Promise<string>(兼容旧用法)。
|
||||
|
||||
// 简单字符串哈希,用于生成固定缩略图文件名
|
||||
const _hash = (s) => {
|
||||
let h = 2166136261;
|
||||
for (let i = 0; i < s.length; i++) {
|
||||
h ^= s.charCodeAt(i);
|
||||
h = Math.imul(h, 16777619);
|
||||
}
|
||||
return (h >>> 0).toString(16);
|
||||
};
|
||||
|
||||
const run = async () => {
|
||||
if (!videoPath) return "";
|
||||
|
||||
// 生成固定的缩略图路径(基于 videoPath 哈希)
|
||||
let coverRel = null;
|
||||
try {
|
||||
const key = _hash(String(videoPath));
|
||||
coverRel = `_doc/video_cover_${key}.jpg`;
|
||||
const coverAbs = typeof plus !== 'undefined' && plus.io ? plus.io.convertLocalFileSystemURL(coverRel) : null;
|
||||
|
||||
// 如果已存在,直接返回
|
||||
if (typeof plus !== 'undefined' && plus.io) {
|
||||
try {
|
||||
const exists = await new Promise((res) => {
|
||||
plus.io.resolveLocalFileSystemURL(coverRel, function(entry) { res(true); }, function() { res(false); });
|
||||
});
|
||||
if (exists) return coverAbs;
|
||||
} catch (e) {
|
||||
// ignore and continue
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
// ignore and continue
|
||||
coverRel = null;
|
||||
}
|
||||
|
||||
// 1. Native plus 方式尝试
|
||||
if (typeof plus !== "undefined" && plus.io) {
|
||||
try {
|
||||
// 规范路径(若有可用转换函数)
|
||||
if (typeof getUniversalVideoPath === 'function') {
|
||||
try { videoPath = await getUniversalVideoPath(videoPath); } catch (e) {}
|
||||
}
|
||||
|
||||
// 尝试 Android 原生 MediaMetadataRetriever 提取帧
|
||||
if (plus.android) {
|
||||
try {
|
||||
var MediaMetadataRetriever = plus.android.importClass('android.media.MediaMetadataRetriever');
|
||||
var retriever = new MediaMetadataRetriever();
|
||||
var setDataSourcePath = videoPath;
|
||||
if (typeof setDataSourcePath === 'string' && setDataSourcePath.indexOf('file://') === 0) {
|
||||
setDataSourcePath = setDataSourcePath.replace('file://', '');
|
||||
}
|
||||
var _setOk = false;
|
||||
try { retriever.setDataSource(setDataSourcePath); _setOk = true; } catch (sdErr) {
|
||||
try {
|
||||
var UriClass = plus.android.importClass('android.net.Uri');
|
||||
var uriObj = UriClass.parse(videoPath);
|
||||
var activity = plus.android.runtimeMainActivity();
|
||||
retriever.setDataSource(activity, uriObj);
|
||||
_setOk = true;
|
||||
} catch (sd2Err) {}
|
||||
}
|
||||
|
||||
var timeUs = (typeof frameIndex === 'number' && frameIndex >= 0) ? Math.floor(frameIndex * 1000000) : 0;
|
||||
var bitmap = null;
|
||||
try { bitmap = retriever.getFrameAtTime(timeUs); } catch (gfErr) {}
|
||||
if (!bitmap) {
|
||||
try { bitmap = retriever.getFrameAtTime(-1); } catch (e2) {}
|
||||
}
|
||||
if (!bitmap) {
|
||||
try { bitmap = retriever.getFrameAtTime(1000000); } catch (e3) {}
|
||||
}
|
||||
|
||||
if (bitmap) {
|
||||
try {
|
||||
var CompressFormat = plus.android.importClass('android.graphics.Bitmap$CompressFormat');
|
||||
var ByteArrayOutputStream = plus.android.importClass('java.io.ByteArrayOutputStream');
|
||||
var baos = new ByteArrayOutputStream();
|
||||
plus.android.invoke(bitmap, 'compress', CompressFormat.JPEG, 80, baos);
|
||||
var bytes = plus.android.invoke(baos, 'toByteArray');
|
||||
|
||||
// 写入到固定路径(如果 coverRel 可用)
|
||||
var tempRel = coverRel || ('_doc/video_cover_' + Date.now() + '.jpg');
|
||||
var tempAbs = plus.io.convertLocalFileSystemURL(tempRel);
|
||||
var tempForJava = tempAbs;
|
||||
if (typeof tempForJava === 'string' && tempForJava.indexOf('file://') === 0) tempForJava = tempForJava.replace('file://', '');
|
||||
var FileOutputStream = plus.android.importClass('java.io.FileOutputStream');
|
||||
var fos = new FileOutputStream(tempForJava);
|
||||
plus.android.invoke(fos, 'write', bytes);
|
||||
plus.android.invoke(fos, 'close');
|
||||
try { retriever.release(); } catch (e) {}
|
||||
return tempAbs;
|
||||
} catch (writeErr) {
|
||||
try { retriever.release(); } catch (e) {}
|
||||
}
|
||||
} else {
|
||||
try { retriever.release(); } catch (e) {}
|
||||
}
|
||||
} catch (mmrErr) {}
|
||||
}
|
||||
|
||||
// 兼容:尝试 plus.getVideoAttributes
|
||||
if (typeof plus.getVideoAttributes === "function") {
|
||||
try {
|
||||
const attr = await new Promise((res, rej) => {
|
||||
plus.getVideoAttributes(videoPath, function(info) { res(info && info.path ? info.path : info); }, function(err) { rej(err); });
|
||||
});
|
||||
if (attr) return attr;
|
||||
} catch (e) {}
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
// 3. H5 capture via video+canvas(在 native 的 WebView 中也可以运行)
|
||||
if (typeof document !== "undefined") {
|
||||
try {
|
||||
const dataUrl = await new Promise((resolve) => {
|
||||
const video = document.createElement('video');
|
||||
video.crossOrigin = 'anonymous';
|
||||
video.src = videoPath;
|
||||
video.muted = true;
|
||||
video.playsInline = true;
|
||||
|
||||
const onError = () => { cleanup(); resolve(''); };
|
||||
const onLoaded = () => {
|
||||
try {
|
||||
const targetTime = (typeof frameIndex === 'number' && frameIndex >= 0) ? Math.min(video.duration, frameIndex) : Math.min(1, Math.max(0, video.duration / 2));
|
||||
video.currentTime = targetTime;
|
||||
} catch (err) {}
|
||||
setTimeout(() => {
|
||||
try {
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = video.videoWidth || 320;
|
||||
canvas.height = video.videoHeight || 240;
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
|
||||
const data = canvas.toDataURL('image/jpeg', 0.8);
|
||||
cleanup();
|
||||
resolve(data || '');
|
||||
} catch (err) { cleanup(); resolve(''); }
|
||||
}, 400);
|
||||
};
|
||||
const cleanup = () => { video.removeEventListener('loadeddata', onLoaded); video.removeEventListener('error', onError); };
|
||||
video.addEventListener('loadeddata', onLoaded);
|
||||
video.addEventListener('error', onError);
|
||||
});
|
||||
|
||||
if (!dataUrl) return '';
|
||||
|
||||
if (typeof plus !== 'undefined' && plus.io) {
|
||||
try {
|
||||
const base64Data = dataUrl.split(',')[1];
|
||||
const bytes = atob(base64Data);
|
||||
const buf = new ArrayBuffer(bytes.length);
|
||||
const arr = new Uint8Array(buf);
|
||||
for (let i = 0; i < bytes.length; i++) arr[i] = bytes.charCodeAt(i);
|
||||
const tempRel = coverRel || ('_doc/video_cover_' + Date.now() + '.jpg');
|
||||
const tempAbs = plus.io.convertLocalFileSystemURL(tempRel);
|
||||
await new Promise((res, rej) => {
|
||||
plus.io.resolveLocalFileSystemURL(tempRel, function(fentry) {
|
||||
fentry.createWriter(function(writer) {
|
||||
writer.onwrite = function() { res(tempAbs); };
|
||||
writer.onerror = function(e) { rej(e); };
|
||||
writer.write(arr.buffer);
|
||||
}, function(e) { rej(e); });
|
||||
}, function() {
|
||||
plus.io.requestFileSystem(plus.io.PRIVATE_DOC, function(fs) {
|
||||
fs.root.getFile(tempRel, {create: true}, function(fentry) {
|
||||
fentry.createWriter(function(writer) { writer.onwrite = function() { res(tempAbs); }; writer.onerror = function(e) { rej(e); }; writer.write(arr.buffer); }, rej);
|
||||
}, rej);
|
||||
}, rej);
|
||||
});
|
||||
});
|
||||
return tempAbs;
|
||||
} catch (e) { return dataUrl; }
|
||||
}
|
||||
return dataUrl;
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
return '';
|
||||
};
|
||||
|
||||
if (typeof callback === 'function') {
|
||||
run().then((p) => { try { callback(p); } catch (e) {} }).catch(() => { try { callback(''); } catch (e) {} });
|
||||
return "";
|
||||
}
|
||||
|
||||
return run();
|
||||
};
|
||||
|
||||
export const getVideoInfo = async (src)=>{
|
||||
return await new Promise((resolve,reject)=>{
|
||||
uni.getVideoInfo({
|
||||
src:src,
|
||||
success(res){
|
||||
resolve(res)
|
||||
},fail(error){
|
||||
reject(error)
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
@@ -119,12 +119,36 @@ export const parseMessageByType = (pmsg) => {
|
||||
return pmsg.textElem.content;
|
||||
case MessageType.PictureMessage:
|
||||
return `[图片]`;
|
||||
case MessageType.VoiceMessage:
|
||||
return `[语音]`;
|
||||
case MessageType.VideoMessage:
|
||||
return `[视频]`;
|
||||
case MessageType.FileMessage:
|
||||
return `[文件]`;
|
||||
case MessageType.MergeMessage:
|
||||
return `[合并消息]`;
|
||||
case MessageType.CardMessage:
|
||||
return `[名片]`;
|
||||
case MessageType.LocationMessage:
|
||||
return `[位置]`;
|
||||
case MessageType.CustomMessage:
|
||||
return `[自定义消息]`;
|
||||
case MessageType.TypingMessage:
|
||||
return `[TypingMessage]`;
|
||||
case MessageType.QuoteMessage:
|
||||
return `[QuoteMessage]`;
|
||||
case MessageType.FaceMessage:
|
||||
return `[FaceMessage]`;
|
||||
case MessageType.MarkdownMessage:
|
||||
return `[MarkdownMessage]`;
|
||||
case MessageType.FriendAdded:
|
||||
return "你们已经是好友了,开始聊天吧~";
|
||||
case MessageType.MemberEnter:
|
||||
const enterDetails = JSON.parse(pmsg.notificationElem.detail);
|
||||
const enterUser = enterDetails.entrantUser;
|
||||
return `${getName(enterUser)}进入了群聊`;
|
||||
case MessageType.OANotification:
|
||||
return `[OANotification]`;
|
||||
case MessageType.GroupCreated:
|
||||
const groupCreatedDetail = JSON.parse(pmsg.notificationElem.detail);
|
||||
const groupCreatedUser = groupCreatedDetail.opUser;
|
||||
@@ -138,9 +162,7 @@ export const parseMessageByType = (pmsg) => {
|
||||
(user, idx) => (inviteStr += getName(user) + "、") && idx > 3,
|
||||
);
|
||||
inviteStr = inviteStr.slice(0, -1);
|
||||
return `${getName(inviteOpUser)}邀请了${inviteStr}${
|
||||
invitedUserList.length > 3 ? "..." : ""
|
||||
}进入群聊`;
|
||||
return `${getName(inviteOpUser)}邀请了${inviteStr}${invitedUserList.length > 3 ? "..." : ""}进入群聊`;
|
||||
|
||||
case MessageType.MemberKicked:
|
||||
const kickDetails = JSON.parse(pmsg.notificationElem.detail);
|
||||
@@ -151,9 +173,13 @@ export const parseMessageByType = (pmsg) => {
|
||||
(user, idx) => (kickStr += getName(user) + "、") && idx > 3,
|
||||
);
|
||||
kickStr = kickStr.slice(0, -1);
|
||||
return `${getName(kickOpUser)}踢出了${kickStr}${
|
||||
kickdUserList.length > 3 ? "..." : ""
|
||||
}`;
|
||||
return `${getName(kickOpUser)}踢出了${kickStr}${kickdUserList.length > 3 ? "..." : ""}`;
|
||||
case MessageType.GroupMemberMuted:
|
||||
return `[GroupMemberMuted]`;
|
||||
case MessageType.GroupMemberCancelMuted:
|
||||
return `[GroupMemberCancelMuted]`;
|
||||
case MessageType.GroupMuted:
|
||||
return `[GroupMuted]`;
|
||||
case MessageType.MemberQuit:
|
||||
const quitDetails = JSON.parse(pmsg.notificationElem.detail);
|
||||
const quitUser = quitDetails.quitUser;
|
||||
@@ -174,9 +200,17 @@ export const parseMessageByType = (pmsg) => {
|
||||
case MessageType.GroupNameUpdated:
|
||||
const groupNameUpdateDetail = JSON.parse(pmsg.notificationElem.detail);
|
||||
const groupNameUpdateUser = groupNameUpdateDetail.opUser;
|
||||
return `${getName(groupNameUpdateUser)}修改了群名称为${
|
||||
groupNameUpdateDetail.group.groupName
|
||||
}`;
|
||||
return `${getName(groupNameUpdateUser)}修改了群名称为${groupNameUpdateDetail.group.groupName}`;
|
||||
case MessageType.GroupCancelMuted:
|
||||
return `[GroupCancelMuted]`;
|
||||
case MessageType.GroupAnnouncementUpdated:
|
||||
return `[GroupAnnouncementUpdated]`;
|
||||
case MessageType.BurnMessageChange:
|
||||
return `[BurnMessageChange]`;
|
||||
case MessageType.RevokeMessage:
|
||||
return `[RevokeMessage]`;
|
||||
case MessageType.MsgPinned:
|
||||
return `[MsgPinned]`;
|
||||
default:
|
||||
return "[暂未支持的消息类型]";
|
||||
}
|
||||
@@ -251,10 +285,7 @@ export const tipMessaggeFormat = (msg, currentUserID) => {
|
||||
(user, idx) => (inviteStr += parseInfo(user) + "、") && idx > 3,
|
||||
);
|
||||
inviteStr = inviteStr.slice(0, -1);
|
||||
return `${parseInfo(inviteOpUser)} 邀请了${inviteStr}${
|
||||
invitedUserList.length > 3 ? "..." : ""
|
||||
}加入群聊`;
|
||||
case MessageType.MemberKicked:
|
||||
return `${parseInfo(inviteOpUser)} 邀请了${inviteStr}${invitedUserList.length > 3 ? "..." : ""}加入群聊`; case MessageType.MemberKicked:
|
||||
const kickDetails = JSON.parse(msg.notificationElem.detail);
|
||||
const kickOpUser = kickDetails.opUser;
|
||||
const kickdUserList = kickDetails.kickedUserList ?? [];
|
||||
@@ -263,9 +294,7 @@ export const tipMessaggeFormat = (msg, currentUserID) => {
|
||||
(user, idx) => (kickStr += parseInfo(user) + "、") && idx > 3,
|
||||
);
|
||||
kickStr = kickStr.slice(0, -1);
|
||||
return `${parseInfo(kickOpUser)} 踢出了${kickStr}${
|
||||
kickdUserList.length > 3 ? "..." : ""
|
||||
}`;
|
||||
return `${parseInfo(kickOpUser)} 踢出了${kickStr}${kickdUserList.length > 3 ? "..." : ""}`;
|
||||
case MessageType.MemberEnter:
|
||||
const enterDetails = JSON.parse(msg.notificationElem.detail);
|
||||
const enterUser = enterDetails.entrantUser;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
//import i18n from '@/locales'
|
||||
import base from '@/common/config';
|
||||
//import store from "@/store";
|
||||
import IMSDK from "openim-uniapp-polyfill";
|
||||
const isString = (v)=> {
|
||||
return typeof v === 'string' || v instanceof String;
|
||||
},
|
||||
@@ -222,5 +223,73 @@ export default{
|
||||
v = parseFloat(v).toFixed(wei || 2);
|
||||
return parseFloat(v);
|
||||
},
|
||||
imapi(method,data){
|
||||
return IMSDK.asyncApi(method,IMSDK.uuid(),data);
|
||||
},
|
||||
|
||||
async fileExsit(fn){
|
||||
return await new Promise((resolve) => {
|
||||
plus.io.resolveLocalFileSystemURL(fn, function(entry) { resolve(true); }, function() { resolve(false); });
|
||||
})
|
||||
},
|
||||
downloadFile (url, savepath, successCb, errorCb, progressCb) {
|
||||
if (!url) {
|
||||
errorCb && errorCb(new Error('empty url'));
|
||||
return;
|
||||
}
|
||||
const startDownload = () => {
|
||||
try {
|
||||
const task = plus.downloader.createDownload(url, { filename: savepath, timeout: 120000 }, function(d, status) {
|
||||
if (status === 200) {
|
||||
const local = d && d.filename ? d.filename : savepath;
|
||||
successCb && successCb(local);
|
||||
} else {
|
||||
errorCb && errorCb(new Error('download status ' + status));
|
||||
}
|
||||
});
|
||||
try {
|
||||
if (task && typeof task.addEventListener === 'function') {
|
||||
task.addEventListener('statechanged', function(t, status) {
|
||||
if (t.state === 3) {
|
||||
var downloaded = t.downloadedSize || t.downloaded || 0;
|
||||
var total = t.totalSize || t.total || 0;
|
||||
var prog = 0;
|
||||
if (total > 0) prog = Math.min(100, Math.floor(downloaded / total * 100));
|
||||
progressCb && progressCb(prog);
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
// ignore
|
||||
}
|
||||
task.start();
|
||||
} catch (e) {
|
||||
errorCb && errorCb(e);
|
||||
}
|
||||
};
|
||||
|
||||
// 确保父目录存在
|
||||
try {
|
||||
const parent = savepath.substring(0, savepath.lastIndexOf('/'));
|
||||
plus.io.resolveLocalFileSystemURL(parent, function(entry) {
|
||||
startDownload();
|
||||
}, function() {
|
||||
// 目录不存在,尝试创建(针对 _doc/<conversationID> 结构)
|
||||
let rel = parent;
|
||||
if (rel.indexOf('_doc/') === 0) rel = rel.replace(/^_doc\//, '');
|
||||
plus.io.requestFileSystem(plus.io.PRIVATE_DOC, function(fs) {
|
||||
fs.root.getDirectory(rel, { create: true }, function(entry) {
|
||||
startDownload();
|
||||
}, function(e) {
|
||||
// 创建失败也尝试下载,可能运行时会自动创建
|
||||
startDownload();
|
||||
});
|
||||
}, function(e) {
|
||||
startDownload();
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
startDownload();
|
||||
}
|
||||
}
|
||||
}
|
||||