|
@@ -1,25 +1,19 @@
|
|
<template>
|
|
<template>
|
|
- <div class="chatGptChat" ref="chatEle">
|
|
|
|
- <!-- <div v-for="(item, index) in chat" :key="index">
|
|
|
|
- <div v-if="item.text && item.type === 'robot'" class="chat">
|
|
|
|
- <van-image width="35px" height="35px" fit="contain" :src="robot" />
|
|
|
|
- <div class="cahtText" v-html="item.text">
|
|
|
|
- </div>
|
|
|
|
- </div>
|
|
|
|
- <div v-if="item.text && item.type === 'user'" class="chat chatRight">
|
|
|
|
- <div class="cahtText" v-text="item.text"></div>
|
|
|
|
- <van-image width="35px" height="35px" fit="contain" :src="user" />
|
|
|
|
- </div>
|
|
|
|
- </div> -->
|
|
|
|
|
|
+ <div :class="{ chatGptChat: true, ortherP: !userData.UserId }" ref="chatEle">
|
|
<div v-for="(item, index) in chat" :key="index">
|
|
<div v-for="(item, index) in chat" :key="index">
|
|
<div v-if="item.text && item.type === 'robot'" class="chat">
|
|
<div v-if="item.text && item.type === 'robot'" class="chat">
|
|
<van-image width="35px" height="35px" fit="contain" :src="robot" />
|
|
<van-image width="35px" height="35px" fit="contain" :src="robot" />
|
|
<div class="cahtText">
|
|
<div class="cahtText">
|
|
- <textShow :text="item.text" />
|
|
|
|
|
|
+ <textShow :text="item.text" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div v-if="item.text && item.type === 'user'" class="chat chatRight">
|
|
<div v-if="item.text && item.type === 'user'" class="chat chatRight">
|
|
- <van-image width="35px" height="35px" fit="contain" :src="userData.UserAvatar || user" />
|
|
|
|
|
|
+ <van-image
|
|
|
|
+ width="35px"
|
|
|
|
+ height="35px"
|
|
|
|
+ fit="contain"
|
|
|
|
+ :src="userData.UserAvatar || user"
|
|
|
|
+ />
|
|
<div class="cahtText" v-text="item.text"></div>
|
|
<div class="cahtText" v-text="item.text"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@@ -47,11 +41,14 @@
|
|
</van-button>
|
|
</van-button>
|
|
</template>
|
|
</template>
|
|
</van-field>
|
|
</van-field>
|
|
|
|
+ <shanshipin v-if="!userData.UserId" />
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
<script setup>
|
|
<script setup>
|
|
|
|
+import shanshipin from '../../components/shanshipin.vue';
|
|
import robot from '../../assets/img/chat/robot_2.png';
|
|
import robot from '../../assets/img/chat/robot_2.png';
|
|
import user from '../../assets/img/chat/user.png';
|
|
import user from '../../assets/img/chat/user.png';
|
|
|
|
+import { showToast } from 'vant';
|
|
import { ref, nextTick } from 'vue';
|
|
import { ref, nextTick } from 'vue';
|
|
|
|
|
|
import textShow from './textShow.vue';
|
|
import textShow from './textShow.vue';
|
|
@@ -71,12 +68,25 @@ const chat = ref([]);
|
|
const load = ref(false);
|
|
const load = ref(false);
|
|
const chatEle = ref(null);
|
|
const chatEle = ref(null);
|
|
const inputText = ref('');
|
|
const inputText = ref('');
|
|
|
|
+
|
|
|
|
+if (!userData.value.UserId) {
|
|
|
|
+ chat.value.push(
|
|
|
|
+ ...[
|
|
|
|
+ {
|
|
|
|
+ text: '闪视频是什么?',
|
|
|
|
+ type: 'user',
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ text: '“闪视频”是全新打造的视听新媒体平台,专注于以视频形式传播陕西文化、讲好陕西故事,汇聚陕西省内党政机关、主流媒体、企事业单位内容资源,深度聚焦移动互联网时代的陕西省域文化建设,为全体关注陕西、热爱陕西的移动互联网用户提供了解陕西、展示自我的窗口和舞台,内容主要以视频内容为主。\n客服联系方式:\n联系电话:18502918086\n邮箱:service_ssp@163.com',
|
|
|
|
+ type: 'robot',
|
|
|
|
+ },
|
|
|
|
+ ]
|
|
|
|
+ );
|
|
|
|
+}
|
|
|
|
+
|
|
function saveText() {
|
|
function saveText() {
|
|
|
|
+ if (!userData.value.UserId) return showToast('请下载闪视频进行完整体验');
|
|
if (!inputText.value) return;
|
|
if (!inputText.value) return;
|
|
- chat.value.push({
|
|
|
|
- text: inputText.value,
|
|
|
|
- type: 'user',
|
|
|
|
- });
|
|
|
|
load.value = true;
|
|
load.value = true;
|
|
nextTick(() => {
|
|
nextTick(() => {
|
|
// 滚动到最底层
|
|
// 滚动到最底层
|
|
@@ -84,7 +94,6 @@ function saveText() {
|
|
chatEle.value.scrollTop = chatEle.value.scrollHeight;
|
|
chatEle.value.scrollTop = chatEle.value.scrollHeight;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
- inputText.value = '';
|
|
|
|
let prompt = [];
|
|
let prompt = [];
|
|
const startIndex = chat.value.length > 10 ? chat.value.length - 10 : 0;
|
|
const startIndex = chat.value.length > 10 ? chat.value.length - 10 : 0;
|
|
for (let i = startIndex; i < chat.value.length; i++) {
|
|
for (let i = startIndex; i < chat.value.length; i++) {
|
|
@@ -96,10 +105,14 @@ function saveText() {
|
|
userName: userData.value.UserName || '',
|
|
userName: userData.value.UserName || '',
|
|
})
|
|
})
|
|
.then(r => {
|
|
.then(r => {
|
|
- console.log(r);
|
|
|
|
load.value = false;
|
|
load.value = false;
|
|
chat.value.push({
|
|
chat.value.push({
|
|
- text: (r.result || ''),
|
|
|
|
|
|
+ text: inputText.value,
|
|
|
|
+ type: 'user',
|
|
|
|
+ });
|
|
|
|
+ inputText.value = '';
|
|
|
|
+ chat.value.push({
|
|
|
|
+ text: r.result || '',
|
|
type: 'robot',
|
|
type: 'robot',
|
|
});
|
|
});
|
|
nextTick(() => {
|
|
nextTick(() => {
|
|
@@ -122,7 +135,9 @@ function saveText() {
|
|
height: 100vh;
|
|
height: 100vh;
|
|
position: relative;
|
|
position: relative;
|
|
padding-bottom: 55px;
|
|
padding-bottom: 55px;
|
|
- background-color: #ffffff;
|
|
|
|
|
|
+ background: url('../../assets/img/chat/bg.png') no-repeat;
|
|
|
|
+ background-size: 100% 10%;
|
|
|
|
+ background-position: center center;
|
|
overflow-y: auto;
|
|
overflow-y: auto;
|
|
.van-field {
|
|
.van-field {
|
|
background-color: #eee;
|
|
background-color: #eee;
|
|
@@ -139,7 +154,7 @@ function saveText() {
|
|
.chat {
|
|
.chat {
|
|
padding: 1em 1.5em;
|
|
padding: 1em 1.5em;
|
|
width: 100%;
|
|
width: 100%;
|
|
- background-color: #f4f4f6;
|
|
|
|
|
|
+ background-color: #f4f4f680;
|
|
.cahtText {
|
|
.cahtText {
|
|
text-align: left;
|
|
text-align: left;
|
|
line-height: 1.5em;
|
|
line-height: 1.5em;
|
|
@@ -160,7 +175,7 @@ function saveText() {
|
|
}
|
|
}
|
|
|
|
|
|
.chatRight {
|
|
.chatRight {
|
|
- background: #ffffff;
|
|
|
|
|
|
+ background: #ffffff80;
|
|
}
|
|
}
|
|
|
|
|
|
.loading {
|
|
.loading {
|
|
@@ -185,6 +200,14 @@ function saveText() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+.ortherP {
|
|
|
|
+ padding-top: 70px;
|
|
|
|
+ .shanshipin {
|
|
|
|
+ top: 0;
|
|
|
|
+ background-color: #eee;
|
|
|
|
+ }
|
|
|
|
+}
|
|
@keyframes load {
|
|
@keyframes load {
|
|
from {
|
|
from {
|
|
background-color: #aaa;
|
|
background-color: #aaa;
|