Authored by uedxwg

Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop

... ... @@ -39,6 +39,7 @@ class CacheConfig
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'; // 品牌信息
const KEY_ACTION_PRODUCT_BRAND_LOGO_DOMAIN = 'key_action_product_brand_logo_domain'; // 品牌信息通过域名取得
const KEY_ACTION_SEARCH_SEARCH = 'key_action_search_search'; // 搜索的数据
const KEY_ACTION_SEARCH_FILTER = 'key_action_search_filter'; // 搜索的过滤条件
... ...
... ... @@ -213,4 +213,15 @@ class BrandData
return Yohobuy::yarClient(Yohobuy::SERVICE_URL . '/shops/service/v1/brand', 'getBrandByids', array($id ));
}
/**
* 通过域名获取品牌LOGO信息
*
* @param int $id 用户ID
* @return array
*/
public static function getBrandLogoByDomain($domain)
{
return Yohobuy::yarClient(Yohobuy::SERVICE_URL . '/shops/service/v1/brand', 'getBrandByDomain', array($domain ));
}
}
... ...
... ... @@ -15,6 +15,7 @@ use Api\Yohobuy;
*/
class DetailData
{
const URI_PACKAGE_ARTICLE = 'guang/service/v2/article/';
const URI_PACKAGE_AUTHOR = 'guang/service/v1/author/';
... ... @@ -38,13 +39,11 @@ class DetailData
$clientType = $isApp ? 'iphone' : 'h5';
// 获取资讯
$article = Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URI_PACKAGE_ARTICLE, 'getArticle', array($id, $clientType));
if (!isset($article['tag'])) {
$article = Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URI_PACKAGE_ARTICLE, 'getArticle', array($id, $clientType), 3600);
if (!isset($article['author_id'])) {
return $result;
}
else {
$result['getArticle'] = $article;
}
// 获取作者信息
Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . self::URI_PACKAGE_AUTHOR, 'getAuthor', array($article['author_id'], $clientType), function ($retval) use (&$result) {
... ... @@ -62,9 +61,11 @@ class DetailData
});
// 获取资讯相关的其它资讯
if (isset($article['tag'])) {
Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . self::URI_PACKAGE_ARTICLE, 'getOtherArticle', array($article['tag'], $id, 0, 3, $clientType), function ($retval) use (&$result) {
$result['getOtherArticle'] = empty($retval) ? array() : $retval;
});
}
// 调用发起请求
Yohobuy::yarConcurrentLoop();
... ...
... ... @@ -9,14 +9,21 @@ var $searchBox = $('.search-box'),
$indexSearch = $('.index-search'),
$indexLogo = $('.index-logo');
var $search = $searchBox.children('input'),
$cancelSearch = $indexSearch.children('.no-search');
var $search = $searchBox.children('input[type="text"]'),
$cancelSearch = $indexSearch.children('.no-search'),
$searchIcon = $searchBox.children('.search-icon');
require('../common');
$search.on('focus', function() {
$indexSearch.addClass('action');
$indexLogo.addClass('action');
}).on('input', function() {
if ($search.val() === '') {
$searchIcon.addClass('empty');
} else {
$searchIcon.removeClass('empty');
}
});
$cancelSearch.on('touchstart', function() {
... ... @@ -27,7 +34,7 @@ $cancelSearch.on('touchstart', function() {
});
$searchBox.children('.clear-text').on('touchstart', function() {
$search.val('').focus();
$search.val('').focus().trigger('input');
});
$searchBox.children('.search-icon').on('touchstart', function() {
... ...
... ... @@ -81,9 +81,13 @@
}
.search-icon {
right: 10rem / $pxConvertRem;
color: #000;
&.empty {
color: #e6e6e6;
}
}
}
.no-search {
display: none;
... ...
... ... @@ -9,7 +9,7 @@
<input type="hidden" name="from" value="search">
<input type="text" name="query" placeholder="搜索" autocomplete="off">
<span class="iconfont clear-text">&#xe623;</span>
<span class="iconfont search-icon">&#xe60f;</span>
<span class="iconfont search-icon empty">&#xe60f;</span>
</div>
</form>
</div>
... ...
... ... @@ -23,7 +23,7 @@ class BoysController extends AbstractAction
}
// 设置COOKIE标识用户访问过该页面了
Index\HomeModel::setSwitchToCookie(Index\HomeModel::COOKIE_NAME_BOYS);
// Index\HomeModel::setSwitchToCookie(Index\HomeModel::COOKIE_NAME_BOYS);
// 设置网站标题
$this->setTitle('男生首页');
... ...
... ... @@ -18,7 +18,7 @@ class GirlsController extends AbstractAction
$this->setExpires(300); // 缓存5分钟
// 设置COOKIE标识用户访问过该页面了
Index\HomeModel::setSwitchToCookie(Index\HomeModel::COOKIE_NAME_GIRLS);
// Index\HomeModel::setSwitchToCookie(Index\HomeModel::COOKIE_NAME_GIRLS);
// 设置网站标题
$this->setTitle('女生首页');
... ...
... ... @@ -18,7 +18,7 @@ class KidsController extends AbstractAction
$this->setExpires(300); // 缓存5分钟
// 设置COOKIE标识用户访问过该页面了
Index\HomeModel::setSwitchToCookie(Index\HomeModel::COOKIE_NAME_KIDS);
// Index\HomeModel::setSwitchToCookie(Index\HomeModel::COOKIE_NAME_KIDS);
// 设置网站标题
$this->setTitle('潮童首页');
... ...
... ... @@ -18,7 +18,7 @@ class LifestyleController extends AbstractAction
$this->setExpires(300); // 缓存5分钟
// 设置COOKIE标识用户访问过该页面了
Index\HomeModel::setSwitchToCookie(Index\HomeModel::COOKIE_NAME_LIFESTYLE);
// Index\HomeModel::setSwitchToCookie(Index\HomeModel::COOKIE_NAME_LIFESTYLE);
// 设置网站标题
$this->setTitle('创意生活首页');
... ...
... ... @@ -16,11 +16,6 @@ class SearchController extends AbstractAction
*/
public function indexAction()
{
// 设置客户端浏览器1小时内不改变
$this->setLastModified(mktime(date('H'), 0, 0, date('n'), date('j'), date('Y')));
// 设置浏览器缓存5分钟
$this->setExpires(300); // 缓存5分钟
$this->setNavHeader('搜索', true, SITE_MAIN);
//$this->_view->html('search');
... ...
... ... @@ -168,7 +168,7 @@ class ListModel
}
// 调用接口查询数据
$brandLogo = BrandData::getBrandLogo($id);
$brandLogo = BrandData::getBrandLogo($id); var_dump($brandLogo); exit;
// 处理返回的数据
if (isset($brandLogo['data'][0])) {
$result = array(
... ... @@ -194,6 +194,53 @@ class ListModel
}
/**
* 根据品牌ID获取品牌LOGO
*
* @param int $id 品牌ID
* @param string $title 品牌标题
* @return array | false
*/
public static function getBrandLogoByDomain($domain, &$title)
{
$result = false;
if (USE_CACHE) {
$key = CacheConfig::KEY_ACTION_PRODUCT_BRAND_LOGO_DOMAIN . strval($domain);
// 先尝试获取一级缓存(master), 有数据则直接返回.
$result = Cache::get($key, 'master');
if (!empty($result)) {
return $result;
}
}
// 调用接口查询数据
$brandLogo = BrandData::getBrandLogoByDomain($domain);
// 处理返回的数据
if (isset($brandLogo['data'])) {
$result = array(
'id' => $brandLogo['data']['id'],
'url' => Helpers::url('', null, $brandLogo['data']['brand_domain']),
'thumb' => Helpers::getImageUrl($brandLogo['data']['brand_ico'], 75, 40),
'name' => $brandLogo['data']['brand_name'],
);
$title = $result['name'];
}
if (USE_CACHE) {
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if (empty($result)) {
$result = Cache::get($key, 'slave');
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
else {
Cache::set($key, $result); // 缓存1小时
}
}
return $result;
}
/**
* 获取所有的品牌名称列表
*
* @return array(
... ...
... ... @@ -28,6 +28,8 @@ class IndexController extends AbstractAction
$gender = $this->get('gender', '1,2,3');
if (is_string($gender)) {
$gender = rawurldecode($gender);
} else {
$gender = Helpers::getGenderByCookie();
}
// // 设置侧边栏逛的默认选中状态
// if ($gender === '1,3') {
... ...
... ... @@ -26,19 +26,27 @@ class InfoController extends AbstractAction
$this->error();
}
$data = array();
$data['guangDetail'] = true; // 模板中使用JS的标识
$data['guang']['id'] = $id;
// 标识是不是APP访问的
$isApp = null !== $this->get('app_version', null);
// 获取详情内容信息, 异常则跳到错误页面
$detail = DetailData::package($id, $isApp);
if (empty($detail['getArticle'])) {
$this->error();
}
// 标识是否是微信访问
$isWeixin = stripos($this->server('HTTP_USER_AGENT', ''), 'MicroMessenger') !== false;
// WAP上设置头部导航
if (!$isApp) {
if (!$isApp && !$isWeixin) {
$this->setNavHeader('逛', true, SITE_MAIN);
}
// 获取详情内容信息, 异常则跳到错误页面
$detail = DetailData::package($id, $isApp);
if (empty($detail['getArticle'])) {
$this->_view->display('index', $data);
return;
}
$data = array();
$data['guangDetail'] = true; // 模板中使用JS的标识
$data['guang']['id'] = $id;
... ... @@ -209,8 +217,7 @@ class InfoController extends AbstractAction
if ($type == 'fav') {
}
}
while (false);
} while (false);
}
}
... ...
... ... @@ -85,6 +85,8 @@ class PlusstarController extends AbstractAction
$channel = $this->get('yh_channel');
// 标识是不是APP客户端
$isApp = is_numeric($channel);
// 标识是否是微信访问
$isWeixin = stripos($this->server('HTTP_USER_AGENT', ''), 'MicroMessenger') !== false;
// APP访问时通过频道参数判断性别
if ($isApp) {
switch (intval($channel)) {
... ... @@ -161,7 +163,7 @@ class PlusstarController extends AbstractAction
}
// 设置头部信息
if (!$isApp) {
if (!$isApp && !$isWeixin) {
$this->setNavHeader($data['ps']['name'], true, SITE_MAIN);
}
... ... @@ -170,7 +172,7 @@ class PlusstarController extends AbstractAction
$data['shareLink'] = $defaultUrl;
$data['shareTitle'] = $data['ps']['name'];
$data['shareDesc'] = (mb_strlen($data['ps']['intro'],'utf-8') > 800) ? mb_substr($data['ps']['intro'], 0, 800, 'utf-8') . '...' : $data['ps']['intro'];
$data['shareDesc'] = (mb_strlen($data['ps']['intro'], 'utf-8') > 800) ? mb_substr($data['ps']['intro'], 0, 800, 'utf-8') . '...' : $data['ps']['intro'];
$data['shareImg'] = $data['ps']['logo'];
$brandInfo = array();
... ...
... ... @@ -85,18 +85,23 @@ class IndexController extends AbstractAction
$this->go(SITE_MAIN);
}
/* 通过品牌域名找到对应的品牌ID */
$domainList = Product\ListModel::getAllBrandDomains();
$brandIds = array_keys($domainList, $domain);
// 存标题信息
$title = '';
$brandLogo = Product\ListModel::getBrandLogoByDomain($domain, $title);
$brandId = 0;
if (isset($brandIds[0])) {
$brandId = $brandIds[0];
if ($brandLogo && isset($brandLogo['id'])) {
$brandId = $brandLogo['id'];
}
/* 通过品牌域名找到对应的品牌ID */
// $domainList = Product\ListModel::getAllBrandDomains();
// $brandIds = array_keys($domainList, $domain);
// $brandId = 0;
// if (isset($brandIds[0])) {
// $brandId = $brandIds[0];
// }
// 当前的登录用户UID
$uid = $this->getUid();
// 存标题信息
$title = '';
/* 搜索框相关 */
$from = $this->get('from');
... ... @@ -131,12 +136,13 @@ class IndexController extends AbstractAction
// 从搜索页过来的,显示搜索框, 和进入品牌引导信息
if ($from === 'search') {
$data['goodList'] = array();
$data['goodList']['brandWay'] = \Product\ListModel::getBrandLogoByIds($brandId, $title);
//$data['goodList']['brandWay'] = \Product\ListModel::getBrandLogoByIds($brandId, $title);
$data['goodList']['brandWay'] = $brandLogo;
$data['goodList']['search']['default'] = $query;
$data['goodList']['search']['url'] = Helpers::url('', null, 'search');
}
// 品牌一览过来的展示品牌介绍和LOGO
else {
elseif ($brandId !== 0) {
$data['brandHome'] = \Product\ListModel::getBrandIntro($brandId, $uid, $title);
$data['goodList'] = array();
}
... ...
... ... @@ -40,7 +40,7 @@ class OptController extends AbstractAction
}
/* 判断用户是否登录 */
$uid = $this->getUdid();
$uid = $this->getUid();
if (!$uid) {
$referer = $this->server('HTTP_REFERER', SITE_MAIN);
$result = array('code' => 400, 'message' => '未登录', 'data' => Helpers::url('/signin.html', array('refer' => $referer)));
... ... @@ -60,6 +60,7 @@ class OptController extends AbstractAction
$result = array('code' => 401, 'message' => '参数不正确', 'data' => false);
break;
}
} while (false);
$this->echoJson($result);
... ...
<?php
use Yaf\Application;
define('SITE_MAIN', 'http://mtesth5.yohobuy.com'); // 网站主域名
define('SITE_MAIN', 'http://m.yohobuy.com'); // 网站主域名
define('OLD_MAIN', 'http://m.yohobuy.com'); // 网站旧域名
define('COOKIE_DOMAIN', '.yohobuy.com'); // COOKIE作用域
define('SUB_DOMAIN', '.mtesth5.yohobuy.com'); // 子域名后缀
define('SUB_DOMAIN', '.m.yohobuy.com'); // 子域名后缀
define('USE_CACHE', true); // 缓存的开关
define('APPLICATION_PATH', dirname(__DIR__)); // 应用目录
define('ROOT_PATH', dirname(dirname(APPLICATION_PATH))); // 根目录
... ...
User-agent: *
Disallow: /
\ No newline at end of file
Disallow:
\ No newline at end of file
... ...