Authored by whb
Commit 2bf9dda219b1ba045667b23e86df3f7326e3b1a7 2 parents 21f47f5f 09c69ef7 master ... develop feature/4LevelAddr feature/birthCoupon feature/cartEvent feature/colorLength feature/commentImgShow feature/deleteMark feature/favShopDelAll feature/help feature/jitTip feature/paySuccess feature/seoUrl feature/shoppingCart feature/wholesaleFrom5.3 gray hotfix/firefoxCart hotfix/govLink hotfix/newPy hotfix/serviceSwitch hotfix/studentSwitch hotfix/yas2.1.2 release/5.3.1 release/5.4 release/5.4.1 release/5.5 5.4.3 5.4.2 5.4.1 5.4.0 5.3.8 5.3.7 5.3.6 5.3.5 5.3.4 5.3.3 5.3.2 5.3.1 5.3.0 5.2.4 5.2.3 5.2.2 5.2.1 5.2.0 5.1.5 5.1.4 5.1.2 5.1.1 5.1.0 5.0.4 5.0.3 5.0.2 5.0.1 5.0.0.before 4.9.24 4.9.23 4.9.22 4.9.21 4.9.20 4.9.19 4.9.18 4.9.17.encryBugsFenliu 4.9.16 4.9.15 4.9.15.pinyou 4.9.14 4.9.14.icon 4.9.13 4.9.12 4.9.11 4.9.10 4.9.1.1 4.9.1.0 4.9.1 4.8.15 4.8.13 4.8.12 4.8.8.2 4.8.8.1 4.8.8 4.8.5 4.8.3 4.8.2 4.8.bak 4.7.2 4.6.2.1 4.6.2 4.6 4 1.3.22 1.3.21 1.3.20 1.3.19 1.3.18 wap.3.2.5 wap.1.4.22 wap.1.4.21 wap.1.4.20 wap.1.4.19 wap.1.4.18 wap.1.4.17 wap.1.4.16.3 wap.1.4.16.2 wap.1.4.16.1 wap.1.4.16 wap.1.4.15 wap.1.4.14 wap.1.4.13 wap.1.4.12 wap.1.4.11 wap.1.4.10 wap.1.4.9 wap.1.4.8 wap.1.4.7 wap.1.4.6 wap.1.4.5 wap.1.4.4 wap.1.4.3 wap.1.4.2 wap.1.4.1 wap.1.4.0 pchttps pc4.8.9 pc4.5 pc.1.4.24 pc.1.4.23 pc.1.4.22 pc.1.4.21 pc.1.4.20 pc.1.4.19 pc.1.4.18 pc.1.4.17 pc.1.4.16 pc.1.4.15 pc.1.4.14 pc.1.4.13 pc.1.4.12 pc.1.4.11 pc.1.4.10 pc.1.4.9 pc.1.4.8 pc.1.4.7 pc.1.4.6 pc.1.0.7 pc.1.0.6 pc.1.0.5 pc.1.0.4 pc.1.0.3 pc.1.0.2 pc.1.0.1 pc.1.0.0 list fix-ip-login-limit fix-ip-limit

Merge branch 'feature/web-list' into develop

