Authored by 梁志锋

Merge remote-tracking branch 'remotes/origin/develop/wap' into beta/wap

... ... @@ -899,9 +899,9 @@ class Helpers
/**
* 按照数组中指定字段排序二维数组
*
* @param array &$array 需要排序的数组
* @param string $field 字段名称
* @param boolean $desc 时候降序排列,默认为false
* @param array &$array 需要排序的数组
* @param string $field 字段名称
* @param boolean $desc 是否降序排列,默认为false
*/
public static function sortArrByField(&$array, $field, $desc = false)
{
... ...
... ... @@ -4,6 +4,7 @@ namespace Product;
use LibModels\Wap\Product\DetailData;
use Plugin\Helpers;
use Plugin\Images;
/**
* 商品详情页模板相关的数据模型
... ... @@ -771,16 +772,26 @@ class DetailModel
// 发售日期
$result['releaseDate'] = $product['saleTime'] . '发售';
// baner
$result['banner'] = $product['defaultUrl'];
$result['banner'] = Helpers::getImageUrl($product['defaultUrl'], 750, '');
$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;
... ... @@ -799,33 +810,29 @@ class DetailModel
switch(intval($attachment['attachType'])) {
case 1: // 大图文字
$result['img'] = array(
'attachUrl' => Helpers::getImageUrl($attachment['attachUrl'], 290, 200),
'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'], 290, 200)
'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');
}
return $result;
}
... ...