Authored by hf

code review by fei.hong : do merge produt detail page limit code

... ... @@ -761,6 +761,7 @@ class DetailModel
do {
$productData = DetailData::limitProductData($uid, $productCode);
if (empty($productData) || empty($productData['data'])) {
break;
}
... ... @@ -775,12 +776,22 @@ class DetailModel
$result['description'] = $product['description'];
// 附件
if (isset($product['attachment'])) {
foreach ($product['attachment'] as $item) {
$result['attaches'][] = self::procLimitProductAttach($item);
if (!isset($product['attachment'])) {
break;
}
$result['attaches'] = array();
foreach ($product['attachment'] as $item) {
if ($item['isDefault'] === 1) { // 排除默认图片
continue;
}
$result['attaches'][] = self::procLimitProductAttach($item);
}
if(count($result['attaches']) > 1) {
Helpers::sortArrByField($result['attaches'], 'orderBy', true);
}
} while (false);
return $result;
... ... @@ -801,31 +812,27 @@ class DetailModel
$result['img'] = array(
'attachUrl' => Helpers::getImageUrl($attachment['attachUrl'], 750, ''),
'attachName' => $attachment['attachName'],
'intro' => $attachment['intro'],
'orderBy' => $attachment['orderBy']
'intro' => $attachment['intro']
);
$result['orderBy'] = $attachment['orderBy'];
break;
case 2: // 视频
$result['video'] = array(
'attachUrl' => $attachment['attachUrl'],
'orderBy' => $attachment['orderBy'],
'img' => Helpers::getImageUrl($attachment['intro'], 750, '')
);
$result['orderBy'] = $attachment['orderBy'];
break;
case 3: // 文本类型
$result['text'] = array(
'intro' => $attachment['intro'],
'orderBy' => $attachment['orderBy']
'intro' => $attachment['intro']
);
$result['orderBy'] = $attachment['orderBy'];
break;
default:
break;
}
if(count($result) > 1) {
Helpers::sortArrByField($result, 'orderBy', true, SORT_NUMERIC);
}
return $result;
}
... ...