From 8e660fd6570fdb90e65c06cdcd3e3a23049bcc89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=99=E8=BF=90=E6=A8=A1?= <1724894114@qq.com> Date: Tue, 12 Nov 2024 19:07:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AE=A2=E6=9C=8D=E6=B6=88?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/scCustomer/index.vue | 121 +++++++++++++++++++--------- src/directives/draggable.js | 39 +++++++++ src/scui.js | 2 + src/views/maintenance/index.vue | 8 ++ src/views/service/faq.vue | 31 ++++++- 5 files changed, 161 insertions(+), 40 deletions(-) create mode 100644 src/directives/draggable.js diff --git a/src/components/scCustomer/index.vue b/src/components/scCustomer/index.vue index 52de5f2..d89bb75 100644 --- a/src/components/scCustomer/index.vue +++ b/src/components/scCustomer/index.vue @@ -7,26 +7,30 @@
智能客服
-
- -
-
{{item.label}}
-
-
-
-
- - - -
-
-
{{item.from_user && item.from_user.name?item.from_user.name:'匿名'}}
-
{{item.to_message}}
-
-
- - - +
+ +
+
+
{{item.label}}
+
+
+
+
+ + + +
+
+
{{item.from_user && item.from_user.name?item.from_user.name:'匿名'}}
+
+
+
+
+
+ + + +
@@ -53,7 +57,6 @@ export default { type:"", to_user_id:"", to_message:"", - }, tagList:[], msgList:[], @@ -79,22 +82,32 @@ export default { switch(res.data.type) { case 36: this.msgList = res.data.rows; + this.scrollDown(); break; case 37: this.params.to_user_id = res.data.user.uid; + this.msgList = [{ + to_user_id:this.user_id, + from_user:{ + name:res.data.user.user_info.name, + avatar:res.data.user.user_info.avatar + }, + to_message:res.data.to_message + }] break; default: break; } } }, - openCustomer(){ this.customerShow = !this.customerShow; if(this.customerShow){ this.getAssign(); this.getRecordList(); this.customerType(); + // 控制条控制在底部 + this.scrollDown(); } }, closeCustomer(){ @@ -107,14 +120,6 @@ export default { async getRecordList() { await this.$API.customer.list.post(); }, - async sendCustomer() { - if(this.params.to_message =="") return - const res = await this.$API.customer.send.post(this.params); - if(res.code == 200){ - this.tagList.push({}); - this.params.to_message = ""; - } - }, async customerType() { const res = await this.$API.customer.typeList.post(); if (res.code == 200) { @@ -123,20 +128,57 @@ export default { }, typeActive(item){ this.params.type = item.value; - } + }, + async sendCustomer() { + if(this.params.to_message =="") return + const res = await this.$API.customer.send.post(this.params); + if(res.code == 200){ + const userInfo = this.$TOOL.data.get("USER_INFO"); + this.msgList.push({ + to_user_id:-1, + from_user:{ + name:userInfo.name, + avatar:userInfo.avatar + }, + to_message:this.params.to_message + }); + this.params.to_message = ""; + this.scrollDown(); + } + }, + + scroll({scrollTop}){ + if(scrollTop>10){ + this.$refs.tagList.style.position = "absolute"; + this.$refs.tagList.style.background = "#fff"; + }else{ + this.$refs.tagList.style.position = "relative"; + this.$refs.tagList.style.background = ""; + } + }, + scrollDown() { + this.$nextTick(() => { + const wrap = this.$refs.scrollbar; + if(wrap){ + const e = wrap.$el.querySelector('.el-scrollbar__wrap') + e.scrollTop = e.scrollHeight; + } + }) + }, } } diff --git a/src/views/service/faq.vue b/src/views/service/faq.vue index 91f378f..de021e0 100644 --- a/src/views/service/faq.vue +++ b/src/views/service/faq.vue @@ -26,7 +26,7 @@
龙隆
- +
@@ -36,7 +36,9 @@
{{item.from_user && item.from_user.name?item.from_user.name:'匿名'}}
-
{{item.to_message}}
+
+
+
@@ -102,7 +104,7 @@ export default { contactsList:[ {name:"龙隆",msg:"嘻嘻"}, {name:"骁骁",msg:"测试信息"}, - {name:"",msg:"怎么能快速挣够一百万"}, + {name:"管理员",msg:"怎么能快速挣够一百万"}, {name:"",msg:"真机运行不需要检查更新,真机运行时appid固定为'HBuilder'"}, {name:"",msg:"真机运行不需要检查更新,真机运行时appid固定为'HBuilder'"}, ], @@ -129,6 +131,7 @@ export default { switch(res.data.type) { case 36: this.msgList = res.data.rows; + this.scrollDown(); break; case 37: this.params.to_user_id = res.data.user.uid; @@ -143,9 +146,29 @@ export default { if(this.params.to_message =="") return const res = await this.$API.customer.send.post(this.params); if(res.code == 200){ + const userInfo = this.$TOOL.data.get("USER_INFO"); + this.msgList.push({ + to_user_id:userInfo.id, + from_user:{ + name:userInfo.name, + avatar:userInfo.avatar + }, + to_message:this.params.to_message + }); this.params.to_message = ""; + this.scrollDown(); } }, + + scrollDown() { + this.$nextTick(() => { + const wrap = this.$refs.scrollbar; + if(wrap){ + const e = wrap.$el.querySelector('.el-scrollbar__wrap') + e.scrollTop = e.scrollHeight; + } + }) + }, } } @@ -247,7 +270,7 @@ export default { } .msgText{ .msgTitle{ - padding: 6px 0; + padding:0 0 8px 0; color: #555; } .textCom{