Authored by 郝肖肖

店铺装修 潮流资讯

... ... @@ -129,4 +129,22 @@ class ListData
return $result;
}
/**
* 通过品牌获取相关文章
* @param type $brandId 品牌id
* @param type $limit 取推荐内容的数量
* @param type $udid
* @return type []
*/
public static function getArticleByBrand($brandId, $limit, $udid = '')
{
$param = Yohobuy::param();
$param['brand_id'] = $brandId;
$param['udid'] = $udid;
$param['limit'] = $limit;
$param['private_key'] = Yohobuy::$privateKeyList['web'];
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::SERVICE_URL . 'guang/service/v2/article/getArticleByBrand', $param);
}
}
... ...
... ... @@ -591,19 +591,33 @@ class ShopModel
* @param type string $tag 搜索内容
* @return array []
*/
public static function getArticle($tag = '')
public static function getArticle($shopId)
{
$result = array();
if (empty($tag)) {
$articleData = array();
$brands = self::getShopsBrands($shopId);
if (empty($brands)) {
return $result;
}
foreach ($brands as $val) {
$article = GuangListData::getArticleByBrand($val['brand_id'], 3);
if (!empty($article['data'])) {
$articleData = array_merge($articleData, $article['data']);
}
if (count($articleData) > 3) {
break;
}
}
$article = GuangListData::article('1,2,3', 0, 0, '', 0, $tag, '', 3);
if (empty($article['data']['list']['artList'])) {
if (empty($articleData)) {
return $result;
}
foreach ($article['data']['list']['artList'] as $artList) {
foreach ($articleData as $key => $artList) {
if ($key >= 3) {
break;
}
$result['trendList'][] = array(
'href' => $artList['url'],
'src' => self::imageView2(substr($artList['src'], 0, strpos($artList['src'], '?')), 264, 173),
... ... @@ -611,7 +625,7 @@ class ShopModel
'Subtitle' => $artList['intro']
);
}
//等于3个才显示
if (count($result['trendList']) < 3) {
return array();
}
... ...
... ... @@ -361,7 +361,7 @@ class IndexController extends WebAction
'shopIndexPage' => true,
'pathNav' => false, // pathNav数据结构同其他页面
'coupon' => false, // 先不做
'trendInfo' => ShopModel::getArticle($domain),
'trendInfo' => ShopModel::getArticle($shopId),
),
ShopModel::getData($shopId, $parameters)
);
... ...