add function of deleting players

This commit is contained in:
printempw 2016-07-23 21:46:20 +08:00
parent 0e155a0f5c
commit 04c475746b
3 changed files with 26 additions and 3 deletions

View File

@ -204,6 +204,9 @@ class AdminController extends BaseController
if ($player->setOwner($_POST['uid']))
View::json('角色 '.$player->player_name.' 已成功让渡至 '.$user->getNickName(), 0);
} elseif ($action == "delete") {
if (PlayerModel::where('pid', $_POST['pid'])->delete())
View::json('角色已被成功删除', 0);
} else {
throw new E('Illegal parameters', 1);
}

View File

@ -2,7 +2,7 @@
* @Author: printempw
* @Date: 2016-07-22 14:02:44
* @Last Modified by: printempw
* @Last Modified time: 2016-07-23 15:22:01
* @Last Modified time: 2016-07-23 21:12:23
*/
'use strict';
@ -265,3 +265,23 @@ function changeOwner(pid) {
error: showAjaxError
});
}
function deletePlayer(pid) {
if (!window.confirm('真的要删除此角色吗?此操作不可恢复')) return;
$.ajax({
type: "POST",
url: "../admin/players?action=delete",
dataType: "json",
data: { 'pid': pid },
success: function(json) {
if (json.errno == 0) {
$('tr#'+pid).remove();
toastr.success(json.msg);
} else {
toastr.warning(json.msg);
}
},
error: showAjaxError
});
}

View File

@ -51,8 +51,8 @@
<td id="player-name">{{ $player->player_name }}</td>
<td>
<select class="form-control" id="preference">
<option {{ ($player->preference == "default") ? 'selected="selected"' : '' }} value="default">Default</option>
<option {{ ($player->preference == "slim") ? 'selected="selected"' : '' }} value="slim">Slim</option>
<option {{ ($player->preference == "default") ? 'selected=selected' : '' }} value="default">Default</option>
<option {{ ($player->preference == "slim") ? 'selected=selected' : '' }} value="slim">Slim</option>
</select>
</td>
<td>