From 07a649b4bed140209da13ab0630ad63663c8a12e Mon Sep 17 00:00:00 2001 From: yangzhe Date: Wed, 31 Dec 2025 15:30:35 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix(home):=20=E4=BD=BF=E7=94=A8messageId?= =?UTF-8?q?=E4=BB=A3=E6=9B=BFconversationId=E4=BD=9C=E4=B8=BA=E5=8D=95?= =?UTF-8?q?=E6=9D=A1AI=E6=B6=88=E6=81=AF=E5=94=AF=E4=B8=80=E6=A0=87?= =?UTF-8?q?=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/home/index/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/home/index/index.vue b/pages/home/index/index.vue index 8e9d3bf..ad9af43 100644 --- a/pages/home/index/index.vue +++ b/pages/home/index/index.vue @@ -947,7 +947,7 @@ export default { // 创建AI回复消息对象 const aiMessage = { id: - data.conversationId || + data.messageId || Math.random().toString(36).substring(2, 15), message: data.content, sendDate: "", From d2cf481a6765e7b6d7abd0e818d762e2351f4f66 Mon Sep 17 00:00:00 2001 From: yangzhe Date: Tue, 20 Jan 2026 11:44:28 +0800 Subject: [PATCH 2/4] =?UTF-8?q?feat(=E5=A4=B4=E5=83=8F=E5=A4=84=E7=90=86):?= =?UTF-8?q?=20=E6=B7=BB=E5=8A=A0=E7=BB=9F=E4=B8=80=E5=A4=B4=E5=83=8FURL?= =?UTF-8?q?=E5=A4=84=E7=90=86=E5=87=BD=E6=95=B0=E5=B9=B6=E6=9B=BF=E6=8D=A2?= =?UTF-8?q?=E7=A1=AC=E7=BC=96=E7=A0=81=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/utils.js | 33 ++++++++++++++++++++++++++++++++ main.js | 8 ++++++++ pages/chat/index.vue | 12 ++---------- pages/home/admissions/index.vue | 2 +- pages/home/userSetting/index.vue | 2 +- 5 files changed, 45 insertions(+), 12 deletions(-) diff --git a/common/utils.js b/common/utils.js index 6f5da6b..ddafdba 100644 --- a/common/utils.js +++ b/common/utils.js @@ -14,3 +14,36 @@ export const Debounce = (fn, wait) => { if (callNow) fn.apply(this, args) } } + +/** + * 处理头像/图片 URL + * @param {String} url 图片路径 + * @param {String} baseUrl 基础路径 + * @param {String} defaultUrl 默认图片路径 + */ +export const getHeadImgUrl = (url, baseUrl, defaultUrl = "/static/common/images/avatar_default2.png") => { + if (!url) return defaultUrl; + if (url.startsWith('http') || url.startsWith('https') || url.startsWith('blob:')) return url; + + // 统一处理反斜杠:将所有的 \ 替换为 / + let cleanUrl = url.replace(/\\/g, '/'); + + // 处理 baseUrl: 替换反斜杠并去除末尾斜杠 + let cleanBaseUrl = ''; + if (baseUrl) { + cleanBaseUrl = baseUrl.replace(/\\/g, '/').replace(/\/$/, ''); + } + + // 情况三:headSculptureUrl = "/UploadImages/tx.jpg" + if (cleanUrl.startsWith('/')) { + return cleanBaseUrl + cleanUrl; + } + + // 情况二:headSculptureUrl = "UploadImages/tx.jpg" + if (cleanUrl.includes('/')) { + return cleanBaseUrl + '/' + cleanUrl; + } + + // 情况一:headSculptureUrl = "tx.jpg" + return cleanBaseUrl + '/UploadImages/' + cleanUrl; +} diff --git a/main.js b/main.js index 33b03ad..38e3cf6 100644 --- a/main.js +++ b/main.js @@ -2,6 +2,7 @@ import Vue from 'vue'; import App from './App'; import "./static/common/css/font.css" import common from './static/common/js/common' +import { getHeadImgUrl } from '@/common/utils.js'; import jweixin from 'jweixin-module' import { HubConnectionBuilder, @@ -27,6 +28,13 @@ var tips = function(title, type, time) { // 导入公用js Vue.prototype.$tips = tips Vue.prototype.common = common +Vue.prototype.$getHeadImgUrl = function (url, defaultUrl) { + let baseUrl = ''; + if (this.$u && this.$u.http && this.$u.http.config && this.$u.http.config.baseUrl) { + baseUrl = this.$u.http.config.baseUrl; + } + return getHeadImgUrl(url, baseUrl, defaultUrl); +} // 导入微信sdk Vue.prototype.jweixin = jweixin // 引入全局uView diff --git a/pages/chat/index.vue b/pages/chat/index.vue index f2ed716..22b4f95 100644 --- a/pages/chat/index.vue +++ b/pages/chat/index.vue @@ -212,19 +212,11 @@ export default { }, receiverHeadSculptureUrl() { - if (this.vuex_msgUser.headSculptureUrl) { - return this.baseUrl + "/" + this.vuex_msgUser.headSculptureUrl; - } - - return "/static/common/images/avatar_default2.png"; + return this.$getHeadImgUrl(this.vuex_msgUser.headSculptureUrl); }, headSculptureUrl() { - if (this.vuex_user.HeadSculptureUrl) { - return this.baseUrl + "/" + this.vuex_user.HeadSculptureUrl; - } - - return "/static/common/images/avatar_default2.png"; + return this.$getHeadImgUrl(this.vuex_user.HeadSculptureUrl); }, }, diff --git a/pages/home/admissions/index.vue b/pages/home/admissions/index.vue index 255eaf9..feea492 100644 --- a/pages/home/admissions/index.vue +++ b/pages/home/admissions/index.vue @@ -26,7 +26,7 @@ > diff --git a/pages/home/userSetting/index.vue b/pages/home/userSetting/index.vue index 289711a..92b8fc1 100644 --- a/pages/home/userSetting/index.vue +++ b/pages/home/userSetting/index.vue @@ -251,7 +251,7 @@ export default { this.imageUrl = ""; this.imageValue = [ { - url: "/static/common/images/avatar_default.jpg", + url: "/static/common/images/avatar_default2.png", extname: "jpg", name: "", }, From c8b66929ae88472fb19aa6c653f41dd8f06e4622 Mon Sep 17 00:00:00 2001 From: yangzhe Date: Tue, 20 Jan 2026 11:57:07 +0800 Subject: [PATCH 3/4] =?UTF-8?q?refactor(home):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=BB=93=E6=9E=84=E5=92=8C=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E6=8F=90=E5=8F=96=E5=A4=B4=E5=83=8FURL=E7=94=9F?= =?UTF-8?q?=E6=88=90=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/home/index/index.vue | 94 +++++++++++--------------------------- 1 file changed, 27 insertions(+), 67 deletions(-) diff --git a/pages/home/index/index.vue b/pages/home/index/index.vue index ad9af43..e62da6b 100644 --- a/pages/home/index/index.vue +++ b/pages/home/index/index.vue @@ -193,10 +193,7 @@ {{ getTransferCardTip(message) }} @@ -321,7 +318,7 @@ class="tab-item" v-for="(tab, index) in floatingTabs" :key="index" - @click="handleFeatureClick({ title: tab.title })" + @click="handleFeatureClick({ title: tab.title, path: tab.path })" > {{ tab.title }} @@ -445,6 +442,7 @@ export default { { title: "招生在线", icon: "/static/common/images/icon_admissions2.png", + path: "/pages/home/admissions/index", }, { title: "转人工", @@ -506,23 +504,10 @@ export default { computed: { headSculptureUrl() { - if (this.vuex_user.HeadSculptureUrl) { - return this.baseUrl + "/" + this.vuex_user.HeadSculptureUrl; - } - - return "/static/common/images/avatar.png"; + return this.$getHeadImgUrl(this.vuex_user.HeadSculptureUrl); }, receiverHeadSculptureUrl() { - const url = - (this.vuex_msgUser && - (this.vuex_msgUser.headSculptureUrl || - this.vuex_msgUser.HeadSculptureUrl)) || - ""; - if (url) { - return this.baseUrl + "/" + url; - } - - return "/static/common/images/avatar_default2.png"; + return this.$getHeadImgUrl(this.vuex_msgUser.headSculptureUrl); }, aiMessageGroups() { return Array.isArray(this.vuex_aiMessageGroups) @@ -544,7 +529,8 @@ export default { isLiveAgentChat() { if (!this.vuex_isTransferChat) return false; const current = this.currentDMid || ""; - const active = this.vuex_msgUser && this.vuex_msgUser.dialogueManagementId; + const active = + this.vuex_msgUser && this.vuex_msgUser.dialogueManagementId; return !!(current && active && String(active) === String(current)); }, }, @@ -677,7 +663,6 @@ export default { this.resetChatState({ isChat: false }); return; } - if (item.title === "转人工") { this.handleTransferEntryClick(); return; @@ -746,7 +731,7 @@ export default { this.isTransferSubmitting = false; const nextList = this.aiMessageGroups.filter( - (m) => !(m && m.customType === "transferCard") + (m) => !(m && m.customType === "transferCard"), ); nextList.push(this.createLocalUserTextMessage("转人工")); @@ -767,14 +752,10 @@ export default { const cardId = this.activeTransferCardId; const findCardIndex = (list) => { if (cardId) { - const byId = list.findIndex( - (m) => m && m.id === cardId - ); + const byId = list.findIndex((m) => m && m.id === cardId); if (byId >= 0) return byId; } - return list.findIndex( - (m) => m && m.customType === "transferCard" - ); + return list.findIndex((m) => m && m.customType === "transferCard"); }; const updateTransferCard = (patch) => { const list = this.aiMessageGroups; @@ -792,7 +773,8 @@ export default { if (idx < 0) return; const current = list[idx] || {}; - if (this.isTransferSubmitting || current.transferStatus === "done") return; + if (this.isTransferSubmitting || current.transferStatus === "done") + return; updateTransferCard({ transferStatus: "idle", @@ -815,7 +797,8 @@ export default { .TransferToALiveAgentApi(params) .then((res) => { const succeed = res && res.succeed !== false; - const serverTip = (res && res.data && res.data.message) || (res && res.error) || ""; + const serverTip = + (res && res.data && res.data.message) || (res && res.error) || ""; if (!succeed) { updateTransferCard({ transferStatus: "idle", @@ -940,15 +923,11 @@ export default { this.currentDMid = data.dmid; // 从消息列表中移除加载状态消息 - const baseList = this.aiMessageGroups.filter( - (msg) => !msg.isLoading - ); + const baseList = this.aiMessageGroups.filter((msg) => !msg.isLoading); // 创建AI回复消息对象 const aiMessage = { - id: - data.messageId || - Math.random().toString(36).substring(2, 15), + id: data.messageId || Math.random().toString(36).substring(2, 15), message: data.content, sendDate: "", isSend: true, @@ -966,9 +945,7 @@ export default { console.error("API请求失败:", error); // 从消息列表中移除加载状态消息 - const baseList = this.aiMessageGroups.filter( - (msg) => !msg.isLoading - ); + const baseList = this.aiMessageGroups.filter((msg) => !msg.isLoading); // 添加错误消息 const errorMessage = { @@ -983,10 +960,7 @@ export default { displayTime: "", }; - this.$store.commit( - "push_AiMsgList", - baseList.concat([errorMessage]) - ); + this.$store.commit("push_AiMsgList", baseList.concat([errorMessage])); }); }, @@ -1058,7 +1032,7 @@ export default { // 从消息列表中移除加载状态消息 const baseList = this.aiMessageGroups.filter( - (msg) => !msg.isLoading + (msg) => !msg.isLoading, ); // 创建AI回复消息对象 @@ -1077,15 +1051,12 @@ export default { }; // 添加到消息列表 - this.$store.commit( - "push_AiMsgList", - baseList.concat([aiMessage]) - ); + this.$store.commit("push_AiMsgList", baseList.concat([aiMessage])); } else { // 从消息列表中移除加载状态消息 this.$store.commit( "push_AiMsgList", - this.aiMessageGroups.filter((msg) => !msg.isLoading) + this.aiMessageGroups.filter((msg) => !msg.isLoading), ); } }) @@ -1093,9 +1064,7 @@ export default { console.error("API请求失败:", error); // 从消息列表中移除加载状态消息 - const baseList = this.aiMessageGroups.filter( - (msg) => !msg.isLoading - ); + const baseList = this.aiMessageGroups.filter((msg) => !msg.isLoading); // 添加错误消息 const errorMessage = { @@ -1110,10 +1079,7 @@ export default { displayTime: "", }; - this.$store.commit( - "push_AiMsgList", - baseList.concat([errorMessage]) - ); + this.$store.commit("push_AiMsgList", baseList.concat([errorMessage])); }); }, @@ -1167,10 +1133,7 @@ export default { const currentList = res.item2 || []; // 将消息按sendDate升序排列,时间相同时用户消息(interactMode=0)排在前面 - this.$store.commit( - "push_AiMsgList", - this.sortMessages(currentList) - ); + this.$store.commit("push_AiMsgList", this.sortMessages(currentList)); }) .finally(() => { // 延迟重置切换对话标志位,确保滚动事件处理完成 @@ -1207,14 +1170,14 @@ export default { const prevList = res3?.item2 || []; this.$store.commit( "push_AiMsgList", - this.sortMessages(prevList) + this.sortMessages(prevList), ); this.pageQuery.PageIndex = prevIndex; }); } else { this.$store.commit( "push_AiMsgList", - this.sortMessages(currentList) + this.sortMessages(currentList), ); } }); @@ -1277,10 +1240,7 @@ export default { // 将消息按sendDate升序排列,时间相同时用户消息(interactMode=0)排在前面 const nextPageMessageGroups = sortChatMessages(res.item2 || []); - this.$store.commit( - "prepend_AiMsgList", - nextPageMessageGroups - ); + this.$store.commit("prepend_AiMsgList", nextPageMessageGroups); }) .finally(() => { setTimeout(() => { From c7e5b0504c639e220d849f9c6a97f9b6a118c2be Mon Sep 17 00:00:00 2001 From: yangzhe Date: Tue, 20 Jan 2026 14:46:20 +0800 Subject: [PATCH 4/4] =?UTF-8?q?feat(=E8=81=8A=E5=A4=A9):=20=20=E6=95=99?= =?UTF-8?q?=E5=B8=88=E4=BF=A1=E6=81=AFcard=E6=B7=BB=E5=8A=A0=E5=9B=9E?= =?UTF-8?q?=E5=A4=8D=E7=BB=9F=E8=AE=A1=E6=A0=87=E7=AD=BE=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/chat/index.vue | 60 ++++++++++++++++++++++++++++++++++++++------ store/index.js | 30 +++++++++++----------- 2 files changed, 67 insertions(+), 23 deletions(-) diff --git a/pages/chat/index.vue b/pages/chat/index.vue index 22b4f95..64053b2 100644 --- a/pages/chat/index.vue +++ b/pages/chat/index.vue @@ -27,14 +27,29 @@ :src="receiverHeadSculptureUrl" >
-
{{ vuex_msgUser.name }}
+
+
{{ vuex_msgUser.name }}
+
+ + 今日已回复{{ + vuex_msgUser.todayNumberOfReplies || 0 + }}人 +
+
- {{ vuex_msgUser.collegeName }} + + + 江西新能源科技职业学院
@@ -442,11 +457,42 @@ export default { gap: 16rpx; flex: 1; - .teacher-name { - font-family: PingFang SC; - font-weight: bold; - font-size: 36rpx; - color: #333333; + .teacher-header { + display: flex; + align-items: center; + + .teacher-name { + font-family: PingFang SC; + font-weight: bold; + font-size: 36rpx; + color: #333333; + height: 52rpx; + line-height: 50rpx; + margin-right: 20rpx; + } + + .reply-tag { + display: flex; + align-items: center; + background-color: #eaedfc; + border-radius: 24rpx; + padding: 10rpx 24rpx; + // height: 48rpx; + box-sizing: border-box; + + .reply-icon { + width: 24rpx; + height: 24rpx; + margin-right: 8rpx; + } + + text { + font-size: 24rpx; + color: #4f6aff; + line-height: 1; + letter-spacing: 1rpx; + } + } } .teacher-school, diff --git a/store/index.js b/store/index.js index eb6a1f3..64735c9 100644 --- a/store/index.js +++ b/store/index.js @@ -498,9 +498,13 @@ const store = new Vuex.Store({ dialogueManagementId !== "00000000-0000-0000-0000-000000000000" ) { // 有会话ID,直接进入会话 - commit("set_MsgUser", { ...user }); - uni.navigateTo({ - url: `/pages/chat/index`, + Vue.prototype.$u.api.GetReceiverUserInfoApi({ Id: id }).then((res) => { + if (res.succeed && res.data) { + commit("set_MsgUser", { ...res.data, dialogueManagementId }); + uni.navigateTo({ + url: `/pages/chat/index`, + }); + } }); return; } @@ -514,19 +518,13 @@ const store = new Vuex.Store({ const resId = res1.data?.dialogueManagementId || ""; if (res1 && res1.succeed) { - // 获取接收者信息,这里没啥用(先注释) - // Vue.prototype.$u.api.GetReceiverUserInfoApi({ Id: id }).then((res) => { - // if (res.succeed && res.data) { - // commit("set_MsgUser", { ...res.data, dialogueManagementId }); - // uni.navigateTo({ - // url: `/pages/chat/index`, - // }); - // return; - // } - // }); - commit("set_MsgUser", { ...user, dialogueManagementId: resId }); - uni.navigateTo({ - url: `/pages/chat/index`, + Vue.prototype.$u.api.GetReceiverUserInfoApi({ Id: id }).then((res) => { + if (res.succeed && res.data) { + commit("set_MsgUser", { ...res.data, dialogueManagementId: resId }); + uni.navigateTo({ + url: `/pages/chat/index`, + }); + } }); return; }