Sale.php 2.15 KB
<?php

namespace Product;

use LibModels\Wap\Product\SearchData;
use LibModels\Web\Product\SearchData as WebProduct;
use Plugin\HelperSearch;
use Plugin\Images;
/**
 * sale首页模板数据模型
 *
 */
class SaleModel 
{

    public static function getSaleSearchData($params, $options, $specialInfo) 
    {
        $data = SearchData::searchElasticByCondition($params);
        
        if (isset($data['code']) && $data['code'] === 200) {
            //获取分类列表数据
            $classes = WebProduct::getClassesData();
            if (isset($classes['code']) && $classes['code'] === 200) {
                $data['data']['filter']['group_sort'] = $classes['data']['sort'];
            }

            //用户浏览记录
            
            // 组织模板数据
            $list = HelperSearch::getList($data, $options);
            
            //删除面包屑导航数据
            unset($list['pathNav']);
            
            $data = array(
                //初始化js
                'productListPage' => true,
                'newSale' => $list
            );
        } else {
            $data = array();
        }
        
        //组织sale数据
        if (isset($specialInfo['data']) && !empty($specialInfo['data']['banner_img'])) {
            $banner = json_decode($specialInfo['data']['banner_img'], true);
            foreach ($banner as $k => $v) {
                $v['img'] = Images::getSourceUrl($v['img'], 'couponImg');
                $specialInfo['data']['banner'][] = $v;
            }
             $special = $specialInfo['data'];
        }
        
        //Sale首页 banner数据
        $data['newSale']['saleBanner']['bannerHeight'] = $special['banner'][0]['height'];
        $data['newSale']['saleBanner']['img'] = $special['banner'][0]['img'];
        $data['newSale']['saleTitle']['name'] = '全部商品';
        $data['newSale']['saleTitle']['count'] = $data['newSale']['totalCount'];
        
        
         //获取广告位数据
        $nodeContent = HelperSearch::formatNodeContent($special['left_ad_code']);
        $data['newSale']['leftContent'][]['picLink']['list'] = $nodeContent;
        
        return $data;
    }

}