上传头像提交修改

master
RuoYi 6 years ago committed by Limy
parent c4eb0c756f
commit 5f06f3ed3b

@ -167,7 +167,7 @@ label.error {
padding: 0;
width: 18px;
height: 18px;
background: url(/img/blue.png) no-repeat;
background: url(../../img/blue.png) no-repeat;
border: none;
cursor: pointer
}

@ -35,7 +35,7 @@
</div>
<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
<a class="btn btn-primary" th:onclick="'javascript:$.operate.add(\''+${dict.dictType}+'\')'" shiro:hasPermission="system:dict:add">
<a class="btn btn-success" th:onclick="'javascript:$.operate.add(\''+${dict.dictType}+'\')'" shiro:hasPermission="system:dict:add">
<i class="fa fa-plus"></i> 新增
</a>
<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="system:dict:edit">

@ -59,7 +59,7 @@
parentCode: "parentId",
uniqueId: "menuId",
expandAll: false,
expandFirst: false,
expandFirst: true,
url: prefix + "/list",
createUrl: prefix + "/add/{id}",
updateUrl: prefix + "/edit/{id}",

@ -18,13 +18,13 @@
<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 th:src="@{/ajax/libs/cropbox/cropbox.js}"></script>
<script type="text/javascript">
var cropper;
$(window).load(function() {
var avatar = '[[${user.avatar}]]';
var options = {
@ -32,9 +32,8 @@ $(window).load(function() {
spinner: '.spinner',
imgSrc: $.common.isEmpty(avatar) ? ctx + 'img/profile.jpg' : ctx + 'profile/avatar/' + avatar
}
var cropper = $('.imageBox').cropbox(options);
$('#avatar').on('change',
function() {
cropper = $('.imageBox').cropbox(options);
$('#avatar').on('change', function() {
var reader = new FileReader();
reader.onload = function(e) {
options.imgSrc = e.target.result;
@ -47,22 +46,7 @@ $(window).load(function() {
}
reader.readAsDataURL(this.files[0]);
})
$('#blobSubmit').on('click', function(){
var img = cropper.getBlob();
var formdata = new FormData();
formdata.append("avatarfile", img);
formdata.append("userId", $("#userId").val());
$.ajax({
url: ctx + "system/user/profile/updateAvatar",
data: formdata,
type: "post",
processData: false,
contentType: false,
success: function(result) {
$.operate.saveSuccess(result);
}
})
})
$('#btnCrop').on('click', function(){
var img = cropper.getDataURL();
$('.cropped').html('');
@ -70,13 +54,32 @@ $(window).load(function() {
$('.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();
})
});
function submitHandler() {
var img = cropper.getBlob();
var formdata = new FormData();
formdata.append("avatarfile", img);
formdata.append("userId", $("#userId").val());
$.ajax({
url: ctx + "system/user/profile/updateAvatar",
data: formdata,
type: "post",
processData: false,
contentType: false,
success: function(result) {
$.operate.saveSuccess(result);
}
})
}
</script>
</body>
</html>

@ -12,7 +12,6 @@ import com.ruoyi.framework.web.page.TableSupport;
import com.ruoyi.system.domain.SysUser;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import java.beans.PropertyEditorSupport;
import java.util.Date;
import java.util.List;

Loading…
Cancel
Save