Browse Source

fix:默认头像问题

super-yimizi 1 month ago
parent
commit
150d4da133
2 changed files with 14 additions and 14 deletions
  1. 4 4
      application/common/library/Auth.php
  2. 10 10
      application/common/model/User.php

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

@@ -154,7 +154,8 @@ class Auth
 
 
         $ip = request()->ip();
         $ip = request()->ip();
         $time = time();
         $time = time();
-
+        $defaultavatar = ShopConfigService::getConfigs('shop.basic.default_user_avator',false) ?? "";
+        //$params['avatar'] = $defaultavatar;
         $data = [
         $data = [
             'username' => $username,
             'username' => $username,
             'password' => $password,
             'password' => $password,
@@ -162,7 +163,7 @@ class Auth
             'mobile'   => $mobile,
             'mobile'   => $mobile,
             'level'    => 1,
             'level'    => 1,
             'score'    => 0,
             'score'    => 0,
-            'avatar'   => '',
+            'avatar'   => $defaultavatar,
         ];
         ];
         $params = array_merge($data, [
         $params = array_merge($data, [
             'nickname'  => preg_match("/^1[3-9]{1}\d{9}$/", $username) ? substr_replace($username, '****', 3, 4) : $username,
             'nickname'  => preg_match("/^1[3-9]{1}\d{9}$/", $username) ? substr_replace($username, '****', 3, 4) : $username,
@@ -176,8 +177,7 @@ class Auth
         ]);
         ]);
         //注册默认头像
         //注册默认头像
         //查询配置 
         //查询配置 
-        $defaultavatar = ShopConfigService::getConfigs('shop.basic.default_user_avator',false) ?? "";
-        $params['avatar'] = $defaultavatar;
+        
         $params['password'] = $this->getEncryptPassword($password, $params['salt']);
         $params['password'] = $this->getEncryptPassword($password, $params['salt']);
         $params = array_merge($params, $extend);
         $params = array_merge($params, $extend);
 
 

+ 10 - 10
application/common/model/User.php

@@ -39,16 +39,16 @@ class User extends Model
         return "/u/" . $data['id'];
         return "/u/" . $data['id'];
     }
     }
 
 
-    /**
-     * 获取头像
-     * @param string $value
-     * @param array  $data
-     * @return string
-     */
-    public function getAvatarAttr($value, $data)
-    {
-        return $value ? $value : '/assets/img/avatar.png';
-    }
+    // /**
+    //  * 获取头像
+    //  * @param string $value
+    //  * @param array  $data
+    //  * @return string
+    //  */
+    // public function getAvatarAttr($value, $data)
+    // {
+    //     return $value ? $value : '/assets/img/avatar.png';
+    // }
 
 
 
 
     /**
     /**