Authored by hf

fixes bug refs YW-905 YW864

framework @ 75bbc3b0
Subproject commit 119c247f5cf929aa1e059e40609bb16dd6b58f05
Subproject commit 75bbc3b075de19f239532f60c5995d06c5f814e2
... ...
... ... @@ -387,16 +387,4 @@ class AbstractAction extends Controller_Abstract
$this->_view->assign('sideNav', \Index\SideModel::getLeftNav($guangChoosed));
}
/**
* 设置首页以及频道页顶部信息
*
* @return void
*/
protected function setHomeChannelHeader()
{
$header['searchUrl'] = '/search';
$this->_view->assign('homeHeader', $header);
}
}
... ...
... ... @@ -38,5 +38,6 @@ class CacheConfig
const KEY_ACTION_PRODUCT_BRAND = 'key_action_product_brand'; // 品类商品列表
const KEY_ACTION_PRODUCT_BRAND_DOMAINS = 'key_action_product_brand_domains'; // 所有品牌域名列表
const KEY_ACTION_PRODUCT_BRAND_NAMES = 'key_action_product_brand_names'; // 所有品牌名称列表
const KEY_ACTION_PRODUCT_BRAND_LOGO = 'key_action_product_brand_logo'; // 品牌信息
}
... ...
... ... @@ -45,9 +45,9 @@ class BrandData
$param['method'] = 'app.brand.brandlist';
$param['yh_channel'] = $channel;
$param['client_secret'] = Sign::getSign($param);
$urlList['brandList'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL, $param, 3600); // 有缓存1小时
$urlList['brandList'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL, $param);
return Yohobuy::getMulti($urlList);
return Yohobuy::getMulti($urlList, array(), 3600); // 有缓存1小时
}
/**
... ... @@ -202,4 +202,15 @@ class BrandData
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 获取品牌LOGO信息
*
* @param int $id 用户ID
* @return array
*/
public static function getBrandLogo($id)
{
return Yohobuy::yarClient(Yohobuy::SERVICE_URL . '/shops/service/v1/brand', 'getBrandByids', array($id ));
}
}
... ...
... ... @@ -246,12 +246,21 @@ class Helpers
$result['text'] = $articleData['intro'];
$result['publishTime'] = $articleData['publish_time'];
$result['pageView'] = $articleData['views_num'];
// 收藏
if ($isApp) {
$result['collect'] = array();
$result['collect']['isCollected'] = isset($articleData['isFavor']) && $articleData['isFavor'] === 'Y';
$result['collect']['url'] = $articleData['url'];
}
// 点赞
else {
$result['like'] = array();
$result['like']['count'] = $articleData['praise_num'];
$result['like']['isLiked'] = isset($articleData['isPraise']) && $articleData['isPraise'] === 'Y';
// 收藏
// $result['collect'] = array();
// $result['collect']['isCollected'] = isset($articleData['isFavor']) && $articleData['isFavor'] === 'Y';
}
// 分享链接
$result['share'] = $isApp && isset($articleData['share']['url']) ? $articleData['share']['url'] : false;
// 判断是否显示作者信息
... ...
... ... @@ -20,46 +20,39 @@ class BoysController extends AbstractAction
// 设置网站标题
$this->setTitle('男生首页');
// 显示侧边栏
$this->setNavSide();
// 设置顶部信息(搜索)
$this->setHomeChannelHeader();
$this->setNavSide('boys');
// 渲染模板并输出
$this->_view->display('index', array(
'boysHomePage' => true,
'showFooterTab'=> false,
'homeHeader' => array('searchUrl' => Helpers::url('/search.html', null, 'search')),
'showFooterTab' => false,
'maybeLike' => true,
'content' => Index\HomeModel::getBoysFloor(),
'pageFooter' => true,
));
}
/**
* 异步获取男首底部banner数据
* @return string 底部Banner数据
*/
public function bottomBannerAction()
{
do
{
if(!$this->isAjax())
{
do {
if (!$this->isAjax()) {
break;
}
$channel = Helpers::getChannelByCookie();
$bottomBanner = Index\HomeModel::getBottomBanner($channel);
if (empty($bottomBanner)) {
break;
}
if($bottomBanner)
{
$this->echoJson($bottomBanner);
}
}
while(false);
echo ' ';
} while (false);
}
}
... ...
... ... @@ -20,45 +20,39 @@ class GirlsController extends AbstractAction
// 设置网站标题
$this->setTitle('女生首页');
// 显示侧边栏
$this->setNavSide();
// 设置顶部信息(搜索)
$this->setHomeChannelHeader();
$this->setNavSide('girls');
// 渲染模板并输出
$this->_view->display('index', array(
'grilsHomePage' => true,
'showFooterTab'=> false,
'homeHeader' => array('searchUrl' => Helpers::url('/search.html', null, 'search')),
'showFooterTab' => false,
'maybeLike' => true,
'content' => Index\HomeModel::getGirlsFloor(),
'pageFooter' => true,
));
}
/**
* 异步获取女首底部banner数据
* @return string 底部Banner数据
*/
public function bottomBannerAction()
{
do
{
if(!$this->isAjax())
{
do {
if (!$this->isAjax()) {
break;
}
$channel = Helpers::getChannelByCookie();
$bottomBanner = Index\HomeModel::getBottomBanner($channel);
if (empty($bottomBanner)) {
break;
}
if($bottomBanner)
{
$this->echoJson($bottomBanner);
}
}
while(false);
echo ' ';
} while (false);
}
}
... ...
... ... @@ -15,7 +15,7 @@ class IndexController extends AbstractAction
public function indexAction()
{
// 先检查COOKIE是否有访问过, 有则跳转到相应的频道页
Index\HomeModel::goSwitchChannel();
// Index\HomeModel::goSwitchChannel();
// 渲染模板
$this->_view->display('index', array(
... ...
... ... @@ -20,13 +20,12 @@ class KidsController extends AbstractAction
$this->setTitle('潮童首页');
// 显示侧边栏
$this->setNavSide();
// 设置顶部信息(搜索)
$this->setHomeChannelHeader();
// 渲染模板并输出
$this->_view->display('index', array(
'kidsHomePage' => true,
'showFooterTab'=> false,
'homeHeader' => array('searchUrl' => Helpers::url('/search.html', null, 'search')),
'showFooterTab' => false,
'maybeLike' => true,
'content' => Index\HomeModel::getKidsFloor(),
'pageFooter' => true,
... ...
... ... @@ -20,13 +20,12 @@ class LifestyleController extends AbstractAction
$this->setTitle('创意生活首页');
// 显示侧边栏
$this->setNavSide();
// 设置顶部信息(搜索)
$this->setHomeChannelHeader();
// 渲染模板并输出
$this->_view->display('index', array(
'lifestyleHomePage' => true,
'showFooterTab'=> false,
'homeHeader' => array('searchUrl' => Helpers::url('/search.html', null, 'search')),
'showFooterTab' => false,
'maybeLike' => true,
'content' => Index\HomeModel::getLifestyleFloor(),
'pageFooter' => true,
... ...
... ... @@ -175,6 +175,8 @@ class SearchController extends AbstractAction
*/
public function searchAction()
{
$data = array();
if ($this->isAjax()) {
// 过滤请求参数
$condition = filter_input_array(INPUT_GET, array(
... ... @@ -207,7 +209,6 @@ class SearchController extends AbstractAction
$type = $this->get('type', '');
$order = Helpers::transOrder($orderVal, $type);
$data = array();
// 查询品类或品牌数据
if (!isset($condition['query'])) {
$condition['order'] = $order;
... ... @@ -237,14 +238,14 @@ class SearchController extends AbstractAction
}
$listData = array();
}
}
if (empty($data)) {
if (empty($data['new'])) {
echo ' ';
} else {
$this->_view->display('page', $data);
}
}
}
/**
* Ajax异步获取筛选数据
... ... @@ -252,6 +253,8 @@ class SearchController extends AbstractAction
*/
public function filterAction()
{
$data = array();
if ($this->isAjax()) {
// 过滤请求参数
$condition = filter_input_array(INPUT_GET, array(
... ... @@ -278,22 +281,19 @@ class SearchController extends AbstractAction
$condition['gender'] = rawurldecode($condition['gender']);
}
$data = array();
$listData = SearchData::searchByCondition($condition);
// 处理返回的数据
if (isset($listData['data']) && isset($listData['data']['filter'])) {
$data['filter'] = ListProcess::getFilterData($listData['data']['filter']);
}
$listData = array();
}
if (empty($data)) {
echo ' ';
} else {
$this->_view->display('filter', $data);
}
} else {
echo ' ';
}
}
/**
... ...
... ... @@ -134,9 +134,9 @@ class ShoppingCartController extends AbstractAction
public function tplAction()
{
if($this->isAjax()) {
$data = file_get_contents('../../../template/m.yohobuy.com/partials/shopping-cart/chose-panel.phtml');
//$data = file_get_contents('../../../template/m.yohobuy.com/partials/shopping-cart/chose-panel.phtml');
echo($data);
//echo($data);
}
}
... ...
... ... @@ -100,6 +100,8 @@ class BrandModel
}
}
$result['pageFooter'] = true;
$brand = array();
return $result;
... ...
... ... @@ -176,6 +176,9 @@ class IndexModel
}
}
// 显示底部
$data['pageFooter'] = true;
$category = array();
$article = array();
... ...
... ... @@ -54,11 +54,11 @@ class PlusstarModel
$brandList = PlusstarData::firstBrandList($gender, $channel);
if (!empty($brandList['recom']['data']['list'][0]['data'])) {
$result['ps']['star'] = self::formatData($brandList['recom']['data']['list'][0]['data'], $gender, true);
$result['leftName'] = isset($brandList['recom']['data']['brand_type_name']) ? $brandList['recom']['data']['brand_type_name'] : '';
//$result['ps']['sName'] = isset($brandList['recom']['data']['brand_type_name']) ? $brandList['recom']['data']['brand_type_name'] : '';
}
if (!empty($brandList['all']['data']['list'][0]['data'])) {
$result['ps']['plus'] = self::formatData($brandList['all']['data']['list'][0]['data'], $gender, true);
$result['rightName'] = isset($brandList['all']['data']['brand_type_name']) ? $brandList['all']['data']['brand_type_name'] : '';
//$result['ps']['pName'] = isset($brandList['all']['data']['brand_type_name']) ? $brandList['all']['data']['brand_type_name'] : '';
}
if (USE_CACHE) {
... ... @@ -110,11 +110,11 @@ class PlusstarModel
$brandList = PlusstarData::brandList($gender, $channel);
if (!empty($brandList['star']['data']['list'][0]['data'])) {
$result['ps']['star'] = self::formatData($brandList['star']['data']['list'][0]['data'], $gender, false);
$result['leftName'] = isset($brandList['star']['data']['brand_type_name']) ? $brandList['star']['data']['brand_type_name'] : '';
//$result['ps']['pName'] = isset($brandList['star']['data']['brand_type_name']) ? $brandList['star']['data']['brand_type_name'] : '';
}
if (!empty($brandList['original']['data']['list'][0]['data'])) {
$result['ps']['plus'] = self::formatData($brandList['original']['data']['list'][0]['data'], $gender, true);
$result['leftName'] = isset($brandList['original']['data']['brand_type_name']) ? $brandList['original']['data']['brand_type_name'] : '';
//$result['ps']['sName'] = isset($brandList['original']['data']['brand_type_name']) ? $brandList['original']['data']['brand_type_name'] : '';
}
if (USE_CACHE) {
... ...
... ... @@ -59,7 +59,7 @@ class SideModel
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
else {
Cache::set(CacheConfig::KEY_COMMON_SIDE_NAV, $result);
Cache::set(CacheConfig::KEY_COMMON_SIDE_NAV, $result, 3600); // 缓存1小时
}
}
... ...
... ... @@ -124,7 +124,7 @@ class ListModel
$result = ListProcess::getListData($listData['data']);
if (!empty($listData['data']['brand'])) {
$result['brandWay'] = array(
'url' => 'http://'. $listData['data']['brand']['brand_domain'] . SUB_DOMAIN,
'url' => 'http://' . $listData['data']['brand']['brand_domain'] . SUB_DOMAIN,
'thumb' => Helpers::getImageUrl($listData['data']['brand']['brand_ico'], 75, 40),
'name' => $listData['data']['brand']['brand_name']
);
... ... @@ -147,6 +147,52 @@ class ListModel
}
/**
* 根据品牌ID获取品牌LOGO
*
* @param int $id 品牌ID
* @param string $title 品牌标题
* @return array | false
*/
public static function getBrandLogoByIds($id, &$title)
{
$result = false;
if (USE_CACHE) {
$key = CacheConfig::KEY_ACTION_PRODUCT_BRAND_INFOS . strval($id);
// 先尝试获取一级缓存(master), 有数据则直接返回.
$result = Cache::get($key, 'master');
if (!empty($result)) {
return $result;
}
}
// 调用接口查询数据
$brandLogo = BrandData::getBrandLogo($id);
// 处理返回的数据
if (isset($brandLogo['data'][0])) {
$result = array(
'url' => Helpers::url('', null, $brandLogo['data'][0]['brand_domain']),
'thumb' => Helpers::getImageUrl($brandLogo['data'][0]['brand_ico'], 75, 40),
'name' => $brandLogo['data'][0]['brand_name'],
);
$title = $result['name'];
}
if (USE_CACHE) {
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if (empty($result)) {
$result = Cache::get($key, 'slave');
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
else {
Cache::set($key, $result, 10800); // 缓存3小时
}
}
return $result;
}
/**
* 获取所有的品牌名称列表
*
* @return array(
... ...
... ... @@ -28,6 +28,9 @@ class PlusstarController extends AbstractAction
$data = Guang\PlusstarModel::getBrands($gender);
$data['psList'] = true; // 控制模板中的JS使用
$data['ps']['sName'] = '明星潮品';
$data['ps']['pName'] = '原创潮牌';
$data[ 'pageFooter'] = true;
$this->_view->display('list', $data);
} else {
... ... @@ -36,8 +39,11 @@ class PlusstarController extends AbstractAction
$data = Guang\PlusstarModel::getFirstBrands($gender);
$data['psList'] = true; // 控制模板中的JS使用
$data['ps']['sName'] = '设计师';
$data['ps']['pName'] = '经典潮牌';
$data[ 'pageFooter'] = true;
$this->_view->display('index', $data);
$this->_view->display('list', $data);
}
}
... ... @@ -56,6 +62,8 @@ class PlusstarController extends AbstractAction
$data = Guang\PlusstarModel::getBrands($gender);
$data['psList'] = true; // 控制模板中的JS使用
$data['ps']['sName'] = '明星潮品';
$data['ps']['pName'] = '原创潮牌';
$this->_view->display('list', $data);
}
... ...
... ... @@ -59,6 +59,7 @@ class IndexController extends AbstractAction
'goodListPage' => true,
'showDownloadApp' => true,
'goodList' => $condition,
'pageFooter' => true,
));
}
... ... @@ -77,14 +78,14 @@ class IndexController extends AbstractAction
/* 品牌域名参数 @see Bootstrap.php */
$domain = $this->param('named');
if (empty($domain)) {
$this->error();
$this->go(SITE_MAIN);
}
/* 通过品牌域名找到对应的品牌ID */
$domainList = Product\ListModel::getAllBrandDomains();
$brandIds = array_keys($domainList, $domain);
if (!isset($brandIds[0])) {
$this->error();
$this->go(SITE_MAIN);
}
// 当前的登录用户UID
... ... @@ -113,12 +114,13 @@ class IndexController extends AbstractAction
$condition['gender'] = rawurldecode($condition['gender']);
}
$data = array();
$data['goodListPage'] = true;
$data['showDownloadApp'] = true;
// 从搜索页过来的,显示搜索框, 和进入品牌引导信息
if ($from === 'search') {
$data['goodList'] = array();
$data['goodList']['brandWay'] = false;
$data['goodList']['brandWay'] = Product\ListModel::getBrandLogoByIds($brandIds[0], $title);
$data['goodList']['search']['default'] = $query;
$data['goodList']['search']['url'] = Helpers::url('', null, 'search');
}
... ... @@ -128,6 +130,7 @@ class IndexController extends AbstractAction
$data['goodList'] = array();
}
$data['goodList'] += $condition;
$data['pageFooter'] = true;
if ($title === '') {
$title = $domain;
... ...
... ... @@ -2,7 +2,6 @@
use Action\AbstractAction;
use LibModels\Wap\Product\NewsaleData;
use Product\NewsaleModel;
use Plugin\Helpers;
/**
... ... @@ -22,13 +21,12 @@ class NewsaleController extends AbstractAction
$this->setNavHeader('新品到着');
$channel = Helpers::getChannelByCookie();
$data = array();
$data['newArrivalPage'] = true;
$data['headerBanner'] = \Product\NewsaleModel::getNewFocus($channel);
// 设置一些筛选的默认参数
$data += array(
'showDownloadApp'=>true,
$data = array(
'newArrivalPage' => true,
'showDownloadApp' => true,
'pageFooter' => true,
'headerBanner' => \Product\NewsaleModel::getNewFocus($channel),
'brand' => '0',
'sort' => '0',
'gender' => Helpers::getGenderByCookie(),
... ... @@ -52,13 +50,12 @@ class NewsaleController extends AbstractAction
$this->setNavHeader('Sale');
$channel = Helpers::getChannelByCookie();
$data = array();
$data['discountPage'] = true;
$data['headerBanner'] = \Product\NewsaleModel::getNewFocus($channel);
// 设置一些筛选的默认参数
$data += array(
'showDownloadApp'=>true,
// 设置一些默认参数
$data = array(
'discountPage' => true,
'headerBanner' => \Product\NewsaleModel::getNewFocus($channel),
'showDownloadApp' => true,
'pageFooter' => true,
'brand' => '0',
'sort' => '0',
'gender' => Helpers::getGenderByCookie(),
... ... @@ -77,6 +74,8 @@ class NewsaleController extends AbstractAction
*/
public function selectNewSaleAction()
{
$result = array();
if ($this->isAjax()) {
$gender = $this->get('gender', null);
$brand = $this->get('brand', null);
... ... @@ -101,15 +100,13 @@ class NewsaleController extends AbstractAction
$gender, $brand, $sort, $color, $size, $price, $p_d, $channel, $dayLimit, $limit, $page, $order
);
$result = \Product\NewsaleModel::selectData($data);
}
if (empty($result)) {
echo ' ';
} else {
$this->_view->display('product', $result);
}
} else {
echo ' ';
}
}
/**
... ... @@ -119,6 +116,8 @@ class NewsaleController extends AbstractAction
*/
public function filterAction()
{
$result = array();
if ($this->isAjax()) {
$gender = $this->get('gender', null);
$brand = $this->get('brand', null);
... ... @@ -142,15 +141,13 @@ class NewsaleController extends AbstractAction
$gender, $brand, $sort, $color, $size, $price, $p_d, $channel, $dayLimit, $limit, $page, $order
);
$result = \Product\NewsaleModel::filterData($data);
}
if (empty($result)) {
echo ' ';
} else {
$this->_view->display('filter', $result);
}
} else {
echo ' ';
}
}
}
... ...