HighSpeaker/.history/app/view/user_20221223152848.html
2022-12-24 22:10:40 +08:00

131 lines
6.2 KiB
HTML

<?php
$page_title='用户配置';
include('common_head.html');?>
<link href="vendor/datatables/dataTables.bootstrap4.min.css" rel="stylesheet">
<!-- Begin Page Content -->
<div class="container-fluid">
<!-- Page Heading -->
<h1 class="h3 mb-4 text-gray-800">用户配置</h1>
<small style="color: #e83e8c;">请注意:HighSpeaker是单用户的,您添加的所有用户都具备和您一样的管理员权限并甚至可以删除您的账号!</small>
<div class="card shadow mb-4">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary">用户列表</h6>
</div>
<div class="card-body">
如遇需更改账号,请先以新账号添加用户,再删除旧账号
<div><code id="notice"></code></div>
<div class="table-responsive">
<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
<thead>
<tr>
<th>头像</th>
<th>姓名</th>
<th>邮箱</th>
<th>账号</th>
<th>密码</th>
<th>操作</th>
</tr>
</thead>
<tfoot>
<tr>
<th>头像</th>
<th>姓名</th>
<th>邮箱</th>
<th>账号</th>
<th>密码</th>
<th>操作</th>
</tr>
</tfoot>
<tbody>
<?php
foreach($user as $us){
$us=json_decode($us);
$headurl='https://cravatar.cn/avatar/' . md5(strtolower(trim( $us->email )));
echo <<<EOF
<tr>
<td><img height="35px" style="border-radius: 100%;" src="$headurl"></img></td>
<td><input id="$us->account/name" class="form-control" name="name" value="$us->name" type="text" /></td>
<td><input id="$us->account.email" class="form-control" name="email" value="$us->email" type="email" /></td>
<td>$us->account</td>
<td><input id="$us->account.password" class="form-control" name="passwd" placeholder="不更改请留空" type="password" /></td>
<td><a href="javascript:change('$us->account')" class="btn btn-success btn-circle btn-sm">
<i class="fas fa-check"></i>
</a><a href="#" class="btn btn-danger btn-circle btn-sm">
<i class="fas fa-trash"></i>
</a></td>
</tr>
EOF;
}
?>
<tr>
<td>新用户</td>
<td>管理员</td>
<td>admin@admin.com</td>
<td>admin</td>
<td>Start date</td>
<td>Salary</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- /.container-fluid -->
</div>
<!-- End of Main Content -->
<?php include('common_foot.html');?>
<!-- Page level plugins -->
<script src="vendor/datatables/jquery.dataTables.min.js"></script>
<script src="vendor/datatables/dataTables.bootstrap4.min.js"></script>
<!-- Page level custom scripts -->
<script src="js/demo/datatables-demo.js"></script>
<script>
function change($account){
var name = $("#("+$account+")name").val();
var password = $("#"+$account+".password").val();
var email = $("#"+$account+".email").val();
if(name=="" || password=="" || email==""){
$('#notice').html('数据不完整');
return false;
}
$.ajax({
type: "POST",
url: '/api/user/change',
data: {'name':name,password:password,email:email,account:$account},
async: false,
dataType: 'json',
cache: false,
beforeSubmit: function () {
$('#notice').html('正在操作');
},
success: function (data) {
if (data.code == 200) {
$('#notice').html('操作成功,即将刷新页面');
$(location).attr('href','user');
} else {
$('#notice').html(data.msg);
}
},
clearForm: false,
resetForm: false
});
}
</script>
</body>
</html>