diff --git a/pages.json b/pages.json
index ed78caf..55a5b8a 100644
--- a/pages.json
+++ b/pages.json
@@ -13,6 +13,12 @@
"enablePullDownRefresh": false
}
},
+ {
+ "path": "pages/message/common-phrases",
+ "style": {
+ "navigationBarTitleText": "常用语"
+ }
+ },
{
"path": "pages/work/work",
"style": {
diff --git a/pages/message/README.md b/pages/message/README.md
new file mode 100644
index 0000000..4cf1f3c
--- /dev/null
+++ b/pages/message/README.md
@@ -0,0 +1,95 @@
+# 常用语功能说明
+
+## 功能概述
+在聊天页面添加了常用语功能,医生可以快速选择并发送预设的常用语内容。
+
+## 功能特性
+
+### 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个字
diff --git a/pages/message/common-phrases.vue b/pages/message/common-phrases.vue
new file mode 100644
index 0000000..f917d00
--- /dev/null
+++ b/pages/message/common-phrases.vue
@@ -0,0 +1,937 @@
+
+
+
+
+
+
+
+
+
+
+
+ +
+ 添加快捷回复
+
+
+ {{ isEditMode ? "完成" : "编辑" }}
+
+
+
+
+
+ {{ phrase.content }}
+
+
+ 编辑
+
+
+ 删除
+
+
+
+
+
+ 暂无常用语
+ 点击上方按钮添加常用语
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/message/components/chat-input.vue b/pages/message/components/chat-input.vue
index 5184f6f..d63b037 100644
--- a/pages/message/components/chat-input.vue
+++ b/pages/message/components/chat-input.vue
@@ -150,6 +150,23 @@ const sendTextMessage = async () => {
inputText.value = "";
};
+// 从常用语发送文本消息
+const sendTextMessageFromPhrase = async (content) => {
+ if (!content.trim()) return;
+
+ await sendMessage("text", content);
+
+ // 发送成功后滚动到底部
+ nextTick(() => {
+ emit("scrollToBottom");
+ });
+};
+
+// 暴露方法给父组件调用
+defineExpose({
+ sendTextMessageFromPhrase
+});
+
// 发送图片消息
const sendImageMessage = async (imageFile) => {
console.log("chat-input sendImageMessage 被调用,参数:", imageFile);
@@ -337,14 +354,40 @@ const sendSurveyMessage = async () => {
await sendCustomMessage(surveyMessage);
};
-// 更多面板按钮配置
+// 跳转到常用语页面
+const goToCommonPhrases = () => {
+ uni.navigateTo({
+ url: '/pages/message/common-phrases'
+ });
+};
+
const morePanelButtons = [
- { text: "照片", icon: "/static/home/photo.png", action: showImagePicker },
- { text: "拍摄", icon: "/static/home/video.png", action: takePhoto },
- // { text: '病情', icon: '/static/home/avatar.svg', action: sendSymptomMessage },
- // { text: '处方', icon: '/static/home/avatar.svg', action: sendPrescriptionMessage },
- // { text: '续方', icon: '/static/home/avatar.svg', action: sendRefillMessage },
- // { text: '问卷', icon: '/static/home/avatar.svg', action: sendSurveyMessage }
+ { text: "照片", icon: "/static/icon/zhaopian.png", action: showImagePicker },
+ {
+ text: "回访任务",
+ icon: "/static/icon/zhaopian.png",
+ action: showImagePicker,
+ },
+ {
+ text: "常用语",
+ icon: "/static/icon/changyongyu.png",
+ action: goToCommonPhrases,
+ },
+ {
+ text: "宣教",
+ icon: "/static/icon/xuanjiaowenzhang.png",
+ action: showImagePicker,
+ },
+ {
+ text: "问卷",
+ icon: "/static/icon/zhaopian.png",
+ action: showImagePicker,
+ },
+ {
+ text: "结束问诊",
+ icon: "/static/icon/jieshuzixun.png",
+ action: showImagePicker,
+ },
];
function handleInputFocus() {
diff --git a/pages/message/index.vue b/pages/message/index.vue
index 19d0432..e09f80f 100644
--- a/pages/message/index.vue
+++ b/pages/message/index.vue
@@ -111,6 +111,7 @@
scrollToBottom(true)"
@@ -153,6 +154,9 @@ const timChatManager = globalTimChatManager;
const { account, openid, isIMInitialized } = storeToRefs(useAccountStore());
const { initIMAfterLogin } = useAccountStore();
+// 聊天输入组件引用
+const chatInputRef = ref(null);
+
const groupId = ref("");
const {
chatMember,
@@ -590,6 +594,18 @@ onHide(() => {
stopIMMonitoring();
});
+// 发送常用语(从常用语页面返回时调用)
+const sendCommonPhrase = (content) => {
+ if (chatInputRef.value) {
+ chatInputRef.value.sendTextMessageFromPhrase(content);
+ }
+};
+
+// 暴露方法给常用语页面调用
+defineExpose({
+ sendCommonPhrase
+});
+
// 页面卸载
onUnmounted(() => {
clearMessageCache();
diff --git a/static/icon/icon-chinese-rx.png b/static/icon/icon-chinese-rx.png
deleted file mode 100644
index 10ee891..0000000
Binary files a/static/icon/icon-chinese-rx.png and /dev/null differ
diff --git a/static/icon/icon-western-rx.png b/static/icon/icon-western-rx.png
deleted file mode 100644
index 00cb9a8..0000000
Binary files a/static/icon/icon-western-rx.png and /dev/null differ
diff --git a/static/icon/kaichufang.png b/static/icon/kaichufang.png
deleted file mode 100644
index 647f267..0000000
Binary files a/static/icon/kaichufang.png and /dev/null differ
diff --git a/static/icon/kaizhongyao.png b/static/icon/kaizhongyao.png
deleted file mode 100644
index f9d649e..0000000
Binary files a/static/icon/kaizhongyao.png and /dev/null differ
diff --git a/static/icon/quxiaobingtuikuan.png b/static/icon/quxiaobingtuikuan.png
deleted file mode 100644
index 97c24a3..0000000
Binary files a/static/icon/quxiaobingtuikuan.png and /dev/null differ
diff --git a/utils/api.js b/utils/api.js
index c14422a..677ea8e 100644
--- a/utils/api.js
+++ b/utils/api.js
@@ -18,7 +18,12 @@ const urlsConfig = {
},
knowledgeBase: {
- getArticleByIds: 'getArticleByIds'
+ getArticleByIds: 'getArticleByIds',
+ getCommonPhrases: 'getCommonPhrases',
+ saveCommonPhrase: 'saveCommonPhrase',
+ deleteCommonPhrase: 'deleteCommonPhrase',
+ getCommonPhraseCategories: 'getCommonPhraseCategories',
+ saveCommonPhraseCategory: 'saveCommonPhraseCategory'
},
member: {
addCustomer: 'add',