diff --git a/common/http.api.js b/common/http.api.js index f54f97d..30a4823 100644 --- a/common/http.api.js +++ b/common/http.api.js @@ -236,18 +236,21 @@ const install = (Vue, vm) => { // 获取消息接收方用户信息 let GetReceiverUserInfoApi = (params = {}) => vm.$u.get("api/Dialogue/GetReceiverUserInfo", params); - // 置顶一个会话 - let OverheadOneDialogueApi = (params = {}) => - vm.$u.post("api/Dialogue/OverheadOneDialogue", params); - // 将会话消息标记为已读 - let ReadMessageApi = (params = {}) => - vm.$u.post("api/Dialogue/ReadMessage", params); + // 置顶一个会话 + let OverheadOneDialogueApi = (params = {}) => + vm.$u.post("api/Dialogue/OverheadOneDialogue", params); + // 将会话消息标记为已读 + let ReadMessageApi = (params = {}) => + vm.$u.post("api/Dialogue/ReadMessage", params); // 删除会话 let DeleteDialogueApi = (params = {}) => vm.$u.post("api/Dialogue/DeleteDialogue", params); + // 转人工服务 + let TransferToALiveAgentApi = (params = {}) => + vm.$u.post("api/Dialogue/TransferToALiveAgent", params); // 将各个定义的接口名称,统一放进对象挂载到vm.$u.api(因为vm就是this,也即this.$u.api)下 - vm.$u.api = { + vm.$u.api = { UploadSingleImage, getTeacherInfo, getData, @@ -306,16 +309,17 @@ const install = (Vue, vm) => { UpdateUserApi, GetTeacherListApi, GetDialogueListApi, - GetDialogueList_UserApi, - AddDialogueApi, - SendMessage_PrivateApi, - GetChatHistoryDataApi, - GetReceiverUserInfoApi, - OverheadOneDialogueApi, - ReadMessageApi, - DeleteDialogueApi, - }; -}; + GetDialogueList_UserApi, + AddDialogueApi, + SendMessage_PrivateApi, + GetChatHistoryDataApi, + GetReceiverUserInfoApi, + OverheadOneDialogueApi, + ReadMessageApi, + DeleteDialogueApi, + TransferToALiveAgentApi, + }; +}; export default { install, diff --git a/pages/home/index/index.vue b/pages/home/index/index.vue index f7f9ac0..16c9692 100644 --- a/pages/home/index/index.vue +++ b/pages/home/index/index.vue @@ -136,11 +136,77 @@ {{ message.displayTime }} + + + + + 请选择您要咨询的类型,以便系统为您转接对应的客服 + + + + + 招生咨询 + + + + 迎新咨询 + + + + + {{ getTransferCardTip(message) }} + + + @@ -157,7 +223,9 @@ !(m && m.customType === "transferCard") + ); + + this.messageGroups.push(this.createLocalUserTextMessage("转人工")); + const card = this.createTransferCardMessage(); + this.activeTransferCardId = card.id; + this.messageGroups.push(card); + }, + + getTransferCardTip(message) { + if (!message) return ""; + if (this.isTransferSubmitting) return "正在为您转接人工客服,请稍等..."; + if (message.transferTipText) return message.transferTipText; + return ""; + }, + + handleTransferTypeSelect(consultationType) { + const cardId = this.activeTransferCardId; + const findCardIndex = () => { + if (cardId) { + const byId = this.messageGroups.findIndex( + (m) => m && m.id === cardId + ); + if (byId >= 0) return byId; + } + return this.messageGroups.findIndex( + (m) => m && m.customType === "transferCard" + ); + }; + const idx = findCardIndex(); + if (idx < 0) return; + + const current = this.messageGroups[idx] || {}; + if (this.isTransferSubmitting || current.transferStatus === "done") return; + + const next = { + ...current, + transferStatus: "idle", + selectedConsultationType: consultationType, + transferTipText: "", + }; + this.$set(this.messageGroups, idx, next); + this.isTransferSubmitting = true; + + const params = { + consultationType, + message: "转人工", + ip: "", + }; + + if (this.currentDMid) { + params.dialogueManagementId = this.currentDMid; + } + + this.$u.api.TransferToALiveAgentApi(params).then((res) => { + this.isTransferSubmitting = false; + const nextIdx = findCardIndex(); + if (nextIdx < 0) return; + const succeed = res && res.succeed !== false; + const serverTip = + (res && res.data && res.data.message) || (res && res.error) || ""; + if (!succeed) { + const updated = { + ...this.messageGroups[nextIdx], + transferStatus: "idle", + transferTipText: serverTip, + }; + this.$set(this.messageGroups, nextIdx, updated); + return; + } + const updated = { + ...this.messageGroups[nextIdx], + transferStatus: "done", + transferTipText: serverTip, + }; + this.$set(this.messageGroups, nextIdx, updated); + }); + }, + // 修改发送消息的方法 sendMessageFn() { if (!this.messageValue) { @@ -1449,6 +1644,79 @@ export default { text-align: left; } } + + .message-transfer { + width: 100%; + margin-bottom: 40rpx; + display: flex; + justify-content: center; + flex-direction: column; + align-items: center; + } + + .transfer-card { + width: 100%; + background-color: #ffffff; + border-radius: 16rpx; + padding: 40rpx 36rpx; + box-shadow: 0 6rpx 20rpx rgba(0, 0, 0, 0.06); + } + + .transfer-card-title { + padding: 0 16rpx; + font-family: PingFang SC; + font-size: 32rpx; + color: #333333; + line-height: 1.6; + font-weight: 500; + } + + .transfer-card-options { + margin-top: 32rpx; + // padding: 24rpx; + border-radius: 16rpx; + // background-color: #f6f8ff; + display: flex; + gap: 36rpx; + } + + .transfer-option { + flex: 1; + height: 112rpx; + border-radius: 16rpx; + background-color: #f6f8fa; + display: flex; + align-items: center; + justify-content: center; + gap: 16rpx; + } + + .transfer-option.selected { + background-color: #eef0fe; + border-color: #dbe3ff; + } + + .transfer-option.disabled { + opacity: 0.7; + } + + .transfer-option-text { + font-family: PingFang SC; + font-size: 30rpx; + color: #333333; + font-weight: 500; + } + + .transfer-option.selected .transfer-option-text { + color: #4a6cf7; + } + + .transfer-card-status { + margin-top: 24rpx; + text-align: center; + font-size: 28rpx; + color: #999; + } } .chat-footer { diff --git a/store/index.js b/store/index.js index 58cf0d5..154ba01 100644 --- a/store/index.js +++ b/store/index.js @@ -43,6 +43,7 @@ const store = new Vuex.Store({ vuex_token: lifeData.vuex_token ? lifeData.vuex_token : "", // 如果vuex_version无需保存到本地永久存储,无需lifeData.vuex_version方式 vuex_version: "1.0.0", + vuex_aiMessageGroups: [], // 当前聊天窗口消息列表(数组 vuex_msgList: [], // 最近联系人/会话列表