2025-07-19 16:04:43 +08:00
|
|
|
|
<template>
|
2026-01-26 15:55:13 +08:00
|
|
|
|
<!-- 根容器 -->
|
2025-07-19 16:04:43 +08:00
|
|
|
|
<view class="chat-container">
|
2025-12-23 08:31:21 +08:00
|
|
|
|
|
2026-02-07 16:17:01 +08:00
|
|
|
|
<!-- ================= 自定义导航栏 ================= -->
|
|
|
|
|
|
<u-navbar
|
|
|
|
|
|
class="chat-navbar"
|
|
|
|
|
|
:is-back="true"
|
|
|
|
|
|
:title="doctorUserInfo.nick_name || '在线问诊'"
|
|
|
|
|
|
:custom-back="handleBack"
|
|
|
|
|
|
title-color="#333"
|
|
|
|
|
|
:border-bottom="false"
|
|
|
|
|
|
></u-navbar>
|
|
|
|
|
|
|
2026-01-26 15:55:13 +08:00
|
|
|
|
<!-- ================= 顶部导航栏 (保持原样) ================= -->
|
2025-12-23 08:31:21 +08:00
|
|
|
|
<view class="chat-header">
|
|
|
|
|
|
<view class="header-main" @click="toggleDoctorDetail">
|
|
|
|
|
|
<view class="doctor-info-group">
|
2025-07-19 16:04:43 +08:00
|
|
|
|
<text class="doctor-name">{{ doctorUserInfo.nick_name }}</text>
|
2025-12-23 08:31:21 +08:00
|
|
|
|
<view class="doctor-badges">
|
|
|
|
|
|
<text class="status-dot"></text>
|
2026-01-15 12:33:46 +08:00
|
|
|
|
<text class="sub-text">在线</text>
|
2025-12-23 08:31:21 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view class="header-action">
|
|
|
|
|
|
<text class="expand-tip">{{ showDoctorDetail ? '收起' : '详情' }}</text>
|
2026-01-26 15:55:13 +08:00
|
|
|
|
<u-icon :name="showDoctorDetail ? 'arrow-up' : 'arrow-down'" size="12" color="#0A84FF"></u-icon>
|
2025-07-19 16:04:43 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
|
2025-12-23 08:31:21 +08:00
|
|
|
|
<view class="doctor-detail-panel" :class="{ 'panel-show': showDoctorDetail }">
|
|
|
|
|
|
<view class="detail-grid">
|
|
|
|
|
|
<view class="detail-row">
|
|
|
|
|
|
<text class="label">职称</text>
|
2026-01-26 16:22:16 +08:00
|
|
|
|
<text class="value tag-value">{{ doctorDetailInfo.title || '--' }}</text>
|
2025-12-23 08:31:21 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
<view class="detail-row">
|
|
|
|
|
|
<text class="label">医院</text>
|
2026-01-26 16:22:16 +08:00
|
|
|
|
<text class="value">{{ doctorDetailInfo.hospital || '--' }}</text>
|
2025-12-23 08:31:21 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
<view class="detail-row full-width">
|
|
|
|
|
|
<text class="label">擅长</text>
|
2026-01-26 16:22:16 +08:00
|
|
|
|
<text class="value desc-value">{{ doctorDetailInfo.good_at || '--' }}</text>
|
2025-12-23 08:31:21 +08:00
|
|
|
|
</view>
|
2025-07-19 16:04:43 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
|
2025-12-23 08:31:21 +08:00
|
|
|
|
<!-- ================= 聊天消息滚动区域 ================= -->
|
2025-07-19 16:04:43 +08:00
|
|
|
|
<scroll-view
|
|
|
|
|
|
class="chat-messages"
|
2025-12-23 10:30:10 +08:00
|
|
|
|
:style="scrollViewStyle"
|
2025-07-19 16:04:43 +08:00
|
|
|
|
scroll-y="true"
|
2025-12-23 08:31:21 +08:00
|
|
|
|
:scroll-into-view="scrollIntoView"
|
2025-07-19 16:04:43 +08:00
|
|
|
|
:scroll-top="scrollTop"
|
|
|
|
|
|
scroll-with-animation
|
|
|
|
|
|
@scrolltoupper="loadHistory"
|
2025-12-23 10:30:10 +08:00
|
|
|
|
@scroll="onScroll"
|
2025-07-19 16:04:43 +08:00
|
|
|
|
>
|
2026-01-26 15:55:13 +08:00
|
|
|
|
<view class="message-list-container" id="msglist" :style="{ paddingBottom: (keyboardHeight > 0 ? keyboardHeight + 10 : 0) + 'px' }">
|
2026-01-14 18:44:20 +08:00
|
|
|
|
|
2026-07-19 16:08:04 +08:00
|
|
|
|
<!-- 协议提示信息:协议名单独节点绑定点击,避免嵌套 text 吞事件 -->
|
2026-02-07 16:17:01 +08:00
|
|
|
|
<view class="notice-box" v-if="showNotice">
|
|
|
|
|
|
<view class="notice-text">
|
2026-07-19 16:08:04 +08:00
|
|
|
|
<block v-for="(part, index) in parsedNoticeParts" :key="index">
|
2026-02-07 16:17:01 +08:00
|
|
|
|
<text v-if="part.type === 'text'">{{ part.text }}</text>
|
2026-07-19 16:08:04 +08:00
|
|
|
|
<text
|
|
|
|
|
|
v-else-if="part.type === 'agreement'"
|
|
|
|
|
|
class="notice-link"
|
|
|
|
|
|
@click.stop="viewAgreement(part.agreementId)"
|
|
|
|
|
|
>《{{ part.text }}》</text>
|
|
|
|
|
|
</block>
|
2026-02-07 16:17:01 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
|
2026-01-14 18:44:20 +08:00
|
|
|
|
<!-- 加载指示器 -->
|
2025-12-23 11:04:45 +08:00
|
|
|
|
<view v-if="loading" class="loading-spinner">
|
|
|
|
|
|
<view class="spinner"></view>
|
2026-01-26 15:55:13 +08:00
|
|
|
|
<text class="spinner-text">历史记录加载中...</text>
|
2025-12-23 11:04:45 +08:00
|
|
|
|
</view>
|
2026-01-14 18:44:20 +08:00
|
|
|
|
|
|
|
|
|
|
<!-- 无更多消息 -->
|
2025-07-25 15:59:33 +08:00
|
|
|
|
<view v-if="isEmpty" class="empty-state">
|
2026-01-26 15:55:13 +08:00
|
|
|
|
<text class="empty-text">没有更多消息了</text>
|
2025-07-25 15:59:33 +08:00
|
|
|
|
</view>
|
2025-12-23 08:31:21 +08:00
|
|
|
|
|
|
|
|
|
|
<!-- 消息列表循环 -->
|
|
|
|
|
|
<view v-for="(msg, index) in messages" :key="index" class="message-wrapper">
|
|
|
|
|
|
|
2026-01-26 15:55:13 +08:00
|
|
|
|
<!-- 时间 -->
|
|
|
|
|
|
<view class="time-divider" v-if="shouldShowTime(msg, index)">
|
|
|
|
|
|
<text class="time-text">{{ msg.created_at_text || msg.time }}</text>
|
2025-07-19 16:04:43 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
|
2026-01-26 15:55:13 +08:00
|
|
|
|
<!-- 使用抽离的组件 -->
|
|
|
|
|
|
<MessageBubble
|
|
|
|
|
|
:msg="msg"
|
|
|
|
|
|
:is-mine="isMsgMine(msg)"
|
|
|
|
|
|
:avatar="getMsgAvatar(msg)"
|
|
|
|
|
|
:is-playing="isPlaying(msg)"
|
|
|
|
|
|
@previewImage="previewImage"
|
|
|
|
|
|
@playAudio="playAudio"
|
|
|
|
|
|
@viewRegister="viewRegister"
|
|
|
|
|
|
@viewPrescription="viewPrescription"
|
|
|
|
|
|
@goToOrderMedicine="goToOrderMedicine"
|
2026-02-02 16:10:46 +08:00
|
|
|
|
@viewOrder="viewOrder"
|
2026-05-06 16:41:19 +08:00
|
|
|
|
@followUpDrugAnswered="onFollowUpDrugAnswered"
|
2026-07-19 16:08:04 +08:00
|
|
|
|
@avatarClick="goDoctorDetail(msg)"
|
2026-01-26 15:55:13 +08:00
|
|
|
|
/>
|
2025-12-23 08:31:21 +08:00
|
|
|
|
|
2025-07-19 16:04:43 +08:00
|
|
|
|
</view>
|
2025-12-23 08:31:21 +08:00
|
|
|
|
|
2026-01-14 18:44:20 +08:00
|
|
|
|
<!-- 底部锚点 -->
|
2025-12-23 08:31:21 +08:00
|
|
|
|
<view id="chat-bottom-anchor" style="height: 1px; width: 100%;"></view>
|
2025-07-19 16:04:43 +08:00
|
|
|
|
</view>
|
2025-07-22 16:54:37 +08:00
|
|
|
|
|
2026-01-14 18:44:20 +08:00
|
|
|
|
<!-- 底部静态占位 -->
|
2026-01-26 15:55:13 +08:00
|
|
|
|
<view style="height: 180rpx;"></view>
|
2025-07-19 16:04:43 +08:00
|
|
|
|
</scroll-view>
|
|
|
|
|
|
|
2026-07-19 16:08:04 +08:00
|
|
|
|
<!-- 协议抽屉:v-if 控制挂载,:show 控制显隐(微信 page-container 要求) -->
|
2026-06-01 09:52:26 +08:00
|
|
|
|
<page-container
|
2026-07-19 16:08:04 +08:00
|
|
|
|
v-if="showAgreement"
|
|
|
|
|
|
:show="showAgreement"
|
2026-06-01 09:52:26 +08:00
|
|
|
|
position="bottom"
|
|
|
|
|
|
round
|
|
|
|
|
|
overlay
|
|
|
|
|
|
custom-style="height:88%;"
|
|
|
|
|
|
@clickoverlay="closeAgreement"
|
|
|
|
|
|
@afterleave="closeAgreement"
|
|
|
|
|
|
>
|
2026-02-07 16:17:01 +08:00
|
|
|
|
<view class="agreement-popup">
|
|
|
|
|
|
<view class="agreement-header">
|
|
|
|
|
|
<text class="agreement-title">{{ currentAgreementName || '协议详情' }}</text>
|
2026-06-01 09:52:26 +08:00
|
|
|
|
<view class="agreement-close" @click="closeAgreement">×</view>
|
2026-02-07 16:17:01 +08:00
|
|
|
|
</view>
|
2026-06-01 09:52:26 +08:00
|
|
|
|
<scroll-view scroll-y class="agreement-content" :show-scrollbar="true">
|
2026-02-07 16:17:01 +08:00
|
|
|
|
<u-parse :html="agreementContent"></u-parse>
|
2026-06-01 09:52:26 +08:00
|
|
|
|
</scroll-view>
|
2026-02-07 16:17:01 +08:00
|
|
|
|
</view>
|
2026-06-01 09:52:26 +08:00
|
|
|
|
</page-container>
|
2026-02-07 16:17:01 +08:00
|
|
|
|
|
2026-01-26 15:55:13 +08:00
|
|
|
|
<!-- ================= 底部输入与工具栏 (重构优化版) ================= -->
|
2026-01-14 18:44:20 +08:00
|
|
|
|
<view class="chat-footer safe-area-inset-bottom" :style="{ bottom: keyboardHeight + 'px' }">
|
2026-01-07 14:21:29 +08:00
|
|
|
|
<view v-if="isConsultationEnded" class="consultation-ended-notice">
|
2026-01-26 15:55:13 +08:00
|
|
|
|
<u-icon name="checkmark-circle-fill" size="18" color="#999"></u-icon>
|
2026-02-07 13:02:15 +08:00
|
|
|
|
<text>本次问诊未开始或已结束</text>
|
2026-01-07 14:21:29 +08:00
|
|
|
|
</view>
|
2026-01-14 18:44:20 +08:00
|
|
|
|
|
2026-01-07 14:21:29 +08:00
|
|
|
|
<template v-else>
|
2026-01-26 15:55:13 +08:00
|
|
|
|
<!-- 相册工具栏 -->
|
|
|
|
|
|
<view class="toolbar-area" v-if="false">
|
|
|
|
|
|
<!-- 暂时隐藏 -->
|
2025-07-19 16:04:43 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
|
2026-01-07 14:21:29 +08:00
|
|
|
|
<view class="input-bar">
|
2026-01-26 15:55:13 +08:00
|
|
|
|
<!-- 左侧:语音切换按钮 -->
|
|
|
|
|
|
<view class="icon-btn left" @click="toggleVoiceInput">
|
|
|
|
|
|
<u-icon :name="voiceInputActive ? 'close' : 'mic'" size="26" color="#333"></u-icon>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 中间:输入框 / 按住说话 -->
|
2026-01-07 14:21:29 +08:00
|
|
|
|
<view class="input-field-wrapper">
|
|
|
|
|
|
<input
|
|
|
|
|
|
v-if="!voiceInputActive"
|
|
|
|
|
|
v-model="newMessage"
|
|
|
|
|
|
class="main-input"
|
2026-01-26 15:55:13 +08:00
|
|
|
|
:adjust-position="false"
|
2026-01-07 14:21:29 +08:00
|
|
|
|
confirm-type="send"
|
|
|
|
|
|
@confirm="sendTextMessage"
|
|
|
|
|
|
cursor-spacing="20"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<view v-else class="voice-btn"
|
|
|
|
|
|
:class="{ 'recording': recording }"
|
|
|
|
|
|
@touchstart="startVoiceRecording"
|
|
|
|
|
|
@touchend="stopVoiceRecording"
|
|
|
|
|
|
@touchcancel="stopVoiceRecording">
|
|
|
|
|
|
<text>{{ recording ? '松开 发送' : '按住 说话' }}</text>
|
|
|
|
|
|
</view>
|
2025-07-19 16:04:43 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
|
2026-01-26 15:55:13 +08:00
|
|
|
|
<!-- 右侧:发送按钮 或 加号 -->
|
|
|
|
|
|
<view class="right-action">
|
|
|
|
|
|
<view v-if="newMessage.trim()" class="send-btn" @click="sendTextMessage">发送</view>
|
|
|
|
|
|
<view v-else class="icon-btn" @click="openMediaPicker('image')">
|
|
|
|
|
|
<u-icon name="plus-circle" size="26" color="#333"></u-icon>
|
2026-01-07 14:21:29 +08:00
|
|
|
|
</view>
|
2025-12-23 08:31:21 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
2026-01-07 14:21:29 +08:00
|
|
|
|
</template>
|
2025-07-19 16:04:43 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
|
2026-01-26 15:55:13 +08:00
|
|
|
|
<!-- 录音蒙层 (保持原样) -->
|
2025-12-23 08:31:21 +08:00
|
|
|
|
<view v-if="showRecordingModal" class="recording-overlay">
|
|
|
|
|
|
<view class="recording-box">
|
|
|
|
|
|
<view class="wave-animation"></view>
|
|
|
|
|
|
<view style="margin: 20rpx 0;">
|
|
|
|
|
|
<u-icon name="mic-fill" size="40" color="#fff"></u-icon>
|
2025-07-19 16:04:43 +08:00
|
|
|
|
</view>
|
2026-01-26 15:55:13 +08:00
|
|
|
|
<text class="timer">正在录音 {{ recordingTime }}s</text>
|
2025-12-23 08:31:21 +08:00
|
|
|
|
<text class="tip">手指上滑取消</text>
|
2025-07-19 16:04:43 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2026-01-26 15:55:13 +08:00
|
|
|
|
import MessageBubble from './components/MessageBubble.vue'; // 引入组件
|
2025-07-19 16:04:43 +08:00
|
|
|
|
import { webSocketManager } from '@/utils/ws/websocket';
|
|
|
|
|
|
import { ChatManager } from '@/store/chat/chat.js';
|
2026-01-07 14:21:29 +08:00
|
|
|
|
import {getChatRegisterInfoApi, sendToUserApi, upLoadChatFileApi, getDoctorInfoApi, getRoomStatusApi} from "@/request/api/im";
|
2026-02-07 16:17:01 +08:00
|
|
|
|
import {getTransferAssistantConfigApi, getTransferConsultationAgreementInfoApi, getAgreementDetailApi} from "@/request/api/transferPrescription";
|
2025-12-24 08:33:13 +08:00
|
|
|
|
import { checkDev } from '@/utils/utils';
|
2026-05-30 16:54:01 +08:00
|
|
|
|
import { prepareImagePath } from '@/utils/image-compress.js';
|
2026-07-13 16:08:29 +08:00
|
|
|
|
import { checkText, checkImage, handleSecurityError, SCENE_CHAT } from '@/utils/content-security.js';
|
2025-12-24 08:33:13 +08:00
|
|
|
|
|
|
|
|
|
|
// 根据环境获取上传URL
|
|
|
|
|
|
const isDev = checkDev('dev');
|
|
|
|
|
|
const uploadBaseUrl = isDev ? 'http://127.0.0.1:18001/api/mobile' : 'https://api.xiaokang88.com/api/mobile';
|
2025-07-19 16:04:43 +08:00
|
|
|
|
|
2026-01-26 15:55:13 +08:00
|
|
|
|
// 辅助函数保留在父组件逻辑中
|
2025-12-23 08:31:21 +08:00
|
|
|
|
function getParsedContent(messageType, messageContent) {
|
2026-01-07 14:21:29 +08:00
|
|
|
|
if ([4, 9, 10, 11, 12, 13].includes(messageType)) {
|
2025-12-23 08:31:21 +08:00
|
|
|
|
try {
|
|
|
|
|
|
return typeof messageContent === 'object' ? messageContent : JSON.parse(messageContent);
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
return messageContent;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return messageContent;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-19 16:04:43 +08:00
|
|
|
|
export default {
|
2026-01-26 15:55:13 +08:00
|
|
|
|
components: {
|
|
|
|
|
|
MessageBubble
|
|
|
|
|
|
},
|
2025-07-19 16:04:43 +08:00
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
2026-01-14 18:44:20 +08:00
|
|
|
|
doctorUserInfo: { id: 0, avatar: '', nick_name: '医生', room_id: '' },
|
2026-01-26 16:22:16 +08:00
|
|
|
|
doctorDetailInfo: { title: '', hospital: '', good_at: '' }, // 医生详情信息
|
2026-01-14 18:44:20 +08:00
|
|
|
|
showDoctorDetail: false,
|
|
|
|
|
|
currentUserId: '',
|
|
|
|
|
|
doctorId: 'doctor-1',
|
2025-07-19 16:04:43 +08:00
|
|
|
|
doctorAvatar: 'https://xiaokang88.oss-cn-hangzhou.aliyuncs.com/xk_upload_20250108/29bdb9560340373bb3096394a845afa5.jpg',
|
|
|
|
|
|
userAvatar: 'https://xiaokang88.oss-cn-hangzhou.aliyuncs.com/xk_upload_20250108/29bdb9560340373bb3096394a845afa5.jpg',
|
2026-02-07 13:02:15 +08:00
|
|
|
|
assistantConfig: { name: '医生助理', avatar: '' }, // 助理配置信息
|
2025-07-22 16:54:37 +08:00
|
|
|
|
messages: [],
|
2026-01-14 18:44:20 +08:00
|
|
|
|
newMessage: '',
|
2026-01-26 15:55:13 +08:00
|
|
|
|
voiceInputActive: false, // 默认文字输入
|
2026-01-14 18:44:20 +08:00
|
|
|
|
recording: false,
|
|
|
|
|
|
recordingTime: 0,
|
|
|
|
|
|
recordingTimer: null,
|
|
|
|
|
|
showRecordingModal: false,
|
|
|
|
|
|
currentPlayingAudio: null,
|
2026-01-26 15:55:13 +08:00
|
|
|
|
innerAudioContext: null, // 音频播放上下文
|
2026-01-14 18:44:20 +08:00
|
|
|
|
hasRecordPermission: false,
|
|
|
|
|
|
scrollTop: 0,
|
|
|
|
|
|
scrollIntoView: '',
|
|
|
|
|
|
scrollViewHeight: 0,
|
|
|
|
|
|
oldScrollViewHeight: 0,
|
|
|
|
|
|
scrollViewStyle: '',
|
|
|
|
|
|
currentScrollPosition: 0,
|
2025-07-22 16:54:37 +08:00
|
|
|
|
page: 1,
|
|
|
|
|
|
pageSize: 20,
|
|
|
|
|
|
hasMore: true,
|
2025-08-29 16:59:14 +08:00
|
|
|
|
loading: false,
|
|
|
|
|
|
isEmpty: false,
|
2026-01-14 18:44:20 +08:00
|
|
|
|
isLoadHistory: false,
|
|
|
|
|
|
isConsultationEnded: false,
|
|
|
|
|
|
keyboardHeight: 0,
|
2026-02-07 16:17:01 +08:00
|
|
|
|
showNotice: true, // 显示协议提示
|
|
|
|
|
|
noticeText: '', // 提示文案
|
|
|
|
|
|
agreements: [], // 协议列表
|
|
|
|
|
|
parsedNoticeParts: [], // 解析后的文案部分(文本和协议链接)
|
|
|
|
|
|
showAgreement: false, // 控制协议抽屉显示
|
|
|
|
|
|
agreementContent: '', // 协议内容
|
|
|
|
|
|
currentAgreementId: 0, // 当前查看的协议ID
|
|
|
|
|
|
currentAgreementName: '', // 当前查看的协议名称
|
2025-07-22 16:54:37 +08:00
|
|
|
|
};
|
|
|
|
|
|
},
|
2025-12-23 08:31:21 +08:00
|
|
|
|
|
2025-07-22 16:54:37 +08:00
|
|
|
|
onLoad: function (option) {
|
2026-02-07 11:12:18 +08:00
|
|
|
|
// 确保 room_id 存在
|
|
|
|
|
|
if (!option.room_id) {
|
|
|
|
|
|
console.error('聊天页面缺少room_id参数');
|
|
|
|
|
|
uni.showToast({
|
|
|
|
|
|
title: '房间ID不能为空',
|
|
|
|
|
|
icon: 'none'
|
|
|
|
|
|
});
|
|
|
|
|
|
setTimeout(() => {
|
2026-02-07 16:17:01 +08:00
|
|
|
|
uni.reLaunch({
|
|
|
|
|
|
url: '/pages/index/index'
|
|
|
|
|
|
});
|
2026-02-07 11:12:18 +08:00
|
|
|
|
}, 1500);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 先设置基础信息
|
2025-07-22 16:54:37 +08:00
|
|
|
|
this.doctorUserInfo = option;
|
2026-01-14 18:44:20 +08:00
|
|
|
|
if (option.avatar) this.doctorAvatar = option.avatar;
|
2025-07-22 16:54:37 +08:00
|
|
|
|
this.currentUserId = 'user-' + uni.getStorageSync('user_id') || 'user-2512';
|
2026-07-19 16:08:04 +08:00
|
|
|
|
// 从登录缓存读取己方微信/用户头像,避免一直用硬编码占位图
|
|
|
|
|
|
this.syncUserAvatar();
|
2025-07-22 16:54:37 +08:00
|
|
|
|
|
2025-12-23 08:31:21 +08:00
|
|
|
|
let doctorId = option.user_id || '';
|
2026-01-14 18:44:20 +08:00
|
|
|
|
if (doctorId.includes('-type-')) doctorId = doctorId.split('-type-')[0];
|
2025-12-23 08:31:21 +08:00
|
|
|
|
this.doctorId = doctorId;
|
|
|
|
|
|
|
2026-02-07 11:12:18 +08:00
|
|
|
|
// 立即进入房间并设置ChatManager(确保消息能正确路由)
|
2025-08-29 16:59:14 +08:00
|
|
|
|
if (typeof ChatManager !== 'undefined') {
|
|
|
|
|
|
ChatManager.enterRoom(option.room_id);
|
|
|
|
|
|
ChatManager.resetUnreadCount(option.room_id);
|
|
|
|
|
|
this.messages = ChatManager.getRoomMessages(option.room_id);
|
2026-01-14 18:44:20 +08:00
|
|
|
|
if (option.room_status === '1' || option.room_status === 1) this.isConsultationEnded = true;
|
|
|
|
|
|
else if (this.messages.some(msg => msg.message_type === 13)) this.isConsultationEnded = true;
|
2025-08-29 16:59:14 +08:00
|
|
|
|
}
|
2025-07-22 16:54:37 +08:00
|
|
|
|
|
2026-01-14 18:44:20 +08:00
|
|
|
|
if (option.room_id) this.fetchRoomStatus(option.room_id);
|
2026-01-07 14:21:29 +08:00
|
|
|
|
|
2026-01-26 16:22:16 +08:00
|
|
|
|
// 无论是否有nickName,都需要获取医生详情信息(职称、医院、擅长)
|
|
|
|
|
|
this.fetchDoctorInfo(doctorId);
|
|
|
|
|
|
|
2026-02-07 16:17:01 +08:00
|
|
|
|
// 加载助理配置信息和协议信息
|
2026-02-07 13:02:15 +08:00
|
|
|
|
this.loadAssistantConfig();
|
2026-02-07 16:17:01 +08:00
|
|
|
|
this.loadAgreementInfo();
|
2026-02-07 13:02:15 +08:00
|
|
|
|
|
2025-12-25 14:28:25 +08:00
|
|
|
|
const nickName = this.doctorUserInfo.nick_name;
|
2026-01-26 16:22:16 +08:00
|
|
|
|
if (nickName && nickName !== 'undefined' && nickName !== 'null') {
|
2026-01-14 18:44:20 +08:00
|
|
|
|
uni.setNavigationBarTitle({ title: `与${nickName}医生的对话` });
|
2026-02-07 11:12:18 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
uni.setNavigationBarTitle({ title: '与医生的对话' });
|
2025-12-25 14:28:25 +08:00
|
|
|
|
}
|
2025-07-22 16:54:37 +08:00
|
|
|
|
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.scrollToBottom();
|
2026-01-14 18:44:20 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
uni.onKeyboardHeightChange(res => {
|
|
|
|
|
|
this.keyboardHeight = res.height;
|
|
|
|
|
|
if (res.height > 0) this.scrollToBottom();
|
2025-07-22 16:54:37 +08:00
|
|
|
|
});
|
|
|
|
|
|
},
|
2025-12-23 08:31:21 +08:00
|
|
|
|
|
2026-02-07 16:17:01 +08:00
|
|
|
|
onBackPress() {
|
2026-06-01 09:52:26 +08:00
|
|
|
|
if (this.showAgreement) {
|
|
|
|
|
|
this.closeAgreement();
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
2026-02-07 16:17:01 +08:00
|
|
|
|
this.handleBack();
|
2026-06-01 09:52:26 +08:00
|
|
|
|
return true;
|
2026-02-07 16:17:01 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
2025-07-22 16:54:37 +08:00
|
|
|
|
onUnload() {
|
2026-01-26 15:55:13 +08:00
|
|
|
|
if (this.innerAudioContext) {
|
|
|
|
|
|
this.innerAudioContext.destroy();
|
|
|
|
|
|
}
|
2026-01-14 18:44:20 +08:00
|
|
|
|
if (typeof ChatManager !== 'undefined') ChatManager.leaveRoom();
|
2025-07-22 16:54:37 +08:00
|
|
|
|
},
|
2025-12-23 08:31:21 +08:00
|
|
|
|
|
2025-07-22 16:54:37 +08:00
|
|
|
|
onShow() {
|
2026-07-19 16:08:04 +08:00
|
|
|
|
// 从资料页返回时再同步一次,避免改过头像后聊天仍显示旧图
|
|
|
|
|
|
this.syncUserAvatar();
|
2026-02-07 11:12:18 +08:00
|
|
|
|
// 确保房间ID已设置(从ChatManager获取,作为备用)
|
|
|
|
|
|
if (!this.doctorUserInfo.room_id && typeof ChatManager !== 'undefined') {
|
|
|
|
|
|
const currentRoomId = ChatManager.getCurrentRoomId();
|
|
|
|
|
|
if (currentRoomId) {
|
|
|
|
|
|
this.doctorUserInfo.room_id = currentRoomId;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 注册事件监听器
|
2025-07-22 16:54:37 +08:00
|
|
|
|
uni.$on('new-room-message', this.handleNewRoomMessage);
|
2025-07-25 15:59:33 +08:00
|
|
|
|
uni.$on('load-room-message', this.handLoadMessageList);
|
|
|
|
|
|
uni.$on('no-more-history', this.handNoMessageList);
|
2025-07-22 16:54:37 +08:00
|
|
|
|
},
|
2025-12-23 08:31:21 +08:00
|
|
|
|
|
2025-07-22 16:54:37 +08:00
|
|
|
|
onHide() {
|
2026-01-26 15:55:13 +08:00
|
|
|
|
this.stopAudio(); // 页面隐藏时停止播放
|
2025-07-22 16:54:37 +08:00
|
|
|
|
uni.$off('new-room-message', this.handleNewRoomMessage);
|
2025-07-25 15:59:33 +08:00
|
|
|
|
uni.$off('load-room-message', this.handLoadMessageList);
|
|
|
|
|
|
uni.$off('no-more-history', this.handNoMessageList);
|
2025-07-22 16:54:37 +08:00
|
|
|
|
},
|
2025-12-23 08:31:21 +08:00
|
|
|
|
|
2025-07-22 16:54:37 +08:00
|
|
|
|
mounted() {
|
|
|
|
|
|
this.recorderManager = uni.getRecorderManager();
|
|
|
|
|
|
this.initRecorder();
|
2026-02-07 11:12:18 +08:00
|
|
|
|
// 延迟注册WebSocket消息处理器,确保onLoad已执行完成,room_id已设置
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
if (typeof webSocketManager !== 'undefined') {
|
|
|
|
|
|
webSocketManager.addMessageHandler(this.handleSocketMessage);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2025-12-23 10:30:10 +08:00
|
|
|
|
this.calculateScrollViewHeight();
|
2025-07-22 16:54:37 +08:00
|
|
|
|
},
|
2025-12-23 08:31:21 +08:00
|
|
|
|
|
2025-07-22 16:54:37 +08:00
|
|
|
|
beforeDestroy() {
|
2026-01-14 18:44:20 +08:00
|
|
|
|
if (typeof webSocketManager !== 'undefined') webSocketManager.removeMessageHandler(this.handleSocketMessage);
|
2025-07-22 16:54:37 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
methods: {
|
2026-01-26 15:55:13 +08:00
|
|
|
|
// === 新增辅助方法 ===
|
2026-07-19 16:08:04 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 从本地 userinfo 同步己方头像(字段为 avatarurl,与登录/我的页一致)
|
|
|
|
|
|
* 无头像时回退到与我的页相同的默认图
|
|
|
|
|
|
*/
|
|
|
|
|
|
syncUserAvatar() {
|
|
|
|
|
|
const userinfo = uni.getStorageSync('userinfo') || {};
|
|
|
|
|
|
this.userAvatar = userinfo.avatarurl
|
|
|
|
|
|
|| 'https://xiaokang88.oss-cn-hangzhou.aliyuncs.com/xk-client-wx/static/mine/mr_tx.png';
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2026-01-26 15:55:13 +08:00
|
|
|
|
isMsgMine(msg) {
|
|
|
|
|
|
return this.getSenderIdWithoutPrefix(msg.sender_user_id) === this.getCurrentUserIdWithoutPrefix();
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
getMsgAvatar(msg) {
|
|
|
|
|
|
if (this.isMsgMine(msg)) {
|
|
|
|
|
|
return this.userAvatar;
|
|
|
|
|
|
}
|
2026-02-07 13:02:15 +08:00
|
|
|
|
// 如果是医生助理发送的消息
|
|
|
|
|
|
const senderId = msg.sender_user_id || msg.senderId;
|
|
|
|
|
|
if (senderId === 'doctor_assistant') {
|
|
|
|
|
|
const avatar = this.assistantConfig.avatar || 'https://xiaokang88.oss-cn-hangzhou.aliyuncs.com/xk_upload_20250108/29bdb9560340373bb3096394a845afa5.jpg';
|
|
|
|
|
|
try {
|
|
|
|
|
|
return decodeURIComponent(avatar);
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
return avatar;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
// 其他情况(医生发送的消息)
|
2026-01-26 15:55:13 +08:00
|
|
|
|
let avatar = this.doctorUserInfo.avatar || this.doctorAvatar || 'https://xiaokang88.oss-cn-hangzhou.aliyuncs.com/xk_upload_20250108/29bdb9560340373bb3096394a845afa5.jpg';
|
|
|
|
|
|
try {
|
|
|
|
|
|
return decodeURIComponent(avatar);
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
return avatar;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2026-05-06 16:41:19 +08:00
|
|
|
|
|
|
|
|
|
|
onFollowUpDrugAnswered({ messageId, answerStatus }) {
|
|
|
|
|
|
const roomId = this.doctorUserInfo.room_id;
|
|
|
|
|
|
const idx = this.messages.findIndex((m) => m.id === messageId);
|
|
|
|
|
|
if (idx === -1) return;
|
|
|
|
|
|
const row = this.messages[idx];
|
|
|
|
|
|
try {
|
|
|
|
|
|
const o = typeof row.message_content === 'string' ? JSON.parse(row.message_content) : { ...row.message_content };
|
|
|
|
|
|
o.answer_status = answerStatus;
|
|
|
|
|
|
const updated = { ...row, message_content: JSON.stringify(o) };
|
|
|
|
|
|
this.$set(this.messages, idx, updated);
|
|
|
|
|
|
if (typeof ChatManager !== 'undefined' && roomId && ChatManager.roomMessages && ChatManager.roomMessages[roomId]) {
|
|
|
|
|
|
const ri = ChatManager.roomMessages[roomId].findIndex((m) => m.id === messageId);
|
|
|
|
|
|
if (ri !== -1) this.$set(ChatManager.roomMessages[roomId], ri, updated);
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
console.error('onFollowUpDrugAnswered', e);
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2026-02-07 13:02:15 +08:00
|
|
|
|
|
|
|
|
|
|
// 加载助理配置信息
|
|
|
|
|
|
async loadAssistantConfig() {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const res = await getTransferAssistantConfigApi();
|
|
|
|
|
|
if (res.data && res.data.code === 0) {
|
|
|
|
|
|
const config = res.data.result || {};
|
|
|
|
|
|
this.assistantConfig = {
|
|
|
|
|
|
name: config.name || '医生助理',
|
|
|
|
|
|
avatar: config.avatar || ''
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('加载助理配置失败:', error);
|
|
|
|
|
|
// 失败不影响继续,使用默认值
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2026-01-26 15:55:13 +08:00
|
|
|
|
|
2026-02-07 16:17:01 +08:00
|
|
|
|
// 加载协议信息
|
|
|
|
|
|
async loadAgreementInfo() {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const res = await getTransferConsultationAgreementInfoApi();
|
|
|
|
|
|
if (res.data && res.data.code === 0) {
|
|
|
|
|
|
const result = res.data.result || {};
|
|
|
|
|
|
this.noticeText = result.notice_text || '';
|
|
|
|
|
|
this.agreements = result.agreements || [];
|
|
|
|
|
|
|
|
|
|
|
|
// 解析文案,提取协议链接
|
|
|
|
|
|
this.parseNoticeText();
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('加载协议信息失败:', error);
|
|
|
|
|
|
// 失败时使用默认文案
|
|
|
|
|
|
this.noticeText = '根据国家互联网医院管理办法要求,平台仅为复诊患者提供服务。为了保障您的用药安全,购买该药物需要经过医生问诊,请根据真实情况回答,并请仔细阅读《互联网医疗风险告知及知情同意书》,继续咨询即表示您已知悉相关规则与风险并同意相关条款。';
|
|
|
|
|
|
this.parseNoticeText();
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
// 解析提示文案,将《协议名称》替换为可点击的链接
|
|
|
|
|
|
parseNoticeText() {
|
|
|
|
|
|
if (!this.noticeText) {
|
|
|
|
|
|
this.parsedNoticeParts = [];
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const parts = [];
|
|
|
|
|
|
// 使用正则表达式匹配《》中的协议名称
|
|
|
|
|
|
const regex = /《([^》]+)》/g;
|
|
|
|
|
|
let lastIndex = 0;
|
|
|
|
|
|
let match;
|
|
|
|
|
|
|
|
|
|
|
|
while ((match = regex.exec(this.noticeText)) !== null) {
|
|
|
|
|
|
// 添加匹配前的文本
|
|
|
|
|
|
if (match.index > lastIndex) {
|
|
|
|
|
|
parts.push({
|
|
|
|
|
|
type: 'text',
|
|
|
|
|
|
text: this.noticeText.substring(lastIndex, match.index)
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-07-19 16:08:04 +08:00
|
|
|
|
// 查找匹配的协议:名称/描述双向 includes,仍无匹配则用列表第一条保证可点
|
2026-02-07 16:17:01 +08:00
|
|
|
|
const agreementName = match[1];
|
2026-07-19 16:08:04 +08:00
|
|
|
|
const agreement = this.findAgreementByName(agreementName);
|
|
|
|
|
|
|
2026-02-07 16:17:01 +08:00
|
|
|
|
if (agreement) {
|
|
|
|
|
|
parts.push({
|
|
|
|
|
|
type: 'agreement',
|
|
|
|
|
|
text: agreementName,
|
|
|
|
|
|
agreementId: agreement.id
|
|
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
parts.push({
|
|
|
|
|
|
type: 'text',
|
2026-07-19 16:08:04 +08:00
|
|
|
|
text: match[0]
|
2026-02-07 16:17:01 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
lastIndex = regex.lastIndex;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 添加剩余的文本
|
|
|
|
|
|
if (lastIndex < this.noticeText.length) {
|
|
|
|
|
|
parts.push({
|
|
|
|
|
|
type: 'text',
|
|
|
|
|
|
text: this.noticeText.substring(lastIndex)
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.parsedNoticeParts = parts;
|
|
|
|
|
|
},
|
2026-07-19 16:08:04 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 按文案中的协议名匹配协议列表(放宽 name/desc 双向包含)
|
|
|
|
|
|
* 匹配不到但列表非空时回退第一条,避免《》无法点击
|
|
|
|
|
|
*/
|
|
|
|
|
|
findAgreementByName(agreementName) {
|
|
|
|
|
|
const list = this.agreements || [];
|
|
|
|
|
|
if (!list.length) return null;
|
|
|
|
|
|
const name = String(agreementName || '');
|
|
|
|
|
|
const hit = list.find((ag) => {
|
|
|
|
|
|
const n = String(ag.name || '');
|
|
|
|
|
|
const d = String(ag.desc || '');
|
|
|
|
|
|
return n === name
|
|
|
|
|
|
|| n.includes(name)
|
|
|
|
|
|
|| name.includes(n)
|
|
|
|
|
|
|| (d && (d === name || d.includes(name) || name.includes(d)));
|
|
|
|
|
|
});
|
|
|
|
|
|
return hit || list[0];
|
|
|
|
|
|
},
|
2026-02-07 16:17:01 +08:00
|
|
|
|
// 查看协议
|
|
|
|
|
|
async viewAgreement(agreementId) {
|
|
|
|
|
|
if (!agreementId) {
|
|
|
|
|
|
uni.showToast({
|
|
|
|
|
|
title: '协议ID不能为空',
|
|
|
|
|
|
icon: 'none'
|
|
|
|
|
|
});
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 查找协议名称
|
|
|
|
|
|
const agreement = this.agreements.find(ag => ag.id === agreementId);
|
|
|
|
|
|
this.currentAgreementId = agreementId;
|
|
|
|
|
|
this.currentAgreementName = agreement ? agreement.name : '协议详情';
|
2026-07-19 16:08:04 +08:00
|
|
|
|
this.agreementContent = '';
|
2026-02-07 16:17:01 +08:00
|
|
|
|
this.showAgreement = true;
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
const res = await getAgreementDetailApi(agreementId);
|
|
|
|
|
|
if (res.data && res.data.code === 0) {
|
|
|
|
|
|
const result = res.data.result || {};
|
|
|
|
|
|
this.agreementContent = result.content || '';
|
|
|
|
|
|
// 如果API返回了协议名称,使用API返回的名称
|
|
|
|
|
|
if (result.name) {
|
|
|
|
|
|
this.currentAgreementName = result.name;
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
throw new Error(res.data.message || '获取协议详情失败');
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('获取协议详情失败:', error);
|
|
|
|
|
|
uni.showToast({
|
|
|
|
|
|
title: error.message || '获取协议详情失败',
|
|
|
|
|
|
icon: 'none'
|
|
|
|
|
|
});
|
|
|
|
|
|
this.showAgreement = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2026-06-01 09:52:26 +08:00
|
|
|
|
closeAgreement() {
|
|
|
|
|
|
this.showAgreement = false;
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2026-07-19 16:08:04 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 点击气泡医生头像进入医生详情(只读,不展示挂号)
|
|
|
|
|
|
* 己方/助理头像不跳转
|
|
|
|
|
|
*/
|
|
|
|
|
|
goDoctorDetail(msg) {
|
|
|
|
|
|
if (!msg || this.isMsgMine(msg)) return;
|
|
|
|
|
|
const senderId = msg.sender_user_id || msg.senderId || '';
|
|
|
|
|
|
if (senderId === 'doctor_assistant') return;
|
|
|
|
|
|
const cleanId = String(this.doctorId || '')
|
|
|
|
|
|
.replace(/^doctor-/, '')
|
|
|
|
|
|
.replace(/-type-.*$/, '');
|
|
|
|
|
|
if (!cleanId) {
|
|
|
|
|
|
uni.showToast({ title: '医生信息缺失', icon: 'none' });
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
|
url: `/subPackages/doctor/doctor-detail?id=${cleanId}&readonly=1`
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2026-01-26 15:55:13 +08:00
|
|
|
|
// === 音频播放逻辑 ===
|
|
|
|
|
|
playAudio(msg) {
|
|
|
|
|
|
const audioUrl = getParsedContent(msg.message_type, msg.message_content);
|
|
|
|
|
|
|
|
|
|
|
|
// 如果点击的是当前正在播放的,则暂停/停止
|
|
|
|
|
|
if (this.currentPlayingAudio === msg.id) {
|
|
|
|
|
|
this.stopAudio();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 停止当前正在播放的
|
|
|
|
|
|
this.stopAudio();
|
|
|
|
|
|
|
|
|
|
|
|
if (!audioUrl) {
|
|
|
|
|
|
uni.showToast({ title: '无效的音频地址', icon: 'none' });
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 初始化音频上下文
|
|
|
|
|
|
if (!this.innerAudioContext) {
|
|
|
|
|
|
this.innerAudioContext = uni.createInnerAudioContext();
|
|
|
|
|
|
|
|
|
|
|
|
// 监听自然播放结束
|
|
|
|
|
|
this.innerAudioContext.onEnded(() => {
|
|
|
|
|
|
this.currentPlayingAudio = null;
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// 监听播放错误
|
|
|
|
|
|
this.innerAudioContext.onError((res) => {
|
|
|
|
|
|
console.error('音频播放错误', res);
|
|
|
|
|
|
this.currentPlayingAudio = null;
|
|
|
|
|
|
uni.showToast({ title: '播放失败', icon: 'none' });
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.innerAudioContext.src = audioUrl;
|
|
|
|
|
|
this.innerAudioContext.play();
|
|
|
|
|
|
this.currentPlayingAudio = msg.id;
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
stopAudio() {
|
|
|
|
|
|
if (this.innerAudioContext) {
|
|
|
|
|
|
this.innerAudioContext.stop();
|
|
|
|
|
|
}
|
|
|
|
|
|
this.currentPlayingAudio = null;
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
isPlaying(msg) {
|
|
|
|
|
|
return this.currentPlayingAudio === msg.id;
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// ... 所有的业务逻辑方法保持原样,无需改动 ...
|
2025-12-25 14:28:25 +08:00
|
|
|
|
async fetchDoctorInfo(doctorId) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const cleanDoctorId = String(doctorId).replace('doctor-', '');
|
|
|
|
|
|
const res = await getDoctorInfoApi({ doctor_id: cleanDoctorId });
|
|
|
|
|
|
if (res.data && res.data.result) {
|
|
|
|
|
|
const doctorInfo = res.data.result;
|
|
|
|
|
|
this.doctorUserInfo = {
|
|
|
|
|
|
...this.doctorUserInfo,
|
|
|
|
|
|
nick_name: doctorInfo.nick_name || '医生',
|
|
|
|
|
|
avatar: doctorInfo.avatar || this.doctorAvatar,
|
|
|
|
|
|
};
|
2026-01-26 16:22:16 +08:00
|
|
|
|
// 保存完整的医生详情信息
|
|
|
|
|
|
this.doctorDetailInfo = {
|
|
|
|
|
|
title: doctorInfo.title || '',
|
|
|
|
|
|
hospital: doctorInfo.hospital || '',
|
|
|
|
|
|
good_at: doctorInfo.good_at || ''
|
|
|
|
|
|
};
|
2026-01-14 18:44:20 +08:00
|
|
|
|
if (doctorInfo.avatar) this.doctorAvatar = doctorInfo.avatar;
|
|
|
|
|
|
uni.setNavigationBarTitle({ title: `与${this.doctorUserInfo.nick_name}医生的对话` });
|
2025-12-25 14:28:25 +08:00
|
|
|
|
}
|
2026-01-14 18:44:20 +08:00
|
|
|
|
} catch (error) { console.error('获取医生信息失败:', error); }
|
2025-12-25 14:28:25 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
2026-01-07 14:21:29 +08:00
|
|
|
|
async fetchRoomStatus(roomId) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const res = await getRoomStatusApi({ room_id: roomId });
|
2026-01-14 18:44:20 +08:00
|
|
|
|
if (res.data && res.data.result) this.isConsultationEnded = res.data.result.status === 1;
|
|
|
|
|
|
} catch (error) { console.error('获取房间状态失败:', error); }
|
2026-01-07 14:21:29 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
2025-12-24 16:05:41 +08:00
|
|
|
|
checkPrivacyAuthorize() {
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
|
// #ifdef MP-WEIXIN
|
|
|
|
|
|
if (typeof uni.requirePrivacyAuthorize === 'function') {
|
|
|
|
|
|
uni.requirePrivacyAuthorize({
|
|
|
|
|
|
success: () => resolve(),
|
|
|
|
|
|
fail: () => {
|
|
|
|
|
|
uni.showToast({ title: '需要同意隐私协议才能使用此功能', icon: 'none' });
|
|
|
|
|
|
reject(new Error('隐私授权被拒绝'));
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2026-01-14 18:44:20 +08:00
|
|
|
|
} else { resolve(); }
|
2025-12-24 16:05:41 +08:00
|
|
|
|
// #endif
|
|
|
|
|
|
// #ifndef MP-WEIXIN
|
|
|
|
|
|
resolve();
|
|
|
|
|
|
// #endif
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2025-12-23 10:30:10 +08:00
|
|
|
|
calculateScrollViewHeight() {
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
const systemInfo = uni.getSystemInfoSync();
|
2026-01-14 18:44:20 +08:00
|
|
|
|
const windowHeight = systemInfo.windowHeight;
|
2025-12-23 10:30:10 +08:00
|
|
|
|
const query = uni.createSelectorQuery().in(this);
|
2026-02-07 16:17:01 +08:00
|
|
|
|
|
|
|
|
|
|
// 获取u-navbar导航栏高度(uView会自动处理状态栏高度)
|
|
|
|
|
|
query.select('.chat-navbar').boundingClientRect((navbarRect) => {
|
|
|
|
|
|
const navbarHeight = navbarRect ? navbarRect.height : 0;
|
|
|
|
|
|
|
|
|
|
|
|
// 获取聊天头部高度
|
|
|
|
|
|
query.select('.chat-header').boundingClientRect((headerRect) => {
|
|
|
|
|
|
const headerHeight = headerRect ? headerRect.height : 0;
|
|
|
|
|
|
|
|
|
|
|
|
// 获取底部输入栏高度
|
|
|
|
|
|
const query2 = uni.createSelectorQuery().in(this);
|
|
|
|
|
|
query2.select('.chat-footer').boundingClientRect((footerRect) => {
|
|
|
|
|
|
const footerHeight = footerRect ? footerRect.height : 0;
|
|
|
|
|
|
const scrollHeight = windowHeight - navbarHeight - headerHeight - footerHeight;
|
|
|
|
|
|
this.scrollViewStyle = `height: ${scrollHeight}px;`;
|
|
|
|
|
|
}).exec();
|
2025-12-23 10:30:10 +08:00
|
|
|
|
}).exec();
|
|
|
|
|
|
}).exec();
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2026-01-14 18:44:20 +08:00
|
|
|
|
onScroll(e) { this.currentScrollPosition = e.detail.scrollTop; },
|
|
|
|
|
|
getSenderIdWithoutPrefix(senderId) { return !senderId ? '' : String(senderId).replace(/^(user-|doctor-)/, ''); },
|
|
|
|
|
|
getCurrentUserIdWithoutPrefix() { return !this.currentUserId ? '' : String(this.currentUserId).replace(/^(user-|doctor-)/, ''); },
|
2025-12-23 08:31:21 +08:00
|
|
|
|
|
|
|
|
|
|
shouldShowTime(msg, index) {
|
|
|
|
|
|
if (index === 0) return true;
|
|
|
|
|
|
const prevMsg = this.messages[index - 1];
|
|
|
|
|
|
const currTime = msg.created_at || msg.timestamp || 0;
|
|
|
|
|
|
const prevTime = prevMsg.created_at || prevMsg.timestamp || 0;
|
|
|
|
|
|
return currTime - prevTime > 300000;
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2026-01-07 14:21:29 +08:00
|
|
|
|
loadRegisterCards() {
|
2025-08-29 16:59:14 +08:00
|
|
|
|
let that = this;
|
2026-01-07 14:21:29 +08:00
|
|
|
|
this.messages.forEach((msg, index) => {
|
|
|
|
|
|
if (msg.message_type === 10) {
|
|
|
|
|
|
const parsedContent = getParsedContent(msg.message_type, msg.message_content);
|
2026-01-14 18:44:20 +08:00
|
|
|
|
if (parsedContent._loaded || !parsedContent.id) return;
|
2026-01-07 14:21:29 +08:00
|
|
|
|
that.fetchRegisterCardInfo(msg, index, parsedContent.id);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
2026-01-14 18:44:20 +08:00
|
|
|
|
|
2026-01-07 14:21:29 +08:00
|
|
|
|
fetchRegisterCardInfo(msg, index, registerId) {
|
|
|
|
|
|
let that = this;
|
|
|
|
|
|
const messageId = msg.id;
|
2026-01-14 18:44:20 +08:00
|
|
|
|
getChatRegisterInfoApi({ id: registerId, message_id: messageId || '' }).then((res) => {
|
2026-01-07 14:21:29 +08:00
|
|
|
|
if (res.data && res.data.result) {
|
|
|
|
|
|
let targetIndex = index;
|
|
|
|
|
|
if (messageId) {
|
2026-01-14 18:44:20 +08:00
|
|
|
|
const foundIndex = that.messages.findIndex(m => m.id === messageId || String(m.id) === String(messageId));
|
|
|
|
|
|
if (foundIndex !== -1) targetIndex = foundIndex;
|
2026-01-07 14:21:29 +08:00
|
|
|
|
}
|
2026-01-14 18:44:20 +08:00
|
|
|
|
const resultWithFlag = { ...res.data.result, _loaded: true };
|
2026-01-07 14:21:29 +08:00
|
|
|
|
that.$set(that.messages, targetIndex, {
|
|
|
|
|
|
...that.messages[targetIndex],
|
|
|
|
|
|
message_content: JSON.stringify(resultWithFlag)
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
2026-01-14 18:44:20 +08:00
|
|
|
|
|
|
|
|
|
|
handNoMessageList() { this.isEmpty = true; this.hasMore = false; },
|
2025-07-25 15:59:33 +08:00
|
|
|
|
handLoadMessageList(type = 0) {
|
|
|
|
|
|
this.loading = false;
|
2026-01-14 18:44:20 +08:00
|
|
|
|
if (typeof ChatManager !== 'undefined') this.messages = ChatManager.roomMessages[this.doctorUserInfo.room_id] || [];
|
2026-01-07 14:21:29 +08:00
|
|
|
|
this.loadRegisterCards();
|
2025-12-23 11:04:45 +08:00
|
|
|
|
const isHistoryLoad = this.isLoadHistory;
|
2026-01-14 18:44:20 +08:00
|
|
|
|
this.isLoadHistory = false;
|
|
|
|
|
|
if (type === 1 && !isHistoryLoad) this.scrollToBottom();
|
|
|
|
|
|
else this.scrollToOldLastMessage();
|
2025-07-25 15:59:33 +08:00
|
|
|
|
},
|
2025-07-19 16:04:43 +08:00
|
|
|
|
|
2025-07-25 15:59:33 +08:00
|
|
|
|
getScrollHeight() {
|
2025-08-29 16:59:14 +08:00
|
|
|
|
const query = uni.createSelectorQuery().in(this);
|
2025-12-23 08:31:21 +08:00
|
|
|
|
query.select('.message-list-container').boundingClientRect(res => {
|
2025-07-25 15:59:33 +08:00
|
|
|
|
if (res) {
|
2025-12-23 10:30:10 +08:00
|
|
|
|
this.oldScrollViewHeight = res.height;
|
2025-08-29 16:59:14 +08:00
|
|
|
|
this.scrollViewHeight = res.height;
|
2025-07-25 15:59:33 +08:00
|
|
|
|
}
|
2025-08-29 16:59:14 +08:00
|
|
|
|
}).exec();
|
2025-07-22 16:54:37 +08:00
|
|
|
|
},
|
2025-07-19 16:04:43 +08:00
|
|
|
|
|
|
|
|
|
|
handleSocketMessage(data) {
|
2026-02-07 11:12:18 +08:00
|
|
|
|
// 获取当前房间ID(优先使用doctorUserInfo.room_id,如果未设置则从ChatManager获取)
|
|
|
|
|
|
const currentRoomId = this.doctorUserInfo.room_id || (typeof ChatManager !== 'undefined' ? ChatManager.getCurrentRoomId() : null);
|
|
|
|
|
|
|
|
|
|
|
|
// 如果房间ID匹配,或者消息的房间ID与当前房间ID匹配,则处理消息
|
|
|
|
|
|
if (data.room_id && (data.room_id === currentRoomId || data.room_id === this.doctorUserInfo.room_id)) {
|
2026-01-07 14:21:29 +08:00
|
|
|
|
this.addMessage(data);
|
|
|
|
|
|
this.scrollToBottom();
|
2025-08-29 16:59:14 +08:00
|
|
|
|
}
|
2025-07-19 16:04:43 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
2025-07-22 16:54:37 +08:00
|
|
|
|
handleNewRoomMessage(message) {
|
2025-07-25 15:59:33 +08:00
|
|
|
|
this.addMessage(message);
|
|
|
|
|
|
this.scrollToBottom();
|
2025-07-19 16:04:43 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
addMessage(message) {
|
2026-01-14 18:44:20 +08:00
|
|
|
|
if (!message.message_content && message.content) message.message_content = message.content;
|
2025-12-23 10:30:10 +08:00
|
|
|
|
if (message.message_type === undefined && message.type !== undefined) {
|
2026-01-14 18:44:20 +08:00
|
|
|
|
const messageTypeMap = { text: 0, image: 1, audio: 2, video: 3, prescription: 4, file: 5, register: 10, 'patient-experience': 11, 'product-card': 12, 'end-consultation': 13 };
|
2025-12-23 10:30:10 +08:00
|
|
|
|
message.message_type = messageTypeMap[message.type] || 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
const existingIndexById = this.messages.findIndex(m => m.id === message.id);
|
|
|
|
|
|
if (existingIndexById !== -1) {
|
|
|
|
|
|
this.messages[existingIndexById] = message;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
const normalizeContent = (content) => {
|
|
|
|
|
|
if (!content) return '';
|
|
|
|
|
|
if (typeof content === 'string') {
|
2026-01-14 18:44:20 +08:00
|
|
|
|
try { return JSON.stringify(JSON.parse(content)); } catch (e) { return content; }
|
|
|
|
|
|
} else if (typeof content === 'object') { return JSON.stringify(content); }
|
2025-12-23 10:30:10 +08:00
|
|
|
|
return String(content);
|
|
|
|
|
|
};
|
|
|
|
|
|
if (!message.isTemporary) {
|
|
|
|
|
|
const tempMessageIndex = this.messages.findIndex(m => {
|
|
|
|
|
|
if (!m.isTemporary) return false;
|
2026-01-14 18:44:20 +08:00
|
|
|
|
if ((m.sender_user_id || '') !== (message.sender_user_id || '')) return false;
|
|
|
|
|
|
if (normalizeContent(m.message_content || m.content || '') !== normalizeContent(message.message_content || message.content || '')) return false;
|
|
|
|
|
|
return Math.abs((m.created_at || m.timestamp || 0) - (message.created_at || message.timestamp || 0)) < 30000;
|
2025-12-23 10:30:10 +08:00
|
|
|
|
});
|
|
|
|
|
|
if (tempMessageIndex !== -1) {
|
|
|
|
|
|
this.messages[tempMessageIndex] = message;
|
|
|
|
|
|
return;
|
2025-12-23 08:31:21 +08:00
|
|
|
|
}
|
2025-12-23 10:30:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
this.messages.push(message);
|
2026-01-07 14:21:29 +08:00
|
|
|
|
if (message.message_type === 10) {
|
|
|
|
|
|
const parsedContent = getParsedContent(message.message_type, message.message_content);
|
2026-01-14 18:44:20 +08:00
|
|
|
|
if (!parsedContent._loaded && parsedContent.id) this.fetchRegisterCardInfo(message, this.messages.length - 1, parsedContent.id);
|
2026-01-07 14:21:29 +08:00
|
|
|
|
}
|
2026-01-14 18:44:20 +08:00
|
|
|
|
if (message.message_type === 13) this.isConsultationEnded = true;
|
|
|
|
|
|
if (this.doctorUserInfo.room_id) this.fetchRoomStatus(this.doctorUserInfo.room_id);
|
2025-07-19 16:04:43 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
2026-01-14 18:44:20 +08:00
|
|
|
|
toggleDoctorDetail() { this.showDoctorDetail = !this.showDoctorDetail; },
|
2025-07-19 16:04:43 +08:00
|
|
|
|
|
|
|
|
|
|
initRecorder() {
|
|
|
|
|
|
this.recorderManager.onStop(res => {
|
|
|
|
|
|
if (res.duration < 1000) {
|
|
|
|
|
|
uni.showToast({ title: '录音时间太短', icon: 'none' });
|
|
|
|
|
|
this.recording = false;
|
|
|
|
|
|
this.showRecordingModal = false;
|
|
|
|
|
|
clearInterval(this.recordingTimer);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2025-07-25 15:59:33 +08:00
|
|
|
|
this.uploadAudioFile(res.tempFilePath, Math.floor(res.duration / 1000));
|
2025-07-19 16:04:43 +08:00
|
|
|
|
this.recording = false;
|
|
|
|
|
|
this.showRecordingModal = false;
|
|
|
|
|
|
clearInterval(this.recordingTimer);
|
|
|
|
|
|
});
|
|
|
|
|
|
this.recorderManager.onError((error) => {
|
|
|
|
|
|
console.error('录音错误:', error);
|
|
|
|
|
|
this.recording = false;
|
|
|
|
|
|
this.showRecordingModal = false;
|
|
|
|
|
|
clearInterval(this.recordingTimer);
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2025-07-25 15:59:33 +08:00
|
|
|
|
async uploadAudioFile(tempFilePath, duration) {
|
|
|
|
|
|
uni.showLoading({ title: '上传中...', mask: true });
|
|
|
|
|
|
try {
|
|
|
|
|
|
uni.uploadFile({
|
2025-12-24 08:33:13 +08:00
|
|
|
|
url: `${uploadBaseUrl}/chat-friends/upload-chat-file`,
|
2025-07-25 15:59:33 +08:00
|
|
|
|
filePath: tempFilePath,
|
|
|
|
|
|
name: 'file',
|
2026-01-14 18:44:20 +08:00
|
|
|
|
header: { "authorization": uni.getStorageSync('token') },
|
|
|
|
|
|
formData: {},
|
2025-07-25 15:59:33 +08:00
|
|
|
|
success: (uploadFileRes) => {
|
|
|
|
|
|
this.sendMessage({
|
|
|
|
|
|
type: 'audio',
|
|
|
|
|
|
content: JSON.parse(uploadFileRes.data).result.url,
|
|
|
|
|
|
duration,
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2025-08-29 16:59:14 +08:00
|
|
|
|
});
|
2026-01-14 18:44:20 +08:00
|
|
|
|
} catch (error) { console.error('音频上传失败:', error); } finally { uni.hideLoading(); }
|
2025-07-25 15:59:33 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
2025-07-19 16:04:43 +08:00
|
|
|
|
sendMessage(message) {
|
|
|
|
|
|
const now = new Date();
|
2025-08-29 16:59:14 +08:00
|
|
|
|
const timeStr = this.formatTime(now);
|
2025-12-23 08:31:21 +08:00
|
|
|
|
let receiverUserId = this.doctorId || '';
|
2026-01-14 18:44:20 +08:00
|
|
|
|
if (receiverUserId.includes('-type-')) receiverUserId = receiverUserId.split('-type-')[0];
|
|
|
|
|
|
if (receiverUserId && !receiverUserId.startsWith('doctor-')) receiverUserId = 'doctor-' + receiverUserId;
|
|
|
|
|
|
const messageTypeMap = { text: 0, image: 1, audio: 2, video: 3, prescription: 4, file: 5, register: 10, 'patient-experience': 11, 'product-card': 12, 'end-consultation': 13 };
|
2025-12-23 08:31:21 +08:00
|
|
|
|
const messageType = messageTypeMap[message.type] || 0;
|
2025-07-19 16:04:43 +08:00
|
|
|
|
const fullMessage = {
|
|
|
|
|
|
...message,
|
|
|
|
|
|
id: Date.now().toString(),
|
2025-12-23 08:31:21 +08:00
|
|
|
|
sender_user_id: this.currentUserId,
|
|
|
|
|
|
receiver_user_id: receiverUserId,
|
2025-07-19 16:04:43 +08:00
|
|
|
|
room_id: this.doctorUserInfo.room_id,
|
2025-12-23 08:31:21 +08:00
|
|
|
|
created_at_text: timeStr,
|
|
|
|
|
|
created_at: now.getTime(),
|
|
|
|
|
|
timestamp: now.getTime(),
|
|
|
|
|
|
message_content: message.message_content || message.content || '',
|
2025-12-23 10:30:10 +08:00
|
|
|
|
message_type: messageType,
|
2026-01-14 18:44:20 +08:00
|
|
|
|
isTemporary: true
|
2025-07-19 16:04:43 +08:00
|
|
|
|
};
|
2025-12-23 08:31:21 +08:00
|
|
|
|
this.addMessage(fullMessage);
|
2025-12-23 11:04:45 +08:00
|
|
|
|
this.scrollToBottom();
|
2026-01-15 12:33:46 +08:00
|
|
|
|
let senderUserId = `user-${this.currentUserId}`;
|
|
|
|
|
|
if (senderUserId.startsWith('user-user-')) {
|
|
|
|
|
|
senderUserId = senderUserId.replace(/^user-user-/, 'user-');
|
|
|
|
|
|
}
|
2025-07-19 16:04:43 +08:00
|
|
|
|
const requestData = {
|
|
|
|
|
|
room_id: this.doctorUserInfo.room_id,
|
2026-01-26 15:55:13 +08:00
|
|
|
|
sender_user_id: senderUserId,
|
2025-12-23 08:31:21 +08:00
|
|
|
|
receiver_user_id: receiverUserId,
|
|
|
|
|
|
message_type: messageType,
|
|
|
|
|
|
message_content: message.message_content || message.content || '',
|
2025-07-19 16:04:43 +08:00
|
|
|
|
isFromHttp: true,
|
|
|
|
|
|
duration: message.duration || 0
|
|
|
|
|
|
};
|
2026-01-14 18:44:20 +08:00
|
|
|
|
if (typeof sendToUserApi !== 'undefined') sendToUserApi(requestData);
|
2025-08-29 16:59:14 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
formatTime(date) {
|
|
|
|
|
|
const hours = date.getHours().toString().padStart(2, '0');
|
|
|
|
|
|
const minutes = date.getMinutes().toString().padStart(2, '0');
|
|
|
|
|
|
return `${hours}:${minutes}`;
|
2025-07-19 16:04:43 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
2026-07-13 16:08:29 +08:00
|
|
|
|
async sendTextMessage() {
|
2025-07-19 16:04:43 +08:00
|
|
|
|
if (!this.newMessage.trim()) return;
|
2026-07-13 16:08:29 +08:00
|
|
|
|
const content = this.newMessage;
|
|
|
|
|
|
try {
|
|
|
|
|
|
await checkText(content, SCENE_CHAT);
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
handleSecurityError(e);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
this.sendMessage({ type: 'text', content });
|
2025-07-19 16:04:43 +08:00
|
|
|
|
this.newMessage = '';
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2025-12-24 16:05:41 +08:00
|
|
|
|
async startVoiceRecording() {
|
2025-07-19 16:04:43 +08:00
|
|
|
|
if (this.recording) return;
|
2026-01-14 18:44:20 +08:00
|
|
|
|
try { await this.checkPrivacyAuthorize(); } catch (e) { return; }
|
2025-08-29 16:59:14 +08:00
|
|
|
|
uni.getSetting({
|
|
|
|
|
|
success: (res) => {
|
|
|
|
|
|
if (res.authSetting['scope.record']) {
|
|
|
|
|
|
this.hasRecordPermission = true;
|
|
|
|
|
|
this.startRecording();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
uni.authorize({
|
|
|
|
|
|
scope: 'scope.record',
|
|
|
|
|
|
success: () => {
|
|
|
|
|
|
this.hasRecordPermission = true;
|
|
|
|
|
|
this.startRecording();
|
|
|
|
|
|
},
|
|
|
|
|
|
fail: () => {
|
|
|
|
|
|
this.hasRecordPermission = false;
|
|
|
|
|
|
this.voiceInputActive = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2025-07-19 16:04:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
startRecording() {
|
|
|
|
|
|
this.recording = true;
|
|
|
|
|
|
this.showRecordingModal = true;
|
|
|
|
|
|
this.recordingTime = 0;
|
2026-01-14 18:44:20 +08:00
|
|
|
|
this.recorderManager.start({ format: 'mp3', sampleRate: 44100, numberOfChannels: 1, encodeBitRate: 192000 });
|
2025-07-19 16:04:43 +08:00
|
|
|
|
this.recordingTimer = setInterval(() => {
|
|
|
|
|
|
this.recordingTime++;
|
2026-01-14 18:44:20 +08:00
|
|
|
|
if (this.recordingTime >= 60) this.stopVoiceRecording();
|
2025-07-19 16:04:43 +08:00
|
|
|
|
}, 1000);
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
stopVoiceRecording() {
|
|
|
|
|
|
if (!this.recording) return;
|
|
|
|
|
|
this.recorderManager.stop();
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2025-12-24 16:05:41 +08:00
|
|
|
|
async openMediaPicker(type) {
|
2026-01-14 18:44:20 +08:00
|
|
|
|
try { await this.checkPrivacyAuthorize(); } catch (e) { return; }
|
2025-07-19 16:04:43 +08:00
|
|
|
|
if (type === 'image') {
|
|
|
|
|
|
uni.chooseImage({
|
2026-01-14 18:44:20 +08:00
|
|
|
|
count: 9, sourceType: ['album', 'camera'],
|
2026-07-13 16:08:29 +08:00
|
|
|
|
success: async (res) => {
|
|
|
|
|
|
for (const file of res.tempFilePaths) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
await checkImage(file, SCENE_CHAT);
|
|
|
|
|
|
this.uploadAndSendFile(file, 'image');
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
handleSecurityError(e);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-12-24 08:33:13 +08:00
|
|
|
|
});
|
2025-07-19 16:04:43 +08:00
|
|
|
|
}
|
2026-05-30 16:54:01 +08:00
|
|
|
|
// if (type === 'image') {
|
|
|
|
|
|
// uni.chooseImage({
|
|
|
|
|
|
// count: 9,
|
|
|
|
|
|
// sourceType: ['album', 'camera'],
|
|
|
|
|
|
// success: async (res) => {
|
|
|
|
|
|
// for (let index = 0; index < res.tempFiles.length; index++) {
|
|
|
|
|
|
// const tempFile = res.tempFiles[index];
|
|
|
|
|
|
// const prepared = await prepareImagePath({
|
|
|
|
|
|
// path: tempFile.path,
|
|
|
|
|
|
// size: tempFile.size,
|
|
|
|
|
|
// });
|
|
|
|
|
|
// if (!prepared) continue;
|
|
|
|
|
|
// this.uploadAndSendFile(prepared.path, 'image');
|
|
|
|
|
|
// }
|
|
|
|
|
|
// },
|
|
|
|
|
|
// });
|
|
|
|
|
|
// }
|
2025-07-19 16:04:43 +08:00
|
|
|
|
},
|
2026-01-14 18:44:20 +08:00
|
|
|
|
|
2025-12-24 08:33:13 +08:00
|
|
|
|
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) {
|
2026-01-14 18:44:20 +08:00
|
|
|
|
this.sendMessage({ type: type, content: result.result.url });
|
2026-07-13 16:08:29 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
uni.showToast({ title: result.message || '上传失败', icon: 'none' });
|
|
|
|
|
|
}
|
2026-01-14 18:44:20 +08:00
|
|
|
|
} catch (e) { uni.showToast({ title: '上传失败', icon: 'none' }); }
|
2025-12-24 08:33:13 +08:00
|
|
|
|
},
|
2026-01-14 18:44:20 +08:00
|
|
|
|
fail: () => { uni.hideLoading(); uni.showToast({ title: '上传失败', icon: 'none' }); }
|
2025-12-24 08:33:13 +08:00
|
|
|
|
});
|
|
|
|
|
|
},
|
2025-07-19 16:04:43 +08:00
|
|
|
|
|
2026-01-14 18:44:20 +08:00
|
|
|
|
previewImage(url) { uni.previewImage({ urls: [url], current: url }); },
|
2025-07-19 16:04:43 +08:00
|
|
|
|
|
2025-12-24 16:05:41 +08:00
|
|
|
|
async toggleVoiceInput() {
|
2025-08-29 16:59:14 +08:00
|
|
|
|
if (!this.voiceInputActive) {
|
2026-01-14 18:44:20 +08:00
|
|
|
|
try { await this.checkPrivacyAuthorize(); } catch (e) { return; }
|
2025-08-29 16:59:14 +08:00
|
|
|
|
uni.getSetting({
|
|
|
|
|
|
success: (res) => {
|
|
|
|
|
|
if (res.authSetting['scope.record']) {
|
|
|
|
|
|
this.hasRecordPermission = true;
|
|
|
|
|
|
this.voiceInputActive = true;
|
|
|
|
|
|
} else {
|
2025-12-24 16:05:41 +08:00
|
|
|
|
uni.authorize({
|
|
|
|
|
|
scope: 'scope.record',
|
|
|
|
|
|
success: () => {
|
|
|
|
|
|
this.hasRecordPermission = true;
|
|
|
|
|
|
this.voiceInputActive = true;
|
|
|
|
|
|
},
|
|
|
|
|
|
fail: () => {
|
|
|
|
|
|
uni.showModal({
|
2026-01-14 18:44:20 +08:00
|
|
|
|
title: '录音权限', content: '需要录音权限才能使用语音输入',
|
|
|
|
|
|
showCancel: true, confirmText: '去设置',
|
|
|
|
|
|
success: (res) => { if (res.confirm) uni.openSetting(); }
|
2025-12-24 16:05:41 +08:00
|
|
|
|
});
|
2025-08-29 16:59:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2026-01-14 18:44:20 +08:00
|
|
|
|
} else { this.voiceInputActive = false; }
|
2025-07-19 16:04:43 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
scrollToBottom() {
|
2025-12-23 10:30:10 +08:00
|
|
|
|
this.scrollIntoView = '';
|
2026-01-14 18:44:20 +08:00
|
|
|
|
this.$nextTick(() => { setTimeout(() => { this.scrollIntoView = 'chat-bottom-anchor'; setTimeout(() => { if (this.scrollIntoView !== 'chat-bottom-anchor') this.scrollIntoView = 'chat-bottom-anchor'; }, 100); }, 300); });
|
2025-07-19 16:04:43 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
2025-07-25 15:59:33 +08:00
|
|
|
|
scrollToOldLastMessage() {
|
2025-12-23 10:30:10 +08:00
|
|
|
|
this.scrollIntoView = '';
|
2025-07-25 15:59:33 +08:00
|
|
|
|
this.$nextTick(() => {
|
2025-12-23 10:30:10 +08:00
|
|
|
|
const query = uni.createSelectorQuery().in(this);
|
|
|
|
|
|
query.select('.message-list-container').boundingClientRect((rect) => {
|
|
|
|
|
|
if (rect) {
|
2026-01-14 18:44:20 +08:00
|
|
|
|
const heightDiff = rect.height - this.oldScrollViewHeight;
|
2025-12-23 10:30:10 +08:00
|
|
|
|
if (heightDiff > 0) {
|
|
|
|
|
|
this.scrollTop = heightDiff;
|
2026-01-14 18:44:20 +08:00
|
|
|
|
this.oldScrollViewHeight = rect.height;
|
2025-12-23 10:30:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}).exec();
|
2025-07-25 15:59:33 +08:00
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2025-07-22 16:54:37 +08:00
|
|
|
|
async loadHistory() {
|
|
|
|
|
|
if (!this.hasMore || this.loading) return;
|
2025-12-23 10:30:10 +08:00
|
|
|
|
this.getScrollHeight();
|
2025-12-23 11:04:45 +08:00
|
|
|
|
this.isLoadHistory = true;
|
2025-07-22 16:54:37 +08:00
|
|
|
|
this.loading = true;
|
2026-01-14 18:44:20 +08:00
|
|
|
|
if (typeof ChatManager !== 'undefined') ChatManager.loadHistory(this.doctorUserInfo.room_id);
|
2026-01-26 15:55:13 +08:00
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
this.loading = false;
|
|
|
|
|
|
}, 3000);
|
2025-08-01 16:37:44 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
2026-01-14 18:44:20 +08:00
|
|
|
|
getStatusText(status) { const map = { 0: '待审核', 1: '已审核', 2: '未通过' }; return map[status] || '未知状态'; },
|
|
|
|
|
|
getRegisterStatusText(status) { const map = { 0: '待就诊', 1: '已缴费', 2: '已就诊', 3: '已取消', 4: '已退费' }; return map[status] || '未知状态'; },
|
|
|
|
|
|
viewPrescription(id, orderNo) { uni.navigateTo({ url: "/subPackages/my/myrecord-detail?id=" + id + '&no=' + orderNo }); },
|
|
|
|
|
|
goToOrderMedicine(id, orderNo) { uni.navigateTo({ url: "/subPackages/my/my-drug/drug-info?id=" + id + '&order_type=prescription' }); },
|
2026-05-06 16:41:19 +08:00
|
|
|
|
viewRegister(id, orderNo) { uni.navigateTo({ url: `/subPackages/register/register-info?id=${id}&type=1` }); },
|
2026-02-07 16:17:01 +08:00
|
|
|
|
viewOrder(orderId, orderNo) { uni.navigateTo({ url: "/subPackages/my/my-drug/drug-info?id=" + orderId }); },
|
|
|
|
|
|
|
|
|
|
|
|
// 处理返回操作(自定义返回逻辑)
|
|
|
|
|
|
handleBack() {
|
2026-06-01 09:52:26 +08:00
|
|
|
|
if (this.showAgreement) {
|
|
|
|
|
|
this.closeAgreement();
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2026-02-07 16:17:01 +08:00
|
|
|
|
// 跳转到首页(tabBar页面需要使用switchTab)
|
|
|
|
|
|
uni.switchTab({
|
|
|
|
|
|
url: '/pages/index/index',
|
|
|
|
|
|
success: () => {
|
|
|
|
|
|
console.log('跳转到首页成功');
|
|
|
|
|
|
},
|
|
|
|
|
|
fail: (err) => {
|
|
|
|
|
|
console.error('跳转到首页失败:', err);
|
|
|
|
|
|
// 如果switchTab失败,尝试使用reLaunch
|
|
|
|
|
|
uni.reLaunch({
|
|
|
|
|
|
url: '/pages/index/index'
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
// 返回 false 阻止 u-navbar 的默认返回行为(重要!)
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2025-07-19 16:04:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
2025-12-23 08:31:21 +08:00
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
|
// ================= 变量定义 =================
|
2026-01-26 15:55:13 +08:00
|
|
|
|
$primary-blue: #0A84FF;
|
|
|
|
|
|
$bg-page: #F4F6F9;
|
2026-01-14 18:44:20 +08:00
|
|
|
|
$bg-white: #ffffff;
|
2025-12-23 08:31:21 +08:00
|
|
|
|
|
|
|
|
|
|
// ================= 基础容器 =================
|
2025-07-19 16:04:43 +08:00
|
|
|
|
.chat-container {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
height: 100vh;
|
2025-12-23 08:31:21 +08:00
|
|
|
|
background-color: $bg-page;
|
2025-07-19 16:04:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-26 15:55:13 +08:00
|
|
|
|
// ================= 顶部导航栏 =================
|
2025-07-19 16:04:43 +08:00
|
|
|
|
.chat-header {
|
2026-01-26 15:55:13 +08:00
|
|
|
|
background: rgba(255, 255, 255, 0.95);
|
2026-01-14 18:44:20 +08:00
|
|
|
|
backdrop-filter: blur(10px);
|
2025-12-23 08:31:21 +08:00
|
|
|
|
z-index: 100;
|
2025-07-19 16:04:43 +08:00
|
|
|
|
position: relative;
|
2026-01-26 15:55:13 +08:00
|
|
|
|
box-shadow: 0 1rpx 2rpx rgba(0,0,0,0.05);
|
2026-02-07 16:17:01 +08:00
|
|
|
|
// u-navbar会自动处理状态栏和导航栏高度,这里不需要额外设置margin-top
|
2025-07-19 16:04:43 +08:00
|
|
|
|
|
2025-12-23 08:31:21 +08:00
|
|
|
|
.header-main {
|
2025-07-19 16:04:43 +08:00
|
|
|
|
display: flex;
|
2025-12-23 08:31:21 +08:00
|
|
|
|
justify-content: space-between;
|
2025-07-19 16:04:43 +08:00
|
|
|
|
align-items: center;
|
2025-12-23 08:31:21 +08:00
|
|
|
|
padding: 24rpx 32rpx;
|
2025-07-19 16:04:43 +08:00
|
|
|
|
|
2025-12-23 08:31:21 +08:00
|
|
|
|
.doctor-info-group {
|
2025-07-19 16:04:43 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
|
2026-01-26 15:55:13 +08:00
|
|
|
|
.doctor-name { font-size: 34rpx; font-weight: 600; color: #333; margin-bottom: 4rpx; }
|
2025-12-23 08:31:21 +08:00
|
|
|
|
.doctor-badges {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
2026-01-26 15:55:13 +08:00
|
|
|
|
.status-dot { width: 12rpx; height: 12rpx; background-color: #52c41a; border-radius: 50%; margin-right: 8rpx; }
|
|
|
|
|
|
.sub-text { font-size: 24rpx; color: #999; }
|
2025-12-23 08:31:21 +08:00
|
|
|
|
}
|
2025-08-29 16:59:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-23 08:31:21 +08:00
|
|
|
|
.header-action {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
2026-01-26 15:55:13 +08:00
|
|
|
|
padding: 10rpx 20rpx;
|
|
|
|
|
|
background: #F0F5FF;
|
2025-12-23 08:31:21 +08:00
|
|
|
|
border-radius: 32rpx;
|
2026-01-14 18:44:20 +08:00
|
|
|
|
.expand-tip { font-size: 24rpx; color: $primary-blue; margin-right: 6rpx; }
|
2025-07-19 16:04:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-12-23 08:31:21 +08:00
|
|
|
|
}
|
2025-07-19 16:04:43 +08:00
|
|
|
|
|
2025-12-23 08:31:21 +08:00
|
|
|
|
.doctor-detail-panel {
|
|
|
|
|
|
max-height: 0;
|
|
|
|
|
|
overflow: hidden;
|
2026-01-14 18:44:20 +08:00
|
|
|
|
transition: max-height 0.3s cubic-bezier(0.25, 0.8, 0.5, 1);
|
2025-12-23 08:31:21 +08:00
|
|
|
|
background: $bg-white;
|
2025-08-29 16:59:14 +08:00
|
|
|
|
|
2026-01-14 18:44:20 +08:00
|
|
|
|
&.panel-show { max-height: 300rpx; border-bottom: 1rpx solid #eee; }
|
2025-07-19 16:04:43 +08:00
|
|
|
|
|
2025-12-23 08:31:21 +08:00
|
|
|
|
.detail-grid {
|
|
|
|
|
|
padding: 24rpx 32rpx;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
|
gap: 24rpx;
|
|
|
|
|
|
.detail-row {
|
|
|
|
|
|
width: 45%;
|
2025-07-19 16:04:43 +08:00
|
|
|
|
display: flex;
|
2025-12-23 08:31:21 +08:00
|
|
|
|
flex-direction: column;
|
2026-01-14 18:44:20 +08:00
|
|
|
|
&.full-width { width: 100%; }
|
2026-01-26 15:55:13 +08:00
|
|
|
|
.label { font-size: 22rpx; color: #999; margin-bottom: 8rpx; }
|
|
|
|
|
|
.value { font-size: 26rpx; color: #333; line-height: 1.4; }
|
|
|
|
|
|
.tag-value { color: $primary-blue; background: #e6f2ff; padding: 2rpx 8rpx; border-radius: 4rpx; display: inline-block; width: fit-content;}
|
|
|
|
|
|
.desc-value { color: #666; }
|
2025-07-19 16:04:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-23 08:31:21 +08:00
|
|
|
|
// ================= 消息滚动区域 =================
|
2025-07-19 16:04:43 +08:00
|
|
|
|
.chat-messages {
|
|
|
|
|
|
flex: 1;
|
2025-12-23 08:31:21 +08:00
|
|
|
|
background-color: $bg-page;
|
|
|
|
|
|
box-sizing: border-box;
|
2025-07-19 16:04:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-23 08:31:21 +08:00
|
|
|
|
.message-list-container {
|
|
|
|
|
|
padding: 30rpx 24rpx;
|
2025-07-19 16:04:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-07 16:17:01 +08:00
|
|
|
|
.notice-box {
|
|
|
|
|
|
margin-bottom: 20rpx;
|
|
|
|
|
|
padding: 24rpx;
|
|
|
|
|
|
background: #F5F5F5;
|
|
|
|
|
|
border-radius: 12rpx;
|
|
|
|
|
|
font-size: 24rpx;
|
|
|
|
|
|
line-height: 1.6;
|
|
|
|
|
|
color: #666;
|
|
|
|
|
|
|
|
|
|
|
|
.notice-text {
|
|
|
|
|
|
display: block;
|
|
|
|
|
|
word-break: break-all;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.notice-link {
|
|
|
|
|
|
color: #0A84FF;
|
|
|
|
|
|
text-decoration: underline;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-26 15:55:13 +08:00
|
|
|
|
.empty-state { text-align: center; padding: 40rpx 0; .empty-text { font-size: 24rpx; color: #ccc; } }
|
|
|
|
|
|
.loading-spinner { display: flex; justify-content: center; align-items: center; padding: 20rpx; .spinner { width: 30rpx; height: 30rpx; border: 2rpx solid #ddd; border-top-color: #999; border-radius: 50%; animation: spin 0.8s linear infinite; } .spinner-text { font-size: 24rpx; color: #999; margin-left: 10rpx;} }
|
|
|
|
|
|
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
|
2025-08-01 16:37:44 +08:00
|
|
|
|
|
2026-01-26 15:55:13 +08:00
|
|
|
|
.time-divider { text-align: center; margin: 30rpx 0; .time-text { font-size: 22rpx; color: #aaa; background: rgba(0,0,0,0.03); padding: 4rpx 16rpx; border-radius: 8rpx; } }
|
2025-08-01 16:37:44 +08:00
|
|
|
|
|
2026-01-14 18:44:20 +08:00
|
|
|
|
// ================= 底部输入 =================
|
2025-12-23 08:31:21 +08:00
|
|
|
|
.chat-footer {
|
2026-01-26 15:55:13 +08:00
|
|
|
|
background-color: #F7F7F7; // 微信风格浅灰背景
|
|
|
|
|
|
border-top: 1rpx solid rgba(0,0,0,0.05);
|
2026-01-14 18:44:20 +08:00
|
|
|
|
padding: 16rpx 24rpx 40rpx 24rpx;
|
2025-07-19 16:04:43 +08:00
|
|
|
|
position: fixed;
|
2026-01-14 18:44:20 +08:00
|
|
|
|
bottom: 0; left: 0; right: 0; z-index: 99;
|
2026-01-26 15:55:13 +08:00
|
|
|
|
transition: bottom 0.2s ease-out;
|
2025-07-19 16:04:43 +08:00
|
|
|
|
|
2026-01-14 18:44:20 +08:00
|
|
|
|
.consultation-ended-notice { display: flex; align-items: center; justify-content: center; padding: 30rpx; color: #999; font-size: 28rpx; gap: 12rpx; }
|
2026-01-07 14:21:29 +08:00
|
|
|
|
|
2026-01-26 15:55:13 +08:00
|
|
|
|
.input-bar {
|
|
|
|
|
|
display: flex; align-items: flex-end; gap: 16rpx;
|
|
|
|
|
|
|
|
|
|
|
|
// 图标按钮
|
|
|
|
|
|
.icon-btn {
|
|
|
|
|
|
width: 72rpx; height: 72rpx;
|
|
|
|
|
|
display: flex; align-items: center; justify-content: center;
|
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
&:active { opacity: 0.6; }
|
2025-08-29 16:59:14 +08:00
|
|
|
|
}
|
2025-07-19 16:04:43 +08:00
|
|
|
|
|
2026-01-26 15:55:13 +08:00
|
|
|
|
// 输入框容器
|
2025-12-23 08:31:21 +08:00
|
|
|
|
.input-field-wrapper {
|
2026-01-26 15:55:13 +08:00
|
|
|
|
flex: 1;
|
|
|
|
|
|
min-height: 72rpx;
|
|
|
|
|
|
display: flex; align-items: center;
|
|
|
|
|
|
|
|
|
|
|
|
.main-input {
|
|
|
|
|
|
width: 100%; height: 72rpx;
|
|
|
|
|
|
padding: 0 20rpx;
|
|
|
|
|
|
font-size: 30rpx; color: #333;
|
|
|
|
|
|
background: #fff;
|
|
|
|
|
|
border-radius: 12rpx;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-23 08:31:21 +08:00
|
|
|
|
.voice-btn {
|
2026-01-26 15:55:13 +08:00
|
|
|
|
width: 100%; height: 72rpx;
|
|
|
|
|
|
background: #fff; border-radius: 12rpx;
|
|
|
|
|
|
display: flex; align-items: center; justify-content: center;
|
|
|
|
|
|
font-size: 30rpx; color: #333; font-weight: 500;
|
|
|
|
|
|
border: 1rpx solid rgba(0,0,0,0.05);
|
|
|
|
|
|
&.recording { background: #f0f0f0; color: #666; }
|
2025-08-29 16:59:14 +08:00
|
|
|
|
}
|
2025-07-19 16:04:43 +08:00
|
|
|
|
}
|
2026-01-26 15:55:13 +08:00
|
|
|
|
|
|
|
|
|
|
// 右侧发送/加号
|
|
|
|
|
|
.right-action {
|
|
|
|
|
|
height: 72rpx; display: flex; align-items: center; justify-content: center;
|
|
|
|
|
|
.send-btn {
|
|
|
|
|
|
background: $primary-blue; color: #fff;
|
|
|
|
|
|
font-size: 26rpx; padding: 0 24rpx; height: 60rpx; line-height: 60rpx;
|
|
|
|
|
|
border-radius: 8rpx;
|
|
|
|
|
|
}
|
2025-08-29 16:59:14 +08:00
|
|
|
|
}
|
2025-07-19 16:04:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-23 08:31:21 +08:00
|
|
|
|
.recording-overlay {
|
2026-01-14 18:44:20 +08:00
|
|
|
|
position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.6); z-index: 999; display: flex; align-items: center; justify-content: center;
|
2025-12-23 08:31:21 +08:00
|
|
|
|
.recording-box {
|
2026-01-14 18:44:20 +08:00
|
|
|
|
width: 300rpx; height: 300rpx; background: rgba(0,0,0,0.8); border-radius: 32rpx; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff; gap: 20rpx;
|
2026-01-26 15:55:13 +08:00
|
|
|
|
.wave-animation { width: 100rpx; height: 4rpx; background: $primary-blue; border-radius: 20rpx; }
|
|
|
|
|
|
.timer { font-size: 32rpx; font-weight: 600; }
|
2025-12-23 08:31:21 +08:00
|
|
|
|
.tip { font-size: 24rpx; color: #ccc; }
|
2025-07-19 16:04:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-02-07 16:17:01 +08:00
|
|
|
|
|
|
|
|
|
|
.agreement-popup {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
background: #fff;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.agreement-header {
|
2026-06-01 09:52:26 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: space-between;
|
2026-02-07 16:17:01 +08:00
|
|
|
|
padding: 30rpx 50rpx 20rpx;
|
|
|
|
|
|
border-bottom: 1rpx solid #e5e7eb;
|
|
|
|
|
|
background: #fff;
|
2026-06-01 09:52:26 +08:00
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.agreement-close {
|
|
|
|
|
|
width: 48rpx;
|
|
|
|
|
|
height: 48rpx;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
font-size: 40rpx;
|
|
|
|
|
|
color: #64748b;
|
|
|
|
|
|
line-height: 1;
|
2026-02-07 16:17:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.agreement-title {
|
|
|
|
|
|
font-size: 32rpx;
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
color: #1e293b;
|
|
|
|
|
|
line-height: 1.5;
|
2026-06-01 09:52:26 +08:00
|
|
|
|
flex: 1;
|
|
|
|
|
|
min-width: 0;
|
2026-02-07 16:17:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.agreement-content {
|
|
|
|
|
|
flex: 1;
|
2026-06-01 09:52:26 +08:00
|
|
|
|
height: 0;
|
|
|
|
|
|
min-height: 200rpx;
|
2026-02-07 16:17:01 +08:00
|
|
|
|
padding: 30rpx 50rpx 40rpx;
|
2026-06-01 09:52:26 +08:00
|
|
|
|
box-sizing: border-box;
|
2026-02-07 16:17:01 +08:00
|
|
|
|
}
|
2025-07-19 16:04:43 +08:00
|
|
|
|
</style>
|