Browse Source

注册昵称,注册流程,用户信息修改

lizhen_gitee 3 years ago
parent
commit
ced2a59bb1
2 changed files with 81 additions and 64 deletions
  1. 16 50
      application/api/controller/User.php
  2. 65 14
      application/common/library/Auth.php

+ 16 - 50
application/api/controller/User.php

@@ -110,7 +110,7 @@ class User extends Api
      * @param string $mobile   手机号
      * @param string $code     验证码
      */
-    public function register()
+    /*public function register()
     {
         $username = $this->request->post('username');
         $password = $this->request->post('password');
@@ -137,44 +137,14 @@ class User extends Api
         } else {
             $this->error($this->auth->getError());
         }
-    }
-
-    //用户详细资料
-    public function userInfo($type = 1){
-        $info = [
-            'id' => $this->auth->id,
-            'username' => $this->auth->username,
-            'truename' => $this->auth->truename,
-            'nickname' => $this->auth->nickname,
-            //'group_id' => $this->auth->group_id,
-            'alipay_account' => $this->auth->alipay_account,
-            'idcard_status' => $this->auth->idcard_status,
-            'bio' => $this->auth->bio,
-            'birthday' => $this->auth->birthday,
-//            'address' => $this->auth->address,
-            'mobile' => $this->auth->mobile,
-
-            'avatar' => $this->auth->avatar,
-            'gender' => $this->auth->gender,
-            'email' => $this->auth->email,
-            'mobile' => $this->auth->mobile,
-            'setpassword' => $this->auth->password ? 1 : 0,
-//            'cover_image' => $this->auth->cover_image,
-//            'photo_images' => $this->auth->photo_images,
-//            'vip_endtime' => $this->auth->vip_endtime,
-        ];
-        //$info['is_vip'] = intval($info['vip_endtime']) - time() > 0 ? 1 : 0;
-        $info['age'] = birthtime_to_age($info['birthday']);
+    }*/
 
-        $info = info_domain_image($info,['avatar']);
 
-        //实名过了才行
-        $info['truename'] = $info['idcard_status'] == 1 ? $info['truename'] : '';
-        $info['alipay_account'] = $info['idcard_status'] == 1 ? $info['alipay_account'] : '';
 
+    //用户详细资料
+    public function userInfo($type = 1){
+        $info = $this->auth->getUserinfo();
         if($type == 'return'){
-            $info = array_merge($info, Token::get($this->auth->getToken())); //token 等多个字段
-            //$info['token'] = $this->auth->getToken();
             return $info;
         }
         $this->success(__('success'),$info);
@@ -272,24 +242,20 @@ class User extends Api
     public function profile()
     {
         $user = $this->auth->getUser();
-        $username = $this->request->post('username');
+
         $nickname = $this->request->post('nickname');
+        $gender = $this->request->post('gender');
+        $birthday = $this->request->post('birthday');
+        $height = $this->request->post('height');
+        $weight = $this->request->post('weight');
+
+
         $bio = $this->request->post('bio');
+        $audio_bio = $this->request->post('audio_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;
-        }
+        $avatar = $this->request->post('photo_images', '', 'trim,strip_tags,htmlspecialchars');
+
+
         $user->bio = $bio;
         $user->avatar = $avatar;
         $user->save();

File diff suppressed because it is too large
+ 65 - 14
application/common/library/Auth.php


Some files were not shown because too many files changed in this diff