Authored by biao

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

... ... @@ -11,31 +11,114 @@ class SearchData extends \LibModels\Wap\Product\SearchData
*
* @return string
*/
private static function getUrl($type = 'search')
public static function getUrl($type = 'search')
{
defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'developer');
switch (APPLICATION_ENV) {
case 'release':
if($type == 'sort'){
if ($type == 'sort') {
return 'http://100.98.132.63/yohosearch/sortgroup.json';
}
elseif($type == 'suggest'){
return 'http://100.98.132.63/yohosearch/suggest.json';
elseif ($type == 'discount') {
return 'http://100.98.132.63/yohosearch/discount.json';
}
elseif ($type == 'recent') {
return 'http://100.98.132.63/yohosearch/recent.json';
}
elseif ($type == 'shop') {
return 'http://100.98.132.63/yohosearch/shops.json';
}
return 'http://100.98.132.63/yohosearch/search.json';
case 'test':
case 'preview':
case 'developer':
default:
if($type == 'sort'){
if ($type == 'sort') {
return 'http://101.200.31.165/yohosearch/sortgroup.json';
}
elseif($type == 'suggest'){
return 'http://101.200.31.165/yohosearch/suggest.json';
elseif ($type == 'discount') {
return 'http://101.200.31.165/yohosearch/discount.json';
}
elseif ($type == 'recent') {
return 'http://101.200.31.165/yohosearch/recent.json';
}
elseif ($type == 'shop') {
return 'http://101.200.31.165/yohosearch/shops.json';
}
// return 'http://101.200.31.165/yohosearch/search.json';
return 'http://192.168.10.64:8080/yohosearch/search-once.json';
}
}
/**
* 根据给定查询数据搜索数据列表 (新的)
*
* @param string $query 查询条件, 默认为null
* @param string $brand 品牌,默认为null
* @param string $gender 性别,默认为null,"1,3"表示男, "2,3"表示女, "1,2,3"表示全部
* @param integer $color 颜色id
* @param integer $size 尺码id
* @param integer $price 价格
* @param string $p_d 折扣,默认为null
* @param string $sort 商品所属品类,默认为null
* @param string $order 排序方式,默认为按照时间倒序排列s_t_desc,
* s_t_asc表示按时间正序排列,
* s_p_asc表示按价格正序排列,
* s_p_desc表示按价格倒序排列,
* p_d_asc表示按折扣正序排列,
* p_d_desc表示按折扣倒序排列
* @param integer $page 指定查询是多少页,默认为第一页
* @param integer $limit 指定查询多少个,默认是60个
* @param integer $channel表示哪个频道,1表示男生,2表示女生,3表示潮童,4表示创意生活
* @return array 搜索到的数据
*/
public static function searchElasticByCondition($condition, $cache = false)
{
// 排序数据映射表
$orderMaps = array(
's_t_desc' => 'shelve_time:desc',
's_t_asc' => 'shelve_time:asc',
's_p_asc' => 'sales_price:asc',
's_p_desc' => 'sales_price:desc',
'p_d_desc' => 'discount:desc',
'p_d_asc' => 'discount:asc',
'skn_desc' => 'product_skn:desc',
'skn_asc' => 'product_skn:asc',
'activities_desc' => 'activities.order_by:desc',
'activities_asc' => 'activities.order_by:asc',
's_n_asc' => 'sales_num:asc',
's_n_desc' => 'sales_num:desc',
'activities_id_desc' => 'activities.activity_id:desc',
'activities_id_asc' => 'activities.activity_id:asc',
);
return 'http://101.200.31.165/yohosearch/search.json';
$param = array();
$param['status'] = 1; // 是否上架,1表示在架,2表示不在
$param['sales'] = 'Y'; // 只搜索销售的产品
$param['stocknumber'] = 1; // 过滤掉已售罄的商品
// $param['needFilter'] = 1; // 是否需要返回筛选条件
if (!isset($condition['order'])) {
$param['order'] = $orderMaps['s_t_desc'];
} else {
$param['order'] = $orderMaps[$condition['order']];
}
if (!isset($condition['page'])) {
$param['page'] = 1;
}
if(isset($condition['viewNum'])) {
$param['viewNum'] = $condition['viewNum'];
} else if (!isset($condition['limit'])) {
$param['viewNum'] = 60;
} else {
$param['viewNum'] = $condition['limit'];
unset($condition['limit']);
}
if (!empty($condition)) {
$param += $condition;
}
return Yohobuy::get(self::getUrl('search'), $param, $cache);
}
/**
* 根据分类列表获取商品信息
... ...
... ... @@ -4,6 +4,7 @@ namespace Plugin;
use Plugin\Paging;
use LibModels\Web\Product\BrandData;
use LibModels\Web\Product\SearchData;
use Api\Yohobuy;
use Api\Sign;
/**
... ... @@ -89,6 +90,10 @@ class HelperSearch
$result['shopEntry'] = isset($data['shop']) && !empty($data['shop']) ? self::shop($data['shop'], $data['sort']['sort']) : array();
//分页
$result['pager'] = self::pager($result['totalCount'],$options['viewNum']-1);
//浏览记录
if (isset($options['reviewNum']) && !empty($options['reviewNum'])) {
$result['latestWalk'] = $options['reviewNum'];
}
//选中条件
$result['filters']['checkedConditions'] = self::getSelected();
if (isset($options['controller']) && $options['controller'] == 'Search') {
... ... @@ -134,7 +139,7 @@ class HelperSearch
if (!empty($val['default_images'])) {
$val['default_images'] = Images::getImageUrl($val['default_images'],$imgSize[0],$imgSize[1]);
}
$goods[] = array(
$good = array(
'tags' => array(
'isNew' => $isNew,
'isLimit' => $isLimit
... ... @@ -143,12 +148,16 @@ class HelperSearch
'thumb' => $val['default_images'],
'name' => $val['product_name'],
'salePrice' => $val['sales_price'],
'marketPrice' => $val['market_price'],
'isFew' => $isFew,
'skn' => $val['product_skn'],
'showColBtn' => true,
'coled' => true
);
//市场价不等于售价时显示
if ($val['market_price'] != $val['sales_price']) {
$good['marketPrice'] = $val['market_price'];
}
$goods[] = $good;
}
return $goods;
}
... ... @@ -343,10 +352,6 @@ class HelperSearch
array(
'index' => 'all',
'name' => '全部'
),
array(
'index' => '0-9',
'name' => '0 ~ 9'
)
),
'brandsShow' => array()
... ... @@ -356,17 +361,29 @@ class HelperSearch
$brandIds = isset($params['brand']) && !empty($params['brand']) ? explode(',', $params['brand']) : array();
if (isset($filter['brand']) && !empty($filter['brand'])) {
$brand = $filter['brand'];
// print_r($filter); exit;
//已选中品牌数量
$existBrandNum = 0;
//已选中品牌标签名
$existName = '';
foreach ($brand as $key => $v) {
$selectBrandIds = $brandIds;
//品牌id在提交的参数中,构造url参数去除该品牌id
//品牌已被选中
if (in_array($v['id'], $brandIds)) {
$filterKey = array_search($v['id'], $selectBrandIds);
unset($selectBrandIds[$filterKey]);
$url = self::buildUrl(array_merge($params, array(
'brand' => implode(',', $selectBrandIds)
)));
if ($existBrandNum === 0) {
$existName .= $v['brand_name'].'、';
}
if ($existBrandNum === 1){
$existName .= substr($v['brand_name'], 0, 3).'...';
}
$existBrandNum++;
}
//该品牌url参数中添加该品牌的id
//该品牌未被选中
else {
$selectBrandIds[] = $v['id'];
$url = self::buildUrl(array_merge($params, array(
... ... @@ -396,25 +413,6 @@ class HelperSearch
}
//清空品牌参数
unset($params['brand']);
//设置已选中的品牌
$existBrandNum = 0;
$existName = '';
foreach ($brandIds as $key => $val) {
if (isset($brandAll[$val])) {
$brandParam = $brandIds;
unset($brandParam[$key]);
if ($existBrandNum === 0) {
$existName .= $brandAll[$val].'、';
}
if ($existBrandNum === 1){
$existName .= substr($brandAll[$val], 0, 3).'...';
}
$existBrandNum++;
}
if ($existBrandNum > 1) {
break;
}
}
//设置选中
if (isset(self::$params['brand']) && !empty(self::$params['brand'])) {
self::$selected['brand'] = array(
... ... @@ -448,6 +446,7 @@ class HelperSearch
if (count($result['brandsShow']) < 11) {
$result['hideMore'] = true;
}
// print_r($result); exit;
return $result;
}
/**
... ... @@ -459,14 +458,14 @@ class HelperSearch
{
$params = self::$params;
$paramsValue = array_filter($params);
if (!$isAjax && empty($paramsValue)) {
return array();
}
$sizeId = isset($params['size']) && !empty($params['size']) ? $params['size'] : '';
if (isset($params['size'])) {
unset($params['size']);
}
$result = array();
if (!$isAjax && empty($paramsValue)) {
return array();
}
if (isset($filter['size']) && !empty($filter['size'])) {
$size = $filter['size'];
foreach ($size as $k=> $v) {
... ... @@ -485,7 +484,7 @@ class HelperSearch
'checked' => isset(self::$params['size']) && self::$params['size'] == $v['size_id'] ? true : false
);
}
if (self::checkSearch('size')) {
if ( self::checkSearch('size')) {
return array();
}
}
... ... @@ -940,8 +939,8 @@ class HelperSearch
}
if ($data) {
$result['conditions'] = $data;
$result['clearUrl'] = self::current();
}
$result['clearUrl'] = self::current();
return $result;
}
... ... @@ -1200,7 +1199,7 @@ class HelperSearch
if (!empty($condition)) {
$param += $condition;
}
return Yohobuy::httpBuildQuery(self::getUrl(), $param);
return Yohobuy::httpBuildQuery(SearchData::getUrl(), $param);
}
/**
... ... @@ -1213,7 +1212,7 @@ class HelperSearch
$condition['sales'] = 'Y'; //在销售商品分类
$condition['status'] = 1; //上架商品分类
$condition['stocknumber'] = 1; //过滤掉已售罄
return Yohobuy::httpBuildQuery(self::getUrl('sort'), $condition);
return Yohobuy::httpBuildQuery(SearchData::getUrl('sort'), $condition);
}
/**
... ... @@ -1223,7 +1222,7 @@ class HelperSearch
public static function getDiscountUrl($param = array())
{
return Yohobuy::httpBuildQuery(self::getUrl('discount'), $param);
return Yohobuy::httpBuildQuery(SearchData::getUrl('discount'), $param);
}
/**
... ... @@ -1231,7 +1230,7 @@ class HelperSearch
*/
public static function getRecentShelveUrl($param = array())
{
return Yohobuy::httpBuildQuery(self::getUrl('recent'), $param);
return Yohobuy::httpBuildQuery(SearchData::getUrl('recent'), $param);
}
/**
... ... @@ -1262,15 +1261,6 @@ class HelperSearch
return Yohobuy::httpBuildQuery(Yohobuy::API_URL, $param);
}
/**
* 并行调接口url获取(获取用户浏览记录)
*/
// public static function getReviewUrl($param = array())
// {
// return Yohobuy::httpBuildQuery(self::getUrl('review'), $param);
// }
/**
... ... @@ -1280,58 +1270,7 @@ class HelperSearch
*/
public static function getShopUrl($param)
{
return Yohobuy::httpBuildQuery(self::getUrl('shop'), $param);
}
/**
* 获取搜索的服务地址
*
* 备注:此处是根据环境来确定使用阿里云内网还是外网的URL
*
* @return string
*/
private static function getUrl($type = 'search')
{
defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'developer');
switch (APPLICATION_ENV) {
case 'release':
if ($type == 'sort') {
return 'http://100.98.132.63/yohosearch/sortgroup.json';
}
elseif ($type == 'discount') {
return 'http://100.98.132.63/yohosearch/discount.json';
}
elseif ($type == 'recent') {
return 'http://100.98.132.63/yohosearch/recent.json';
}
// elseif ($type == 'review') {
//
// }
elseif ($type == 'shop') {
return 'http://100.98.132.63/yohosearch/shops.json';
}
return 'http://100.98.132.63/yohosearch/search.json';
case 'test':
case 'preview':
case 'developer':
default:
if ($type == 'sort') {
return 'http://101.200.31.165/yohosearch/sortgroup.json';
}
elseif ($type == 'discount') {
return 'http://101.200.31.165/yohosearch/discount.json';
}
elseif ($type == 'recent') {
return 'http://101.200.31.165/yohosearch/recent.json';
}
// elseif ($type == 'review') {
//
// }
elseif ($type == 'shop') {
return 'http://101.200.31.165/yohosearch/shops.json';
}
// return 'http://101.200.31.165/yohosearch/search.json';
return 'http://192.168.10.64:8080/yohosearch/search-once.json';
}
return Yohobuy::httpBuildQuery(SearchData::getUrl('shop'), $param);
}
/**
... ...
... ... @@ -32,7 +32,7 @@
<div class="size-list block-list">
<span>尺码</span>
{{# sizes}}
<ul id="{{sizeName}}" data-index="{{@index}}" class="size-row clearfix {{#unless @first}}hide{{/if}}">
<ul class="size-row clearfix {{#unless @first}}hide{{/if}}">
{{# size}}
<li class="block {{#if chosed}}chosed{{/if}} {{#unless sizeNum}}zero-stock{{/unless}}" data-num="{{sizeNum}}" data-id="{{id}}" data-skuid="{{skuId}}">
{{name}}
... ...
... ... @@ -25,7 +25,8 @@
<input name="mobile" id="mobile" type="hidden" value="{{mobile}}">
<input name="verifyCode" id="captchaPic" type="hidden" value="{{verifyCode}}">
<input name="refer" id="refer" type="hidden" value="">
<input id="next-step" class="btn next-step disable" type="submit" value="下一步" disabled="">
<a id="next-step" class="btn next-step disable" href="javascript:;">下一步</a>
<!-- <input id="next-step" class="btn next-step disable" type="submit" value="下一步" disabled=""> -->
</li>
</ul>
</form>
... ...
... ... @@ -5,7 +5,7 @@
{{/if}}
{{#if preEnv}}
<script src="http://cdn.yoho.cn/yohobuy/{{version}}/lib.js"></script>
<script src="http://cdn.yoho.cn/yohobuy/{{version}}/index.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>
... ...
... ... @@ -83,7 +83,11 @@
<ul class="sub-nav-list">
{{# subnav}}
<li class="sub-nav-item">
<a href="{{link}}">{{name}}</a>
<a href="{{link}}">{{name}}
{{#if is_new}}
<span class="newlogo"></span>
{{/if}}
</a>
{{#if thirdnav}}
<div class="third-nav-wrapper">
<div class="third-nav">
... ... @@ -96,7 +100,7 @@
{{#branditems}}
<li class="category-
item thirdnavbar">
<a href="{{link}}" hot={{hot}}>{{brandname}}</a>
<a href="{{link}}" hot={{hot}} >{{brandname}}</a>
</li>
{{/branditems}}
</ul>
... ...
... ... @@ -179,7 +179,7 @@
</div>
{{/if}}
<div class="size section hide">
<div class="size section {{#unless size}}hide{{/unless}}">
<span class="title">尺码:</span>
<div class="attr-content clearfix">
... ...
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
... ... @@ -97,8 +97,35 @@ window.submitSearch = function() {
return false;
}
}
}
};
/**
* 增加关键字
* @return {[type]} [description]
*/
function actionAddKeyWords() {
var keywords = $('#nav_keyword').text();
var defaultsearch = 'vans';
var $query_key = $('#query_key');
if (keywords !== '') {
$query_key.css({
'color': '#000'
});
$query_key.val(keywords);
} else {
$query_key.css({
'color': '#e0e0e0'
});
$query_key.val(defaultsearch);
$query_key.on('focus', function(e) {
$query_key.css({
'color': '#000'
});
$query_key.val('');
})
}
}
/**
* 定义购物车扩展
*/
... ... @@ -1316,6 +1343,7 @@ function actionSearch() {
* @return {[type]} [description]
*/
function actionLoginState(_data) {
console.log(_data);
var timestamp = new Date().getTime();
var noLoginHtml = '<span>Hi~</span>[<a href="http://www.yohobuy.com/signin.html" class="list-a login-out ">' +
'请登录</a>]&nbsp;' +
... ... @@ -1482,6 +1510,7 @@ function init() {
actionListenCartMore(); //
actionLoginInfo(); //获取登录信息
actionCover(); //初次登录弹框
actionAddKeyWords();//增加关键字
}
init();
\ No newline at end of file
... ...
... ... @@ -89,11 +89,11 @@ $('#captcha').keyup(function() {
if (res.code === 200) {
//添加验证码正确验证
$next.removeClass('disable').removeAttr('disabled');
$next.removeClass('disable').attr('href', res.data);
$errTip.addClass('hide');
$(that).removeClass('error');
} else {
$next.addClass('disable').attr('disabled', true);
$next.addClass('disable');
$errTip.removeClass('hide').find('em').text('验证码输入错误');
$(that).addClass('error');
}
... ...
... ... @@ -13,7 +13,7 @@ var $latestWalkCount = $('#latest-walk-count');
(function() {
var tpl;
if ($latestWalkCount.lenght < 0) {
if ($latestWalkCount.length === 0) {
return;
}
... ...
... ... @@ -159,4 +159,5 @@ class CommonController extends WebAction
return $this->helpJsonCallbackResult($callback, 403, '意见反馈失败', '');
}
}
}
\ No newline at end of file
... ...
<?php
use Action\WebAction;
use Plugin\Cache;
use Configs\CacheConfig;
use Plugin\AuthCode;
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(
'男生首页'=> CacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_boys',
'女生首页'=> CacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_girls',
'kids首页'=> CacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_kids',
'lifestyle首页'=> CacheConfig::KEY_WEB_HOME_CHANNEL_DATA.'_lifestyle',
);
$html = '';
foreach ($channels as $key => $val) {
$url = '/tools/cacheclear?key='.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)) {
AuthCode::decode($key, 'yohobuy');
if(!empty($key)) {
Cache::delete($key);
echo '清除成功';
}
}
}
}
?>
\ No newline at end of file
... ...
... ... @@ -154,6 +154,7 @@ class SearchModel
//$urlList['reviewUrl'] = HelperSearch::getReviewUrl($searchCondition['condition']);
$result = Yohobuy::getMulti($urlList, array(), true);
// 组织模板数据
$data = HelperSearch::getList($result, $searchCondition['options']);
return $data;
... ...
... ... @@ -40,13 +40,15 @@ class BackController extends WebAction {
'message' => '验证成功'
);
if (PassportModel::verifyCode($verifyCode)) {
if (Helpers::verifyEmail($phoneNum)) {
if (empty(PassportModel::getUserInfoByEmail($phoneNum))) {
if (Helpers::verifyEmail($phoneNum)) {
$ret = PassportModel::getUserInfoByEmail($phoneNum);
if (empty($ret)) {
$data['message'] = '该账户不存在';
$data['code'] = 400;
}
} else if (Helpers::verifyMobile($phoneNum)) {
if (empty(PassportModel::getUserInfoByMobile($area, $phoneNum))) {
} else if (Helpers::verifyMobile($phoneNum)) {
$ret = PassportModel::getUserInfoByMobile($area, $phoneNum);
if (empty($ret)) {
$data['message'] = '该账户不存在';
$data['code'] = 400;
}
... ...
... ... @@ -50,7 +50,7 @@ class ListController extends WebAction
public function saleAction()
{
$condition = array();
$list = SearchModel::getListData($condition);
$list = SearchModel::getListData($condition,array('reviewNum'=>6));
$data = array(
//初始化js
'productListPage' => true,
... ...