转诊方功能优化

This commit is contained in:
李琦
2026-02-07 14:17:30 +08:00
parent 800aabf5ee
commit da8ef2019f
3 changed files with 108 additions and 10 deletions

View File

@@ -313,8 +313,16 @@ export default {
title: '同意转诊成功',
icon: 'success'
})
// 触发消息更新事件
uni.$emit('chat-message-update')
// 跳转到咨询页面
setTimeout(() => {
uni.redirectTo({
url: `/subPackages/transfer/transfer-consultation?transfer_id=${messageData.transfer_id}`,
fail: (err) => {
console.error('跳转失败:', err)
uni.showToast({ title: '跳转失败,请重试', icon: 'none' })
}
})
}, 1000)
} else {
uni.showToast({
title: result.data.message || '操作失败',

View File

@@ -142,10 +142,16 @@
title: '同意转诊成功',
icon: 'success'
})
// 刷新列表
this.page = 1
this.infoList = []
this.getInfos()
// 跳转到咨询页面
setTimeout(() => {
uni.redirectTo({
url: `/subPackages/transfer/transfer-consultation?transfer_id=${transferData.id}`,
fail: (err) => {
console.error('跳转失败:', err)
uni.showToast({ title: '跳转失败,请重试', icon: 'none' })
}
})
}, 1000)
} else {
uni.showToast({
title: result.data.message || '操作失败',

View File

@@ -66,6 +66,21 @@
</view>
</view>
<!-- "正在回复"提示气泡 -->
<view v-if="isTyping" class="message-item other typing-indicator">
<image class="avatar" :src="assistantAvatar" mode="aspectFill"></image>
<view class="message-content">
<view class="assistant-label">{{ assistantName }}</view>
<view class="message-bubble typing-bubble">
<view class="typing-dots">
<view class="dot"></view>
<view class="dot"></view>
<view class="dot"></view>
</view>
</view>
</view>
</view>
<!-- 底部锚点 -->
<view id="bottom-anchor" style="height: 1px;"></view>
</view>
@@ -111,7 +126,9 @@ export default {
assistantAvatar: '/static/images/assistant-avatar.png', // 医生助理头像(默认值,会从后端获取)
assistantName: '医生助理', // 医生助理名字(默认值,会从后端获取)
userAvatar: '/static/images/user-avatar.png', // 用户头像(需要替换为实际路径)
prescriptionInfo: '炒黄芪等共2味' // 处方信息(可以从转诊详情中获取)
prescriptionInfo: '炒黄芪等共2味', // 处方信息(可以从转诊详情中获取)
replyDelay: 1.00, // 回复延迟时间(秒),从配置中获取
isTyping: false // 是否显示"正在回复"提示
}
},
computed: {
@@ -276,6 +293,7 @@ export default {
const config = res.data.result || {}
this.assistantName = config.name || '医生助理'
this.assistantAvatar = config.avatar || '/static/images/assistant-avatar.png'
this.replyDelay = parseFloat(config.reply_delay) || 1.00 // 获取延迟时间,支持小数
}
} catch (error) {
console.error('加载助理配置失败:', error)
@@ -304,6 +322,17 @@ export default {
setTimeout(() => {
uni.navigateBack()
}, 1500)
} else {
// 延迟显示第一个问题(模拟真人回复)
this.isTyping = true
setTimeout(() => {
this.isTyping = false
// 显示第一个问题
this.currentQuestionIndex = 0
this.$nextTick(() => {
this.scrollIntoView = 'bottom-anchor'
})
}, this.replyDelay * 1000) // 延迟时间(毫秒)
}
} else {
throw new Error(res.data.message || '获取问题失败')
@@ -328,13 +357,24 @@ export default {
// 保存答案
this.userAnswers.push(answer)
// 如果还有下一个问题,显示下一个问题
// 如果还有下一个问题,延迟显示下一个问题(模拟真人回复)
if (this.currentQuestionIndex < this.questions.length - 1) {
this.currentQuestionIndex++
// 滚动到底部,显示新问题
// 显示"正在回复"提示
this.isTyping = true
// 滚动到底部
this.$nextTick(() => {
this.scrollIntoView = 'bottom-anchor'
})
// 延迟后显示下一个问题
setTimeout(() => {
this.isTyping = false
this.currentQuestionIndex++
// 滚动到底部,显示新问题
this.$nextTick(() => {
this.scrollIntoView = 'bottom-anchor'
})
}, this.replyDelay * 1000) // 延迟时间(毫秒)
} else {
// 所有问题已回答,提交答案
// 先滚动到底部
@@ -576,6 +616,50 @@ export default {
}
}
}
&.typing-indicator {
.typing-bubble {
padding: 18rpx 24rpx;
min-width: 80rpx;
}
.typing-dots {
display: flex;
align-items: center;
gap: 8rpx;
.dot {
width: 12rpx;
height: 12rpx;
border-radius: 50%;
background: #999;
animation: typing 1.4s infinite ease-in-out;
}
.dot:nth-child(1) {
animation-delay: 0s;
}
.dot:nth-child(2) {
animation-delay: 0.2s;
}
.dot:nth-child(3) {
animation-delay: 0.4s;
}
}
}
}
@keyframes typing {
0%, 60%, 100% {
transform: translateY(0);
opacity: 0.7;
}
30% {
transform: translateY(-10rpx);
opacity: 1;
}
}
.action-footer {