Authored by 郝肖肖

店铺装修 潮流资讯

@@ -129,4 +129,22 @@ class ListData @@ -129,4 +129,22 @@ class ListData
129 return $result; 129 return $result;
130 } 130 }
131 131
  132 + /**
  133 + * 通过品牌获取相关文章
  134 + * @param type $brandId 品牌id
  135 + * @param type $limit 取推荐内容的数量
  136 + * @param type $udid
  137 + * @return type []
  138 + */
  139 + public static function getArticleByBrand($brandId, $limit, $udid = '')
  140 + {
  141 + $param = Yohobuy::param();
  142 + $param['brand_id'] = $brandId;
  143 + $param['udid'] = $udid;
  144 + $param['limit'] = $limit;
  145 + $param['private_key'] = Yohobuy::$privateKeyList['web'];
  146 + $param['client_secret'] = Sign::getSign($param);
  147 +
  148 + return Yohobuy::get(Yohobuy::SERVICE_URL . 'guang/service/v2/article/getArticleByBrand', $param);
  149 + }
132 } 150 }
@@ -591,19 +591,33 @@ class ShopModel @@ -591,19 +591,33 @@ class ShopModel
591 * @param type string $tag 搜索内容 591 * @param type string $tag 搜索内容
592 * @return array [] 592 * @return array []
593 */ 593 */
594 - public static function getArticle($tag = '') 594 + public static function getArticle($shopId)
595 { 595 {
596 $result = array(); 596 $result = array();
597 - if (empty($tag)) { 597 + $articleData = array();
  598 + $brands = self::getShopsBrands($shopId);
  599 + if (empty($brands)) {
598 return $result; 600 return $result;
599 } 601 }
  602 + foreach ($brands as $val) {
  603 + $article = GuangListData::getArticleByBrand($val['brand_id'], 3);
  604 + if (!empty($article['data'])) {
  605 + $articleData = array_merge($articleData, $article['data']);
  606 + }
  607 +
  608 + if (count($articleData) > 3) {
  609 + break;
  610 + }
  611 + }
600 612
601 - $article = GuangListData::article('1,2,3', 0, 0, '', 0, $tag, '', 3);  
602 - if (empty($article['data']['list']['artList'])) { 613 + if (empty($articleData)) {
603 return $result; 614 return $result;
604 } 615 }
605 616
606 - foreach ($article['data']['list']['artList'] as $artList) { 617 + foreach ($articleData as $key => $artList) {
  618 + if ($key >= 3) {
  619 + break;
  620 + }
607 $result['trendList'][] = array( 621 $result['trendList'][] = array(
608 'href' => $artList['url'], 622 'href' => $artList['url'],
609 'src' => self::imageView2(substr($artList['src'], 0, strpos($artList['src'], '?')), 264, 173), 623 'src' => self::imageView2(substr($artList['src'], 0, strpos($artList['src'], '?')), 264, 173),
@@ -611,7 +625,7 @@ class ShopModel @@ -611,7 +625,7 @@ class ShopModel
611 'Subtitle' => $artList['intro'] 625 'Subtitle' => $artList['intro']
612 ); 626 );
613 } 627 }
614 - 628 + //等于3个才显示
615 if (count($result['trendList']) < 3) { 629 if (count($result['trendList']) < 3) {
616 return array(); 630 return array();
617 } 631 }
@@ -361,7 +361,7 @@ class IndexController extends WebAction @@ -361,7 +361,7 @@ class IndexController extends WebAction
361 'shopIndexPage' => true, 361 'shopIndexPage' => true,
362 'pathNav' => false, // pathNav数据结构同其他页面 362 'pathNav' => false, // pathNav数据结构同其他页面
363 'coupon' => false, // 先不做 363 'coupon' => false, // 先不做
364 - 'trendInfo' => ShopModel::getArticle($domain), 364 + 'trendInfo' => ShopModel::getArticle($shopId),
365 ), 365 ),
366 ShopModel::getData($shopId, $parameters) 366 ShopModel::getData($shopId, $parameters)
367 ); 367 );