|
@@ -35,44 +35,19 @@ class Product extends Base |
|
@@ -35,44 +35,19 @@ class Product extends Base |
|
35
|
}
|
35
|
}
|
|
36
|
|
36
|
|
|
37
|
public function setThumbAttribute($value){
|
37
|
public function setThumbAttribute($value){
|
|
38
|
- $value['url'] = Upload::url2path($value['url']);
|
38
|
+ $value['url'] = $this->getImageUrl($value['url']);
|
|
39
|
$this->attributes['thumb'] = Arr::a2s($value);
|
39
|
$this->attributes['thumb'] = Arr::a2s($value);
|
|
40
|
}
|
40
|
}
|
|
41
|
- /**
|
|
|
|
42
|
- * @remark :获取图片链接
|
|
|
|
43
|
- * @name :getImageUrl
|
|
|
|
44
|
- * @author :lyh
|
|
|
|
45
|
- * @method :post
|
|
|
|
46
|
- * @time :2023/7/20 16:46
|
|
|
|
47
|
- */
|
|
|
|
48
|
- public function getImageUrl($hash){
|
|
|
|
49
|
- if(is_array($hash)){
|
|
|
|
50
|
- $url = [];
|
|
|
|
51
|
- foreach ($hash as $k => $v){
|
|
|
|
52
|
- $url['images_link'][$k] = $this->getImageUrl($v);
|
|
|
|
53
|
- }
|
|
|
|
54
|
- }else{
|
|
|
|
55
|
- $imageModel = new Image();
|
|
|
|
56
|
- $info = $imageModel->read(['hash'=>$hash]);
|
|
|
|
57
|
- if($info['is_cos'] == 1){
|
|
|
|
58
|
- $cos = new CosService();
|
|
|
|
59
|
- $url = $cos->getImageUrl($info['path']);
|
|
|
|
60
|
- }else{
|
|
|
|
61
|
- $url = url('b/image/'.$info['hash']);
|
|
|
|
62
|
- }
|
|
|
|
63
|
- }
|
|
|
|
64
|
|
41
|
|
|
65
|
- return $url;
|
|
|
|
66
|
- }
|
|
|
|
67
|
public function getThumbAttribute($value){
|
42
|
public function getThumbAttribute($value){
|
|
68
|
$value = Arr::s2a($value);
|
43
|
$value = Arr::s2a($value);
|
|
69
|
- $value['url'] = Upload::path2url($value['url']);
|
44
|
+ $value['url'] = $this->getImageUrl($value['url']);
|
|
70
|
return $value;
|
45
|
return $value;
|
|
71
|
}
|
46
|
}
|
|
72
|
|
47
|
|
|
73
|
public function setGalleryAttribute($value){
|
48
|
public function setGalleryAttribute($value){
|
|
74
|
foreach ($value as &$v){
|
49
|
foreach ($value as &$v){
|
|
75
|
- $v['url'] = Upload::url2path($v['url']);
|
50
|
+ $v['url'] = $this->getImageUrl($value['url']);
|
|
76
|
}
|
51
|
}
|
|
77
|
$this->attributes['gallery'] = Arr::a2s($value);
|
52
|
$this->attributes['gallery'] = Arr::a2s($value);
|
|
78
|
}
|
53
|
}
|
|
@@ -80,7 +55,7 @@ class Product extends Base |
|
@@ -80,7 +55,7 @@ class Product extends Base |
|
80
|
public function getGalleryAttribute($value){
|
55
|
public function getGalleryAttribute($value){
|
|
81
|
$value = Arr::s2a($value);
|
56
|
$value = Arr::s2a($value);
|
|
82
|
foreach ($value as &$v){
|
57
|
foreach ($value as &$v){
|
|
83
|
- $v['url'] = Upload::path2url($v['url']);
|
58
|
+ $v['url'] = $this->getImageUrl($value['url']);
|
|
84
|
}
|
59
|
}
|
|
85
|
return $value;
|
60
|
return $value;
|
|
86
|
}
|
61
|
}
|