166 lines
5.3 KiB
HTML
166 lines
5.3 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport"
|
||
content="width=device-width, initial-scale=1,minimum-scale=1, maximum-scale=1,user-scalable=no">
|
||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||
<meta http-equiv="Access-Control-Allow-Origin" content="*">
|
||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||
<meta name="format-detection" content="telephone=no, email=no">
|
||
<meta name="full-screen" content="true">
|
||
<meta name="screen-orientation" content="portrait">
|
||
<meta name="x5-fullscreen" content="true">
|
||
<meta name="360-fullscreen" content="true">
|
||
<title>deepseek测试页面</title>
|
||
<script src="/x_admin/js/jq.js"></script>
|
||
<style>
|
||
*{
|
||
padding: 0 0;
|
||
margin: 0 0;
|
||
}
|
||
.big_box{
|
||
width: 100vw;
|
||
height: 100vh;
|
||
position: absolute;
|
||
top: 0;
|
||
left: 0;
|
||
display: flex;
|
||
flex-direction: column;
|
||
}
|
||
.chat_box {
|
||
flex: 1;
|
||
/* overflow-y: auto; */
|
||
overflow-y: scroll;
|
||
padding: 10px;
|
||
border-bottom: 1px solid #ccc;
|
||
}
|
||
.input_box {
|
||
display: flex;
|
||
padding: 10px;
|
||
border-top: 1px solid #ccc;
|
||
}
|
||
.input_box input {
|
||
flex: 1;
|
||
padding: 10px;
|
||
border: 1px solid #ccc;
|
||
border-radius: 5px;
|
||
}
|
||
.input_box button {
|
||
margin-left: 10px;
|
||
padding: 10px 20px;
|
||
border: none;
|
||
background-color: #007bff;
|
||
color: white;
|
||
border-radius: 5px;
|
||
cursor: pointer;
|
||
}
|
||
.message {
|
||
margin: 10px 0;
|
||
display: flex;
|
||
}
|
||
.message.user {
|
||
justify-content: flex-end;
|
||
}
|
||
.message.bot {
|
||
justify-content: flex-start;
|
||
}
|
||
.message .content {
|
||
max-width: 70%;
|
||
padding: 10px;
|
||
border-radius: 5px;
|
||
background-color: #f1f0f0;
|
||
}
|
||
.message.user .content {
|
||
background-color: #dcf8c6;
|
||
}
|
||
.fugai{
|
||
display: none;
|
||
position: absolute;
|
||
width: 100vw;
|
||
height: 100vh;
|
||
text-align: center;
|
||
line-height: 100vh;
|
||
color: white;
|
||
font-size: 10vw;
|
||
font-weight: bold;
|
||
background-color: rgba(0, 0, 0, 0.5);
|
||
}
|
||
</style>
|
||
</head>
|
||
|
||
<body id="box_k">
|
||
<div class="big_box">
|
||
<div class="chat_box" id="chat_box">
|
||
<!-- 对话内容将在这里展示 -->
|
||
</div>
|
||
<div class="input_box">
|
||
<input type="text" id="message_input" placeholder="输入消息..." value="我是一个河南的25岁女性,身高64.52cm,体重68.00kg,请根据我的这个信息,从睡眠、饮食、运动三个方向给我一些健康建议。">
|
||
<button id="send_button">发送</button>
|
||
</div>
|
||
<div class='fugai'>思考中请稍等</div>
|
||
</div>
|
||
|
||
</body>
|
||
</html>
|
||
|
||
<script>
|
||
$(document).ready(function() {
|
||
var pd = true;
|
||
$('#send_button').click(function() {
|
||
$('.fugai').show()
|
||
if(pd == false){
|
||
return;
|
||
}
|
||
pd = false;
|
||
var message = $('#message_input').val();
|
||
if (message.trim() === '') {
|
||
return;
|
||
}
|
||
|
||
// 显示用户消息
|
||
$('#chat_box').append('<div class="message user"><div class="content">' + message + '</div></div>');
|
||
// document.getElementById('scroll_button').addEventListener('click', function() {
|
||
// var chatBox = document.getElementById('chat_box');
|
||
// chatBox.scrollTop = chatBox.scrollHeight;
|
||
// });
|
||
|
||
// 清空输入框
|
||
$('#message_input').val('');
|
||
|
||
$.ajax({
|
||
url:"https://tc.pcxbc.com/ai/send_msg_deepseek", //请求的url地址
|
||
dataType:"json", //返回格式为json
|
||
async:true,//请求是否异步,默认为异步,这也是ajax重要特性
|
||
data:{"msg":message}, //参数值
|
||
type:"POST", //请求方式
|
||
success:function(req){
|
||
$('.fugai').hide()
|
||
pd = true;
|
||
//请求成功时处理
|
||
if(req.code == 0){
|
||
$('#chat_box').append('<div class="message bot"><div class="content">' + req.msg + '</div></div>');
|
||
}
|
||
},
|
||
error:function(){
|
||
//请求出错处理
|
||
}});
|
||
// 模拟对方回复
|
||
// setTimeout(function() {
|
||
// var reply = '对方回复: ' + message;
|
||
// $('#chat_box').append('<div class="message bot"><div class="content">' + reply + '</div></div>');
|
||
// }, 1000);
|
||
});
|
||
|
||
// // 按下回车键发送消息
|
||
// $('#message_input').keypress(function(e) {
|
||
// console.log(e)
|
||
// // if (e.which == 13) {
|
||
// // $('#send_button').click();
|
||
// // }
|
||
// });
|
||
});
|
||
</script>
|
||
|