2018-06-07 00:45:47 +08:00
|
|
|
|
$(function () {
|
|
|
|
|
var $headerIcon = $('#headerIcon');
|
|
|
|
|
var preIcon = $headerIcon.attr('src');
|
|
|
|
|
$('#fileIcon').fileinput({
|
2018-06-24 16:16:58 +08:00
|
|
|
|
uploadUrl: $.formatUrl(Profiles.url),
|
|
|
|
|
browseOnZoneClick: true,
|
2018-08-02 17:21:00 +08:00
|
|
|
|
theme: 'fa',
|
2018-06-07 00:45:47 +08:00
|
|
|
|
language: 'zh',
|
|
|
|
|
maxFileSize: 5000,
|
|
|
|
|
allowedFileExtensions: ['jpg', 'png', 'bmp', 'gif', 'jpeg'],
|
|
|
|
|
initialPreview: [
|
|
|
|
|
preIcon
|
|
|
|
|
],
|
|
|
|
|
initialPreviewConfig: [
|
2018-06-24 16:16:58 +08:00
|
|
|
|
{ caption: "现在头像", size: $('#fileIcon').attr('data-init'), showZoom: true },
|
2018-06-07 00:45:47 +08:00
|
|
|
|
],
|
|
|
|
|
initialPreviewAsData: true,
|
|
|
|
|
overwriteInitial: true,
|
|
|
|
|
dropZoneTitle: "请选择头像"
|
|
|
|
|
}).on('fileuploaded', function (event, data, previewId, index) {
|
2018-06-24 16:16:58 +08:00
|
|
|
|
var url = data.response.initialPreview[0];
|
2018-09-02 00:50:13 +08:00
|
|
|
|
if (!!url === true) $headerIcon.attr('src', url);
|
2018-06-07 00:45:47 +08:00
|
|
|
|
});
|
|
|
|
|
|
2018-09-18 23:14:43 +08:00
|
|
|
|
$('.site-footer').footer();
|
|
|
|
|
|
2018-09-02 00:50:13 +08:00
|
|
|
|
var dataBinder = new DataEntity({
|
|
|
|
|
Password: "#currentPassword",
|
|
|
|
|
NewPassword: "#newPassword",
|
|
|
|
|
DisplayName: "#displayName",
|
|
|
|
|
UserName: "#userName",
|
|
|
|
|
Css: "#css"
|
2018-06-07 12:25:03 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('button[data-method]').on('click', function (e) {
|
|
|
|
|
var $this = $(this);
|
2018-08-10 18:01:26 +08:00
|
|
|
|
if ($this.parent().attr("data-admin") === "True") return false;
|
2018-09-02 00:50:13 +08:00
|
|
|
|
var data = dataBinder.get();
|
2018-06-07 12:25:03 +08:00
|
|
|
|
switch ($this.attr('data-method')) {
|
|
|
|
|
case 'password':
|
2018-09-07 15:53:16 +08:00
|
|
|
|
data.UserStatus = 'ChangePassword';
|
2018-09-09 13:19:05 +08:00
|
|
|
|
$.bc({ url: User.url, method: "put", data: data, title: "更改密码" });
|
2018-06-07 12:25:03 +08:00
|
|
|
|
break;
|
|
|
|
|
case 'user':
|
2018-09-07 15:53:16 +08:00
|
|
|
|
data.UserStatus = 'ChangeDisplayName';
|
2018-06-07 12:25:03 +08:00
|
|
|
|
$.bc({
|
2018-09-09 13:19:05 +08:00
|
|
|
|
url: User.url, method: "put", data: data, title: "修改用户显示名称",
|
2018-06-07 12:25:03 +08:00
|
|
|
|
callback: function (result) {
|
|
|
|
|
if (result) {
|
|
|
|
|
$('#userDisplayName').text(data.DisplayName);
|
|
|
|
|
}
|
2018-06-07 00:45:47 +08:00
|
|
|
|
}
|
2018-06-07 12:25:03 +08:00
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
case 'css':
|
2018-09-07 15:53:16 +08:00
|
|
|
|
data.UserStatus = 'ChangeTheme';
|
2018-09-07 16:11:18 +08:00
|
|
|
|
$.bc({
|
2018-09-09 13:19:05 +08:00
|
|
|
|
url: User.url, method: "put", data: data, title: "保存样式", callback: function (result) {
|
2018-09-07 16:11:18 +08:00
|
|
|
|
if (result) {
|
|
|
|
|
window.setTimeout(function () { window.location.reload(true); }, 1000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2018-06-07 12:25:03 +08:00
|
|
|
|
break;
|
2018-06-07 00:45:47 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
2018-08-10 18:34:06 +08:00
|
|
|
|
$('[data-admin="False"]').removeClass('d-none');
|
|
|
|
|
if ($('[enctype="multipart/form-data"]').is(":hidden")) {
|
|
|
|
|
$('.card-img').removeClass('d-none');
|
|
|
|
|
}
|
2018-08-10 19:38:15 +08:00
|
|
|
|
$('#css').dropdown('val');
|
2016-11-16 17:27:03 +08:00
|
|
|
|
});
|