Authored by Rock Zhang

优化列表以及为你优选商品图片选择逻辑

Code Review By Rock Zhang
... ... @@ -221,8 +221,8 @@ class Helpers
$flag = false; // 判别默认的商品是否将默认的图片URL赋值到skn
$firstGood = array(); // 第一个skc产品
// 如果设置了默认图片,就取默认的图片
foreach ($productData['goods_list'] as $k => $oneGoods) {
if ($k === 0) {
foreach ($productData['goods_list'] as $oneGoods) {
if (empty($firstGood)) {
$firstGood = $oneGoods;
}
... ... @@ -298,9 +298,9 @@ class Helpers
$cover2 = isset($images['cover_2']) ? $images['cover_2'] : '';
$gender = self::getGenderByCookie();
if ($gender === '2,3') {
return !empty($cover2) ? $cover2 : !empty($cover1) ? $cover1 : $imgUrl;
return !empty($cover2) ? $cover2 : (!empty($cover1) ? $cover1 : $imgUrl);
} else {
return !empty($cover1) ? $cover1 : !empty($cover2) ? $cover2 : $imgUrl;
return !empty($cover1) ? $cover1 : (!empty($cover2) ? $cover2 : $imgUrl);
}
}
... ...