123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <?php
- namespace User\Src;
- use Dever;
- use User\Lib\Core;
- class Info extends Core
- {
- # 获取基本信息
- public function get()
- {
- $this->data['user'] = $this->user;
- if (Dever::project('set')) {
- $this->data['config'] = Dever::load('set/lib/config')->getInfo();
- }
- if (Dever::project('score')) {
- $this->data['score'] = Dever::load('score/lib/core')->getUserScore($this->uid);
- }
- if (Dever::project('account')) {
- $this->data['account'] = Dever::load('account/lib/info')->getUserInfo($this->uid);
- }
-
- return $this->data;
- }
- # 获取邀请码
- public function invite()
- {
- if (Dever::project('invite')) {
- $this->data['code'] = Dever::load('invite/api')->code($this->uid);
- }
- if (Dever::project('set')) {
- $this->data['config'] = Dever::load('set/lib/config')->getInfo();
- }
- return $this->data;
- }
- # 根据邀请码获取信息
- public function getInviteInfo()
- {
- $this->data['parent'] = array();
- $code = Dever::input('code');
- if ($code) {
- $uid = Dever::load('invite/api')->getUid($code);
- if (!$uid || $uid <= 0) {
- Dever::alert('邀请码不正确');
- }
- $this->data['parent'] = Dever::load('user/lib/info')->get($this->uid);
- }
- if (Dever::project('set')) {
- $this->data['config'] = Dever::load('set/lib/config')->getInfo();
- }
- return $this->data;
- }
- # 更新用户信息
- public function update()
- {
- $uid = $this->uid;
- $name = Dever::input('username');
- $avatar = Dever::input('avatar');
- $sex = Dever::input('sex');
- //$province = Dever::input('province');
- //$city = Dever::input('city');
- //$country = Dever::input('country');
- return Dever::load('user/lib/info')->update($uid, $name, $avatar, $sex);
- }
- # 修改手机号
- public function updateMobile()
- {
- $uid = $this->uid;
- $mobile = Dever::load('user/info')->checkCode();
- $info = Dever::db('user/info')->find($uid);
- if ($info) {
- $update['mobile'] = $mobile;
- $update['where_id'] = $uid;
- Dever::db('user/info')->update($update);
- } else {
- Dever::alert('更新失败');
- }
- $result = Dever::load('user/lib/info')->getSign($uid);
- return $result;
- }
- # 修改密码
- public function updatePassword()
- {
- $uid = $this->uid;
- $old_password = Dever::input('old_password');
- $password = Dever::input('password');
- if ($old_password == $password) {
- Dever::alert('旧密码与新密码相同');
- }
- $cpassword = Dever::input('cpassword');
- if ($password != $cpassword) {
- Dever::alert('新密码与确认密码不同');
- }
- $info = Dever::db('user/info')->find($uid);
- if ($info) {
- $update['password'] = sha1($password);
- $update['where_id'] = $uid;
- Dever::db('user/info')->update($update);
- } else {
- Dever::alert('更新失败');
- }
- $result = Dever::load('user/lib/info')->getSign($uid);
- return $result;
- }
- }
|