Info.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. namespace User\Src;
  3. use Dever;
  4. use User\Lib\Core;
  5. class Info extends Core
  6. {
  7. # 获取基本信息
  8. public function get()
  9. {
  10. $this->data['user'] = $this->user;
  11. if (Dever::project('set')) {
  12. $this->data['config'] = Dever::load('set/lib/config')->getInfo();
  13. }
  14. if (Dever::project('score')) {
  15. $this->data['score'] = Dever::load('score/lib/core')->getUserScore($this->uid);
  16. }
  17. if (Dever::project('account')) {
  18. $this->data['account'] = Dever::load('account/lib/info')->getInfo($this->uid);
  19. }
  20. return $this->data;
  21. }
  22. # 更新用户信息
  23. public function update()
  24. {
  25. $uid = $this->uid;
  26. $name = Dever::input('username');
  27. $avatar = Dever::input('avatar');
  28. $sex = Dever::input('sex');
  29. //$province = Dever::input('province');
  30. //$city = Dever::input('city');
  31. //$country = Dever::input('country');
  32. return Dever::load('user/lib/info')->update($uid, $name, $avatar, $sex);
  33. }
  34. # 修改手机号
  35. public function updateMobile()
  36. {
  37. $uid = $this->uid;
  38. $mobile = Dever::load('user/info')->checkCode();
  39. $info = Dever::db('user/info')->find($uid);
  40. if ($info) {
  41. $update['mobile'] = $mobile;
  42. $update['where_id'] = $uid;
  43. Dever::db('user/info')->update($update);
  44. } else {
  45. Dever::alert('更新失败');
  46. }
  47. $result = Dever::load('user/lib/info')->getSign($uid);
  48. return $result;
  49. }
  50. # 修改密码
  51. public function updatePassword()
  52. {
  53. $uid = $this->uid;
  54. $old_password = Dever::input('old_password');
  55. $password = Dever::input('password');
  56. if ($old_password == $password) {
  57. Dever::alert('旧密码与新密码相同');
  58. }
  59. $cpassword = Dever::input('cpassword');
  60. if ($password != $cpassword) {
  61. Dever::alert('新密码与确认密码不同');
  62. }
  63. $info = Dever::db('user/info')->find($uid);
  64. if ($info) {
  65. $update['password'] = sha1($password);
  66. $update['where_id'] = $uid;
  67. Dever::db('user/info')->update($update);
  68. } else {
  69. Dever::alert('更新失败');
  70. }
  71. $result = Dever::load('user/lib/info')->getSign($uid);
  72. return $result;
  73. }
  74. }