-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser_info.html
169 lines (159 loc) · 7.37 KB
/
user_info.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>user_info</title>
<link rel="stylesheet" type="text/css" href="css/reset.css">
<link rel="stylesheet" type="text/css" href="css/user_info.css">
<link rel="stylesheet" type="text/css" href="font-awesome-4.7.0/css/font-awesome.min.css">
<script type="text/JavaScript" src="js/jquery3-3-1.js"></script>
<script type="text/JavaScript" src="js/jquery-form.js"></script>
</head>
<body>
<header>
<nav>
<div class="pull-left">
<ul>
<li class="logo"><a href="#">MyBlog</a></li>
</ul>
</div>
<div class="pull-right">
<ul>
<li>
<div class="search-bar">
<input type="text" style="float: left" class="input-search" placeholder="搜博主/文章">
<a href="#" style="float: right" class="btn-search"><i id="search_button" class="fa fa-search" aria-hidden="true"></i></a>
</div>
</li>
<li class="login-center">
<a href="#" id="navAvatar">
<!--<img src="img/login.png">-->
</a>
<div class="user-control">
<!--<div>-->
<!--<a href="#" target="_blank">我的博客</a>-->
<!--</div>-->
<!--<div>-->
<!--<a href="#" target="_blank">关注/粉丝</a>-->
<!--</div>-->
<!--<div>-->
<!--<a href="#" target="_blank">修改资料</a>-->
<!--</div>-->
<!--<div>-->
<!--<a href="#" target="_blank">退出</a>-->
<!--</div>-->
</div>
</li>
</ul>
</div>
</nav>
</header>
<div class="banner">
<div class="title-box">
<h6 class="title-blog">Elenore的博客</h6>
</div>
</div>
<div class="container">
<div class="filter-box">
<h3>个人信息</h3>
</div>
<div class="user-avatar">
<img src="img/user-avatar.jpg">
</div>
<div class="user-info">
<ul id="userInfoUl">
<!--<li><a href="#" class="edit-info"><i class="fa fa-pencil-square-o" aria-hidden="true"></i> 修改个人信息</a></li>-->
<li><span class="user-name">用户名:Elenore</span></li>
<li><span class="phone-num">手机号:18923912345</span></li>
<li><span class="e-mail">E-mail:[email protected]</span></li>
<li><span class="github">GitHub:https://github.com/Elenore1997</span></li>
<li><span class="school">学校:广东外语外贸大学</span></li>
</ul>
</div>
<div class="data-info">
<dl class="focus-num">
<dt><a href="#">关注</a></dt>
<dd>
<span class="count">2</span>
</dd>
</dl>
<dl class="fans-num">
<dt><a href="#">粉丝</a></dt>
<dd>
<span class="count">4</span>
</dd>
</dl>
</div>
</div>
<script src="js/set_nav_banner.js"></script>
<script>
function getUrlParam(name){
//正则表达式过滤
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
//正则规则
// console.log("reg==="+reg);
//search:返回URL的查询部分
// console.log("location.search==="+location.search);
//substr(1):从字符串第一个位置中提取一些字符
// console.log("location.search.substr(1)==="+location.search.substr(1));
// match():在字符串内检索与正则表达式匹配的指定值,返回一个数组给r
// console.log("window.location.search.substr(1).match(reg)==="+window.location.search.substr(1).match(reg));
var r = window.location.search.substr(1).match(reg);
//获取r数组中下标为2的值;(下标从0开始),用decodeURI()进行解码
// console.log("decodeURI(r[2])==="+decodeURI(r[2]));
// console.log("-----------------分隔符------------------------");
if (r != null) return decodeURI(r[2]); return null;
}
var username = getUrlParam('username'); // 访问博客的用户名
// title 和 banner
// title
$("title").html(username + "的博客 -myblog");
// banner
var blogTitle = document.getElementsByClassName('title-box')[0];
blogTitle.innerHTML = "<h6 class=\"title-blog\">" + username + "的博客</h6>";
jQuery(document).ready(function () {
$.ajax({
type: "POST",
url: "php/get_main.php",
data: {
do: "get_info",
username: username
},
dataType: "json",
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert('连接错误:' + textStatus + errorThrown);
}, //如果请求出错,弹出错误提示
success: function (data) {
// 关注和粉丝
// console.log($(".count")[0].innerHTML);
$(".count")[0].innerHTML = data['follow'];
$(".count")[1].innerHTML = data['fans'];
// 个人信息显示
// 头像
if (data['avatar'][0].length == 0){
$(".user-avatar").children("img").attr("src", "img/default.jpg");
}
else{
$(".user-avatar").children("img").attr("src", data['avatar'][0]);
}
console.log(data['school']);
console.log(data['avatar']);
$(".user-name")[0].innerHTML = "用户名:" + username;
$(".phone-num")[0].innerHTML = "手机号:" + data['mobile'][0];
$(".e-mail")[0].innerHTML = "E-mail:" + data['email'][0];
$(".github")[0].innerHTML = "Github:" + data['github'][0];
$(".school")[0].innerHTML = "学校:" + data['school'][0];
if (username == data['now_session']) {
$("#userInfoUl").prepend("<li><a href=\"#\" class=\"edit-info\"><i class=\"fa fa-pencil-square-o\" aria-hidden=\"true\"></i> 修改个人信息</a></li>");
$(".edit-info").attr("href", "edit-info.html?username=" + data['now_session']);
}
}
})
});
// url of following and fans
// alert($('.focus-num').children().children().innerHTML);
$('.focus-num').children().children().attr('href', 'following.html?username=' + username);
$('.fans-num').children().children().attr('href', 'fans.html?username=' + username);
</script>
</body>
</html>