Authored by yangyang

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

<?php
namespace LibModels\Web\Product;
use Api\Yohobuy;
/**
* 热销排行
*/
class HotrankData extends \LibModels\Wap\Product\SearchData
{
{
const URI_HOTRANK_TAG = 'operations/service/v1/hotranktag';
/**
* 获取标签
* $client_type 客户端类型
* $channel 频道类型
*/
public static function getHotranktag($client_type = 'web',$channel = 0,$is_concurrent = true)
public static function getHotrankTag($client_type = 'web', $channel = 0, $is_concurrent = true)
{
$params = array('client_type'=>$client_type,'channel'=>$channel,'is_concurrent' => $is_concurrent);
return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URI_HOTRANK_TAG, 'getTag',$params);
$params = array(
'client_type' => $client_type,
'channel' => $channel,
'is_concurrent' => $is_concurrent);
return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URI_HOTRANK_TAG, 'getTag', $params);
}
/**
* 通过ID获取标签信息
* $id 标签ID
*/
public static function getTagById($id,$is_concurrent = true)
public static function getTagById($id, $is_concurrent = true)
{
$params['id'] = $id;
return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URI_HOTRANK_TAG, 'getOneTag',$params);
return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URI_HOTRANK_TAG, 'getOneTag', $params);
}
}
\ No newline at end of file
}
... ...
... ... @@ -151,7 +151,7 @@
<div class="attr-content clearfix">
{{# price}}
<a class="attr {{#if checked}}checked{{/if}}" href="{{href}}">¥{{name}}</a>
<a class="attr{{#if checked}} checked{{/if}}" href="{{href}}">¥{{name}}</a>
{{/ price}}
<div class="ud-price-range">
... ... @@ -172,8 +172,14 @@
<div class="attr-content clearfix">
{{# color}}
<a class="attr {{#if checked}}checked{{/if}}" href="{{href}}">
<i class="color-block" style="background: {{rgb}}"></i>
<a class="attr{{#if checked}} checked{{/if}}" href="{{href}}">
{{#if checked}}
<span class="color-block">
<i class="sub-color-block" style="background: {{rgb}}"></i>
</span>
{{^}}
<i class="color-block" style="background: {{rgb}}"></i>
{{/if}}
{{name}}
</a>
{{/ color}}
... ...
... ... @@ -19,7 +19,8 @@ define("js/common", ["jquery","handlebars","source-map","index"], function(requi
var $ = require("jquery");
require("js/footer");
require("js/simple-header");
function cookie(name) {
... ... @@ -144,8 +145,12 @@ window.getUser = getUser;
window.getUid = getUid;
window.getShoppingKey = getShoppingKey;
if($('.simple-header').hasClass('simple-header')){
require("js/simple-header");
}else{
require("js/header");
}
require("js/header");
});
define("js/footer", ["jquery"], function(require, exports, module){
... ... @@ -735,26 +740,26 @@ function JsonPCallBack(data) {
if (+data.code === 200) {
if (typeof data.data === 'object') {
if(data.data.url !== ''){
topbanner = '<a target="_blank" href="' + data.data.url + '" class="page-top-banner"' +
'style="height:36px;border:none;background-image:url(' + window.unescape(data.data.src) + ');' +
'background-position: center;display:block;background-size:contain">&nbsp;</a>';
}else{
topbanner = '<div class="noticewrapper">' +
'<div class="noticecontainer">' +
'<h1 class="noticetitle">关于系统升级的公告</h1>' +
'<div class="noticecontent">' +
'<p class="tips">尊敬的顾客:</p>' +
'<p class="detail">您好!为了向您提供更优质的服务,目前系统正在升级,请耐心等待。</p>' +
'<p class="detail">' +
'系统升级期间,部分地区用户体验会有暂时中断,如遇紧急事宜,欢迎垂询客服热线:400-889-9646 09:00-22:30(周一至周日)。稍后系统将恢复正常' +
'</p>' +
'<p class="detail">使用,欢迎您继续光顾YOHO!BUY有货!带来不便之处深表歉意,请您谅解!</p>' +
'</div>' +
'</div>' +
'</div>';
}
$('body').prepend(topbanner);
if (data.data.url !== '') {
topbanner = '<a target="_blank" href="' + data.data.url + '" class="page-top-banner"' +
'style="height:36px;border:none;background-image:url(' + window.unescape(data.data.src) + ');' +
'background-position: center;display:block;background-size:contain">&nbsp;</a>';
} else {
topbanner = '<div class="noticewrapper">' +
'<div class="noticecontainer">' +
'<h1 class="noticetitle">关于系统升级的公告</h1>' +
'<div class="noticecontent">' +
'<p class="tips">尊敬的顾客:</p>' +
'<p class="detail">您好!为了向您提供更优质的服务,目前系统正在升级,请耐心等待。</p>' +
'<p class="detail">' +
'系统升级期间,部分地区用户体验会有暂时中断,如遇紧急事宜,欢迎垂询客服热线:400-889-9646 09:00-22:30(周一至周日)。稍后系统将恢复正常' +
'</p>' +
'<p class="detail">使用,欢迎您继续光顾YOHO!BUY有货!带来不便之处深表歉意,请您谅解!</p>' +
'</div>' +
'</div>' +
'</div>';
}
$('body').prepend(topbanner);
}
}
}
... ... @@ -1189,6 +1194,7 @@ function actionTipPic() {
var $img = '';
var $title = '';
var $link = '';
var logolink = '';
$(document).on('mouseenter', '.sub-nav-item', function() {
$contentcode = $(this).find('.showdetail').attr('data-code');
... ... @@ -1206,6 +1212,8 @@ function actionTipPic() {
}
}
});
logolink = $('.first-nav-list .cur').find('a').attr('href');
$('.main-link').attr('href', link);
}
... ...
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
... ... @@ -60,6 +60,19 @@
margin-right: 0;
}
.checked .color-block {
width: 16px;
height: 16px;
border: 2px solid #222;
padding: 2px;
.sub-color-block {
display: block;
width: 16px;
height: 16px;
}
}
.checked-conditions {
line-height: 30px;
... ...
<?php
namespace product;
use WebPlugin\Images;
use Api\Yohobuy;
use Plugin\Helpers;
use LibModels\Web\Product\HotrankData;
use LibModels\Web\Product\SearchData;
use LibModels\Web\Home\IndexData;
... ... @@ -12,33 +14,49 @@ use WebPlugin\DataProcess\Channel as ChannelProcess;
* Hotrank页数据模型
*/
class HotrankModel {
class HotrankModel
{
/**
* 获取频道资源
*
* @return array
*/
static public function getChannelResource()
public static function getChannelResource()
{
$channel = isset($_COOKIE['_Channel']) ? $_COOKIE['_Channel'] : 'boys';
switch ($channel)
{
switch ($channel) {
case 'boys' :
$resource = array('channel' => 'boys', 'gender' => '1,3','road' => 1,'code' => '80d772d8dff25300a2a2e4c97165330c');
$resource = array(
'channel' => 'boys',
'gender' => '1,3',
'road' => 1,
'code' => '80d772d8dff25300a2a2e4c97165330c');
return $resource;
case 'girls' :
$resource = array('channel' => 'girls','gender' => '2,3','road' => 2,'code' => '8df64e505e94edb9881fd1e7efb702e9');
$resource = array(
'channel' => 'girls',
'gender' => '2,3',
'road' => 2,
'code' => '8df64e505e94edb9881fd1e7efb702e9');
return $resource;
case 'lifestyle' :
$resource = array('channel' => 'lifestyle','gender' => '','road' => 4,'code' => 'd131aba83a84a6977eee3a7403a713de');
$resource = array(
'channel' => 'lifestyle',
'gender' => '',
'road' => 4,
'code' => 'd131aba83a84a6977eee3a7403a713de');
return $resource;
case 'kids' :
$resource = array('channel' => 'kids','gender' => '','road' => 3,'code' => 'bd6a06a08f8ca9b0db762f78e0bc5b68');
$resource = array(
'channel' => 'kids',
'gender' => '',
'road' => 3,
'code' => 'bd6a06a08f8ca9b0db762f78e0bc5b68');
return $resource;
}
}
/**
* 获取热销排行所有资源
* @param $data 频道信息
... ... @@ -46,26 +64,27 @@ class HotrankModel {
* @param $page 页码
* @return array
*/
static public function HotrankResource($data,$sid,$page)
public static function getHotrankResource($data, $sid, $page)
{
//焦点图 热门品牌
$focus = self::getFocusResource($data['channel'], $data['code']);
$data['hotrank']['slide'] = $focus[0]['slide'];
$data['hotrank']['hotBrands'] = $focus[1]['hotBrands'];
// $focus = self::getFocusResource($data['channel'], $data['code']);
// $data['slide'] = $focus[0]['slide'];
// $data['hotBrands'] = $focus[1]['hotBrands'];
//人气单品 一周热卖
$config = array('sort' =>$sid,'gender' => $data['gender'],'road' => $data['road']);
$publiclist = self::getSearchData($config,$page,0);
$data['hotrank']['popular'] = $publiclist['popular'];
$data['hotrank']['hotWeek'] = $publiclist['hotWeek'];
$sort = ($sid == 1) ? '' : $sid;
$config = array(
'sort' => $sort,
'gender' => $data['gender'],
'road' => $data['road']);
$publiclist = self::getSearchData($config, $page, 0);
$data['popular'] = $publiclist['popular'];
$data['hotWeek'] = $publiclist['hotWeek'];
//分类标签
$nav = HotrankModel::getHotranktag('web',$data['road'],true);
$data['hotrank']['hotWeek']['nav'] = $nav;
return $data['hotrank'];
$nav = self::getHotrankTag('web', $data['road'], true);
$data['hotWeek']['nav'] = $nav;
return $data;
}
/*
* 一周热卖加载更多
... ... @@ -73,194 +92,172 @@ class HotrankModel {
* @param $sid 一周热卖分类id
* @param $page 页码
*/
static public function getListData($data,$sid,$page)
public static function getListData($data, $sid, $page)
{
$sort = '';
$sort = '';
//是否是默认标签
if($sid > 1)
{
if ($sid > 1) {
//通过ID获取标签信息
$info = HotrankData::getTagById($sid, false);
if(!empty($info['data']))
{
if (!empty($info['data'])) {
$sort = $info['data']['category_id'];
}
}
}
//获取频道资源
$channel = self::getChannelResource();
//一周热卖
$config = array('sort' =>$sort,'gender' => $data['gender'],'road' => $data['road']);
$config = array(
'sort' => $sort,
'gender' => $data['gender'],
'road' => $data['road']);
$list = self::getSearchData($config, $page, 1);
$lister = $list['hotWeek']['list'];
$lister = array_values($lister);
if($sid == 1 && $page == 1)
{
if ($sid == 1 && $page == 1) {
$lister = array_slice($lister, 10, 50);
}else{
}
else {
$lister = array_slice($lister, 0, 50);
}
$data = array( 'code'=>200, 'data'=>$lister,);
$data = array(
'code' => 200,
'data' => $lister,);
return $data;
}
/**
* 获取焦点图,热门品牌资源
* @param string $channel
* @param string $content_code
* @return array
*/
static public function getFocusResource($channel, $content_code)
public static function getFocusResource($channel, $content_code)
{
$resource = IndexData::getResourceData($content_code);
// 格式化数据
$data = ChannelProcess::getFormat($channel, $resource['data']);
return $data;
$resource = IndexData::getResourceData($content_code);
// 格式化数据
$data = ChannelProcess::getFormat($channel, $resource['data']);
return $data;
}
/**
* 获取人气单品,一周热卖商品资源
* @param $config 过滤参数
* @param $page 当前页数
* @param $ajax 是否是ajax加载 默认0不是
*/
static public function getSearchData($config,$page,$ajax)
public static function getSearchData($config, $page, $ajax)
{
//配置查询商品参数
$viewNum = 60;
$param = array('order'=>'s_n_desc','viewNum'=>$viewNum,'page'=>$page,'stocknumber'=>1,'status'=>1,
'sort'=>$config['sort'],'gender'=>$config['gender'],'attribute_not'=>2);
if($ajax == 0)
{
if($config['sort'] != 0)
{
$param['sort'] = $sort_id;
}else{
$param['sort'] = '';
}
if($config['road'] == 3)
{
$param['msort'] = 365;
}elseif($config['road'] == 4){
$param['msort'] = 10;
}else{
$param['not_maxSortId'] = '10,365';
}
}else{
if(empty($param['sort']))
{
if($config['road'] == 3)
{
$param = array(
'order' => 's_n_desc',
'viewNum' => $viewNum,
'page' => $page,
'stocknumber' => 1,
'status' => 1,
'sort' => $config['sort'],
'gender' => $config['gender'],
'attribute_not' => 2);
if ($ajax == 0 || ($ajax == 1 && empty($param['sort']))) {
switch ($config['road']) {
case 3 :
$param['msort'] = 365;
}elseif($config['road'] == 4){
break;
case 4 :
$param['msort'] = 10;
}else{
break;
default :
$param['not_maxSortId'] = '10,365';
}
}
}
//根据给定查询数据搜索数据列表
$result = SearchData::searchElasticByCondition($param);
$data = self::getProductList($result,$page,$ajax);
$data = self::getProductList($result, $page, $ajax);
return $data;
}
/**
* 获取标签资源
* @param $client_type 客户端类型
* @param $channel 频道类型
* @param $is_concurrent 是否异步,true异步,false同步,默认true
* 获取标签资源
* @param $client_type 客户端类型
* @param $channel 频道类型
* @param $is_concurrent 是否异步,true异步,false同步,默认true
*/
static public function getHotranktag($client_type,$channel,$is_concurrent)
public static function getHotrankTag($client_type, $channel, $is_concurrent)
{
$list = \LibModels\Web\Product\HotrankData::getHotranktag($client_type,$channel,$is_concurrent);
$list = HotrankData::getHotrankTag($client_type, $channel, $is_concurrent);
$nav = array();
if(!empty($list['data']['list']))
{
foreach($list['data']['list'] as $li=>$lt)
{
$nav[$li]['sid'] = $lt['id'];
$nav[$li]['textCn'] = $lt['tag_name'];
}
if (!empty($list['data']['list'])) {
foreach ($list['data']['list'] as $li => $lt) {
$nav[$li]['sid'] = $lt['id'];
$nav[$li]['textCn'] = $lt['tag_name'];
}
}
return $nav;
}
/**
* 人气单品 一周热卖 数据处理
* @param $result 过滤参数
* @param $page 当前页数
* @param $ajax 是否是ajax加载 默认0不是
*/
static public function getProductList($result,$page,$ajax=0)
public static function getProductList($result, $page, $ajax = 0)
{
// 调用发起请求
Yohobuy::yarConcurrentLoop();
if(empty($result) || empty($result['data']) || empty($result['data']['product_list']))
{
return;
$product = array();
if (empty($result) || empty($result['data']) || empty($result['data']['product_list'])) {
return $product;
}
$data = $result['data']['product_list'];
$popular = array();
$hotWeek = array();
foreach($data as $key=>$val)
{
if(empty($val['goods_list']))
{
foreach ($data as $key => $val) {
if (empty($val['goods_list'])) {
continue;
}
$defaultGoodsId = 0;
foreach ($val['goods_list'] as $v)
{
if($v['is_default'] == 'Y')
{
foreach ($val['goods_list'] as $v) {
if ($v['is_default'] == 'Y') {
$defaultGoodsId = $v['goods_id'];
}
}
if(empty($defaultGoodsId))
{
if (empty($defaultGoodsId)) {
$defaultGoodsId = $val['goods_list'][0]['goods_id'];
}
$product_id = empty($val['product_id']) ? '' : $val['product_id'];
$re['name'] = $val['product_name'];
if($key <= 9 && $page == 1 && $ajax == 0)
{
$product['name'] = $val['product_name'];
if ($key <= 9 && $page == 1 && $ajax == 0) {
//人气单品
$re['rank'] = $key + 1;
$re['href'] = 'http://item.yohobuy.com/product/pro_'.$product_id.'_'.$defaultGoodsId.'.html';
$re['price'] = (int)$val['market_price'] == (int)$val['sales_price'] ? '' : $val['market_price'];
$re['sPrice'] = empty($val['sales_price']) ? '' : $val['sales_price'];
if($key <= 5)
{
$re['img'] = empty($val['default_images']) ? '' : Images::getImageUrl($val['default_images'], 378, 504, 2);
$popular['list'][] = $re;
}else{
$re['img'] = empty($val['default_images']) ? '' : Images::getImageUrl($val['default_images'], 280, 373, 2);
$popular['list'][] = $re;
$product['rank'] = $key + 1;
$product['href'] = 'http://item.yohobuy.com/product/pro_' . $product_id . '_' . $defaultGoodsId . '.html';
$product['price'] = (int) $val['market_price'] == (int) $val['sales_price'] ? '' : $val['market_price'];
$product['sPrice'] = empty($val['sales_price']) ? '' : $val['sales_price'];
if ($key <= 5) {
$product['img'] = empty($val['default_images']) ? '' : Images::getImageUrl($val['default_images'], 378, 504, 2);
$popular['list'][] = $product;
}
else {
$product['img'] = empty($val['default_images']) ? '' : Images::getImageUrl($val['default_images'], 280, 373, 2);
$popular['list'][] = $product;
}
}else{
}
else {
//一周热卖
$re['url'] = 'http://item.yohobuy.com/product/pro_'.$product_id.'_'.$defaultGoodsId.'.html';
$re['marketPrice'] = (int)$val['market_price'] == (int)$val['sales_price'] ? '' : $val['market_price'];
$re['salePrice'] = empty($val['sales_price']) ? '' : $val['sales_price'];
$re['rank'] = '';
$re['thumb'] = empty($val['default_images']) ? '' : Images::getImageUrl($val['default_images'], 280, 373, 2);
$hot[] = $re;
// $product['url'] = 'http://item.yohobuy.com/product/pro_' . $product_id . '_' . $defaultGoodsId . '.html';
$product['url'] = Helpers::url('/product/pro',array('product_id' => $product_id,'defaultGoodsId'=> $defaultGoodsId),'item');
$product['marketPrice'] = (int) $val['market_price'] == (int) $val['sales_price'] ? '' : $val['market_price'];
$product['salePrice'] = empty($val['sales_price']) ? '' : $val['sales_price'];
$product['rank'] = '';
$product['thumb'] = empty($val['default_images']) ? '' : Images::getImageUrl($val['default_images'], 280, 373, 2);
$hot[] = $product;
}
}
$popular['name'] = '人气单品';
$hotWeek = array(
'name'=>'一周热卖',
'list'=>$hot,
'name' => '一周热卖',
'list' => $hot,
);
$data['popular'] = $popular;
$data['hotWeek'] = $hotWeek;
return $data;
}
}
\ No newline at end of file
}
... ...
... ... @@ -101,8 +101,16 @@ class LoginController extends WebAction
$ip = Helpers::getClientIp();
$ipKey = md5('ip_signin_' . $ip);
$accountKey = md5('account_signin_' . $account);
$accountTimes = Cache::increment($accountKey, 1, 0, 1800);
$ipTimes = Cache::increment($ipKey, 1, 0, 3600);
if(!Cache::get($ipKey)){
Cache::set($ipKey, 0);
}
if(!Cache::get($accountKey)){
Cache::set($accountKey, 0);
}
Cache::increment($accountKey, 1, 0, 1800);
Cache::increment($ipKey, 1, 0, 3600);
$accountTimes = Cache::get($accountKey);
$ipTimes = Cache::get($ipKey);
if ($accountTimes > 10) {
$data = array('code' => 400, 'message' => '您输入的密码及账户名不匹配,是否忘记密码?', 'data' => '');
break;
... ...
... ... @@ -47,8 +47,11 @@ class RegisterController extends WebAction
$area = intval(trim($this->post('area'), ' '));
$ip = Helpers::getClientIp();
$data = array('code' => 400, 'message' => '', 'data' => '');
$ip_key = md5('ip_checkmobile_' . $ip);
$ip_times = Cache::increment($ip_key, 1, 0, 3600);
$ipKey = md5('ip_checkmobile_' . $ip);
if (!Cache::get($ipKey)) {
Cache::set($ipKey, 0);
}
$ipTimes = Cache::increment($ipKey, 1, 0, 3600);
do{
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
... ... @@ -59,7 +62,7 @@ class RegisterController extends WebAction
$data['message'] = '手机号码格式不正确';
break;
}
if ($ip_times >= 500) {
if ($ipTimes >= 500) {
$data['message'] = '由于你IP受限无法注册';
break;
}
... ...
... ... @@ -133,10 +133,10 @@ class IndexController extends WebAction
$channel = HotrankModel::getChannelResource();
$this->setWebNavHeader($channel['channel']);
$page = $this->get('page',1);
$sort_id = $this->get('sid',0);
$sort = $this->get('sid',1);
$data = array( 'hotrankPage' => true,
'footerTop'=> true,
'hotrank' => HotrankModel::HotrankResource($channel,$sort_id,$page)
'hotrank' => HotrankModel::getHotrankResource($channel, $sort, $page)
);
$this->_view->display('hotrank', $data);
}
... ... @@ -157,7 +157,7 @@ class IndexController extends WebAction
//获取频道资源
$channel = HotrankModel::getChannelResource();
//获取一周热卖资源
$data = HotrankModel::getListData($channel,$sid,$page);
$data = HotrankModel::getListData($channel, $sid, $page);
echo json_encode($data);
exit;
}
... ...