fix: 修复患者就诊历史
This commit is contained in:
@@ -447,7 +447,11 @@
|
||||
<view class="icon-circle"><u-icon name="camera-fill" size="20" color="#606266"></u-icon></view>
|
||||
<text>拍摄</text>
|
||||
</view>
|
||||
<!-- 预留扩展位:可以在这里添加发处方、发文件等按钮 -->
|
||||
<!-- 视频按钮 -->
|
||||
<view class="action-item" @click="openMediaPicker('video')">
|
||||
<view class="icon-circle"><u-icon name="play-circle-fill" size="20" color="#606266"></u-icon></view>
|
||||
<text>视频</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -519,6 +523,11 @@
|
||||
import { webSocketManager } from '@/utils/ws/websocket';
|
||||
import { ChatManager } from '@/store/chat/chat.js';
|
||||
import {getChatRegisterInfoApi, sendToUserApi, upLoadChatFileApi} from "@/request/api/im";
|
||||
import { checkDev } from '@/utils/utils';
|
||||
|
||||
// 根据环境获取上传URL
|
||||
const isDev = checkDev('dev');
|
||||
const uploadBaseUrl = isDev ? 'http://127.0.0.1:18001/api/mobile' : 'https://api.xiaokang88.com/api/mobile';
|
||||
|
||||
/**
|
||||
* 辅助函数:按需解析消息内容
|
||||
@@ -1032,7 +1041,7 @@ export default {
|
||||
uni.showLoading({ title: '上传中...', mask: true });
|
||||
try {
|
||||
uni.uploadFile({
|
||||
url: 'http://127.0.0.1:18001/api/mobile/chat-friends/upload-chat-file',
|
||||
url: `${uploadBaseUrl}/chat-friends/upload-chat-file`,
|
||||
filePath: tempFilePath,
|
||||
name: 'file',
|
||||
header: {
|
||||
@@ -1213,38 +1222,68 @@ export default {
|
||||
sourceType: ['album', 'camera'],
|
||||
success: res => {
|
||||
res.tempFilePaths.forEach(file => {
|
||||
// 此处复用了上传音频的接口逻辑,可根据实际需求调整为图片上传接口
|
||||
uni.uploadFile({
|
||||
url: 'http://127.0.0.1:18001/api/mobile/chat-friends/upload-chat-file',
|
||||
filePath: file,
|
||||
name: 'file',
|
||||
header: { "authorization": uni.getStorageSync('token') },
|
||||
formData: {},
|
||||
success: (uploadFileRes) => {
|
||||
this.sendMessage({
|
||||
type: 'image',
|
||||
content: JSON.parse(uploadFileRes.data).result.url
|
||||
});
|
||||
},
|
||||
fail: (res) => { console.log(res, '上传失败'); }
|
||||
});
|
||||
this.uploadAndSendFile(file, 'image');
|
||||
});
|
||||
},
|
||||
fail: (e) => { console.log('错误', e); },
|
||||
});
|
||||
} else if (type === 'video') {
|
||||
// 选择视频
|
||||
uni.chooseVideo({
|
||||
sourceType: ['album', 'camera'],
|
||||
maxDuration: 60, // 最长60秒
|
||||
camera: 'back',
|
||||
success: res => {
|
||||
this.uploadAndSendFile(res.tempFilePath, 'video');
|
||||
},
|
||||
fail: (e) => { console.log('选择视频错误', e); },
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 通用文件上传并发送方法
|
||||
*/
|
||||
uploadAndSendFile(filePath, type) {
|
||||
uni.showLoading({ title: '上传中...', mask: true });
|
||||
uni.uploadFile({
|
||||
url: `${uploadBaseUrl}/chat-friends/upload-chat-file`,
|
||||
filePath: filePath,
|
||||
name: 'file',
|
||||
header: { "authorization": uni.getStorageSync('token') },
|
||||
formData: {},
|
||||
success: (uploadFileRes) => {
|
||||
uni.hideLoading();
|
||||
try {
|
||||
const result = JSON.parse(uploadFileRes.data);
|
||||
if (result.code === 0 && result.result && result.result.url) {
|
||||
this.sendMessage({
|
||||
type: type,
|
||||
content: result.result.url
|
||||
});
|
||||
} else {
|
||||
uni.showToast({ title: result.message || '上传失败', icon: 'none' });
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('解析上传结果失败:', e);
|
||||
uni.showToast({ title: '上传失败', icon: 'none' });
|
||||
}
|
||||
},
|
||||
fail: (res) => {
|
||||
uni.hideLoading();
|
||||
console.log(res, '上传失败');
|
||||
uni.showToast({ title: '上传失败', icon: 'none' });
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
openCamera() {
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
sourceType: ['camera'],
|
||||
success: res => {
|
||||
// 这里可以复用上面的上传逻辑
|
||||
this.sendMessage({
|
||||
type: 'image',
|
||||
content: res.tempFilePaths[0] // 注意:实际应用中也需要上传
|
||||
});
|
||||
// 使用通用上传方法上传拍摄的照片
|
||||
this.uploadAndSendFile(res.tempFilePaths[0], 'image');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user