User.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace app\Admin\controller;
  3. use think\Db;
  4. class User extends Base
  5. {
  6. public function __construct()
  7. {
  8. parent::__construct();
  9. }
  10. /**
  11. *
  12. */
  13. public function ResetInfo(){
  14. $pasword = isset($this->post['password']) && $this->post['password']!="" ? $this->post['password'] :"";
  15. $data=[];
  16. if($pasword!=""){
  17. $data['salt']=makeSalt();
  18. $data['password']=sha1($pasword.$data['salt']);
  19. }
  20. $nickname = isset($this->post['nickname'])&& $this->post['nickname']!="" ? trim($this->post['nickname']):"";
  21. if($nickname!=""){
  22. $data['nickname']=$nickname;
  23. }
  24. $mobile = isset($this->post['mobile'])&& $this->post['mobile']!="" ? trim($this->post['mobile']):"";
  25. if($mobile!=""){
  26. $data['mobile']=$mobile;
  27. }
  28. $data['updatetime'] = date("Y-m-d H:i:s");
  29. $result=Db::name('admin')->where(['id'=>$this->userinfo['id']])->update($data);
  30. $msg =isset($data['password'])? "修改密码为:{$pasword}":"";
  31. $msg .=isset($data['nickname'])? "修改昵称为:{$nickname}":"";
  32. $msg .=isset($data['mobile'])? "修改手机号为:{$mobile}":"";
  33. if($result){
  34. write_log("管理员{$this->userinfo['nickname']}修改个人信息成功{$msg}",$this->userinfo,"user","edit");
  35. return app_show(0,"信息修改成功");
  36. }else{
  37. return error_show(1003,"信息修改失败");
  38. }
  39. }
  40. //获取用户信息
  41. public function UserInfo(){
  42. return app_show(0,"获取成功",$this->userinfo);
  43. }
  44. }