From 33d6a9c0c750518e53895b160c5d97c28cd5c316 Mon Sep 17 00:00:00 2001 From: lqmac Date: Wed, 17 Apr 2024 01:44:35 +0800 Subject: [PATCH] 1 --- app/api/model/Goods.php | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/app/api/model/Goods.php b/app/api/model/Goods.php index 9a42571c..48a8fd57 100644 --- a/app/api/model/Goods.php +++ b/app/api/model/Goods.php @@ -330,22 +330,29 @@ class Goods extends GoodsModel $jd = new \app\common\service\Jd(); $res = $jd->getGoodsMainImageAndDetail($goodsInfo->goods_no); if ($res) { - $goods_images = []; - foreach ($res['mainImageList'] as $seq => $image) { - $goods_images[] = [ - 'file_id' => $seq, - 'file_type' => 10, - 'preview_url' => $image, - 'external_url' => $image, - ]; + if ($res['mainImageList']) { + $goods_images = []; + foreach ($res['mainImageList'] as $seq => $image) { + $goods_images[] = [ + 'file_id' => $seq, + 'file_type' => 10, + 'preview_url' => $image, + 'external_url' => $image, + ]; + } + $goodsInfo->goods_images = $goods_images; + $goodsInfo->goods_image = $res['mainImageList'][0]; + } - $goodsInfo->goods_images = $goods_images; - $goodsInfo->goods_image = $res['mainImageList'][0]; - $content = ""; - foreach ($res['infoImageList'] as $value) { - $content .= '

'; + + if ($res['infoImageList']) { + $content = ""; + foreach ($res['infoImageList'] as $value) { + $content .= '

'; + } + $goodsInfo->content = $content; } - $goodsInfo->content = $content; + } break; case 'sn':