-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
executable file
·239 lines (231 loc) · 9.77 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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>主页-闲言</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="res/layui/css/layui.css">
<link rel="stylesheet" href="res/static/css/mian.css">
</head>
<body class="lay-blog">
<div class="header">
<div class="header-wrap">
<h1 class="logo pull-left">
<a href="index.html">
<img src="res/static/images/logo.png" alt="" class="logo-img">
<img src="res/static/images/logo-text.png" alt="" class="logo-text">
</a>
</h1>
<form class="layui-form blog-seach pull-left" action="">
<div class="layui-form-item blog-sewrap">
<div class="layui-input-block blog-sebox">
<i class="layui-icon layui-icon-search"></i>
<input type="text" name="title" lay-verify="title" autocomplete="off" class="layui-input" placeholder="输入昵称或邮箱账号关注好友">
<div class="search-output">
<ul class="search-follow">
</ul>
</div>
</div>
</div>
</form>
<div class="blog-nav pull-right">
<ul class="layui-nav pull-left">
<li class="layui-nav-item layui-this"><a href="index.html">首页</a></li>
<li class="layui-nav-item"><a href="message.html">留言</a></li>
<li class="layui-nav-item"><a href="about.html">关于</a></li>
</ul>
<a href="#" class="personal pull-left layui-nav-item exit" style="font-size: 16px;">
<i class="layui-icon layui-icon-username"></i>
退出
</a>
</div>
<div class="mobile-nav pull-right" id="mobile-nav">
<a href="javascript:;">
<i class="layui-icon layui-icon-more"></i>
</a>
</div>
</div>
<ul class="pop-nav" id="pop-nav">
<li><a href="index.html">首页</a></li>
<li><a href="message.html">留言</a></li>
<li><a href="about.html">关于</a></li>
</ul>
</div>
<div class="bg">
<div class="bg-wrap">
<div class="self-intro">
<span class="head-pic"></span>
<span class="nick"></span>
</div>
</div>
</div>
<div class="container-wrap indexTop">
<!--屏幕正中动态列表-->
<div class="index-container container">
<div class="leftBar">
<div class="data-statics">
<div class="static-item">
<span></span>
<div>动态</div>
</div>
<div class="static-item">
<span></span>
<div>留言</div>
</div>
</div>
<div class="personal-intro">
<span class="intro-head">个人档</span>
<span class="intro-item"><i class="layui-icon layui-icon-component"></i></span>
<span class="intro-item"><i class="layui-icon layui-icon-nan"></i></span>
</div>
<div class="friendList">
<span class="intro-head">我的关注</span>
<ul class="friend-items">
<li>
</li>
</ul>
</div>
</div>
<div class="contar-wrap index-wrap">
<div class="contar-wrap fixed">
<form class="layui-form" action="">
<div class="layui-form-item layui-form-text">
<textarea class="layui-textarea" id="LAY-msg-content"></textarea>
</div>
</form>
<div class="item-list">
<span class="suc-upload " id="suc_upload"></span>
<span class="image-path " id="imagepath"></span>
<button class="btn" id="submit-btn">发布动态</button>
<span class="fileUpload">
<input type="file" id="upload" accept="image/jpg, image/png, image/jpeg, image/gif">
<button class="upload btn">上传图片</button>
</span>
</div>
</div>
</div>
</div>
</div>
<div class="footer">
<p>
<span>© 2019</span>
<span><a href="http://www.layui.com" target="_blank">浙江大学软件学院</a></span>
<span>S403</span>
</p>
<p><span>人生就是一场修行,祝君猪事顺利</span></p>
</div>
<script src="res/jquery/Myfunc.js"></script>
<script src="res/layui/layui.js"></script>
<script>
layui.config({
base: 'res/static/js/'
}).use('blog');
</script>
<script src="res/jquery/jquery-1.12.4.js"></script>
<script>
$(function () {
// 获取当前用户的个人信息以及好友动态
let userAccount = JSON.parse(localStorage.getItem('UserAccount'));
let pageOne;
$.ajax({
url:'http://47.100.226.85:8080/find-friends/look/homepage',
type:'post',
contentType:'application/json',
xhrFields:{
withCredentials:true
},
data:JSON.stringify({'owner':userAccount}),
success:function (data) {
console.log(data);
pageOne = data.lastPage;
// 初始化用户信息
$('.head-pic').css({
background:`url("${data.personal.headpic}") center center`,
backgroundSize: "100%"
});
$('.nick').text(data.personal.nickname);
$('.intro-item').eq(0).html('<i class="layui-icon layui-icon-component"></i> ' + data.personal.motto);
$('.intro-item').eq(1).html('<i class="layui-icon layui-icon-nan"></i> ' + data.personal.sex + " " + data.personal.age + '岁 ' + data.personal.xinzuo);
// 初始化首页统计信息
$('.static-item').eq(0).children('span').text(data.statics.dongtai);
$('.static-item').eq(1).children('span').text(data.statics.liuyan);
// 初始化好友列表
let content = '';
for (let i = 0; i < data.friends.length; i++) {
content = content + `<li class="friendBox">
<span class="item-head" style="background:url('${data.friends[i].headpic}') center center;background-size: 100%"></span>
<span>${data.friends[i].nickname}</span>
<span class="friendEmail" style="display: none" >${data.friends[i].email}</span>
<div class="cancelFollow"><div class="canclebtn"></div></div>
</li>`
}
$('.friend-items').html(content);
//展示好友动态
$(showMoment(data.dongtailist)).insertAfter(".fixed");
}
});
$('.friend-items').delegate('li','click',function (event) {
let friend = $(this).children('.friendEmail').text();
let box= $(this).children('.friendEmail').parents('.friendBox');
if(event.target.className=='canclebtn'){
if (confirm('确认取消关注?')){
$.ajax({
url:'http://47.100.226.85:8080/find-friends/user/makefriends',
xhrFields:{
withCredentials:true
},
data:JSON.stringify({
email:friend,
isDelete:'true'
}),
type:'post',
contentType:'application/json',
success:function () {
console.log($(this).parents('.friendBox'));
box.remove();
},
})
}
}
else{
localStorage.setItem("friendAccount", JSON.stringify(friend));
var newWeb=window.open('_blank');
newWeb.location='friendIndex.html';
}
});
// 动态列表懒加载
let flag = true;//是否在加载过程中
let page =1;
$(window).on('scroll', function () {
if ($(window).height() + $(window).scrollTop() + 80 >= $(document).height() && flag && pageOne) {
// 提示加载中
$(".index-wrap").append('<div class="item-btn loading" ><span>加载中... </span><span class="loading-pic"></span></div>');
flag = false; //加载中不允许插入加载提示
page++;
// 获取下一页动态
$.ajax({
url:'http://47.100.226.85:8080/find-friends/moment/refresh',
xhrFields:{
withCredentials:true
},
data:JSON.stringify({
ownerAccount: userAccount,
pageNumber:page,
isPublish:'false'
}), // 参数是页码
type:'post',
contentType:'application/json',
success:function (data) {
console.log(data);
$(".index-wrap").append(showMoment(data.moments)); // 在动态列表内插入新的动态
$('.item-btn').remove(); // 移除加载提示
flag = true;
pageOne = data.lastPage;
},
});
}
});
});
</script>
</body>
</html>