上传头像提交修改
This commit is contained in:
parent
ecfba42651
commit
0c5da2cf17
@ -167,7 +167,7 @@ label.error {
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
width: 18px;
|
width: 18px;
|
||||||
height: 18px;
|
height: 18px;
|
||||||
background: url(/img/blue.png) no-repeat;
|
background: url(../../img/blue.png) no-repeat;
|
||||||
border: none;
|
border: none;
|
||||||
cursor: pointer
|
cursor: pointer
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
|
<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> 新增
|
<i class="fa fa-plus"></i> 新增
|
||||||
</a>
|
</a>
|
||||||
<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="system:dict:edit">
|
<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="system:dict:edit">
|
||||||
|
@ -59,7 +59,7 @@
|
|||||||
parentCode: "parentId",
|
parentCode: "parentId",
|
||||||
uniqueId: "menuId",
|
uniqueId: "menuId",
|
||||||
expandAll: false,
|
expandAll: false,
|
||||||
expandFirst: false,
|
expandFirst: true,
|
||||||
url: prefix + "/list",
|
url: prefix + "/list",
|
||||||
createUrl: prefix + "/add/{id}",
|
createUrl: prefix + "/add/{id}",
|
||||||
updateUrl: prefix + "/edit/{id}",
|
updateUrl: prefix + "/edit/{id}",
|
||||||
|
@ -18,13 +18,13 @@
|
|||||||
<input type="button" id="btnCrop" class="Btnsty_peyton" value="裁切" />
|
<input type="button" id="btnCrop" class="Btnsty_peyton" value="裁切" />
|
||||||
<input type="button" id="btnZoomIn" 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="btnZoomOut" class="Btnsty_peyton" value="-" />
|
||||||
<input type="button" id="blobSubmit" class="Btnsty_peyton" value="提交" />
|
|
||||||
</div>
|
</div>
|
||||||
<div class="cropped"></div>
|
<div class="cropped"></div>
|
||||||
</div>
|
</div>
|
||||||
<div th:include="include::footer"></div>
|
<div th:include="include::footer"></div>
|
||||||
<script th:src="@{/ajax/libs/cropbox/cropbox.js}"></script>
|
<script th:src="@{/ajax/libs/cropbox/cropbox.js}"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
var cropper;
|
||||||
$(window).load(function() {
|
$(window).load(function() {
|
||||||
var avatar = '[[${user.avatar}]]';
|
var avatar = '[[${user.avatar}]]';
|
||||||
var options = {
|
var options = {
|
||||||
@ -32,9 +32,8 @@ $(window).load(function() {
|
|||||||
spinner: '.spinner',
|
spinner: '.spinner',
|
||||||
imgSrc: $.common.isEmpty(avatar) ? ctx + 'img/profile.jpg' : ctx + 'profile/avatar/' + avatar
|
imgSrc: $.common.isEmpty(avatar) ? ctx + 'img/profile.jpg' : ctx + 'profile/avatar/' + avatar
|
||||||
}
|
}
|
||||||
var cropper = $('.imageBox').cropbox(options);
|
cropper = $('.imageBox').cropbox(options);
|
||||||
$('#avatar').on('change',
|
$('#avatar').on('change', function() {
|
||||||
function() {
|
|
||||||
var reader = new FileReader();
|
var reader = new FileReader();
|
||||||
reader.onload = function(e) {
|
reader.onload = function(e) {
|
||||||
options.imgSrc = e.target.result;
|
options.imgSrc = e.target.result;
|
||||||
@ -47,22 +46,7 @@ $(window).load(function() {
|
|||||||
}
|
}
|
||||||
reader.readAsDataURL(this.files[0]);
|
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(){
|
$('#btnCrop').on('click', function(){
|
||||||
var img = cropper.getDataURL();
|
var img = cropper.getDataURL();
|
||||||
$('.cropped').html('');
|
$('.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: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>');
|
$('.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(){
|
$('#btnZoomIn').on('click', function(){
|
||||||
cropper.zoomIn();
|
cropper.zoomIn();
|
||||||
})
|
})
|
||||||
|
|
||||||
$('#btnZoomOut').on('click', function(){
|
$('#btnZoomOut').on('click', function(){
|
||||||
cropper.zoomOut();
|
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>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -12,7 +12,6 @@ import com.ruoyi.framework.web.page.TableSupport;
|
|||||||
import com.ruoyi.system.domain.SysUser;
|
import com.ruoyi.system.domain.SysUser;
|
||||||
import org.springframework.web.bind.WebDataBinder;
|
import org.springframework.web.bind.WebDataBinder;
|
||||||
import org.springframework.web.bind.annotation.InitBinder;
|
import org.springframework.web.bind.annotation.InitBinder;
|
||||||
|
|
||||||
import java.beans.PropertyEditorSupport;
|
import java.beans.PropertyEditorSupport;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user