一行四图
This commit is contained in:
parent
89e4a0c98a
commit
e0685c9069
|
|
@ -40,7 +40,7 @@ class DesignService
|
||||||
{
|
{
|
||||||
if ($moduleCode == 'slideshow') {
|
if ($moduleCode == 'slideshow') {
|
||||||
return self::handleSlideShow($content);
|
return self::handleSlideShow($content);
|
||||||
} elseif ($moduleCode == 'image_401') {
|
} elseif ($moduleCode == 'image401') {
|
||||||
return self::handleImage401($content);
|
return self::handleImage401($content);
|
||||||
}
|
}
|
||||||
return $content;
|
return $content;
|
||||||
|
|
@ -56,20 +56,12 @@ class DesignService
|
||||||
*/
|
*/
|
||||||
private static function handleSlideShow($content): array
|
private static function handleSlideShow($content): array
|
||||||
{
|
{
|
||||||
foreach ($content['images'] as $index => $image) {
|
$images = $content['images'];
|
||||||
$imagePath = 'catalog' . ($image['image'][current_language_code()] ?? '');
|
if (empty($images)) {
|
||||||
$content['images'][$index]['image'] = image_origin($imagePath);
|
return $content;
|
||||||
|
}
|
||||||
|
|
||||||
$link = $image['link'];
|
$content['images'] = self::handleImages($images);
|
||||||
if (empty($link)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$type = $link['type'] ?? '';
|
|
||||||
$value = (int)$link['value'] ?? 0;
|
|
||||||
if ($type && $value) {
|
|
||||||
$content['images'][$index]['link']['link'] = self::handleLink($type, $value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -83,9 +75,44 @@ class DesignService
|
||||||
*/
|
*/
|
||||||
private static function handleImage401($content): array
|
private static function handleImage401($content): array
|
||||||
{
|
{
|
||||||
|
$images = $content['images'];
|
||||||
|
if (empty($images)) {
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$content['images'] = self::handleImages($images);
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理图片以及链接
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
private static function handleImages($images): array
|
||||||
|
{
|
||||||
|
if (empty($images)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($images as $index => $image) {
|
||||||
|
$imagePath = 'catalog/' . ($image['image'][current_language_code()] ?? '');
|
||||||
|
$images[$index]['image'] = image_origin($imagePath);
|
||||||
|
|
||||||
|
$link = $image['link'];
|
||||||
|
if (empty($link)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$type = $link['type'] ?? '';
|
||||||
|
$value = (int)$link['value'] ?? 0;
|
||||||
|
if ($type && $value) {
|
||||||
|
$images[$index]['link']['link'] = self::handleLink($type, $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $images;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理链接
|
* 处理链接
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,6 @@ class ImageService
|
||||||
{
|
{
|
||||||
$this->image = $image ?: self::PLACEHOLDER_IMAGE;
|
$this->image = $image ?: self::PLACEHOLDER_IMAGE;
|
||||||
$imagePath = public_path($this->image);
|
$imagePath = public_path($this->image);
|
||||||
if (!file_exists($imagePath)) {
|
|
||||||
throw new \Exception("图片不存在");
|
|
||||||
}
|
|
||||||
$this->imagePath = $imagePath;
|
$this->imagePath = $imagePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue