作者 郭宇鹏
1 个管道 的构建 通过 耗费 1 秒

'0041'

@@ -62,6 +62,11 @@ class Login extends BaseApi @@ -62,6 +62,11 @@ class Login extends BaseApi
62 'userinfo' => $this->auth->getUserinfo(), 62 'userinfo' => $this->auth->getUserinfo(),
63 'thirdinfo' => $result, 63 'thirdinfo' => $result,
64 ]; 64 ];
  65 + if ($this->auth->avatar != '' && !in_array(substr($this->auth->avatar,-4),explode(',','jpg,png,bmp,jpeg,gif,zip,rar,xls,xlsx'))){
  66 + $content = file_get_contents($this->auth->avatar);
  67 + file_put_contents(ROOT_PATH.'/public/uploads/user_avatar/user_id_'.$this->auth->id.'.jpg', $content);
  68 + model('user')->where('id',$this->auth->id)->update(['avatar'=>'/uploads/user_avatar/user_id_'.$this->auth->id.'.jpg']);
  69 + }
65 $this->success(__('Logged in successful'), $data); 70 $this->success(__('Logged in successful'), $data);
66 } 71 }
67 } 72 }
@@ -94,11 +94,6 @@ class Treasured extends BaseApi @@ -94,11 +94,6 @@ class Treasured extends BaseApi
94 if ($this->auth->authlist == '' || $this->auth->authlist == ','){ 94 if ($this->auth->authlist == '' || $this->auth->authlist == ','){
95 $this->error('请您先实名认证'); 95 $this->error('请您先实名认证');
96 } 96 }
97 - if ($this->auth->avatar != '' && !in_array(substr($this->auth->avatar,-4),explode(',','jpg,png,bmp,jpeg,gif,zip,rar,xls,xlsx'))){  
98 - $content = file_get_contents($this->auth->avatar);  
99 - file_put_contents(ROOT_PATH.'/public/uploads/user_avatar/user_id_'.$this->auth->id.'.jpg', $content);  
100 - model('user')->where('id',$this->auth->id)->update(['avatar'=>'/public/uploads/user_avatar/user_id_'.$this->auth->id.'.jpg']);  
101 - }  
102 //2.获取数据 97 //2.获取数据
103 $data = $this->get_data_array([ 98 $data = $this->get_data_array([
104 ['url','域名不能为空'], 99 ['url','域名不能为空'],
@@ -126,7 +126,14 @@ class User extends Model @@ -126,7 +126,14 @@ class User extends Model
126 //$value = '/assets/img/avatar.png'; 126 //$value = '/assets/img/avatar.png';
127 $value = letter_avatar($data['nickname']); 127 $value = letter_avatar($data['nickname']);
128 } 128 }
129 - return cdnurl($value,true); 129 + if (file_exists(cdnurl($value,true))){
  130 + return cdnurl($value,true);
  131 + }
  132 + if (file_exists(ROOT_PATH.$value)){
  133 + return this_url().$value;
  134 + }
  135 + dd(11212);
  136 + return this_url()."/uploads/user_avatar/001.jpg";
130 } 137 }
131 138
132 /** 139 /**