小程序优化

This commit is contained in:
2026-01-22 11:36:26 +08:00
parent 8ab6107f25
commit 12d9294f3d
5 changed files with 173 additions and 96 deletions

View File

@@ -156,10 +156,10 @@
<!-- 输入和操作行 -->
<view class="input-row">
<view class="input-actions">
<view class="action-btn" @tap="chooseFile">
<text class="action-icon">📎</text>
</view>
<view class="action-btn" @tap="showUploadOptions">
<text class="action-icon">📎</text>
</view>
</view>
<input class="chat-input" v-model="inputText" placeholder="输入消息..."
@confirm="sendMessage" />
<view class="send-btn" @tap="sendMessage" :class="{ disabled: isUploading || selectedFiles.length === 0 && !inputText.trim() }">
@@ -697,45 +697,27 @@ async function handleJoinMeeting(meetingId: string) {
const meetingName = meetingData.meetingName || '视频会议'
console.log('[handleJoinMeeting] 获取到会议页面URL:', meetingPageUrl, '会议名称:', meetingName)
// 小程序环境直接使用固定的HTTPS域名
const protocol = 'https:'
const host = 'org.xyzh.yslg'
// 如果meetingPageUrl不包含/workcase需要加上
const fullPath = meetingPageUrl.startsWith('/workcase')
? meetingPageUrl
: '/workcase' + meetingPageUrl
// 附加roomId参数用于离开会议后返回聊天室
const fullMeetingUrl = `${protocol}//${host}${fullPath}&roomId=${roomId.value}`
// 使用API返回的完整jitsiIframeUrl作为会议链接
let fullMeetingUrl = meetingData.jitsiIframeUrl || ''
// 如果没有jitsiIframeUrl再使用iframeUrl构建
if (!fullMeetingUrl && meetingData.iframeUrl) {
// 小程序环境直接使用固定的HTTPS域名
const protocol = 'https:'
const host = 'org.xyzh.yslg'
// 如果meetingPageUrl不包含/workcase需要加上
const fullPath = meetingData.iframeUrl.startsWith('/workcase')
? meetingData.iframeUrl
: '/workcase' + meetingData.iframeUrl
// 附加roomId参数用于离开会议后返回聊天室
fullMeetingUrl = `${protocol}//${host}${fullPath}&roomId=${roomId.value}`
}
console.log('[handleJoinMeeting] 完整会议URL:', fullMeetingUrl)
// 小程序环境:显示提示,引导用户复制链接在浏览器打开
uni.showModal({
title: '视频会议',
content: '微信小程序暂不支持视频会议,请复制链接在浏览器中打开',
confirmText: '复制链接',
cancelText: '取消',
success: (res) => {
if (res.confirm) {
// 复制链接到剪贴板
uni.setClipboardData({
data: fullMeetingUrl,
success: () => {
uni.showToast({
title: '链接已复制,请在浏览器中打开',
icon: 'none',
duration: 3000
})
},
fail: () => {
uni.showToast({
title: '复制失败,请手动复制',
icon: 'none'
})
}
})
}
}
// 跳转到会议页面
uni.navigateTo({
url: `/pages/meeting/Meeting?meetingId=${meetingId}&meetingName=${encodeURIComponent(meetingName)}&jitsiIframeUrl=${encodeURIComponent(fullMeetingUrl)}`
})
} else {
console.error('[handleJoinMeeting] 加入会议失败, isSuccess:', isSuccess, 'data:', meetingData)
@@ -780,23 +762,120 @@ async function handleCommentSubmit(rating: number) {
// 文件操作相关函数
// 选择文件
async function chooseFile() {
try {
const res = await uni.chooseMessageFile({
count: 9, // 最多选择9个文件
type: 'file',
ext: ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'pdf', 'txt', 'jpg', 'jpeg', 'png', 'gif']
})
if (res.tempFiles && res.tempFiles.length > 0) {
// 添加到选中文件列表
selectedFiles.value = [...selectedFiles.value, ...res.tempFiles]
// 显示上传选项
function showUploadOptions() {
uni.showActionSheet({
itemList: ['拍照', '从相册选择', '选择文件'],
success: (res) => {
switch (res.tapIndex) {
case 0:
// 拍照
chooseImageFromCamera()
break
case 1:
// 从相册选择
chooseImageFromAlbum()
break
case 2:
// 选择文件
chooseFile()
break
}
}
} catch (error) {
console.error('选择文件失败:', error)
uni.showToast({ title: '选择文件失败', icon: 'none' })
})
}
// 拍照
function chooseImageFromCamera() {
uni.chooseImage({
count: 9,
sourceType: ['camera'],
success: (res) => {
if (res.tempFiles && res.tempFiles.length > 0) {
// 添加到选中文件列表
selectedFiles.value = [...selectedFiles.value, ...res.tempFiles]
}
},
fail: (err) => {
console.error('拍照失败:', err)
uni.showToast({ title: '拍照失败', icon: 'none' })
}
})
}
// 从相册选择
function chooseImageFromAlbum() {
uni.chooseImage({
count: 9,
sourceType: ['album'],
success: (res) => {
if (res.tempFiles && res.tempFiles.length > 0) {
// 添加到选中文件列表
selectedFiles.value = [...selectedFiles.value, ...res.tempFiles]
}
},
fail: (err) => {
console.error('从相册选择失败:', err)
uni.showToast({ title: '选择图片失败', icon: 'none' })
}
})
}
// 选择文件
function chooseFile() {
// #ifdef MP-WEIXIN
// 微信小程序使用 chooseMessageFile
uni.chooseMessageFile({
count: 9,
type: 'file',
extension: ['pdf', 'doc', 'docx', 'xls', 'xlsx', 'txt', 'jpg', 'jpeg', 'png', 'gif'],
success: (res : any) => {
console.log('选择文件成功:', res)
if (res.tempFiles && res.tempFiles.length > 0) {
// 添加到选中文件列表
selectedFiles.value = [...selectedFiles.value, ...res.tempFiles]
}
},
fail: (err : any) => {
console.error('选择文件失败:', err)
uni.showToast({
title: '选择文件失败',
icon: 'none'
})
}
})
// #endif
// #ifndef MP-WEIXIN
// 非微信小程序环境
// @ts-ignore
if (typeof uni.chooseFile === 'function') {
// @ts-ignore
uni.chooseFile({
count: 9,
extension: ['.pdf', '.doc', '.docx', '.xls', '.xlsx', '.txt', '.jpg', '.jpeg', '.png', '.gif'],
success: (res : any) => {
console.log('选择文件成功:', res)
if (res.tempFiles && res.tempFiles.length > 0) {
// 添加到选中文件列表
selectedFiles.value = [...selectedFiles.value, ...res.tempFiles]
}
},
fail: (err : any) => {
console.error('选择文件失败:', err)
uni.showToast({
title: '选择文件失败',
icon: 'none'
})
}
})
} else {
uni.showToast({
title: '当前环境不支持文件选择',
icon: 'none'
})
}
// #endif
}
// 删除选中的文件
@@ -822,6 +901,7 @@ async function uploadFiles(): Promise<string[]> {
isUploading.value = true
uni.showLoading({ title: '上传中...' })
try {
// 获取文件路径数组
const filePaths = selectedFiles.value.map(file => file.path)