... ... @@ -19,13 +19,15 @@ class BrandData
const URI_BRAND_TOPPOS = 'operations/api/v5/resource/get';
const URL_BRAND_LOGO = '/shops/service/v1/brand';
const URL_BRAND_FOLDER = '/cmsproduct/service/v1/brands';
const URL_BRAND_NODECONTENT = '/operations/service/v6/htmlcontent';
/**
* 获取品牌介绍
* 获取品牌简介
*
* @param integer $brandId 品牌ID
* @param int 用户ID
* @return array 品牌介绍信息
* @param int 用户ID
* @return array 品牌介绍信息
*/
public static function getBrandIntro($brandId, $uid)
{
... ... @@ -42,9 +44,9 @@ class BrandData
}
/**
* 获取品牌banner数据
* 获取品牌banner
* @param integer $brandId 品牌ID
* @return array banner数据
* @return array banner
*/
public static function getBrandBanner($brandId)
{
... ... @@ -58,17 +60,17 @@ class BrandData
}
/**
* 获取品牌介绍信息
* 获取品牌介绍详情
*
* @param int $id 品牌id
* @return array
*/
public static function getBrandLogo($id)
{
return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URL_BRAND_LOGO, 'getBrandByids', array($id ));
public static function getBrandLogo($brandId)
{
return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URL_BRAND_LOGO, 'getBrandByids', array($brandId ));
}
/**
/**
* 通过域名获取品牌LOGO信息
*
* @param int $domain 品牌domain
... ... @@ -78,5 +80,27 @@ class BrandData
{
return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URL_BRAND_LOGO, 'getBrandByDomain', array($domain ));
}
/**
* 通过品牌id获取品牌Folder
*
* @param int $brand_id 品牌id
* @param int $status 状态
* @return array
*/
public static function getFolderByBrand($brand_id,$status = 1)
{
return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URL_BRAND_FOLDER, 'getFolderByBrand', array($brand_id,$status ));
}
/**
* 根据节点和运行模式选择静态内容
* @param $node 20141219-100447
* @param string $mode
* @return mixed
*/
public static function getByNodeContent($node, $mode='release')
{
return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URL_BRAND_NODECONTENT, 'getByNodeContent', array($node, $mode));
}
}
... ...
... ... @@ -68,14 +68,48 @@ class SearchData extends \LibModels\Wap\Product\SearchData
}
/**
* 获取品类数据
*
* @return array 品类数据
* 根据查询条件查询品类列表
*
* @param string $query 关键字
* @param bool $needAllSort 为1时返回全部分类
* @param bool needSmallSort 为1时返回小分类
* @param string $brand 品牌,查多个品牌以逗号分隔
* @param string $mosort 产品产品大分类ID,查多个大类以逗号分隔
* @param string $misort 产品产品中分类ID,查多个中类以逗号分隔
* @param string $sort 产品产品小分类ID,查多个小类以逗号分隔
* @param string $gender 性别,默认为null,"1"表示男, "2"表示女, "3"表示通用
* @param integer $color 颜色id
* @param integer $size 尺码id
* @param integer $price 价格
* @param integer $style 风格ID
* @param integer $parameter_xxx 属性类型ID与值ID 参数名称格式:parameter_{属性类型ID}={属性值ID},如查询厚度为中“parameter_875=4801”
* @param integer $stocknumber 库存量
* @param integer $shelve_time 时间区间
* @param integer $specialoffer 特价类型
* @param bool $sales 是否销售
* @param bool $promotion 是否为促销品
* @param integer $vdt 是否为促销品
* @param bool $vdt 折扣类型
* @param integer $p_d 促销浮点值
* @param integer $attribute 商品属性 1正常商品 2赠品
* @param integer $limited 是否限量 “N”或“Y”
* @param integer $new 是否新品 “N”或“Y”
* @param integer $status 是否上架
* @param integer $sell_channels 销售平台
* @param integer $p_d_int 促销折扣 int型如7
* @param integer $act_temp 活动模板
* @param integer $act_rec 活动模板是否推荐
* @param integer $act_status 活动模板商品状态
* @param integer $attribute_not 过滤商品属性,attribute_not=2过滤掉赠品
* @param integer $not_* not_字段名,过滤字段
* @return array 搜索到的数据
*/
public static function getClassesData($condition = array(), $cache = false)
public static function getClassesData($classes = array(), $cache = false)
{
$param['brand'] = $condition;
return Yohobuy::get(self::getUrl('sort'),$param, $cache);
$classes['sales'] = 'Y'; //在销售商品分类
$classes['status'] = 1; //上架商品分类
$classes['stocknumber'] = 1; //过滤掉已售罄
return Yohobuy::get(self::getUrl('sort'),$classes, $cache);
}
/**
... ...
<?php
namespace Plugin;
use Plugin\Images;
use Plugin\Paging;
/**
* 搜索辅助类
*/
... ... @@ -10,11 +10,10 @@ class HelperSearch
/**
* 请求时用的所有参数
*/
private static $params = array();
public static $params = array();
//当前页面
private static $current_url = '';
private static $page = 1;
//当前页
public static $page = 1;
/**
* 选中的条件
... ... @@ -25,147 +24,142 @@ class HelperSearch
* list分类面包屑
* @var array
*/
public static $listnav = array(
array(
public static $listnav = array();
//设置导航
private static function setListNav($option = array())
{
$cookieChannel = isset($_COOKIE['_Channel']) ? $_COOKIE['_Channel'] : 'boys';
if (isset($option['brandName']) && !empty($option['brandName'])) {
$initNav = $option['brandName'];
}else{
$initNav = '列表';
}
self::$listnav[0] = array(
'href' => '',
'name' => '首页'
),
array(
'name' => $cookieChannel
);
self::$listnav[1] = array(
'href' => '',
'name' => '列表'
)
);
'name' => $initNav
);
}
/**
* 组织搜索模板数据
* @param array $data
* @param array $options
* @return array
*/
public static function getList($data = array() , $options = array()) {
if (empty($data)) {
return array();
}
public static function getList($data = array() , $options = array())
{
$result = array();
self::$params = $_GET;
unset(self::$params['/']);
unset(self::$params['page']);
unset(self::$params['/sale']);
unset(self::$params['sale']);
$result = array();
if (!isset($data['data']) || !isset($data['data']['product_list']) || !is_array($data['data']['product_list'])) {
return array();
}
$result['product_list'] = self::getProductList($data['data']['product_list'], $options['imgSize'], $options['minImgSize'], $options['gender']);
$filter = $data['data']['filter'];
//产品列表
$result['goods'] = self::getProductList($data['data']['product_list'], $options['imgSize']);
//总页数
$result['page_total'] = $data['data']['page_total'];
$result['total'] = $data['data']['total'];
//当前页
$result['page'] = $data['data']['page'];
//设置当前页
self::$page = $result['page'];
//搜索条件
if (isset($data['data']['filter']) && !empty($data['data']['filter'])) {
$filter = $data['data']['filter'];
$result['filter']['left_sort'] = isset($filter['minsort']) ? self::minsort($filter['minsort']) : array();
$result['filter']['group_sort'] = isset($filter['group_sort']) ? self::groupSort($filter['group_sort'], $options) : array();
$result['filter']['size'] = self::size($filter);
$result['filter']['color'] = self::color($filter);
$result['filter']['price'] = self::price($filter);
$result['filter']['brand'] = self::brand($filter);
$result['filter']['parameters'] = self::standard($filter);
$result['filter']['rowNum4'] = self::rowNum();
$result['filter']['rowNum6'] = self::rowNum(6);
$result['filter']['viewNum'] = self::viewNum();
$result['filter']['priceSubmit'] = self::priceSubmit();
$result['filter']['gender'] = self::gender($filter);
$result['filter']['selected'] = self::getSelected();
$result['filter']['checks'] = array(self::isnew(),self::specialoffer(),self::limited());
$result['filter']['sortType'] = array( self::orderDefault(),self::orderTime(),self::orderPrice(),self::orderDiscount());
$result['filter']['clear'] =self::current();
$result['filter']['next'] = self::next($data['data']['page_total'],$data['data']['filter']);
$result['filter']['listnav'] = self::$listnav;
$result['filter']['discount'] = self::getDiscount($filter['discount']);
$result['filter']['recent'] = self::recentShelve($filter['recent']);
$result['filter']['seniorChose'] = self::seniorChose($filter);
}
//清除选中
$result['filters']['checkedConditions']['clearUrl'] = self::current();
//频道
$result['filters']['channel'] = self::gender($filter);
//分类
$result['filters']['sort'] = array();
//品牌
$result['filters']['brand'] = self::brand($filter);
//价格
$result['filters']['price'] = self::price($filter);
//颜色
$result['filters']['color'] = self::color($filter);
//尺寸
$result['filters']['size'] = self::size($filter);
//高级选项
$result['filters']['seniorChose'] = self::seniorChose($filter);
//排序方式
$result['opts']['sortType'] = array( self::orderDefault(),self::orderTime(),self::orderPrice(),self::orderDiscount());
//特殊:新品、特价、限量
$result['opts']['checks'] = array(self::isnew(),self::specialoffer(),self::limited());
//每行显示5个产品
$result['opts']['fivePerLine'] = true;
//每行显示6个产品
$result['opts']['sixPerLineHref'] = true;
//每页显示的数量
$result['opts']['countPerPage'] = $options['viewNum'];
//可选每页显示数量
$result['opts']['pageCounts'] = self::viewNum();
$result['opts']['curPage'] = self::$page;
$result['opts']['pageCount'] = $data['data']['page_total'];
$result['opts']['nextHref'] = self::next($data['data']['page_total'],$data['data']['filter']);
$result['hasNextPage'] = array(
'href' => self::next($data['data']['page_total'],$data['data']['filter']),
'src' => 'http://img10.static.yhbimg.com/product/2014/01/15/11/01fa01614784f6239760f1b749663016f1.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90'
);
//分类
$result['leftContent'][]['allSort'] = isset($filter['group_sort']) ? self::groupSort($filter['group_sort'], $options) : array();
//一周新品上架
$result['leftContent'][]['newSales'] = self::recentShelve($filter['recent']);
//全部折扣
$result['leftContent'][]['allDiscount'] = self::getDiscount($filter['discount']);
//总记录数
$result['totalCount'] = $data['data']['total'];
//分页
$result['pager'] = self::pager($result['totalCount'],$options['viewNum']);
//echo $result['pager']; exit;
//选中条件
$result['filters']['checkedConditions']['conditions'] = self::getSelected();
$result['pathNav'] = self::$listnav;
return $result;
}
/**
* 组织列表模板数据
*
*/
public static function getTemplateData($result, $options){
//模板数据
$data = array(
'brandBanner' => array(),
'pathNav' => $result['filter']['listnav'],
'shopEntry' => array(),
'filters' => array(
'checkedConditions' => array(
'conditions' => $result['filter']['selected'],
'clearUrl' => $result['filter']['clear']
),
'channel' => $result['filter']['gender'],
'sort' => array() ,
'brand' => $result['filter']['brand'],
'price' => $result['filter']['price'],
'color' => $result['filter']['color'],
'size' => $result['filter']['size'],
'seniorChose' => $result['filter']['seniorChose']
),
'opts' => array(
'sortType' => $result['filter']['sortType'],
'checks' => $result['filter']['checks'],
'fivePerLine' => true,
'sixPerLineHref' => '',
'countPerPage' => $options['viewNum'],
'pageCounts' => $result['filter']['viewNum'],
'curPage' => $result['page'],
'pageCount' => $result['page_total'],
'nextHref' => $result['filter']['next']
),
'goods' => $result['product_list'],
'allSort' => array(
'updateNum' => $result['filter']['group_sort']['all']['num'],
'list' => $result['filter']['group_sort']['list']
),
'advNav' => array(),
'advPic' => array(),
'newSales' => $result['filter']['recent'],
'allDiscount' => $result['filter']['discount']
);
return $data;
}
/**
* TODO 组织商品列表信息
* @param $product 接口返回商品列表
* @author sefon 2015-12-21 17:24:04
* @return array
*/
public static function getProductList($product,$imgSize){
$result = array();
$goods = array();
foreach($product as $key => $val){
//NEW
$isNew = $val['is_new'] == 'Y' ? true : false;
$isFew = $val['is_soon_sold_out'] == 'Y' ? true : false;
$is_promotion = $val['is_promotion'];
//限量商品
$isLimit = isset($val['is_limited']) && $val['is_limited'] === 'Y';
//即将售罄
$isFew = $val['is_soon_sold_out'] === 'Y' ? true : false;
//SALE
//新品节
//再到着
//年终大促
// 年中大促
foreach($val['goods_list'] as $k => $v){
$goods_list[$k]['url'] = Helpers::getUrlBySkc($val['product_id'], $v['goods_id'], $val['cn_alphabet']);
}
if (!empty($val['default_images'])) {
$val['default_images'] = Images::getImageUrl($val['default_images'],$imgSize[0],$imgSize[1]);
}
$result[] = array(
$goods[] = array(
'tags' => array(
'isNew' => $isNew,
'isYearEndPromotion' => $is_promotion
'isLimit' => $isLimit
),
'url' => $goods_list[0]['url'],
'thumb' => $val['default_images'],
'name' => $val['product_name'],
'salePrice' => $val['sales_price'],
'isFew' => $isFew
'marketPrice' => $val['market_price'],
'isFew' => $isFew,
'skn' => $val['product_skn']
);
}
return $result;
return $goods;
}
/**
* 版型等其它筛选项
... ... @@ -256,13 +250,8 @@ class HelperSearch
* @param array $params
* @return array
*/
/**
* 组织搜索列表页面的左侧分类
* @param array $sort
* @param array $params
* @return array
*/
public static function groupSort($sort, $option = array()) {
self::setListNav();
$params = self::$params;
$gender = isset($params['gender']) ? $params['gender'] : '';
... ... @@ -295,8 +284,8 @@ class HelperSearch
'sort_id' => 0,
'name' => '全部品类',
'href' => self::buildurl($query) ,
'num' => 0,
'selected' => ''
// 'num' => 0,
'active' => ''
) ,
'list' => array()
);
... ... @@ -311,12 +300,12 @@ class HelperSearch
))
);
}
$result['all']['num']+= $val['count'];
//$result['all']['num']+= $val['count'];
$msort = array(
'sort_id' => $val['sort_id'],
'name' => $val['sort_name'],
'num' => $val['count'],
'selected' => isset($params['msort']) && $params['msort'] == $val['sort_id'] ? true : false,
// 'num' => $val['count'],
'active' => isset($params['msort']) && $params['msort'] == $val['sort_id'] ? true : false,
'href' => self::buildurl(array_merge($query, array(
'msort' => $val['sort_id']
))) ,
... ... @@ -328,8 +317,8 @@ class HelperSearch
$sub[] = array(
'sort_id' => $val['sort_id'],
'name' => '全部' . $val['sort_name'],
'num' => $val['count'],
'selected' => !isset($params['misort']) && isset($params['msort']) && $params['msort'] == $val['sort_id'] ? true : false,
// 'num' => $val['count'],
'childActive' => !isset($params['misort']) && isset($params['msort']) && $params['msort'] == $val['sort_id'] ? true : false,
'href' => self::buildurl(array_merge($query, array(
'msort' => $val['sort_id']
))) ,
... ... @@ -346,8 +335,8 @@ class HelperSearch
$sub[] = array(
'sort_id' => $mval['sort_id'],
'name' => $mval['sort_name'],
'num' => $mval['count'],
'selected' => isset($params['misort']) && $params['misort'] == $mval['sort_id'] ? true : false,
// 'num' => $mval['count'],
'childActive' => isset($params['misort']) && $params['misort'] == $mval['sort_id'] ? true : false,
'href' => self::buildurl(array_merge($query, array(
'msort' => $val['sort_id'],
'misort' => $mval['sort_id']
... ... @@ -364,16 +353,18 @@ class HelperSearch
/**
* 品牌,可以多选
* @param array $brand
* @param array $options
* @return array
*/
public static function brand($filter) {
public static function brand($filter, $options = array()) {
if (isset($options['brandName'])) {
return array();
}
$params = self::$params;
$brand_ids = isset($params['brand']) && !empty($params['brand']) ? explode(',', $params['brand']) : array();
if (isset($params['brand'])) {
unset($params['brand']);
}
$result = array(
'default' => array() ,
'brandIndex' => array(
... ... @@ -391,14 +382,11 @@ class HelperSearch
'U~Z' => array() ,
)
);
$brand_keys = array_reverse(array_keys($result['list']));
if (isset($filter['brand']) && !empty($filter['brand'])) {
//有商品结果时
$brand = $filter['brand'];
foreach ($brand as $v) {
if (!isset($v['brand_alif']) && isset($v['brand_name_en'])) {
$v['brand_alif'] = substr($v['brand_name_en'], 0, 1);
}
... ... @@ -408,7 +396,6 @@ class HelperSearch
if (!isset($v['brand_domain'])) {
$v['brand_domain'] = '';
}
//选中的筛选条件
if (in_array($v['id'], $brand_ids)) {
$selected_brand = explode(',', self::$params['brand']);
... ... @@ -421,9 +408,7 @@ class HelperSearch
'href' => self::buildurl($selected_params)
);
}
$selected_brand = isset(self::$params['brand']) && !empty(self::$params['brand']) ? explode(',', self::$params['brand']) : array();
if (empty($selected_brand)) {
$url = self::buildurl(array_merge($params, array(
'brand' => $v['id']
... ... @@ -442,15 +427,13 @@ class HelperSearch
'brand' => implode(',', $selected_brand)
)));
}
$this_brand = array(
'brand_id' => $v['id'],
'name' => $v['brand_name'],
'alif' => $v['brand_alif'],
'href' => $url,
'selected' => in_array($v['id'], $brand_ids) ? true : false
'active' => in_array($v['id'], $brand_ids) ? true : false
);
if (count($result['default']) < 10) {
$result['default'][] = $this_brand;
}
... ... @@ -472,11 +455,9 @@ class HelperSearch
}
}
else if (isset($filter['paramNames']) && isset($filter['paramNames']['brand'])) {
//无商品结果时且选择了品牌
$brand = $filter['paramNames']['brand'];
foreach ($brand as $v) {
//选中的筛选条件
if (in_array($v['id'], $brand_ids)) {
$selected_brand = explode(',', self::$params['brand']);
... ... @@ -743,7 +724,8 @@ class HelperSearch
/**
* 高级选项
*/
public static function seniorChose($filter){
public static function seniorChose($filter)
{
$style = self::style($filter);
$other = self::standard($filter);
$result = array_merge($style,$other);
... ... @@ -753,9 +735,9 @@ class HelperSearch
/**
* 每页显示数量
*/
public static function viewNum() {
public static function viewNum()
{
$params = self::$params;
$view_num = array(
60,
100,
... ... @@ -776,8 +758,9 @@ class HelperSearch
/**
* 显示行数
*/
public static function rowNum($num = 5) {
$params = self::$params;
public static function rowNum($num = 5)
{
$params = self::$params;
$params['rowNum'] = $num;
... ... @@ -787,7 +770,8 @@ class HelperSearch
/**
* 是否特价
*/
public static function specialoffer() {
public static function specialoffer()
{
$params = self::$params;
if (isset($params['specialoffer']) && !empty($params['specialoffer'])) {
unset($params['specialoffer']);
... ... @@ -808,7 +792,8 @@ class HelperSearch
/**
* 是否限量
*/
public static function limited() {
public static function limited()
{
$params = self::$params;
if (isset($params['limited']) && !empty($params['limited'])) {
unset($params['limited']);
... ... @@ -828,7 +813,8 @@ class HelperSearch
/**
* 是否新品
*/
public static function isnew() {
public static function isnew()
{
$params = self::$params;
if (isset($params['isNew']) && !empty($params['isNew'])) {
... ... @@ -849,7 +835,8 @@ class HelperSearch
/**
* 排序是否最新
*/
public static function orderTime() {
public static function orderTime()
{
$params = self::$params;
if (isset($params['order'])) {
unset($params['order']);
... ... @@ -867,7 +854,8 @@ class HelperSearch
/**
* 排序是否默认
*/
public static function orderDefault() {
public static function orderDefault()
{
$params = self::$params;
if (isset($params['order'])) {
unset($params['order']);
... ... @@ -883,7 +871,8 @@ class HelperSearch
/**
* 价格排序
*/
public static function orderPrice() {
public static function orderPrice()
{
$params = self::$params;
if (isset($params['order'])) {
unset($params['order']);
... ... @@ -925,7 +914,8 @@ class HelperSearch
/**
* 折扣排序
*/
public static function orderDiscount() {
public static function orderDiscount()
{
$params = self::$params;
if (isset($params['order'])) {
unset($params['order']);
... ... @@ -967,7 +957,8 @@ class HelperSearch
/**
* 获取自定义价格要提交的地址
*/
public static function priceSubmit() {
public static function priceSubmit()
{
$params = self::$params;
$price = array();
if (isset($params['price'])) {
... ... @@ -1009,7 +1000,8 @@ class HelperSearch
* @param array $params
* @return string
*/
private static function buildurl($params) {
private static function buildurl($params)
{
if (empty($params)) {
return self::current();
}
... ... @@ -1033,7 +1025,8 @@ class HelperSearch
/**
* 获取选中的条件
*/
public static function getSelected() {
public static function getSelected()
{
$result = array();
$is_array_key = array(
'brand',
... ... @@ -1057,7 +1050,10 @@ class HelperSearch
* @param array $list
* @return array
*/
public static function getDiscount(array $list = array()) {
public static function getDiscount(array $list = array())
{
$params = self::$params;
if (empty($list)) {
return array();
}
... ... @@ -1077,12 +1073,12 @@ class HelperSearch
$total+= $v['count'];
$query['p_d'] = $k;
$list[$k]['href'] = self::buildurl($query);
$list[$k]['num'] = $total;
$list[$k]['selected'] = isset($params['p_d']) && $params['p_d'] == $k ? true : false;
//$list[$k]['num'] = $total;
$list[$k]['active'] = isset($params['p_d']) && $params['p_d'] == $k ? true : false;
}
$result = array(
'updateNum' => $total,
'list' => $list
//'updateNum' => $total,
'list' => array_values($list)
);
return $result;
}
... ... @@ -1090,11 +1086,12 @@ class HelperSearch
/**
* 最新上架
*/
public static function recentShelve($list = array()){
public static function recentShelve($list = array())
{
if (empty($list)) {
return array();
}
$params = $_GET;
$params = self::$params;
$query = array();
if (isset($params['gender'])) {
$query['gender'] = $params['gender'];
... ... @@ -1106,21 +1103,21 @@ class HelperSearch
$query['misort'] = $params['misort'];
}
$data = array();
$total = 0;
$i = 0;
foreach ($list as $k => $v) {
$total+= $v;
$star_time = strtotime($k);
$end_time = $star_time+60*60*24;
$query['shelve_time'] = '';
$query['shelve_time'] = $star_time.','.$end_time;
if (isset($params['shelve_time']) && $query['shelve_time'] == $params['shelve_time']) {
$data[$i]['active'] = true;
}
@$data[$i]['href'] = self::buildurl($query);
$data[$i]['num'] = $v;
$data[$i]['name'] = $k;
$i++;
}
$result = array(
'updateNum' => $total,
//'updateNum' => $total,
'list' => $data
);
return $result;
... ... @@ -1130,11 +1127,7 @@ class HelperSearch
*/
public static function current(){
$url = explode('?', $_SERVER['REQUEST_URI']);
self::$current_url = $url[0];
self::$listnav[0] = array(
'href' => '$url[0]',
'name' => '首页'
);
self::$listnav[0]['href'] = $url[0];
return $url[0];
}
/**
... ... @@ -1150,4 +1143,28 @@ class HelperSearch
}
return self::buildurl($param);
}
/**
* 组织产品的图片
* @param $product
* @param $options
* @return array
*/
public static function getProductPic($product, $options)
{
$result = array();
if (isset($product[0]['goods_list']) && !empty($product[0]['goods_list'])){
foreach ($product[0]['goods_list'] as $key => $val){
$result[$key]['coverImg'] = Images::getImageUrl($val['images_url'], $options['imgSize'][0], $options['imgSize'][1]);
$result[$key]['url'] = Helpers::getUrlBySkc($product[0]['product_id'], $val['goods_id'], $product[0]['cn_alphabet']);
$result[$key]['src'] = Images::getImageUrl($val['images_url'], $options['imgSize'][0], $options['imgSize'][1]);
}
}
return $result;
}
//分页
public static function pager($total,$view_num){
$Paging = new Paging('Yoho');
return $Paging->setTotal($total)->setSize($view_num)->view(0);
}
}
... ...
<?php
namespace Plugin;
use \Hood\Paging as HPage;
class Paging extends HPage
{
/**
* 路径
*
* @var String
*/
private $path = '';
/**
* 查询参数
* String or Array
* @var mixed
*/
private $query;
/**
* 分页集尺寸
*
* @var Integer
*/
private $pageSetSize = 11;
/**
* 子串
*
* @var String
*/
private $substring = '?';
/**
* 连接符号
*
* @var String
*/
private $sign = '=';
/**
* 对符
*
* @var String
*/
private $pairs = '&';
/**
* 模板路径
*
* @var String
*/
private $templatePath = '';
/**
* jsName
* @var String
*/
private $jsFName = '';
/**
* 废弃参数
* @var String
*/
private $disuse = null;
/**
* 设置分页链接中的关键字
*
* @var String
*/
private $keyword = 'page';
/**
* 是否开启rewrite url
*
* @var bool
*/
private $rewrite = false;
/**
* 附加参数
* @var string
*/
private $appendParam = '';
/**
* 分页中代码当前页码的常量
*
*/
const PAGER_VARIABLE_STRING = "%{PAGE_NO}";
public function __construct($file)
{
$this->templatePath = __DIR__ . '/Paging/' . ucfirst($file) . '.php';
}
/**
* 新的获取当前偏移
* @return Integer
*/
public function getNewCurrent()
{
if ($this->currentPage > 1) {
return min($this->currentPage, $this->getPageNum());
}
$pageNo = !isset($_GET[$this->keyword]) ? 0 : (int)(intval($_GET[$this->keyword]) * $this->getSize()) - $this->getSize();
return (int)($pageNo < 0 ? 0 : $pageNo);
}
/**
* 重载当前页方法
* @return Integer
*/
public function getCurrent()
{
if ($this->currentPage > 1) {
return min($this->currentPage, $this->getPageNum());
}
$pageNo = isset($_GET[$this->keyword]) ? (int)intval($_GET[$this->keyword]) : 1;
if ($pageNo <= 0) {
$pageNo = 1;
}
$this->currentPage = min($pageNo, $this->getPageNum());
return $this->currentPage;
}
/**
* 获取关键词
* @return String
*/
public function getKeyword()
{
return $this->keyword;
}
/**
* 设置关键词
*
* @param String $keyword
* @return QLib_Paging
*/
public function setKeyword($keyword)
{
if (!empty($keyword)) {
$this->keyword = $keyword;
}
return $this;
}
/**
* 设置js名字
* @param String $name
* @return Q_Page_Abstract
*/
public function setFJs($name)
{
if (!empty($name)) {
$this->jsFName = $name;
}
return $this;
}
/**
* 设置附加参数
* @param string $param
* @return Q_Page_Abstract
*/
public function setAppendParam($param)
{
$this->appendParam = $param;
return $this;
}
/**
* 获取附加参数
* @return string
*/
public function getAppendParam()
{
return $this->appendParam;
}
/**
* 获取分页js名字
* @return String
*
*/
public function getFJs()
{
return $this->jsFName;
}
/**
*
* 设置链接的路径
*
* @param String $path
* @return QLib_Paging
*/
public function setPath($path)
{
if (!empty($path)) {
$this->path = trim($path);
}
return $this;
}
/**
* 设置连续Url
*
* @param bool $seo
* @return QLib_Paging
*/
public function rewrite($rw = true)
{
if ($rw == true) {
$this->substring = '';
$this->sign = '/';
$this->pairs = '/';
$this->rewrite = true;
}
return $this;
}
/**
* 取得程序路径
* @return String
*/
public function getPath()
{
return $this->path;
}
/**
* 设置分页集尺寸
*
* @param integer $num 大于1
* @return QLib_Paging
*/
public function setPageSetSize($num)
{
$this->pageSetSize = (int)intval($num);
return $this;
}
/**
* 取得分页集尺寸
*
* @return integer
*/
public function getPageSetSize()
{
return (int)$this->pageSetSize;
}
/**
* 获取查询参数
* @return String
*/
public function getQuery()
{
$query = $this->query;
if (empty($this->query)) {
$this->query = $this->autoUrl();
}
if (is_array($this->query) && count($this->query) > 0) {
$_query = array();
foreach ($this->query as $key => $value) {
if($key == '_pjax'){
break;
}
if ($key == $this->getKeyword()) {
continue;
}
if (is_array($value)) {
foreach ($value as $k => $val) {
$_query[] = "{$key}[]" . $this->sign . $val;
}
} else {
$_query[] = "{$key}" . $this->sign . $value;
}
}
$this->query = $this->pairs . implode($this->pairs, $_query);
}
return $this->query ? $this->query : '';
}
/**
* 获取URL
*
* @param Integer $pageNo
* @return String
*/
public function getUrl($pageNo)
{
$query = $this->getQuery();
if (strstr($query, self::PAGER_VARIABLE_STRING) && is_string($query)) {
$query = str_replace(self::PAGER_VARIABLE_STRING, $pageNo, $query);
} else {
if (empty($query)) {
$query = $this->getKeyword() . $this->sign . $pageNo;
} else {
$query = $this->getKeyword() . $this->sign . $pageNo . $query;
}
}
$url = $this->getPath() . $this->substring . $query;
if ($this->getFJs()) {
$url = $query;
}
return $url;
}
/**
* 设置查询参数
*
* @param mixed $query String or Array
* @return QLib_Paging
*/
public function setQuery($query)
{
$this->query = $query;
return $this;
}
/**
* 设置模板路径
*
* @param String $path
* @return QLib_Paging
*/
public function setTemplate($path)
{
$this->templatePath = $path;
return $this;
}
/**
* 输出模板
*/
public function view($print = true)
{
if ($this->getTotal() > 0) {
include($this->templatePath);
if($print){
print $html;
}else{
return $html;
}
}
return '';
}
/**
* 自动组织 URL
* @return Array
*/
private function autoUrl()
{
$queryOpt = $_SERVER['REQUEST_URI'];
$queryArg = parse_url($queryOpt);
$queryOpt = isset($queryArg['query']) ? explode('&', $queryArg['query']) : array();
$query = array();
foreach ($queryOpt as $key => $val) {
$strTmp = explode('=', $val);
if (count($strTmp) < 2 || empty($strTmp[0]) || $strTmp[1] == '' || $strTmp[0] == $this->getKeyword()) {
continue;
}
if (is_array($this->disuse)) {
if (in_array($strTmp[1], $this->disuse) || in_array($strTmp[0], $this->disuse)) {
continue;
}
} else {
if ($strTmp[1] == $this->disuse || $strTmp[0] == $this->disuse) {
continue;
}
}
$query[$strTmp[0]] = $strTmp[1];
}
return $query;
}
/**
* set废弃参数
* @param mixed $disuse
* @return QLib_Paging
*/
public function setDisuse($disuse = null)
{
$this->disuse = $disuse;
return $this;
}
}
\ No newline at end of file
... ...
<?php
$pages = array();
$pageNum = $this->getPageNum(); #总分页数
$current = $this->getCurrent(); #当前页
$size = $this->getSize(); #每页显示数
$total = $this->getTotal(); #获取总数
$pageSetNum = $this->getPageSetSize(); #分页集数
$start = $end = 0;
if($current <= 4){
$start = 1;
$end = $start + 4;
}elseif(($pageNum - $current - 2) > 1)
{
$start = $current - 2 < 1 ? 1 : $current - 2;
$end = $current + 2;
}else{
$start = $current - 2;
$end = $pageNum;
}
if($end > $pageNum)
{
$end = $pageNum;
}
$startNum = $size * ($current - 1) + 1;
$endNum = min($size * $current, $total);
$html = '';
if($current > 1)
{
$html .= '<a href="' . $this->getUrl($current - 1) . '" title="上一页"><span class="ifont10"><</span></a>';
}
if ($pageNum > 1) {
if($pageNum > 5 && $current > 4){
$html .= '<a href="' . $this->getUrl(1) . '"><span>' . 1 . '</span></a>';
$html .= '<a><span>...</span></a>';
$start = $current - 2;
$end = $pageNum - $current <= 3 ? $pageNum : $current + 2;
}
for ($i = $start; $i <= $end; ++$i) {
$_start = $size * ($i - 1) + 1;
$_end = min($size * $i, $total);
if ($i != $current) {
$html .= '<a href="' . $this->getUrl($i) . '"><span>' . $i . '</span></a>';
}
else {
$html .= '<a href="'. $this->getUrl($i) .'" class="cur"><span>' . $i . '</span></a>';
}
}
if($pageNum > 5 && $pageNum - $current > 3){
$html .= '<a><span>...</span></a>';
$html .= '<a href="' . $this->getUrl($pageNum) . '"><span>' . $pageNum . '</span></a>';
}
}
if ($current < $pageNum) {
$html .= '<a href="' . $this->getUrl($current + 1) . '" class="page_next" title="下一页"><span class="ifont10">></span></a>';
}
... ...
<?php
$pages = array();
$pageNum = $this->getPageNum(); #总分页数
$current = $this->getCurrent(); #当前页
$size = $this->getSize(); #每页显示数
$total = $this->getTotal(); #获取总数
$pageSetNum = $this->getPageSetSize(); #分页集数
$start = $end = 0;
if($current <= 4){
$start = 1;
$end = $start + 4;
}elseif(($pageNum - $current - 2) > 1)
{
$start = $current - 2 < 1 ? 1 : $current - 2;
$end = $current + 2;
}else{
$start = $current - 2;
$end = $pageNum;
}
if($end > $pageNum)
{
$end = $pageNum;
}
$startNum = $size * ($current - 1) + 1;
$endNum = min($size * $current, $total);
$html = '<div class="left"><span class="rgb9">'.$startNum.' - '.$endNum.' / 共'.$total.'件商品</span></div><div class="goods-page right">';
if ($current > 1) {
$html .= '<a href="' . $this->getUrl($current - 1) . '" class="page_pre" title="上一页"><span class="ifont10"><</span>上一页</a>';
}
if ($pageNum > 1) {
if($pageNum > 5 && $current > 4){
$html .= '<a href="' . $this->getUrl(1) . '"><span>' . 1 . '</span></a>';
$html .= '<a><span>...</span></a>';
$start = $current - 2;
$end = $pageNum - $current <= 3 ? $pageNum : $current + 2;
}
for ($i = $start; $i <= $end; ++$i) {
$_start = $size * ($i - 1) + 1;
$_end = min($size * $i, $total);
if ($i != $current) {
$html .= '<a href="' . $this->getUrl($i) . '"><span>' . $i . '</span></a>';
}else {
$html .= '<a href="'. $this->getUrl($i) .'" class="cur"><span>' . $i . '</span></a>';
}
}
if($pageNum > 5 && $pageNum - $current > 3){
$html .= '<a><span>...</span></a>';
$html .= '<a href="' . $this->getUrl($pageNum) . '"><span>' . $pageNum . '</span></a>';
}
}
if ($current < $pageNum) {
$html .= '<a href="' . $this->getUrl($current + 1) . '" title="下一页">下一页<span class="ifont10">></span></a>';
}
$html .= '</div>';
... ...
<?php
$pages = array();
$pageNum = $this->getPageNum(); #总分页数
$current = $this->getCurrent(); #当前页
$size = $this->getSize(); #每页显示数
$total = $this->getTotal(); #获取总数
$pageSetNum = $this->getPageSetSize(); #分页集数
$start = $end = 0;
if($current <= 4){
$start = 1;
$end = $start + 4;
}elseif(($pageNum - $current - 2) > 1)
{
$start = $current - 2 < 1 ? 1 : $current - 2;
$end = $current + 2;
}else{
$start = $current - 2;
$end = $pageNum;
}
if($end > $pageNum)
{
$end = $pageNum;
}
$startNum = $size * ($current - 1) + 1;
$endNum = min($size * $current, $total);
$html = '<div class="left"></div><div class="list-page right">';
if ($current > 1) {
$html .= '<a href="' . $this->getUrl($current - 1) . '" class="page_pre" title="上一页"><span class="ifont10"><</span>上一页</a>';
}
if ($pageNum > 1) {
if($pageNum >= 5 && $current > 4){
$html .= '<a href="' . $this->getUrl(1) . '"><span>' . 1 . '</span></a>';
$html .= '<a><span>...</span></a>';
$start = $current - 2;
$end = $pageNum - $current <= 3 ? $pageNum : $current + 2;
}
for ($i = $start; $i <= $end; ++$i) {
$_start = $size * ($i - 1) + 1;
$_end = min($size * $i, $total);
if ($i != $current) {
$html .= '<a href="' . $this->getUrl($i) . '"><span>' . $i . '</span></a>';
}else {
$html .= '<a href="'. $this->getUrl($i) .'" class="cur"><span>' . $i . '</span></a>';
}
}
if($pageNum > 5 && $pageNum - $current > 3){
$html .= '<a><span>...</span></a>';
$html .= '<a href="' . $this->getUrl($pageNum) . '"><span>' . $pageNum . '</span></a>';
}
}
if ($current < $pageNum) {
$html .= '<a href="' . $this->getUrl($current + 1) . '" title="下一页">下一页<span class="ifont10">></span></a>';
}
$html .= '</div>';
\ No newline at end of file
... ...
{{> layout/header}}
<div class="product-search-page product-page yoho-page center-content">
{{# search}}
{{> layout/path-nav}}
{{> product/standard-content}}
{{> product/latest-walk}}
{{/ search}}
</div>
{{> layout/footer}}
\ No newline at end of file
... ...
... ... @@ -95,7 +95,7 @@ exports.init = function(num) {
});
$.ajax({
type: 'POST',
url: '/product/index/getProductPic',
url: '/product/list/getProductPic',
dataType: 'json',
data: {
skn: event.target.attr('data-skn')
... ...
... ... @@ -3,18 +3,62 @@ namespace Product;
use Plugin\Helpers;
use LibModels\Web\Product\BrandData;
use Product\SearchModel;
use LibModels\Wap\Product\SearchData;
use LibModels\Web\Product\SearchData as WebProduct;
/**
* Description of Brands
* 品牌首页模板数据模型
*
* @author Administrator
*/
class BrandsModel
{
const URL_BRAND_INDEX = '/product/brands/index';
const URL_BRAND_INDEX = '/product/index/brand';
public static $shopName;
public static $home;
/**
* 搜索品牌数据
*
* @param $condition array
* 搜索数据的条件
* @param $options array
* @return array
*/
public static function getBrandSearchData($condition, $options,$domain,$uid,$brandId)
{
// 调用商品搜索接口
$data = SearchData::searchElasticByCondition($condition);
//导航名
$brandName = self::$shopName;
$option['brandName'] = $brandName;
//配置调用分类接口参数
$param = array();
$param['brand'] = $condition['brand'];
//获取分类列表数据
$classes = WebProduct::getClassesData($param);
//获取品牌系列数据
$adNav = self::getAdNav($condition['brand']);
//获取品牌数据
$banner = self::getBannerByDomain($domain, $brandId, $uid = '');
//开始组装数据
return $data;
}
/**
* 获取品牌首页banner条
* @string $domain 品牌域名
... ... @@ -23,18 +67,18 @@ class BrandsModel
*
* @return array 品牌banner条数据
*/
public static function getBannerByDomain($domain, $bannerId, $uid = '')
public static function getBannerByDomain($domain, $brandId, $uid = '')
{
// 构造品牌主页url
$home = Helpers::url('', '', $domain) . self::URL_BRAND_INDEX;
self::$home = Helpers::url('', '', $domain) . self::URL_BRAND_INDEX;
// 根据品牌Id获取品牌banner图
$bannerImg = BrandData::getBrandBanner($bannerId);
$bannerImg = BrandData::getBrandBanner($brandId);
if (isset($bannerImg['data'])) {
$bannerImg = Helpers::getImageUrl($bannerImg['data']['banner'], 1366, 150);
$bannerImg = Helpers::getImageUrl($bannerImg['data']['banner'], '', 150);
}
// 根据品牌Id获取品牌(简介)、收藏
if (isset($uid)) {
$intro = BrandData::getBrandIntro($bannerId, $uid);
$intro = BrandData::getBrandIntro($brandId, $uid);
}
$is_favorite = false;
$logo = false;
... ... @@ -53,7 +97,7 @@ class BrandsModel
// 获取品牌logo
$logo = Helpers::getImageUrl($intro['data']['brand_ico'], 80, 50);
// 获取品牌名
$shopName = $intro['data']['brand_name'];
self::$shopName = $intro['data']['brand_name'];
} while (false);
// 返回banner数据
... ... @@ -65,9 +109,9 @@ class BrandsModel
'banner' => $bannerImg
),
'shopEntry' => array(
'home' => $home,
'home' => self::$home,
'logo' => $logo,
'shopName' => $shopName,
'shopName' => self::$shopName,
'sort' => array(
array(
'href' => '',
... ... @@ -83,20 +127,22 @@ class BrandsModel
);
}
/**
* 搜索品牌数据
*
* @param $condition array
* 搜索数据的条件
* @param $options array
* @return array
*/
public static function getBrandSearchData($condition, $options)
{
// 调用商品搜索接口
$data = \Product\SearchModel::getSearchData($condition, $options);
unset($data['list']['filters']['brand']);
return $data;
}
}
//获取品牌系列数据
public static function getAdNav($brandId,$status = 1)
{//$condition['brand']
//调用接口获得数据
$advNav = BrandData::getFolderByBrand($brandId,$status);
$result = array();
if (isset($advNav['data']) && $advNav['code'] === 200) {
foreach ($advNav['data'] as $key => $value) {
$result['list'][$key]['href'] = self::$home . '?folder=' . $value['id'];
$result['list'][$key]['src'] = $value['brand_sort_ico'];
}
}
return $result;
//$data['list']['advNav'] = $result;
}
}
... ...
... ... @@ -2,6 +2,7 @@
namespace Product;
use Configs\CacheConfig;
use Plugin\HelperSearchNew;
use Plugin\Images;
use Plugin\Cache;
use Plugin\HelperSearch;
... ... @@ -30,32 +31,58 @@ class SearchModel
*/
public static function getSearchData($condition, $options)
{
$data = array();
// 调用接口查询商品数据
$result = SearchData::searchElasticByCondition($condition);
// 调用分类信息
$category = SearchData::getClassesData();
if (isset($category['code']) && $category['code'] === 200) {
$result['data']['filter']['group_sort'] = $category['data']['sort'];
}
// 调用折扣区间
$discount = SearchData::getDiscount();
if (isset($discount['code']) && $discount['code'] === 200) {
$result['data']['filter']['discount'] = $discount['data']['discount'];
}
// 调用最新上架
$recent = SearchData::recentShelve();
if (isset($discount['code']) && $discount['code'] === 200) {
$result['data']['filter']['recent'] = $recent['data']['recent'];
}
// 组织模板数据
if (isset($result['code']) && $result['code'] === 200) {
$res = HelperSearch::getList($result, $options);
$list = HelperSearch::getTemplateData($res, $options);
// 调用分类信息
$category = SearchData::getClassesData();
if (isset($category['code']) && $category['code'] === 200) {
$result['data']['filter']['group_sort'] = $category['data']['sort'];
}
// 调用折扣区间
$discount = SearchData::getDiscount();
if (isset($discount['code']) && $discount['code'] === 200) {
$result['data']['filter']['discount'] = $discount['data']['discount'];
}
// 调用最新上架
$recent = SearchData::recentShelve();
if (isset($discount['code']) && $discount['code'] === 200) {
$result['data']['filter']['recent'] = $recent['data']['recent'];
}
// 组织模板数据
$list = HelperSearch::getList($result, $options);
$data = array(
'productListPage' => true, //初始化js
'list' => $list
);
}
return $data;
}
//初始化js
'productListPage' => true,
'list' => $list
);
}else{
//接口异常,调用二级缓存
$data = array();
}
return $data;
}
/**
* 根据product_sn查询产品图片信息
* @param $product_sn
* @param $options
* @author sefon 2015-12-28 18:09:28
* @return array
*/
public static function getProductPic($product_sn, $options)
{
$condition['query'] = $product_sn;
//返回搜索条件
$condition['needFilter'] = 0;
//获取产品数据
$data = SearchData::searchElasticByCondition($condition);
if (isset($data['code']) && $data['code'] === 200 && isset($data['data']['product_list']) && !empty($data['data']['product_list'])) {
//组织数据结构
$data = HelperSearch::getProductPic($data['data']['product_list'], $options);
}
echo json_encode($data);
}
}
\ No newline at end of file
... ...
... ... @@ -16,16 +16,16 @@ class IndexController extends WebAction
$this->go(SITE_MAIN);
}
$uid = $this->getUid();
//根据品牌域名获取品牌id
//根据品牌域名获取品牌id(同时判断品牌域名是否有效)
$brandInfo = BrandData::getBrandLogoByDomain($domain);
if(!empty($brandInfo['data']) && $brandInfo['code'] === 200){
$brandId = $brandInfo['data']['id'];
}else{
$this->go(SITE_MAIN);
}
//获取品牌banner
$brandBanner = BrandsModel::getBannerByDomain($domain, $brandId, $uid = '');
/* 过滤请求参数 */
$condition = array();
$condition = filter_input_array(INPUT_GET, array(
//'query' => FILTER_SANITIZE_STRING,
'sort' => FILTER_VALIDATE_INT,
... ... @@ -38,10 +38,6 @@ class IndexController extends WebAction
'gender' => FILTER_DEFAULT,
'p_d' => FILTER_DEFAULT,
'shelve_time' => FILTER_DEFAULT,
'parameter_790' => FILTER_DEFAULT,
'parameter_824' => FILTER_DEFAULT,
'parameter_825' => FILTER_DEFAULT,
'parameter_787' => FILTER_DEFAULT,
'isNew' => FILTER_DEFAULT,
'specialoffer' => FILTER_DEFAULT,
'limited' => FILTER_DEFAULT,
... ... @@ -50,8 +46,8 @@ class IndexController extends WebAction
'rowNum' => FILTER_VALIDATE_INT,
'page' => FILTER_VALIDATE_INT,), false);
if(!empty($condition)) {
//字符转码
//字符转码
if (!empty($condition)) {
foreach ($condition as &$value) {
$value = rawurldecode($value);
}
... ... @@ -59,8 +55,7 @@ class IndexController extends WebAction
//传品牌ID参数
$condition['brand'] = $brandId;
//获取性别数据
$gender_cookie = !isset($_COOKIE['_Gender']) ? '3' : ($_COOKIE['_Gender']=='2,3' ? 2 : 1);
$gender = $this->get('gender') ? ($this->get('gender') == '2,3' ? 2 : 1) : $gender_cookie;
$gender = $this->get('gender') ? ($this->get('gender') == '2,3' ? 2 : 1) : (!isset($_COOKIE['_Gender']) ? '3' : ($_COOKIE['_Gender']=='2,3' ? 2 : 1));
$condition['gender'] = $gender;
//每页显示商品数
... ... @@ -97,12 +92,9 @@ class IndexController extends WebAction
$params = $condition + $_GET;
$params = array_filter($params);
$data = Product\BrandsModel::getBrandSearchData($params,$options);
$data = Product\BrandsModel::getBrandSearchData($params,$options,$domain,$uid,$brandId);
$cate = array('boys','girls','kids','lifestyle');
$this->setWebNavHeader($cate[$gender-1]);
//合并banner与搜索数据
$data = array_merge_recursive($data,$brandBanner);
//删除搜索参数中的品牌选项
//渲染模板
$this->_view->display('list',$data);
}
... ...
<?php
use Action\WebAction;
use Product\SearchModel;
class ListController extends WebAction
{
public function indexAction()
{
}
public function newAction(){
}
/**
* list列表sale
... ... @@ -76,9 +80,40 @@ class ListController extends WebAction
);
$params = $condition + $_GET;
$params = array_filter($params);
$data = Product\SearchModel::getSearchData($params,$options);
$data = SearchModel::getSearchData($params,$options);
$cate = array('boys','girls','kids','lifestyle');
$this->setWebNavHeader($cate[$gender-1]);
$this->_view->display('list', $data);
}
/**
* 根据product_skn获取产品图片信息
* @author sefon 2015-12-28 18:35:24
* @return json
*/
public function getProductPicAction()
{
$product_skn = $this->post('skn');
if (!$product_skn) {
return ;
}
//大图
$imgSize = array();
//小图
$minImgSize = array();
$rowNum = $this->post('rowNum');
if ($rowNum == 5) {
$imgSize = array(195, 260);
$minImgSize = array(50, 67);
} else {
$condition['rowNum'] = 4;
$imgSize = array(235, 314);
$minImgSize = array(60, 80);
}
$options = array(
'imgSize' => $imgSize,
'minImgSize' => $minImgSize,
);
SearchModel::getProductPic($product_skn, $options);
}
}
\ No newline at end of file
... ...