Search.php 1.65 KB
<?php

use Action\AbstractAction;
use LibModels\Wap\Product\SearchData;
/**
 * 搜索页
 */
class SearchController extends AbstractAction
{
    public function indexAction()
    {
        $data = array(
            array(
                'hot' => array(
                    array(
                        'name' => '夹克',
                        'url' => 'm.yohobuy.com'
                    ),
                    array(
                        'name' => '休闲运动鞋',
                        'url' => 'm.yohobuy.com'
                    ),
                    array(
                        'name' => 'Into the Rainbow',
                        'url' => 'm.yohobuy.com'
                    )
                ),
                'history' => array(
                    array(
                        'name' => 'what',
                        'url' => 'm.yohobuy.com'
                    ),
                    array(
                        'name' => 'the',
                        'url' => 'm.yohobuy.com'
                    ),
                    array(
                        'name' => 'fuck',
                        'url' => 'm.yohobuy.com'
                    )
                )
            )
        );
        $this->_view->display('index', array('search' => $data, 'searchPage' => true, 'pageFooter' => true));
    }

    /**
     * 模糊搜索指定字符
     * 
     * @return array 模糊搜索的结果
     */
    public function fuzzysearch()
    {
        if($this->isAjax())
        {
            $keyword = $this->post('keyword', '');

            $result = SearchData::searchFuzzyDatas($keyword);

            $this->echoJson($result);
        }
    }
}