|
...
|
...
|
@@ -35,44 +35,19 @@ class Product extends Base |
|
|
|
}
|
|
|
|
|
|
|
|
public function setThumbAttribute($value){
|
|
|
|
$value['url'] = Upload::url2path($value['url']);
|
|
|
|
$value['url'] = $this->getImageUrl($value['url']);
|
|
|
|
$this->attributes['thumb'] = Arr::a2s($value);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @remark :获取图片链接
|
|
|
|
* @name :getImageUrl
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/7/20 16:46
|
|
|
|
*/
|
|
|
|
public function getImageUrl($hash){
|
|
|
|
if(is_array($hash)){
|
|
|
|
$url = [];
|
|
|
|
foreach ($hash as $k => $v){
|
|
|
|
$url['images_link'][$k] = $this->getImageUrl($v);
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
$imageModel = new Image();
|
|
|
|
$info = $imageModel->read(['hash'=>$hash]);
|
|
|
|
if($info['is_cos'] == 1){
|
|
|
|
$cos = new CosService();
|
|
|
|
$url = $cos->getImageUrl($info['path']);
|
|
|
|
}else{
|
|
|
|
$url = url('b/image/'.$info['hash']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $url;
|
|
|
|
}
|
|
|
|
public function getThumbAttribute($value){
|
|
|
|
$value = Arr::s2a($value);
|
|
|
|
$value['url'] = Upload::path2url($value['url']);
|
|
|
|
$value['url'] = $this->getImageUrl($value['url']);
|
|
|
|
return $value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setGalleryAttribute($value){
|
|
|
|
foreach ($value as &$v){
|
|
|
|
$v['url'] = Upload::url2path($v['url']);
|
|
|
|
$v['url'] = $this->getImageUrl($value['url']);
|
|
|
|
}
|
|
|
|
$this->attributes['gallery'] = Arr::a2s($value);
|
|
|
|
}
|
|
...
|
...
|
@@ -80,7 +55,7 @@ class Product extends Base |
|
|
|
public function getGalleryAttribute($value){
|
|
|
|
$value = Arr::s2a($value);
|
|
|
|
foreach ($value as &$v){
|
|
|
|
$v['url'] = Upload::path2url($v['url']);
|
|
|
|
$v['url'] = $this->getImageUrl($value['url']);
|
|
|
|
}
|
|
|
|
return $value;
|
|
|
|
}
|
...
|
...
|
|