From 5d03f0fc79b9a5fc0f10e9afce97891042bb2aca Mon Sep 17 00:00:00 2001 From: wangdongbo <949818794@qq.com> Date: Tue, 27 Jan 2026 13:42:59 +0800 Subject: [PATCH] IM --- App.vue | 25 ++- pages.json | 12 ++ pages/message/article-detail.vue | 209 +++++++++++++++++++++ pages/message/article-list.vue | 132 +++++++++---- pages/message/chat.scss | 10 +- pages/message/common-phrases.vue | 2 +- pages/message/components/chat-input.vue | 22 ++- pages/message/components/message-types.vue | 22 ++- pages/message/index.vue | 149 ++++++++++----- pages/message/survey-list.vue | 171 +++++++++-------- pages/webview/webview.vue | 24 +++ styles/theme.scss | 58 ++++++ uni.scss | 2 +- utils/api.js | 20 +- 14 files changed, 680 insertions(+), 178 deletions(-) create mode 100644 pages/message/article-detail.vue create mode 100644 pages/webview/webview.vue create mode 100644 styles/theme.scss diff --git a/App.vue b/App.vue index 0ea7c2d..9fedd72 100644 --- a/App.vue +++ b/App.vue @@ -29,13 +29,36 @@ export default { diff --git a/pages/message/article-list.vue b/pages/message/article-list.vue index 83f488d..6880edf 100644 --- a/pages/message/article-list.vue +++ b/pages/message/article-list.vue @@ -19,10 +19,10 @@ v-for="cate in categoryList" :key="cate._id || 'all'" class="category-item" - :class="{ active: currentCateId === (cate._id || 'all') }" + :class="{ active: currentCateId === cate._id }" @click="selectCategory(cate)" > - {{ cate.name }} + {{ cate.label }} @@ -54,17 +54,17 @@ > {{ article.title }} - 创建时间:{{ article.date }} - - - + + + + @@ -75,8 +75,7 @@ + class="no-more"> 没有更多了 @@ -94,7 +93,9 @@ - + + + @@ -120,8 +121,8 @@ const searchTitle = ref(""); let searchTimer = null; // 分类列表 -const categoryList = ref([{ _id: "", name: "全部" }]); -const currentCateId = ref(""); +const categoryList = ref([{ _id: "", label: "全部" }]); +const currentCateId = ref(""); // 默认选中"全部"(_id 为空字符串) // 文章列表 const articleList = ref([]); @@ -143,7 +144,7 @@ const getCategoryList = async () => { const res = await getArticleCateList({ corpId: corpId }); if (res.success && res.list) { const cates = res.list || []; - categoryList.value = [{ _id: "", name: "全部" }, ...cates]; + categoryList.value = [{ _id: "", label: "全部" }, ...cates]; } } catch (error) { console.error("获取分类列表失败:", error); @@ -238,6 +239,36 @@ const loadMore = () => { loadArticleList(); }; +// 处理富文本内容,使图片自适应 +const processRichTextContent = (html) => { + if (!html) return ''; + + // 给所有 img 标签添加样式 + let processedHtml = html.replace( + / { + return match.replace(/width:\s*\d+px;?/gi, 'max-width:100%;'); + } + ); + + // 处理表格,添加自适应样式 + processedHtml = processedHtml.replace( + /${processedHtml}`; + + return processedHtml; +}; + // 预览文章 const previewArticle = async (article) => { try { @@ -245,10 +276,10 @@ const previewArticle = async (article) => { const res = await getArticle({ id: article._id, corpId: corpId }); uni.hideLoading(); - if (res.success && res.data ) { + if (res.success && res.data) { previewArticleData.value = { title: res.data.title || article.title, - content: res.data.content || "", + content: processRichTextContent(res.data.content || ""), }; previewPopup.value?.open(); } else { @@ -358,18 +389,20 @@ onMounted(() => { } .category-item { - padding: 32rpx 24rpx; + padding: 20rpx 24rpx; font-size: 28rpx; color: #333; text-align: center; border-bottom: 1px solid #eee; + transition: all 0.3s ease; + position: relative; } .category-item.active { background-color: #fff; - color: #1890ff; + color: #0877F1; font-weight: bold; - border-left: 4rpx solid #1890ff; + border-left: 4rpx solid #0877F1; } .article-list { @@ -397,39 +430,48 @@ onMounted(() => { } .article-item { - display: flex; - align-items: center; padding: 24rpx 30rpx; border-bottom: 1px solid #eee; + transition: background-color 0.2s ease; +} + +.article-item:active { + background-color: #f5f5f5; } .article-content { - flex: 1; display: flex; flex-direction: column; - margin-right: 20rpx; + gap: 16rpx; } .article-title { font-size: 28rpx; color: #333; - line-height: 1.5; + line-height: 1.6; word-break: break-all; - margin-bottom: 12rpx; + font-weight: 500; +} + +.article-footer { + display: flex; + align-items: center; + justify-content: space-between; + gap: 20rpx; } .article-date { + flex: 1; font-size: 24rpx; color: #999; } -.article-action { - flex-shrink: 0; -} - .send-btn { - padding: 8rpx 32rpx; + flex-shrink: 0; font-size: 26rpx; + padding: 8rpx 32rpx; + height: auto; + line-height: 1.4; } .loading-more, @@ -486,10 +528,28 @@ onMounted(() => { .preview-content { flex: 1; - padding: 30rpx; + padding: 0; overflow-y: auto; } +.rich-text-wrapper { + padding: 30rpx; + width: 100%; + box-sizing: border-box; + overflow: hidden; +} + +/* rich-text 内部样式 */ +.rich-text-wrapper ::v-deep rich-text { + width: 100%; +} + +.rich-text-wrapper ::v-deep rich-text img { + max-width: 100% !important; + height: auto !important; + display: block; +} + .preview-footer { padding: 20rpx; border-top: 1px solid #eee; diff --git a/pages/message/chat.scss b/pages/message/chat.scss index 4ea23f9..454cddf 100644 --- a/pages/message/chat.scss +++ b/pages/message/chat.scss @@ -136,7 +136,7 @@ $primary-color: #0877F1; .message-list { padding: 0 16rpx; - padding-bottom: 20rpx; + padding-bottom: 60rpx; /* 增加底部内边距,防止被小程序底部横线遮挡 */ } .message-item { @@ -350,10 +350,10 @@ $primary-color: #0877F1; flex: 1; padding: 0 46rpx; background-color: #f3f5fa; - border-radius: 50rpx; + border-radius: 20rpx; margin: 0 16rpx; font-size: 28rpx; - height: 96rpx; + height: 80rpx; border: none; outline: none; box-sizing: border-box; @@ -372,8 +372,8 @@ $primary-color: #0877F1; justify-content: flex-start; background: #fff; border-top: 1rpx solid #eee; - padding: 20rpx 0 8rpx 60rpx; - gap: 40rpx; + padding: 20rpx 0 40rpx 60rpx; + gap: 40rpx 50rpx; flex-wrap: wrap; background-color: #f5f5f5; } diff --git a/pages/message/common-phrases.vue b/pages/message/common-phrases.vue index c5f549b..3f5bde1 100644 --- a/pages/message/common-phrases.vue +++ b/pages/message/common-phrases.vue @@ -621,7 +621,7 @@ onMounted(() => { diff --git a/styles/theme.scss b/styles/theme.scss new file mode 100644 index 0000000..c147f45 --- /dev/null +++ b/styles/theme.scss @@ -0,0 +1,58 @@ +/** + * 项目主题色配置 + * 统一管理项目中使用的主题色 + */ + +// 主题色 +$primary-color: #0877F1; +$primary-light: #e8f3ff; +$primary-dark: #0660c9; +$primary-gradient-start: #1b5cc8; +$primary-gradient-end: #0877F1; + +// 辅助色 +$success-color: #4cd964; +$warning-color: #f0ad4e; +$error-color: #dd524d; +$info-color: #909399; + +// 文字颜色 +$text-color-primary: #333; +$text-color-regular: #666; +$text-color-secondary: #999; +$text-color-placeholder: #c0c4cc; +$text-color-white: #fff; + +// 背景颜色 +$bg-color-white: #ffffff; +$bg-color-page: #f5f5f5; +$bg-color-hover: #f1f1f1; +$bg-color-mask: rgba(0, 0, 0, 0.4); + +// 边框颜色 +$border-color-base: #e4e7ed; +$border-color-light: #ebeef5; +$border-color-lighter: #f2f6fc; + +// 圆角 +$border-radius-small: 4rpx; +$border-radius-base: 8rpx; +$border-radius-large: 16rpx; +$border-radius-round: 999rpx; + +// 间距 +$spacing-small: 16rpx; +$spacing-base: 24rpx; +$spacing-large: 32rpx; + +// 字体大小 +$font-size-small: 24rpx; +$font-size-base: 28rpx; +$font-size-medium: 32rpx; +$font-size-large: 36rpx; +$font-size-xlarge: 40rpx; + +// 阴影 +$box-shadow-light: 0 2rpx 12rpx rgba(0, 0, 0, 0.04); +$box-shadow-base: 0 4rpx 16rpx rgba(0, 0, 0, 0.08); +$box-shadow-dark: 0 8rpx 24rpx rgba(0, 0, 0, 0.12); diff --git a/uni.scss b/uni.scss index b9249e9..ac62a44 100644 --- a/uni.scss +++ b/uni.scss @@ -15,7 +15,7 @@ /* 颜色变量 */ /* 行为相关颜色 */ -$uni-color-primary: #007aff; +$uni-color-primary: #0877F1; $uni-color-success: #4cd964; $uni-color-warning: #f0ad4e; $uni-color-error: #dd524d; diff --git a/utils/api.js b/utils/api.js index 5ce9b95..7fc9c56 100644 --- a/utils/api.js +++ b/utils/api.js @@ -61,7 +61,9 @@ const urlsConfig = { getUserSig: 'getUserSig', sendSystemMessage: "sendSystemMessage", getChatRecordsByGroupId: "getChatRecordsByGroupId", - sendConsultRejectedMessage: "sendConsultRejectedMessage" + sendConsultRejectedMessage: "sendConsultRejectedMessage", + endConsultation: "endConsultation", + getGroupListByGroupId: "getGroupListByGroupId" } } @@ -141,3 +143,19 @@ export async function sendConsultRejectedMessage(data) { } }); } + +// 结束问诊接口 +export async function endConsultation(data) { + return request({ + url: '/getYoucanData/im', + data: { + type: 'endConsultation', + ...data + } + }); +} + +// 根据群组ID获取群组记录 +export async function getGroupListByGroupId(data) { + return api('getGroupListByGroupId', data); +}