若依开源1.1.3发布
This commit is contained in:
81
src/main/resources/templates/system/user/profile/avatar.html
Normal file
81
src/main/resources/templates/system/user/profile/avatar.html
Normal file
@@ -0,0 +1,81 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.w3.org/1999/xhtml">
|
||||
<meta charset="utf-8">
|
||||
<title>用户头像修改</title>
|
||||
<link href="/ajax/libs/cropbox/cropbox.css" th:href="@{/ajax/libs/cropbox/cropbox.css}" rel="stylesheet"/>
|
||||
<body class="white-bg">
|
||||
<div class="container">
|
||||
<div class="imageBox">
|
||||
<div class="thumbBox"></div>
|
||||
<div class="spinner" style="display: none">Loading...</div>
|
||||
</div>
|
||||
<div class="action">
|
||||
<div class="new-contentarea tc">
|
||||
<a href="javascript:void(0)" class="upload-img"> <label for="avatar">上传图像</label> </a>
|
||||
<input type="file" class="" name="avatar" id="avatar" />
|
||||
</div>
|
||||
<input type="button" id="btnCrop" class="Btnsty_peyton" value="裁切" />
|
||||
<input type="button" id="btnZoomIn" class="Btnsty_peyton" value="+" />
|
||||
<input type="button" id="btnZoomOut" class="Btnsty_peyton" value="-" />
|
||||
<input type="button" id="blobSubmit" class="Btnsty_peyton" value="提交" />
|
||||
</div>
|
||||
<div class="cropped"></div>
|
||||
</div>
|
||||
<div th:include="include::footer"></div>
|
||||
<script src="/ajax/libs/cropbox/cropbox.js" th:src="@{/ajax/libs/cropbox/cropbox.js}"></script>
|
||||
<script type="text/javascript">
|
||||
$(window).load(function() {
|
||||
var options = {
|
||||
thumbBox: '.thumbBox',
|
||||
spinner: '.spinner',
|
||||
imgSrc: '/img/profile.jpg'
|
||||
}
|
||||
var cropper = $('.imageBox').cropbox(options);
|
||||
$('#avatar').on('change',
|
||||
function() {
|
||||
var reader = new FileReader();
|
||||
reader.onload = function(e) {
|
||||
options.imgSrc = e.target.result;
|
||||
cropper = $('.imageBox').cropbox(options);
|
||||
}
|
||||
reader.readAsDataURL(this.files[0]);
|
||||
})
|
||||
$('#blobSubmit').on('click', function(){
|
||||
var img = cropper.getBlob();
|
||||
var formdata = new FormData();
|
||||
formdata.append("avatarfile", img);
|
||||
formdata.append("userId", 1);
|
||||
$.ajax({
|
||||
url: ctx + "system/user/profile/updateAvatar",
|
||||
data: formdata,
|
||||
type: "post",
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(result) {
|
||||
if (result.code == "0") {
|
||||
parent.layer.msg("修改成功,正在刷新数据请稍后……",{icon:1,time: 500,shade: [0.1,'#fff']},function(){
|
||||
$.parentReload();
|
||||
});
|
||||
}else{
|
||||
$.modalAlert(result.msg, "error");
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
$('#btnCrop').on('click', function(){
|
||||
var img = cropper.getDataURL();
|
||||
$('.cropped').html('');
|
||||
$('.cropped').append('<img src="'+img+'" align="absmiddle" style="width:64px;margin-top:4px;border-radius:64px;box-shadow:0px 0px 12px #7E7E7E;" ><p>64px*64px</p>');
|
||||
$('.cropped').append('<img src="'+img+'" align="absmiddle" style="width:128px;margin-top:4px;border-radius:128px;box-shadow:0px 0px 12px #7E7E7E;"><p>128px*128px</p>');
|
||||
$('.cropped').append('<img src="'+img+'" align="absmiddle" style="width:180px;margin-top:4px;border-radius:180px;box-shadow:0px 0px 12px #7E7E7E;"><p>180px*180px</p>');
|
||||
})
|
||||
$('#btnZoomIn').on('click', function(){
|
||||
cropper.zoomIn();
|
||||
})
|
||||
$('#btnZoomOut').on('click', function(){
|
||||
cropper.zoomOut();
|
||||
})
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@@ -27,6 +27,7 @@
|
||||
<ul class="dropdown-menu dropdown-user">
|
||||
<li><a href="javascript:edit()">修改信息</a></li>
|
||||
<li><a href="javascript:resetPwd()">修改密码</a></li>
|
||||
<li><a href="javascript:avatar()">修改头像</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
@@ -34,7 +35,7 @@
|
||||
<div class="contact-box">
|
||||
<div class="col-sm-4">
|
||||
<div class="text-center">
|
||||
<img alt="image" class="img-circle m-t-xs img-responsive" src="/img/profilel.jpg">
|
||||
<img alt="image" class="img-circle m-t-xs img-responsive" th:src="(${user.avatar} == '') ? '/img/profile.jpg' : '/profile/' + ${user.avatar}">
|
||||
<div class="m-t-xs font-bold">CEO</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -45,7 +46,7 @@
|
||||
<p><i class="fa fa-group"></i> [[${user.dept.deptName}]] / [[${#strings.defaultString(postGroup,'无岗位')}]]</p>
|
||||
<p><i class="fa fa-transgender"></i> [[${user.sex}]]</p>
|
||||
<p><i class="fa fa-envelope-o"></i> [[${user.email}]]</p>
|
||||
<p><i class="fa fa-calendar"></i> [[${user.createTime}]]</p>
|
||||
<p><i class="fa fa-calendar"></i> [[${user.createDateTimeStr}]]</p>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</a>
|
||||
@@ -68,6 +69,11 @@
|
||||
var url = ctx + 'system/user/profile/resetPwd/' + userId;
|
||||
layer_show("重置密码", url, '800', '500');
|
||||
}
|
||||
/*用户管理-头像*/
|
||||
function avatar() {
|
||||
var url = ctx + 'system/user/profile/avatar/' + userId;
|
||||
layer_showAuto("修改头像", url);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
Reference in New Issue
Block a user