Info.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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')->getUserInfo($this->uid);
  19. }
  20. return $this->data;
  21. }
  22. # 获取邀请码
  23. public function invite()
  24. {
  25. if (Dever::project('invite')) {
  26. $this->data['code'] = Dever::load('invite/api')->code($this->uid);
  27. }
  28. if (Dever::project('set')) {
  29. $this->data['config'] = Dever::load('set/lib/config')->getInfo();
  30. }
  31. return $this->data;
  32. }
  33. # 根据邀请码获取信息
  34. public function getInviteInfo()
  35. {
  36. $this->data['parent'] = array();
  37. $code = Dever::input('code');
  38. if ($code) {
  39. $uid = Dever::load('invite/api')->getUid($code);
  40. if (!$uid || $uid <= 0) {
  41. Dever::alert('邀请码不正确');
  42. }
  43. $this->data['parent'] = Dever::load('user/lib/info')->get($this->uid);
  44. }
  45. if (Dever::project('set')) {
  46. $this->data['config'] = Dever::load('set/lib/config')->getInfo();
  47. }
  48. return $this->data;
  49. }
  50. # 更新用户信息
  51. public function update()
  52. {
  53. $uid = $this->uid;
  54. $name = Dever::input('username');
  55. $avatar = Dever::input('avatar');
  56. $sex = Dever::input('sex');
  57. //$province = Dever::input('province');
  58. //$city = Dever::input('city');
  59. //$country = Dever::input('country');
  60. return Dever::load('user/lib/info')->update($uid, $name, $avatar, $sex);
  61. }
  62. # 修改手机号
  63. public function updateMobile()
  64. {
  65. $uid = $this->uid;
  66. $mobile = Dever::load('user/info')->checkCode();
  67. $info = Dever::db('user/info')->find($uid);
  68. if ($info) {
  69. $update['mobile'] = $mobile;
  70. $update['where_id'] = $uid;
  71. Dever::db('user/info')->update($update);
  72. } else {
  73. Dever::alert('更新失败');
  74. }
  75. $result = Dever::load('user/lib/info')->getSign($uid);
  76. return $result;
  77. }
  78. # 修改密码
  79. public function updatePassword()
  80. {
  81. $uid = $this->uid;
  82. $old_password = Dever::input('old_password');
  83. $password = Dever::input('password');
  84. if ($old_password == $password) {
  85. Dever::alert('旧密码与新密码相同');
  86. }
  87. $cpassword = Dever::input('cpassword');
  88. if ($password != $cpassword) {
  89. Dever::alert('新密码与确认密码不同');
  90. }
  91. $info = Dever::db('user/info')->find($uid);
  92. if ($info) {
  93. $update['password'] = sha1($password);
  94. $update['where_id'] = $uid;
  95. Dever::db('user/info')->update($update);
  96. } else {
  97. Dever::alert('更新失败');
  98. }
  99. $result = Dever::load('user/lib/info')->getSign($uid);
  100. return $result;
  101. }
  102. }