2016-02-04 17:21:05 +08:00
|
|
|
/*
|
|
|
|
* @Author: prpr
|
|
|
|
* @Date: 2016-02-04 16:48:42
|
|
|
|
* @Last Modified by: prpr
|
2016-02-05 22:08:06 +08:00
|
|
|
* @Last Modified time: 2016-02-05 22:01:44
|
2016-02-04 17:21:05 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
2016-02-05 15:56:17 +08:00
|
|
|
function uploadSkin(uname) {
|
|
|
|
Ply.dialog("confirm", {
|
2016-02-05 22:08:06 +08:00
|
|
|
text: "更改该用户对应哪个模型的皮肤?",
|
2016-02-05 15:56:17 +08:00
|
|
|
ok: "Steve",
|
|
|
|
cancel: "Alex"
|
|
|
|
}).done(function(){
|
|
|
|
uploadTexture(uname, 'steve');
|
|
|
|
}).fail(function(){
|
|
|
|
uploadTexture(uname, 'alex');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-02-04 18:35:14 +08:00
|
|
|
function uploadTexture(uname, type) {
|
2016-02-04 17:21:05 +08:00
|
|
|
var ply = new Ply({
|
2016-02-05 22:08:06 +08:00
|
|
|
el: '<h2>为该用户上传新的 '+type+':</h2>'+
|
2016-02-04 18:35:14 +08:00
|
|
|
'<input type="file" id="file" accept="image/png">'+
|
2016-02-05 22:08:06 +08:00
|
|
|
'<button id="upload" class="pure-button pure-button-primary fw">上传</button>',
|
2016-02-04 17:21:05 +08:00
|
|
|
effect: "fade",
|
2016-02-04 18:35:14 +08:00
|
|
|
onaction: function(){
|
|
|
|
var form_data = new FormData();
|
|
|
|
var file = $('#file').get(0).files[0];
|
|
|
|
if (file) {
|
|
|
|
form_data.append('file', file);
|
|
|
|
$.ajax({
|
|
|
|
type: 'POST',
|
|
|
|
contentType: false,
|
|
|
|
url: 'admin_ajax.php?action=upload&type='+type+'&uname='+uname,
|
|
|
|
dataType: "json",
|
|
|
|
data: form_data,
|
|
|
|
processData: false,
|
|
|
|
success: function(json) {
|
|
|
|
if (json.errno == 0) {
|
2016-02-05 22:08:06 +08:00
|
|
|
showAlert("上传成功。", function(){
|
2016-02-04 18:35:14 +08:00
|
|
|
location.reload();
|
|
|
|
});
|
|
|
|
} else {
|
2016-02-05 22:08:06 +08:00
|
|
|
showAlert("上传材质的时候出错啦:\n" + json.msg);
|
2016-02-04 18:35:14 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
2016-02-04 17:21:05 +08:00
|
|
|
});
|
|
|
|
ply.open();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-04 18:35:14 +08:00
|
|
|
function changePasswd(uname) {
|
2016-02-04 17:21:05 +08:00
|
|
|
Ply.dialog("prompt", {
|
2016-02-05 22:08:06 +08:00
|
|
|
title: "修改 "+uname+" 的登录密码:",
|
|
|
|
form: { passwd: "新的密码" }
|
2016-02-04 17:21:05 +08:00
|
|
|
}).done(function(ui){
|
|
|
|
var passwd = ui.data.passwd;
|
|
|
|
$.ajax({
|
|
|
|
type: "POST",
|
|
|
|
url: "admin_ajax.php?action=change&uname="+uname,
|
|
|
|
dataType: "json",
|
|
|
|
data: { "passwd": passwd },
|
|
|
|
success: function(json) {
|
|
|
|
if (json.errno == 0) {
|
|
|
|
showAlert(json.msg);
|
|
|
|
} else {
|
|
|
|
showAlert(json.msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-02-04 18:35:14 +08:00
|
|
|
function deleteAccount(uname) {
|
2016-02-04 17:21:05 +08:00
|
|
|
Ply.dialog("prompt", {
|
2016-02-05 22:08:06 +08:00
|
|
|
title: "确定要删除 "+uname+"?此操作不可恢复。",
|
2016-02-04 17:21:05 +08:00
|
|
|
}).done(function(ui){
|
|
|
|
$.ajax({
|
|
|
|
type: "POST",
|
|
|
|
url: "admin_ajax.php?action=delete&uname="+uname,
|
|
|
|
dataType: "json",
|
|
|
|
success: function(json) {
|
|
|
|
if (json.errno == 0) {
|
2016-02-04 18:19:04 +08:00
|
|
|
showAlert(json.msg, function(){
|
|
|
|
location.reload();
|
|
|
|
});
|
2016-02-04 17:21:05 +08:00
|
|
|
} else {
|
|
|
|
showAlert(json.msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2016-02-04 18:13:32 +08:00
|
|
|
|
2016-02-04 18:35:14 +08:00
|
|
|
function changeModel(uname) {
|
2016-02-04 18:13:32 +08:00
|
|
|
Ply.dialog("prompt", {
|
2016-02-05 22:08:06 +08:00
|
|
|
title: "修改 "+uname+" 的优先皮肤模型:",
|
|
|
|
form: { text: "输入 `slim` 或者 `default`" }
|
2016-02-04 18:13:32 +08:00
|
|
|
}).done(function(ui){
|
|
|
|
var model = ui.data.text;
|
|
|
|
if (model == 'slim'| model == 'default') {
|
|
|
|
$.ajax({
|
|
|
|
type: "POST",
|
|
|
|
url: "admin_ajax.php?action=model&uname="+uname,
|
|
|
|
data: { "model": ui.data.text },
|
|
|
|
dataType: "json",
|
|
|
|
success: function(json) {
|
|
|
|
if (json.errno == 0) {
|
2016-02-04 18:19:04 +08:00
|
|
|
showAlert(json.msg, function(){
|
|
|
|
location.reload();
|
|
|
|
});
|
2016-02-04 18:13:32 +08:00
|
|
|
} else {
|
|
|
|
showAlert(json.msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
2016-02-05 22:08:06 +08:00
|
|
|
showAlert('只能输入 `slim` 或者 `default` 哦');
|
2016-02-04 18:13:32 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|