Authored by zhangxiaoru

首页

<?php
use Action\AbstractAction;
// use LibModels\Wap\Product\SearchData;
// use Plugin\DataProcess\ListProcess;
use LibModels\Wap\Product\SearchData;
use Plugin\DataProcess\ListProcess;
use Plugin\Helpers;
/**
... ... @@ -39,6 +39,7 @@ class SearchController extends AbstractAction
'shop' => FILTER_DEFAULT,
'categoryId' => FILTER_DEFAULT,
'subCategoryId' => FILTER_DEFAULT,
'title' => FILTER_DEFAULT,
'query' => FILTER_DEFAULT,
'brand' => FILTER_DEFAULT,
'sort' => FILTER_DEFAULT,
... ... @@ -106,9 +107,9 @@ class SearchController extends AbstractAction
// 跳转到品牌商品列表页
if ($domain !== null) {
$url = Helpers::url('', array(
'from' => 'search',
'query' => $query
), $domain);
'from' => 'search',
'query' => $query
), $domain);
$this->go($url);
}
}
... ... @@ -122,7 +123,7 @@ class SearchController extends AbstractAction
if (empty($classNames)) {
break;
}
/* 精确查一级品类 */
$sorts = array_keys($classNames['first'], $query, true);
if (isset($sorts[0])) {
... ... @@ -151,13 +152,11 @@ class SearchController extends AbstractAction
if ($isQueryFirstClass) {
$this->setTitle('全部' . $query);
$this->setNavHeader('全部' . $query, true, SITE_MAIN);
}
// 搜索是二级品类
} // 搜索是二级品类
elseif ($isQuerySecondClass) {
$this->setTitle($query);
$this->setNavHeader($query, true, SITE_MAIN);
}
// 搜索其它内容
} // 搜索其它内容
else {
$from = $this->get('from');
if ($haveQuery || $from) {
... ... @@ -196,6 +195,11 @@ class SearchController extends AbstractAction
$listData = array();
}
if($condition['title']){
$this->setTitle($condition['title']);
$this->setNavHeader($condition['title'], true, SITE_MAIN);
}
$this->_view->display('list', $data);
}
... ... @@ -254,8 +258,7 @@ class SearchController extends AbstractAction
// 为了兼容现在运营在用的p_d
if (isset($condition['p_d'])) {
$condition['p_d'] = rawurldecode($condition['p_d']);
}
// 转换折扣
} // 转换折扣
elseif (isset($condition['discount'])) {
$condition['p_d'] = rawurldecode($condition['discount']);
unset($condition['discount']);
... ... @@ -345,8 +348,7 @@ class SearchController extends AbstractAction
// 为了兼容现在运营在用的p_d
if (isset($condition['p_d'])) {
$condition['p_d'] = rawurldecode($condition['p_d']);
}
// 转换折扣
} // 转换折扣
elseif (isset($condition['discount'])) {
$condition['p_d'] = rawurldecode($condition['discount']);
unset($condition['discount']);
... ...
... ... @@ -350,10 +350,11 @@ class ListModel
/**
* @param $data
* @param $shop_id
* @return array 返回的处理好的数据
* @author chengyao.guo
*/
public static function categoryData($data)
public static function categoryData($data , $shop_id)
{
$result = array();
$result['class'] = array();
... ... @@ -361,9 +362,13 @@ class ListModel
foreach ($data as &$item) {
array_push($result['class'], array('name' => $item['category_name']));
foreach ($item['sub'] as &$item2) {
$item2['url'] = Helpers::url('/search/list',array(
'shop' => '326'
)); // tar mark 还有其他参数
$item2['url'] = Helpers::url('/search/list', array(
'shop' => $shop_id,
'categoryId' => $item['category_id'],
'subCategoryId' => $item2['category_id'],
'title' => $item2['category_name'],
'query' => $item2['category_name'],
));
}
array_push($result['category'], array('subcategory' => $item['sub']));
}
... ... @@ -374,18 +379,22 @@ class ListModel
* 店铺所有品牌信息处理
* @author chengyao.guo
* @param $data
* @param $shop_id
* @return mixed
*/
public static function brandData($data)
public static function brandData($data,$shop_id)
{
// 处理图片链接
foreach ($data as &$item) {
$item['brand_ico'] = Images::getImageUrl($item['brand_ico'], 0, 0);
$item['url'] = Helpers::url('',array(),$item['brand_domain']);
$item['url'] = Helpers::url('/search/list', array(
'shop' => $shop_id,
'brand' => $item['brand_id'],
'title' => $item['brand_name'],
));
}
return $data;
}
/**
* 新店铺首页
* @param int $shopId 店铺id
... ...
... ... @@ -255,9 +255,8 @@ class IndexController extends AbstractAction
$result = array();
$resource = ShopData::getShopBrands($requestData['shop_id']);
if($resource['code'] === 200){
$result = ListModel::brandData($resource['data']);
$result = ListModel::brandData($resource['data'],$requestData['shop_id']);
}
// ShopData::debugOut($resource);
if(Mobile::isMobile()){
$this->setTitle('品牌');
}else{
... ... @@ -285,14 +284,13 @@ class IndexController extends AbstractAction
$result = array();
$resource = ShopData::getShopCategory($requestData['shop_id'], Helpers::getChannelByCookie(), Helpers::getGenderByCookie());
if ($resource['code'] === 200) {
$result = ListModel::categoryData($resource['data']);
$result = ListModel::categoryData($resource['data'],$requestData['shop_id']);
}
if(Mobile::isMobile()){
$this->setTitle('品类');
}else{
$this->setNavHeader('品类', true, SITE_MAIN);
}
// ShopData::debugOut($resource);
return $this->_view->display('category', array(
'productCategoryPage' => true,
'content' => $result,
... ... @@ -322,7 +320,6 @@ class IndexController extends AbstractAction
}else{
$this->setNavHeader('店铺简介', true, SITE_MAIN);
}
// ShopData::debugOut($resource);
return $this->_view->display('intro', array(
'content' => $result,
));
... ...