ykt-wxapp/pages/message/README.md
2026-01-23 15:51:26 +08:00

96 lines
2.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 常用语功能说明
## 功能概述
在聊天页面添加了常用语功能,医生可以快速选择并发送预设的常用语内容。
## 功能特性
### 1. 常用语列表页面 (`common-phrases.vue`)
- 支持分类管理(文字随访、语音随访、常用回复等)
- 支持添加、编辑、删除常用语
- 支持添加自定义分类
- 点击常用语直接发送到聊天
### 2. 聊天输入框集成
- 在聊天输入框的"更多"面板中添加"常用语"入口
- 点击后跳转到常用语列表页面
- 选择常用语后自动返回并发送
### 3. 数据持久化
- 常用语数据存储在MongoDB的`common-words`集合中
- 支持机构级别和个人级别的常用语
- 与PC端管理后台数据互通
## 文件结构
```
ykt-wx-app/pages/message/
├── common-phrases.vue # 常用语列表页面
├── components/
│ └── chat-input.vue # 聊天输入框组件(已更新)
├── index.vue # 聊天主页面(已更新)
└── README.md # 本文档
ykt-wx-app/utils/
└── api.js # API配置已添加常用语接口
ytk-customer-service/knowledgeBase/common-words/
└── index.js # 后端常用语接口(已添加小程序接口)
```
## API接口
### 1. 获取常用语列表
```javascript
api('getCommonPhrases', { corpId })
```
### 2. 保存常用语
```javascript
api('saveCommonPhrase', {
id, // 可选,更新时传入
corpId,
userId,
categoryId,
content
})
```
### 3. 删除常用语
```javascript
api('deleteCommonPhrase', {
id,
corpId
})
```
### 4. 获取分类列表
```javascript
api('getCommonPhraseCategories', { corpId })
```
### 5. 保存分类
```javascript
api('saveCommonPhraseCategory', {
corpId,
userId,
name
})
```
## 使用流程
1. 用户在聊天页面点击输入框右侧的"+"按钮
2. 在弹出的功能面板中点击"常用语"
3. 跳转到常用语列表页面
4. 可以切换分类查看不同类型的常用语
5. 点击任意常用语,自动返回聊天页面并发送该内容
6. 在编辑模式下可以添加、编辑、删除常用语
## 注意事项
1. 常用语功能需要用户已登录并有有效的corpId
2. 如果后端API调用失败会使用本地模拟数据
3. 常用语内容最多500字
4. 分类名称最多6个字