From 7c08eaec80ead920c796528bc4414fb8151bcf6e Mon Sep 17 00:00:00 2001 From: zhaoxiang <756958008@qq.com> Date: Wed, 16 Nov 2016 00:07:40 +0800 Subject: [PATCH] =?UTF-8?q?modified=20=E5=AE=9E=E7=8E=B0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/User.php | 76 ++++++++++++++++++++++++- application/admin/view/public/base.html | 2 +- public/admin/static/js/template/form.js | 7 ++- 3 files changed, 81 insertions(+), 4 deletions(-) diff --git a/application/admin/controller/User.php b/application/admin/controller/User.php index a7bad6e..bc046fe 100644 --- a/application/admin/controller/User.php +++ b/application/admin/controller/User.php @@ -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); + } + } } \ No newline at end of file diff --git a/application/admin/view/public/base.html b/application/admin/view/public/base.html index 7a8b14d..c3b741e 100644 --- a/application/admin/view/public/base.html +++ b/application/admin/view/public/base.html @@ -70,7 +70,7 @@