You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

152 lines
6.0 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head th:replace="common/header :: common_head(~{::title},~{},~{::link},~{})">
<title th:text="'账号设置_'+${application.website.name}"></title>
<link rel="stylesheet" href="/css/user.css"/>
</head>
<body class="">
<div th:replace="common/top :: top('')">
</div>
<div class="main box_center cf">
<div class="userBox cf">
<div class="my_l">
<ul class="log_list">
<li><a class="link_1 " href="/user/userinfo.html"></a></li>
<li><a class="link_4" href="/user/favorites.html"></a></li>
<li><a class="link_6" href="/user/comment.html"></a></li>
<li><a class="link_7 " href="/user/feedback_list.html"></a></li>
<li><a class="link_8 on" href="/user/setup.html"></a></li>
</ul>
</div>
<div class="my_r">
<div class="my_info cf">
<div class="my_info_txt">
<ul class="mytab_list">
<li><i class="tit"></i>
<a style="position: relative">
<img id="imgLogo" class="user_img" alt="我的头像" src="/images/man.png"/>
<input class="opacity" onchange="picChange()" type="file" id="file0" name="file"
title="点击上传图片"
style="z-index: 100;cursor: pointer;left: 0px; top: -25px; width: 60px; height: 80px; opacity: 0; position: absolute; "/>
</a>
</li>
<li><i class="tit"></i><a href="/user/set_name.html" id="my_name"></a></li>
<li style="display:none"><i class="tit"></i><a href="javascript:void(0);"></a></li>
<li><i class="tit"></i><a href="/user/set_sex.html" id="my_sex"></a></li>
<li><i class="tit"></i><a href="/user/set_password.html"></a></li>
<li><i class="tit"></i><a href="javascript:logout()">退</a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div th:replace="common/footer :: footer">
</div>
<div th:replace="common/js :: js"></div>
<script src="/javascript/user.js" type="text/javascript"></script>
<script src="/javascript/ajaxfileupload.js" type="text/javascript"></script>
<script type="text/javascript">
//查询用户信息
$.ajax({
type: "get",
url: "/user/userInfo",
data: {},
dataType: "json",
success: function (data) {
if (data.code == 200) {
if (data.data.userPhoto) {
$("#imgLogo").attr("src", data.data.userPhoto);
}
if (data.data.nickName) {
$("#my_name").html(data.data.nickName + "<em class=\"ml10\">[修改]</em>");
} else {
$("#my_name").html(data.data.username + "<em class=\"ml10\">[修改]</em>");
}
if (data.data.userSex === '0') {
$("#my_sex").html("男<em class=\"ml10\">[修改]</em>");
} else if (data.data.userSex === '1') {
$("#my_sex").html("女<em class=\"ml10\">[修改]</em>");
} else {
$("#my_sex").html("请选择");
}
} else if (data.code == 1001) {
//未登录
location.href = '/user/login.html?originUrl=' + encodeURIComponent(location.href);
} else {
layer.alert(data.msg);
}
},
error: function () {
layer.alert('');
}
})
function picChange() {
var file = $("#file0").val(); //文件名称
if (file != "") {
if (checkPicUpload($("#file0")[0])) {
$.ajaxFileUpload({
url: "/file/picUpload", //用于文件上传的服务器端请求地址
secureuri: false, //是否需要安全协议一般设置为false
fileElementId: "file0", //文件上传域的ID
dataType: "json", //返回值类型 一般设置为json
type: "post",
success: function (data) { //服务器成功响应处理函数
if (data.code == 200) {
$.ajax({
type: "POST",
url: "/user/updateUserInfo",
data: {'userPhoto': data.data},
dataType: "json",
success: function (data) {
if (data.code == 200) {
window.location.href = '/user/setup.html';
} else if (data.code == 1001) {
//未登录
location.href = '/user/login.html?originUrl=' + encodeURIComponent(location.href);
} else {
layer.alert(data.msg);
}
},
error: function () {
layer.alert('');
}
})
} else {
layer.alert(data.msg);
}
}
});
}
} else {
alert("请选择上传文件!");
}
}
</script>
</body>
</html>