Przeglądaj źródła

用户信息接口

lizhen_gitee 1 rok temu
rodzic
commit
727c9c43dc

+ 8 - 18
application/api/controller/User.php

@@ -94,7 +94,7 @@ class User extends Api
 
         $user = \app\common\model\User::getByMobile($mobile);
         if ($user) {
-            if ($user->status != 'normal') {
+            if ($user->status != 1) {
                 $this->error(__('Account is locked'));
             }
             //如果已经有账号则直接登录
@@ -115,6 +115,11 @@ class User extends Api
         }
     }
 
+    public function getUserinfo(){
+        $info = $this->auth->getUserinfo();
+        $this->success(1,$info);
+    }
+
     /**
      * 注册会员
      *
@@ -179,25 +184,10 @@ class User extends Api
     public function profile()
     {
         $user = $this->auth->getUser();
-        $username = $this->request->post('username');
         $nickname = $this->request->post('nickname');
-        $bio = $this->request->post('bio');
         $avatar = $this->request->post('avatar', '', 'trim,strip_tags,htmlspecialchars');
-        if ($username) {
-            $exists = \app\common\model\User::where('username', $username)->where('id', '<>', $this->auth->id)->find();
-            if ($exists) {
-                $this->error(__('Username already exists'));
-            }
-            $user->username = $username;
-        }
-        if ($nickname) {
-            $exists = \app\common\model\User::where('nickname', $nickname)->where('id', '<>', $this->auth->id)->find();
-            if ($exists) {
-                $this->error(__('Nickname already exists'));
-            }
-            $user->nickname = $nickname;
-        }
-        $user->bio = $bio;
+
+        $user->nickname = $nickname;
         $user->avatar = $avatar;
         $user->save();
         $this->success();

+ 2 - 2
application/common/library/Auth.php

@@ -26,7 +26,7 @@ class Auth
     //默认配置
     protected $config = [];
     protected $options = [];
-    protected $allowFields = ['id', 'username', 'nickname', 'mobile', 'avatar', 'score'];
+    protected $allowFields = ['id', 'username', 'nickname', 'mobile', 'avatar'];
 
     public function __construct($options = [])
     {
@@ -410,7 +410,7 @@ class Auth
 
         //追加
         $userinfo['avatar'] = one_domain_image($userinfo['avatar']);
-        $userinfo['money'] = model('wallet')->getWallet($this->id,'money');
+//        $userinfo['money'] = model('wallet')->getWallet($this->id,'money');
 
         return $userinfo;
     }