Browse Source

修改昵称

lizhen_gitee 6 months ago
parent
commit
81dd237eeb
1 changed files with 9 additions and 1 deletions
  1. 9 1
      application/api/controller/User.php

+ 9 - 1
application/api/controller/User.php

@@ -171,6 +171,7 @@ class User extends Api
 
         $avatar = input('avatar', '', 'trim,strip_tags,htmlspecialchars');
         $mobile = input('mobile', '');
+        $nickname = input('nickname', '');
 
         //修改用户
         $data = [];
@@ -179,14 +180,21 @@ class User extends Api
         {
            $data['avatar'] = $avatar;
         }
+
         if(!empty($mobile))
         {
             if (\app\common\model\User::where('mobile', $mobile)->where('id', '<>', $this->auth->id)->find()) {
-                $this->error('手机号已存在');
+                $this->error('手机号已被占用');
             }
            $data['mobile'] = $mobile;
         }
 
+        //未通过实名认证的才能改昵称
+        if(!empty($nickname) && $this->auth->idcard_status != 1)
+        {
+            $data['nickname'] = $nickname;
+        }
+
         if(!empty($data)){
             $update_rs = Db::name('user')->where('id',$this->auth->id)->update($data);
             if($update_rs === false){