Merge branch 'main' of http://sl.vrgon.com:3000/JiXinHui/YingXingAI
This commit is contained in:
commit
d854f4dbe0
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
8
main.js
8
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
|
||||
|
|
|
|||
|
|
@ -21,12 +21,44 @@
|
|||
>
|
||||
<view class="chat-content">
|
||||
<!-- 教师信息 -->
|
||||
<div class="teacher-info-card">
|
||||
<div class="teacher-info-card" v-if="vuex_userType == 0">
|
||||
<image
|
||||
class="teacher-avatar"
|
||||
:src="receiverHeadSculptureUrl"
|
||||
></image>
|
||||
<div class="teacher-info">
|
||||
<div class="teacher-info" >
|
||||
<div>{{vuex_userType}}</div>
|
||||
<div class="teacher-header">
|
||||
<div class="teacher-name">{{ vuex_msgUser.name }}</div>
|
||||
<div class="reply-tag">
|
||||
<image
|
||||
class="reply-icon"
|
||||
src="/static/common/images/icon_chat3.png"
|
||||
></image>
|
||||
<text
|
||||
>今日已回复{{
|
||||
vuex_msgUser.todayNumberOfReplies || 0
|
||||
}}人</text
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <div class="teacher-school">
|
||||
<image
|
||||
class="school-icon"
|
||||
src="/static/common/images/icon_college.png"
|
||||
></image>
|
||||
<!--= 后端让先写死 -->
|
||||
<!-- <text class="school-text">{{ vuex_msgUser.collegeName }}</text> -->
|
||||
<text class="school-text">江西新能源科技职业学院</text>
|
||||
</div>
|
||||
</div>
|
||||
<div class="teacher-info-card" v-if="vuex_userType ==1">
|
||||
<image
|
||||
class="teacher-avatar"
|
||||
:src="receiverHeadSculptureUrl"
|
||||
></image>
|
||||
<div class="teacher-info" v-if="vuex_userType == 1">
|
||||
<div class="teacher-name-row">
|
||||
<div class="teacher-name">{{ vuex_msgUser.name }}</div>
|
||||
<image
|
||||
|
|
@ -47,22 +79,6 @@
|
|||
归属地: <span style="font-weight: bold;">{{vuex_msgUser.shen}}</span>
|
||||
</text>
|
||||
</div>
|
||||
|
||||
<!-- <div class="teacher-school">
|
||||
<image
|
||||
class="school-icon"
|
||||
src="/static/common/images/icon_college.png"
|
||||
></image>
|
||||
<text class="school-text">{{ vuex_msgUser.collegeName }}</text>
|
||||
</div> -->
|
||||
|
||||
<!-- <div class="teacher-college">
|
||||
<image
|
||||
class="college-icon"
|
||||
src="/static/common/images/icon_major.png"
|
||||
></image>
|
||||
<text class="college-text">{{ vuex_msgUser.collegeName }}</text>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -231,19 +247,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);
|
||||
},
|
||||
},
|
||||
|
||||
|
|
@ -469,11 +477,44 @@ 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-name-row {
|
||||
display: flex;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
>
|
||||
<image
|
||||
class="teacher-avatar"
|
||||
src="/static/common/images/avatar.png"
|
||||
:src="$getHeadImgUrl(teacher.headSculptureUrl)"
|
||||
></image>
|
||||
<view class="teacher-info">
|
||||
<view class="teacher-detail">
|
||||
|
|
|
|||
|
|
@ -193,10 +193,7 @@
|
|||
</view>
|
||||
<view
|
||||
class="transfer-card-status"
|
||||
v-if="
|
||||
isTransferSubmitting ||
|
||||
!!message.transferTipText
|
||||
"
|
||||
v-if="isTransferSubmitting || !!message.transferTipText"
|
||||
>
|
||||
{{ getTransferCardTip(message) }}
|
||||
</view>
|
||||
|
|
@ -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 })"
|
||||
>
|
||||
<image class="tab-icon" :src="tab.icon" mode="scaleToFill" />
|
||||
<text>{{ tab.title }}</text>
|
||||
|
|
@ -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.conversationId ||
|
||||
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(() => {
|
||||
|
|
|
|||
|
|
@ -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: "",
|
||||
},
|
||||
|
|
|
|||
|
|
@ -499,9 +499,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;
|
||||
}
|
||||
|
|
@ -515,19 +519,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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue