mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-04-06 03:58:00 +08:00
modified 实现用户信息修改
This commit is contained in:
parent
696ce12863
commit
7c08eaec80
@ -242,7 +242,7 @@ class User extends Base {
|
||||
[
|
||||
'module' => 'text',
|
||||
'description' => '',
|
||||
'info' => '用户名称:',
|
||||
'info' => '账户名:',
|
||||
'attr' => [
|
||||
'name' => 'username',
|
||||
'value' => '',
|
||||
@ -291,4 +291,78 @@ class User extends Base {
|
||||
}
|
||||
$this->error('操作失败!');
|
||||
}
|
||||
|
||||
public function edit(){
|
||||
if( $this->request->isPut() ){
|
||||
if( $this->request->put('password') != $this->request->put('repassword') ){
|
||||
$this->error('两次密码输入不一致!', '');
|
||||
}
|
||||
if( empty($this->request->put('nickname')) ){
|
||||
$this->error('昵称不能为空', '');
|
||||
}
|
||||
$userModel = new \app\admin\model\User();
|
||||
$userDetail = $userModel->where([$this->primaryKey => $this->uid])->find();
|
||||
if( !empty($this->request->put('password')) ){
|
||||
$userDetail->password = $this->request->put('password');
|
||||
}
|
||||
$userDetail->nickname = $this->request->put('nickname');
|
||||
$userDetail->save();
|
||||
$this->success('操作成功!', url('User/index'));
|
||||
|
||||
}else{
|
||||
$form = [
|
||||
'formTitle' => $this->menuInfo['name'],
|
||||
'tempType' => 'edit',
|
||||
'formAttr' => [
|
||||
'target' => url('User/edit'),
|
||||
'formId' => 'edit-user-form',
|
||||
'backUrl' => url('User/index'),
|
||||
],
|
||||
'formList' => [
|
||||
[
|
||||
'module' => 'text',
|
||||
'description' => '',
|
||||
'info' => '账户名:',
|
||||
'attr' => [
|
||||
'name' => 'username',
|
||||
'value' => $this->userInfo['username'],
|
||||
'placeholder' => '',
|
||||
'disabled' => true
|
||||
]
|
||||
],
|
||||
[
|
||||
'module' => 'text',
|
||||
'description' => '',
|
||||
'info' => '用户昵称:',
|
||||
'attr' => [
|
||||
'name' => 'nickname',
|
||||
'value' => $this->userInfo['nickname'],
|
||||
'placeholder' => $this->userInfo['nickname']
|
||||
]
|
||||
],
|
||||
[
|
||||
'module' => 'password',
|
||||
'description' => '',
|
||||
'info' => '新密码:',
|
||||
'attr' => [
|
||||
'name' => 'password',
|
||||
'value' => '',
|
||||
'placeholder' => ''
|
||||
]
|
||||
],
|
||||
[
|
||||
'module' => 'password',
|
||||
'description' => '',
|
||||
'info' => '确认密码:',
|
||||
'attr' => [
|
||||
'name' => 'repassword',
|
||||
'value' => '',
|
||||
'placeholder' => ''
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
$this->result($form, ReturnCode::GET_TEMPLATE_SUCCESS);
|
||||
}
|
||||
}
|
||||
}
|
@ -70,7 +70,7 @@
|
||||
<!-- Menu Footer-->
|
||||
<li class="user-footer">
|
||||
<div class="pull-left">
|
||||
<a href="#" class="btn btn-default btn-flat">修改信息</a>
|
||||
<a url="{:url('User/edit')}" class="refresh btn btn-default btn-flat">修改信息</a>
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
<a href="{:url('User/logout')}" class="btn btn-default btn-flat">退出登录</a>
|
||||
|
@ -114,14 +114,17 @@
|
||||
*/
|
||||
function buildInput( inputObj ) {
|
||||
var formHtml = '<div><div class="col-xs-8 form-group"><label>'+ inputObj.info +'</label>';
|
||||
var placeholder = '', value = '';
|
||||
var placeholder = '', value = '', disabled = '';
|
||||
if( inputObj.attr.placeholder){
|
||||
placeholder = 'placeholder="'+ inputObj.attr.placeholder +'"';
|
||||
}
|
||||
if( inputObj.attr.value){
|
||||
value = 'value="'+ inputObj.attr.value +'"';
|
||||
}
|
||||
formHtml += '<input type="text" class="form-control" '+ placeholder +' '+ value +' name="'+ inputObj.attr.name +'"></div>';
|
||||
if( inputObj.attr.disabled ){
|
||||
disabled = 'disabled';
|
||||
}
|
||||
formHtml += '<input type="text" class="form-control" '+ placeholder +' '+ disabled +' '+ value +' name="'+ inputObj.attr.name +'"></div>';
|
||||
if( inputObj.description && inputObj.description.length ){
|
||||
formHtml += ' <div class="col-xs-4 form-group" style="margin-top: 30px"><span class="label label-info">'+ inputObj.description +'</span></div>';
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user