|
@@ -0,0 +1,278 @@
|
|
|
|
|
+<!-- 模板区域 -->
|
|
|
|
|
+<template>
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <!-- 模板内容 -->
|
|
|
|
|
+ <el-drawer title="掌柜在线客服" :visible.sync="drawer" :direction="direction" :show-close="true" :modal="false" :size="440"
|
|
|
|
|
+ :wrapperClosable="false">
|
|
|
|
|
+ <div class="drawer">
|
|
|
|
|
+ <div class="scroll-view" ref="scrollView">
|
|
|
|
|
+ <div id="okk">
|
|
|
|
|
+ <div class="flex f-c j-c" v-for="(item, index) in msgList" :key="index">
|
|
|
|
|
+ <div class="flex f-c " v-if="!item.my">
|
|
|
|
|
+ <div class="flex j-c a-c">
|
|
|
|
|
+ <span class="initTime flex j-c a-c">{{ item.initTime }}</span>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div style="max-width: 350px;" class="flex">
|
|
|
|
|
+ <div class="conversationText flex j-s a-c">
|
|
|
|
|
+ <img v-if="index == 0" src="../../assets/customerService/customerService1.png" alt="">
|
|
|
|
|
+ <span :style="{ marginLeft: index === 0 ? '60px' : '10px' }">{{ item.msg }}</span>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="flex f-c a-end" v-if="item.my">
|
|
|
|
|
+ <div class="conversationText1 flex j-s a-c">
|
|
|
|
|
+ <span>{{ item.msg }}</span>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="flex f-c " v-if="msgLoad" style="width:65px;">
|
|
|
|
|
+ <div class="conversationText1loding flex j-c a-end">
|
|
|
|
|
+ <isLoading />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="outerLayer">
|
|
|
|
|
+ <div class="textInput flex j-s a-c">
|
|
|
|
|
+ <el-input v-model="msg" class="Input" placeholder="请描述您的问题" @focus="Inputfocus" @blur="InputBlur"
|
|
|
|
|
+ @change="InputChange"></el-input>
|
|
|
|
|
+ <img v-if="InputfocusShow" src="../../assets/customerService/Frame1.png" alt="">
|
|
|
|
|
+ <img v-else src="../../assets/customerService/Frame2.png" alt="">
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </el-drawer>
|
|
|
|
|
+ </div>
|
|
|
|
|
+</template>
|
|
|
|
|
+
|
|
|
|
|
+<!-- 行为区域 -->
|
|
|
|
|
+<script>
|
|
|
|
|
+import isLoading from "@/components/customerService/Loading.vue";
|
|
|
|
|
+
|
|
|
|
|
+export default {
|
|
|
|
|
+ components: {
|
|
|
|
|
+ isLoading,
|
|
|
|
|
+ },
|
|
|
|
|
+ // 数据存放区域
|
|
|
|
|
+ data() {
|
|
|
|
|
+ return {
|
|
|
|
|
+ InputfocusShow: false,
|
|
|
|
|
+ drawer: false,
|
|
|
|
|
+ direction: 'rtl',
|
|
|
|
|
+ msgLoad: false,
|
|
|
|
|
+ msg: "",
|
|
|
|
|
+ msgList: [{
|
|
|
|
|
+ my: false,
|
|
|
|
|
+ msg: "您好,掌柜智能客服助理为您服务!",
|
|
|
|
|
+ initTime: this.getFormattedTime(),
|
|
|
|
|
+ },
|
|
|
|
|
+ ],
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ // 生命周期函数
|
|
|
|
|
+ created() {
|
|
|
|
|
+
|
|
|
|
|
+ },
|
|
|
|
|
+ // 方法函数
|
|
|
|
|
+ methods: {
|
|
|
|
|
+ InputChange() {
|
|
|
|
|
+ if (this.msg == "") {
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ this.msgList.push({
|
|
|
|
|
+ "msg": this.msg,
|
|
|
|
|
+ "my": true
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ // 保证消息可见
|
|
|
|
|
+ this.msgGo()
|
|
|
|
|
+ // 回答问题
|
|
|
|
|
+ this.msgKf(this.msg)
|
|
|
|
|
+ // 清除消息
|
|
|
|
|
+ this.msg = ""
|
|
|
|
|
+ },
|
|
|
|
|
+ msgGo() {
|
|
|
|
|
+ // 选择消息体元素
|
|
|
|
|
+ // const scrollView = document.querySelector('.scroll-view'); // 获取第一个类名为 'arr' 的元素
|
|
|
|
|
+ const content = document.getElementById('okk');
|
|
|
|
|
+ if (!content) return; // 确保元素存在
|
|
|
|
|
+ // 获取当前视口高度
|
|
|
|
|
+ // 这里直接获取消息体高度
|
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
|
+ const scrollView = this.$refs.scrollView;
|
|
|
|
|
+ scrollView.scrollTop = scrollView.scrollHeight;
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ msgKf(msg) {
|
|
|
|
|
+ // loading
|
|
|
|
|
+ this.msgLoad = true
|
|
|
|
|
+ // 这里连接服务器获取答案
|
|
|
|
|
+ this.$api.aiSupport.AIsendMessage({
|
|
|
|
|
+ message: msg
|
|
|
|
|
+ }).then((res) => {
|
|
|
|
|
+ if (res.code == 200) {
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ // 取消loading
|
|
|
|
|
+ this.msgLoad = false
|
|
|
|
|
+ this.msgList.push({
|
|
|
|
|
+ my: false,
|
|
|
|
|
+ msg: res.data.message,
|
|
|
|
|
+ initTime: res.data.date
|
|
|
|
|
+ })
|
|
|
|
|
+ this.msgGo()
|
|
|
|
|
+ }, 1000)
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ Inputfocus() {
|
|
|
|
|
+ this.InputfocusShow = true;
|
|
|
|
|
+ },
|
|
|
|
|
+ InputBlur() {
|
|
|
|
|
+ this.InputfocusShow = false;
|
|
|
|
|
+
|
|
|
|
|
+ },
|
|
|
|
|
+ getFormattedTime() {
|
|
|
|
|
+ const date = new Date();
|
|
|
|
|
+ const year = date.getFullYear();
|
|
|
|
|
+ const month = (date.getMonth() + 1).toString().padStart(2, '0');
|
|
|
|
|
+ const day = date.getDate().toString().padStart(2, '0');
|
|
|
|
|
+ const hours = date.getHours().toString().padStart(2, '0');
|
|
|
|
|
+ const minutes = date.getMinutes().toString().padStart(2, '0');
|
|
|
|
|
+
|
|
|
|
|
+ return `${year}-${month}-${day} ${hours}:${minutes}`;
|
|
|
|
|
+ },
|
|
|
|
|
+ setBackupVisible: function (backupVisible) {
|
|
|
|
|
+ this.drawer = backupVisible
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ // 计算属性
|
|
|
|
|
+ computed: {
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+</script>
|
|
|
|
|
+<!-- 样式区域 -->
|
|
|
|
|
+<style lang='scss' scoped>
|
|
|
|
|
+/deep/ {
|
|
|
|
|
+ .el-drawer {
|
|
|
|
|
+ height: 600px;
|
|
|
|
|
+ border-radius: 8px;
|
|
|
|
|
+ position: fixed;
|
|
|
|
|
+ bottom: 8%;
|
|
|
|
|
+ right: 5%;
|
|
|
|
|
+ top: initial;
|
|
|
|
|
+ background: linear-gradient(90deg, #FFFFFF 0%, #EDF3FE 100%);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .el-drawer__header {
|
|
|
|
|
+ color: #333;
|
|
|
|
|
+ font-weight: bold;
|
|
|
|
|
+ font-size: 16px;
|
|
|
|
|
+ margin-bottom: 16px;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .el-drawer__close-btn {
|
|
|
|
|
+ color: #979AA0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .el-input__inner {
|
|
|
|
|
+ height: 48px;
|
|
|
|
|
+ border: none;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+.drawer {
|
|
|
|
|
+
|
|
|
|
|
+ .scroll-view {
|
|
|
|
|
+ padding: 20px;
|
|
|
|
|
+ overflow-y: auto;
|
|
|
|
|
+ /* 允许垂直滚动 */
|
|
|
|
|
+ height: calc(600px - 113px);
|
|
|
|
|
+ box-sizing: border-box;
|
|
|
|
|
+ padding-bottom: 50px;
|
|
|
|
|
+ /* 适应消息区和底部导航栏 */
|
|
|
|
|
+ cursor: pointer;
|
|
|
|
|
+
|
|
|
|
|
+ /* 防止内容溢出 */
|
|
|
|
|
+ .initTime {
|
|
|
|
|
+ background: rgba(207, 207, 207, 0.2);
|
|
|
|
|
+ border-radius: 20px 20px 20px 20px;
|
|
|
|
|
+ padding: 4px 16px;
|
|
|
|
|
+ font-size: 12px;
|
|
|
|
|
+ color: rgba(0, 0, 0, 0.85);
|
|
|
|
|
+ margin-bottom: 15px;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .conversationText {
|
|
|
|
|
+ background: #FFFFFF;
|
|
|
|
|
+ box-shadow: 0px 4px 10px 0px #DAE3F4;
|
|
|
|
|
+ border-radius: 0px 4px 4px 4px;
|
|
|
|
|
+ margin-bottom: 18px;
|
|
|
|
|
+ position: relative;
|
|
|
|
|
+ padding: 8px;
|
|
|
|
|
+
|
|
|
|
|
+ span {
|
|
|
|
|
+
|
|
|
|
|
+ font-size: 14px;
|
|
|
|
|
+ color: #000000;
|
|
|
|
|
+ word-break: break-all;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ img {
|
|
|
|
|
+ width: 58px;
|
|
|
|
|
+ height: 58px;
|
|
|
|
|
+ position: absolute;
|
|
|
|
|
+ bottom: 0;
|
|
|
|
|
+ left: 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .conversationText1 {
|
|
|
|
|
+ background: #0052FF;
|
|
|
|
|
+ box-shadow: 0px 4px 10px 0px #DAE3F4;
|
|
|
|
|
+ border-radius: 4px;
|
|
|
|
|
+ padding: 8px;
|
|
|
|
|
+ margin-bottom: 18px;
|
|
|
|
|
+
|
|
|
|
|
+ span {
|
|
|
|
|
+ color: #FFFFFF;
|
|
|
|
|
+ font-size: 14px;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .conversationText1loding {
|
|
|
|
|
+ box-shadow: 0px 4px 10px 0px #DAE3F4;
|
|
|
|
|
+ border-radius: 4px;
|
|
|
|
|
+ height: 36px;
|
|
|
|
|
+ padding: 4px 8px;
|
|
|
|
|
+ box-sizing: border-box;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .outerLayer {
|
|
|
|
|
+ width: 100%;
|
|
|
|
|
+ height: auto;
|
|
|
|
|
+ position: absolute;
|
|
|
|
|
+ bottom: 0;
|
|
|
|
|
+ left: 0;
|
|
|
|
|
+ background: linear-gradient(90deg, #FFFFFF 0%, #EDF3FE 100%);
|
|
|
|
|
+ padding: 10px 20px;
|
|
|
|
|
+ box-sizing: border-box;
|
|
|
|
|
+
|
|
|
|
|
+ .textInput {
|
|
|
|
|
+ width: 100%;
|
|
|
|
|
+ height: 48px;
|
|
|
|
|
+ background: #FFFFFF;
|
|
|
|
|
+ box-shadow: 6px 6px 12px 0px rgba(83, 98, 153, 0.08);
|
|
|
|
|
+ border-radius: 4px 4px 4px 4px;
|
|
|
|
|
+
|
|
|
|
|
+ img {
|
|
|
|
|
+ width: 28px;
|
|
|
|
|
+ height: 28px;
|
|
|
|
|
+ margin-right: 20px;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+</style>
|