-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
196 lines (185 loc) · 4.51 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="Author" content="ZacharyJoke">
<meta name="Description" content="这里加一句话来描述你的html">
<title>互动聊天机器人</title>
<style type="text/css">
*{margin:0;padding:0;}
body{
background: url("./images/1.jpg") no-repeat top center;
background-size: cover;
font-family: "微软雅黑";
font-size: 12px;
color: #666;
margin: 0 auto;
}
img{
border: none;
border-radius: 50%;
}
.container{
width: 700px;
height: 700px;
background: #f5e2e2;
margin: 80px auto;
border-radius: 15px 15px 0px 0px;
}
/*header start*/
.container .header{
height: 60px;
background:#06F;
border-radius: 15px 15px 0px 0px;
position: relative;
}
.header .logo{
width: 435px;
height: 88px;
position: absolute;
bottom: 0px;
}
.header .hide{
width: 76px;
height: 60px;
float: right;
color: #fff;
font:20px/60px 微软雅黑;
text-align: center;
}
/*header end*/
/*center start*/
.container .center{
height: 500px;
background: #EFF0F2;
border: 1px solid green;
padding: 10px;
overflow: auto;
}
.center .left{
width: 100%;
font-size: 16px;
color:#F60;
}
.center .right{
width: 100%;
font-size: 16px;
color: #00F;
text-align: right;
}
/*center end*/
/*send start*/
.container .send{
height: 120px;
}
.send #sendContent{
width: 700px;
height: 70px;
border: none;
border-top: 1px solid #ddd;
outline: medium;
}
.send .bottom{
height: 50px;
cursor: pointer;
}
.bottom span{
margin-left: 20px;
}
.bottom #button{
width: 100px;
float: right;
border: none;
background: #33F;
margin: 5px;
color: #FFF;
border-radius: 10px;
height: 30px;
outline:none;
cursor: pointer;
}
/*send end*/
</style>
</head>
<body>
<div class="container">
<!--header start-->
<div class="header">
<div class="logo">
<img src="./images/logo.png">
</div>
<div class="hide">X</div>
</div>
<!--header end-->
<!--center start-->
<div class="center">
<!--
<div class="left">
<img src="./images/jimi.png" width="50" height="50">
<span class="msg">
你好,我是Zachary,有什么可以为你效劳的呢?
</span>
</div>
<div class="right">
<span class="msg">
在吗
</span>
<img src="./images/job.jpg" width="50" height="50">
</div>
-->
</div>
<!--center end-->
<!--send start-->
<div class="send">
<input type="text" id="sendContent" placeholder="亲爱的,请描述你的问题~">
<div class="bottom">
<span>满意度调查</span>
<span>教我说话吧</span>
<button id="button">发送</button>
</div>
</div>
<!--send start-->
</div>
<script type="text/javascript" src="js/jquery-1.10.2.min.js">
</script>
<script type="text/javascript">
$(function(){
// alert("这是个聊天机器人");
/*
var htmlr = "<div class='right'><span class='msg'>在吗</span><img src='./images/job.jpg' width='50' height='50'></div>"
*/
var htmll = "<div class='left'><img src='./images/jimi.png' width='50' height='50'><span class='msg'>你好,我是Zachary,有什么可以为你效劳的呢?</span></div>"
$(".center").append(htmll);
});
$("#button").click(function(){
var content = $("#sendContent").val();
var center = $(".center");
// alert(content);
var htmlr = "<div class='right'><span class='msg'>"+content+"</span><img src='./images/job.jpg' width='50' height='50'></div>"
center.append(htmlr);
$("#sendContent").val("");
$.ajax({
type:"get",
url:"http://www.tuling123.com/openapi/api?key=49de46c409c047d19b2ed2285e8775a6&info="+content,
success:function(result){
var obj = result;
var tmp = "<span>"+obj.text+"</span>"
if (obj.url) {
tmp+= "<a href='"+obj.url+"' target='_blank'>"+obj.text+"</a>"
}
var htmll = "<div class='left'><img src='./images/jimi.png' width='50' height='50'><span class='msg'>"+tmp+"</span></div>"
center.append(htmll);
center.scrollTop(center[0].scrollHeight);
}
});
});
window.onkeydown=function(e){
var key = e.keyCode;
//alert(key);
if (key == 13) {
$("#button").click();
}
}
</script>
</body>
</html>