更改登录界面,完善修改密码界面

dev
曾超新 5 years ago
parent 266f7aef98
commit 43fc5dca5a
  1. 13
      frontend/controllers/CommonController.php
  2. 2
      frontend/views/common/login.php
  3. 119
      frontend/views/common/update-pwd.php
  4. BIN
      frontend/web/assets/img/login_bj.jpg

@ -25,6 +25,7 @@ class CommonController extends \yii\web\Controller
public $my = null; public $my = null;
public $web = null; public $web = null;
public $enableCsrfValidation = false; public $enableCsrfValidation = false;
public $layout = 'blue-main';
public function init() public function init()
{ {
@ -237,6 +238,7 @@ class CommonController extends \yii\web\Controller
$request = Yii::$app->request; $request = Yii::$app->request;
$result = array(); $result = array();
$result['success'] = false; $result['success'] = false;
$result['msg'] = '更改失败';
if($request->isPost){ if($request->isPost){
$user_id = $request->post('id'); $user_id = $request->post('id');
@ -260,20 +262,19 @@ class CommonController extends \yii\web\Controller
if($user!= '' && $user_pwd != '') { if($user!= '' && $user_pwd != '') {
$user->salt = MyLib::randomStr(4); $user->salt = MyLib::randomStr(4);
$user->password = MyLib::hashPwd($user_pwd,$user->salt); $user->password = MyLib::hashPwd($user_pwd,$user->salt);
$user_res = $user->save(); if(!$user->save()) {
if(!$user_res){ throw new \Exception(print_r($user->getErrors(), true));
throw new \Exception('操作失败!');
} }
$result['success'] = true; $result['success'] = true;
$result['msg'] = '保存成功'; $result['msg'] = '保存成功';
$tran->commit();
} }
$tran->commit();
}catch(\Exception $e){ }catch(\Exception $e){
$tran->rollBack(); $tran->rollBack();
throw $e; $result['msg'] = $e->getMessage();
} }
return $result;
} }
return $result;
} }
public function actionLeft() public function actionLeft()

@ -30,7 +30,7 @@
</div> </div>
<div class="col-sm-5"> <div class="col-sm-5">
<form method="post"> <form method="post">
<h2 class="m-t-md text-center">汇盈车险业务系统</h2> <h2 class="m-t-md text-center" style="color: #000;">汇盈车险业务系统</h2>
<input type="text" id="username" name="username" class="form-control uname" placeholder="用户名" /> <input type="text" id="username" name="username" class="form-control uname" placeholder="用户名" />
<input type="password" id="password" name="password" class="form-control pword m-b" placeholder="密码" /> <input type="password" id="password" name="password" class="form-control pword m-b" placeholder="密码" />
<button id="login" class="btn btn-danger btn-block">登录</button> <button id="login" class="btn btn-danger btn-block">登录</button>

@ -1,53 +1,86 @@
<table width="50%" border="0" align="center" cellpadding="3" cellspacing="1" class="table" style="margin-top:200px;"> <?php
<form id="theFrm"> use \common\libs\MyLib;
<input type="hidden" name="id" value="<?= $user_info->id ?>"> ?>
<tr> <?php $this->beginBlock('header_css'); ?>
<td width="100" height="25" align="center" class="td_bg">工号</td> <link href="/assets/css/plugins/iCheck/custom.css" rel="stylesheet">
<td height="25" class="td_bg" align="center"><?=$user_info->username?></td> <?php $this->endBlock(); ?>
</tr>
<tr> <div class="wrapper wrapper-content animated fadeInRight">
<td width="100" height="25" align="center" class="td_bg">姓名</td> <div class="ibox float-e-margins">
<td height="25" class="td_bg" align="center"><?=$user_info->name?></td> <div class="ibox-title">
</tr> <h5>修改密码</h5>
<tr> </div>
<td width="100" height="25" align="center" class="td_bg">电话</td> <div class="ibox-content">
<td height="25" class="td_bg" align="center"><?=$user_info->phone?></td> <div class="row">
</tr> <div class="col-md-12">
<tr> <form role="form" class="form-horizontal data-from" id="theFrm">
<td width="100" height="25" align="center" class="td_bg">修改密码</td> <input type="hidden" name="id" value="<?=$user_info->id?>">
<td height="25" class="td_bg" align="center"> <div class="form-group">
<input type="Password" name="pwd" placeholder="在这里输入新密码" /> <label class="col-md-1 control-label">工号</label>
</td> <div class="col-md-6">
</tr> <label class="form-control-static"><?=$user_info->username?></label>
<tr> </div>
<td width="100" height="25" align="center" class="td_bg">确认密码</td> </div>
<td height="25" class="td_bg" align="center"> <div class="form-group">
<input type="Password" name="re_pwd" placeholder="在这里确认新密码" /> <label class="col-md-1 control-label">姓名</label>
</td> <div class="col-md-6">
</tr> <label class="form-control-static"><?=$user_info->name?></label>
</form> </div>
<tr> </div>
<td height="22" colspan="2" align="center" class="td_bg"> <div class="form-group">
<input id="submit-btn" type=button class="ACT_btn" name=Submit1 value=" 提交 "/> <label class="col-md-1 control-label">电话</label>
</td> <div class="col-md-6">
</tr> <label class="form-control-static"><?=$user_info->phone?></label>
</table> </div>
<script type="text/javascript" language="javascript" src="/js/jquery-1.8.3.js"></script> </div>
<script type="text/javascript" language="javascript" src="/js/ajax.js"></script> <div class="form-group">
<script type="text/javascript" language="javascript" src="/js/func.js"></script> <label class="col-md-1 control-label">新密码</label>
<div class="col-md-6">
<input type="password" name="pwd" value="" class="form-control">
</div>
</div>
<div class="form-group">
<label class="col-md-1 control-label">确认密码</label>
<div class="col-md-6">
<input type="password" name="re_pwd" value="" class="form-control">
</div>
</div>
<div>
<div class="row">
<div class="col-md-5 col-md-offset-5">
<button class="btn btn-primary btn-save" type="button">
<strong>修改密码</strong>
</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<?php $this->beginBlock('footer_js'); ?>
<script type="text/javascript" language="javascript"> <script type="text/javascript" language="javascript">
$(function () { $(function () {
//提交按钮 //提交按钮
$("#submit-btn").click(function(){ $(".btn-save").click(function(){
if(confirm('是否确认提交?')) { parent.layer.confirm('是否确认提交?', {
btn: ['确认','取消'], //按钮
shade: false //不显示遮罩
}, function(){
var params = $("#theFrm").serialize(); var params = $("#theFrm").serialize();
$.post('/common/update-pwd-save',params,function(obj){ $.post('/common/update-pwd-save',params,function(data){
alert(obj.msg); parent.layer.msg(data.msg);
if(obj.success){ if(data.success) {
window.top.location.href = "/common/logout"; window.top.location.href = "/common/logout";
} }
},'json'); },'json');
} }, function(){
//
});
}); });
}) })
</script> </script>
<?php $this->endBlock('footer_js'); ?>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 150 KiB

After

Width:  |  Height:  |  Size: 60 KiB

Loading…
Cancel
Save