Authored by xiaowei

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

... ... @@ -480,7 +480,7 @@ class WebAction extends Controller_Abstract
$header = array(
'navbars'=> \Index\HomeModel::getNavBars($channel),
'gobytype'=> 'gobuy'.$channel,
'searchcate'=>'searchcate'.$channel,
// 'searchcate'=>'searchcate'.$channel,
'header'=> true,
'apiDomain'=> $apiDomain
);
... ...
... ... @@ -20,7 +20,7 @@ class HelperSearch
//总页数
public static $pageTotal;
//总记录数
public static $total;
public static $total = 0;
//接口返回搜索条件
public static $filter;
//选中的条件
... ... @@ -142,10 +142,6 @@ class HelperSearch
}
//选中条件
$result['filters']['checkedConditions'] = self::getSelected();
if (empty($result['goods'])) {
$result['filters'] = array();
$result['opts'] = array();
}
$result['pathNav'] = isset($options['controller']) && $options['controller'] == 'Sale' ? array() : self::$listNav;
return $result;
}
... ... @@ -680,10 +676,6 @@ class HelperSearch
public static function price($filter)
{
$result = array();
//商品记录小于10,不显示价格区间
if (self::$total < 10) {
return $result;
}
$params = self::$params;
$priceId = isset($params['price']) && !empty(self::$params['price']) ? self::$params['price'] : '';
if (isset($params['price'])) {
... ... @@ -707,6 +699,10 @@ class HelperSearch
'href' => self::buildUrl($params)
);
}
//商品记录小于10,不显示价格区间
if (self::$total < 10) {
return $result;
}
if (self::checkSearch('price')) {
return array();
}
... ... @@ -777,7 +773,7 @@ class HelperSearch
$styleName = $v['style_name']."";
}
elseif ($styleNum ===1){
$styleName .= substr($v['style_name'], 0, 3).'...';
$styleName .= substr($v['style_name'], 0, 4).'...';
}
$styleNum ++;
}
... ... @@ -1086,6 +1082,10 @@ class HelperSearch
public static function getSelected()
{
$result = array();
//无结果
if (self::$total == 0 && self::$options['controller'] == 'Search') {
return $result;
}
$data = array();
foreach (self::$selected as $key => $val) {
$data[] = $val;
... ... @@ -1386,6 +1386,10 @@ class HelperSearch
*/
public static function getOpts()
{
//无结果
if (self::$total == 0 && self::$options['controller'] == 'Search') {
return array();
}
//排序方式
$result['sortType'] = array( self::orderDefault(),self::orderTime(),self::orderPrice(),self::orderDiscount());
//特殊:新品、特价、限量
... ...
{{> layout/page-footer}}
{{#if rlsEnv}}
<script src="http://cdn.yoho.cn/yohobuy/{{version}}/lib.js"></script>
<script src="http://cdn.yoho.cn/yohobuy/{{version}}/index.js"></script>
{{/if}}
{{#if preEnv}}
<script src="http://cdn.yoho.cn/yohobuy/{{version}}/lib.js"></script>
<script src="http://cdn.yoho.cn/yohobuy/{{version}}/index-debug.js"></script>
{{/if}}
{{#if testEnv}}
<script src="http://static.buy.test.yoho.cn/dist/yohobuy/{{version}}/lib.js"></script>
<script src="http://static.buy.test.yoho.cn/dist/yohobuy/{{version}}/index-debug.js"></script>
{{/if}}
{{#if devEnv}}
<script src="http://localhost:8001/static/js/sea.js?nowrap"></script>
<script>
seajs.config({
base: 'http://localhost:8001/'
});
</script>
{{/if}}
{{> layout/use}}
{{> layout/analysis}}
</body>
</html>
{{> layout/page-footer}}
{{#if rlsEnv}}
<script src="http://cdn.yoho.cn/yohobuy/{{version}}/lib.js"></script>
<script src="http://cdn.yoho.cn/yohobuy/{{version}}/index.js"></script>
{{/if}}
{{#if preEnv}}
<script src="http://cdn.yoho.cn/yohobuy/{{version}}/lib.js"></script>
<script src="http://cdn.yoho.cn/yohobuy/{{version}}/index-debug.js"></script>
{{/if}}
{{#if testEnv}}
<script src="http://cdn.yoho.cn/yohobuy/{{version}}/lib.js"></script>
<script src="http://cdn.yoho.cn/yohobuy/{{version}}/index-debug.js"></script>
{{/if}}
{{#if devEnv}}
<script src="http://localhost:8001/static/js/sea.js?nowrap"></script>
<script>
seajs.config({
base: 'http://localhost:8001/'
});
</script>
{{/if}}
{{> layout/use}}
{{> layout/analysis}}
</body>
</html>
... ...
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<meta name="renderer" content="webkit">
<meta name="keywords" content="{{keywords}}">
<meta name="description" content="{{description}}">
<title>{{title}}</title>
<link rel="dns-prefetch" href="//cdn.yoho.cn">
<link rel="dns-prefetch" href="//static.yohobuy.com">
<link rel="dns-prefetch" href="//img10.static.yhbimg.com">
<link rel="dns-prefetch" href="//img11.static.yhbimg.com">
<link rel="dns-prefetch" href="//img12.static.yhbimg.com">
<link rel="dns-prefetch" href="//img13.static.yhbimg.com">
{{#if rlsEnv}}
<link rel="stylesheet" href="http://cdn.yoho.cn/yohobuy/{{version}}/index.css">
{{/if}}
{{#if preEnv}}
<link rel="stylesheet" href="http://cdn.yoho.cn/yohobuy/{{version}}/index.css">
{{/if}}
{{#if testEnv}}
<link rel="stylesheet" href="http://static.buy.test.yoho.cn/dist/yohobuy/{{version}}/index.css">
{{/if}}
{{#if devEnv}}
<link rel="stylesheet" href="http://webstatic.dev.yohobuy.com/css/index.css">
{{/if}}
</head>
<body>
{{> layout/page-header}}
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<meta name="renderer" content="webkit">
<meta name="keywords" content="{{keywords}}">
<meta name="description" content="{{description}}">
<title>{{title}}</title>
<link rel="dns-prefetch" href="//cdn.yoho.cn">
<link rel="dns-prefetch" href="//static.yohobuy.com">
<link rel="dns-prefetch" href="//img10.static.yhbimg.com">
<link rel="dns-prefetch" href="//img11.static.yhbimg.com">
<link rel="dns-prefetch" href="//img12.static.yhbimg.com">
<link rel="dns-prefetch" href="//img13.static.yhbimg.com">
{{#if rlsEnv}}
<link rel="stylesheet" href="http://cdn.yoho.cn/yohobuy/{{version}}/index.css">
{{/if}}
{{#if preEnv}}
<link rel="stylesheet" href="http://cdn.yoho.cn/yohobuy/{{version}}/index.css">
{{/if}}
{{#if testEnv}}
<link rel="stylesheet" href="http://cdn.yoho.cn/yohobuy/{{version}}/index.css">
{{/if}}
{{#if devEnv}}
<link rel="stylesheet" href="http://webstatic.dev.yohobuy.com/css/index.css">
{{/if}}
</head>
<body>
{{> layout/page-header}}
{{> layout/simple-header}}
\ No newline at end of file
... ...
<?php
use Action\WebAction;
use WebPlugin\Cache;
use Configs\WebCacheConfig;
use WebPlugin\AuthCode;
use Index\HomeModel;
class ToolsController extends WebAction
{
public function init()
{
$valid_passwords = array ('test' => '123456');
$valid_users = array_keys($valid_passwords);
$user = $pass = '';
if(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_USER']))
{
$user = $_SERVER['PHP_AUTH_USER'];
$pass = $_SERVER['PHP_AUTH_PW'];
}
$validated = (in_array($user, $valid_users)) && ($pass == $valid_passwords[$user]);
if (!$validated) {
header('WWW-Authenticate: Basic realm="www.yohobuy.com"');
header('HTTP/1.0 401 Unauthorized');
die ("Not authorized");
}
}
/**
* 缓存html
*
*/
public function cacheAction()
{
//频道=>key
$channels = array(
'导航' => WebCacheConfig::KEY_WEB_HOME_NAVBAR_DATA,
'男生首页'=> WebCacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.HomeModel::CODE_BOYS_CHANNEL,
'女生首页'=> WebCacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.HomeModel::CODE_GIRLS_CHANNEL,
'kids首页'=> WebCacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.HomeModel::CODE_KIDS_CHANNEL,
'lifestyle首页'=> WebCacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.HomeModel::CODE_LIFESTYLE_CHANNEL,
);
$html = '';
foreach ($channels as $key => $val) {
$url = '/tools/cacheclear?key='.urlencode(AuthCode::encode($val, 'yohobuy'));
$html.= sprintf('<li><a href="%s" target="_blank">清除%s缓存</a></li>',$url, $key);
}
echo $html;
}
/**
* 清除缓存
*
* @return json
*/
public function cacheclearAction()
{
$key = $this->get('key');
if(!empty($key)) {
$key = AuthCode::decode($key, 'yohobuy');
if(!empty($key)) {
//导航清除
if($key == WebCacheConfig::KEY_WEB_HOME_NAVBAR_DATA) {
$list = array(HomeModel::COOKIE_NAME_BOYS, HomeModel::COOKIE_NAME_GIRLS, HomeModel::COOKIE_NAME_KIDS, HomeModel::COOKIE_NAME_LIFESTYLE);
foreach ($list as $val) {
Cache::delete($key.'_'.$val);
}
} else {
Cache::delete($key);
}
echo '清除成功';
}
}
}
public function logAction()
{
print_r($_SERVER);
}
}
<?php
use Action\WebAction;
use WebPlugin\Cache;
use Configs\WebCacheConfig;
use WebPlugin\AuthCode;
use Index\HomeModel;
use Api\Yohobuy;
use Api\Sign;
use LibModels\Web\Home\IndexData;
class ToolsController extends WebAction
{
public function init()
{
if(APPLICATION_ENV == 'production') {
$valid_passwords = array ('yoho' => '9646abcdef');
} else {
$valid_passwords = array ('test' => '123456');
}
$valid_users = array_keys($valid_passwords);
$user = $pass = '';
if(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_USER']))
{
$user = $_SERVER['PHP_AUTH_USER'];
$pass = $_SERVER['PHP_AUTH_PW'];
}
$validated = (in_array($user, $valid_users)) && ($pass == $valid_passwords[$user]);
if (!$validated) {
header('WWW-Authenticate: Basic realm="www.yohobuy.com"');
header('HTTP/1.0 401 Unauthorized');
die ("Not authorized");
}
}
/**
* 工具首页
*/
public function indexAction()
{
$html = '<br/><h2>工具首页</h2><br/>';
$channels = array('JAVA API'=>'/tools/javaapi', '缓存页面' =>'/tools/cache');
foreach($channels as $name => $url) {
$html .= sprintf('<li style="font-size:18px;"><a href="%s" target="_blank">%s</a></li>',$url, $name);
}
echo $html;
}
/**
* java api测试
*
*/
public function javaapiAction()
{
$html = '<br/><h3>java api测试</h3><br/>';
$channels = array('获取资源位'=> $this->getResourceUrl(), '获取最新上架' =>'');
foreach($channels as $name => $url) {
$html .= sprintf('<li style="font-size:18px;"><a href="%s" target="_blank">%s</a></li>',$url, $name);
}
echo $html;
}
/**
* 获取资源位地址
*
* @return string
*/
private function getResourceUrl()
{
$client_type ='web';
$content_code = '0c911d3000f52e8ca7cffb74f5864c29';
$params = Yohobuy::param();
$params['content_code'] = $content_code;
$params['client_type'] = $client_type;
$params['private_key'] = Yohobuy::$privateKeyList[$client_type];
$params['client_secret'] = Sign::getSign($params);
return Yohobuy::httpBuildQuery(Yohobuy::SERVICE_URL.IndexData::URL_OPERATIONS_RESOURCE_GET, $params);
}
/**
* 缓存html
*/
public function cacheAction()
{
//频道=>key
$channels = array(
'导航' => WebCacheConfig::KEY_WEB_HOME_NAVBAR_DATA,
'男生首页'=> WebCacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.HomeModel::CODE_BOYS_CHANNEL,
'女生首页'=> WebCacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.HomeModel::CODE_GIRLS_CHANNEL,
'kids首页'=> WebCacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.HomeModel::CODE_KIDS_CHANNEL,
'lifestyle首页'=> WebCacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_'.HomeModel::CODE_LIFESTYLE_CHANNEL,
);
$html = '<br/><h3>缓存页面</h3><br/>';
foreach ($channels as $key => $val) {
$url = '/tools/cacheclear?key='.urlencode(AuthCode::encode($val, 'yohobuy'));
$html.= sprintf('<li><a href="%s" target="_blank">清除%s缓存</a></li>',$url, $key);
}
echo $html;
}
/**
* 清除缓存
*
* @return json
*/
public function cacheclearAction()
{
$key = $this->get('key');
if(!empty($key)) {
$key = AuthCode::decode($key, 'yohobuy');
if(!empty($key)) {
//导航清除
if($key == WebCacheConfig::KEY_WEB_HOME_NAVBAR_DATA) {
$list = array(HomeModel::COOKIE_NAME_BOYS, HomeModel::COOKIE_NAME_GIRLS, HomeModel::COOKIE_NAME_KIDS, HomeModel::COOKIE_NAME_LIFESTYLE);
foreach ($list as $val) {
Cache::delete($key.'_'.$val);
}
} else {
Cache::delete($key);
}
echo '清除成功';
}
}
}
public function logAction()
{
print_r($_SERVER);
}
}
?>
\ No newline at end of file
... ...
... ... @@ -9,10 +9,10 @@ use LibModels\Web\Home\IndexData;
use LibModels\Web\Product\SearchData;
use WebPlugin\DataProcess\Channel as ChannelProcess;
define('CODE_BOYS_CHANNEL_TMP', (APPLICATION_ENV == 'production' || APPLICATION_ENV == 'preview') ? '79372627eee75d73afe7f9bac91e5ce6' : 'c15bf0cbfbd4893fd70c869c991f6d3d');
define('CODE_GIRLS_CHANNEL_TMP', (APPLICATION_ENV == 'production' || APPLICATION_ENV == 'preview') ? '75215008957605c05e8cd375eac4f817' : 'a519ba44ef3a85cf3c05e405c6ba8e53');
define('CODE_KIDS_CHANNEL_TMP', (APPLICATION_ENV == 'production' || APPLICATION_ENV == 'preview') ? 'd71f4b27f2a7229fbb31a4bc490a6f36' : 'a7741b94e8bb9d56d0d36e00c05956f7');
define('CODE_LIFESTYLE_CHANNEL_TMP', (APPLICATION_ENV == 'production' || APPLICATION_ENV == 'preview') ? '8a341ca7eacc069ba80f02dec80eaf34' : '1b053fd044834f5c86d5eb15fb237af9');
// define('CODE_BOYS_CHANNEL_TMP', (APPLICATION_ENV == 'production' || APPLICATION_ENV == 'preview') ? '79372627eee75d73afe7f9bac91e5ce6' : 'c15bf0cbfbd4893fd70c869c991f6d3d');
// define('CODE_GIRLS_CHANNEL_TMP', (APPLICATION_ENV == 'production' || APPLICATION_ENV == 'preview') ? '75215008957605c05e8cd375eac4f817' : 'a519ba44ef3a85cf3c05e405c6ba8e53');
// define('CODE_KIDS_CHANNEL_TMP', (APPLICATION_ENV == 'production' || APPLICATION_ENV == 'preview') ? 'd71f4b27f2a7229fbb31a4bc490a6f36' : 'a7741b94e8bb9d56d0d36e00c05956f7');
// define('CODE_LIFESTYLE_CHANNEL_TMP', (APPLICATION_ENV == 'production' || APPLICATION_ENV == 'preview') ? '8a341ca7eacc069ba80f02dec80eaf34' : '1b053fd044834f5c86d5eb15fb237af9');
/**
... ... @@ -46,15 +46,15 @@ class HomeModel
//lifestyle:8a341ca7eacc069ba80f02dec80eaf34,1b053fd044834f5c86d5eb15fb237af9
// 男首首页
const CODE_BOYS_CHANNEL = '79372627eee75d73afe7f9bac91e5ce6';
const CODE_BOYS_CHANNEL = 'c15bf0cbfbd4893fd70c869c991f6d3d';
// 女首首页
const CODE_GIRLS_CHANNEL = '75215008957605c05e8cd375eac4f817';
const CODE_GIRLS_CHANNEL = 'a519ba44ef3a85cf3c05e405c6ba8e53';
// 潮童首页
const CODE_KIDS_CHANNEL = 'd71f4b27f2a7229fbb31a4bc490a6f36';
const CODE_KIDS_CHANNEL = 'a7741b94e8bb9d56d0d36e00c05956f7';
// 创意生活新
const CODE_LIFESTYLE_CHANNEL = '8a341ca7eacc069ba80f02dec80eaf34';
const CODE_LIFESTYLE_CHANNEL = '1b053fd044834f5c86d5eb15fb237af9';
// 创意生活
const CODE_LIFESTYLE_CHANNEL_1 = '380c38155fd8beee10913a3f5b462da6';
... ...