Search.php
3.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
use Action\WebAction;
use Product\SearchModel;
class SearchController extends WebAction
{
public function indexAction()
{
$this->setTitle('潮流商品搜索 | YOHO!有货');
$this->setKeywords('Yoho! 有货,潮流,时尚,流行,购物,B2C,正品,购物网站,网上购物,货到付款,品牌服饰,男士护肤,黑框眼镜,匡威,板鞋,i.t,izzue,5cm,eastpak,vans,lylescott,g-shock,new balance,lacoste,melissa,casio,卡西欧手表,舒雅,jasonwood,odm,AAAA,香港购物,日本潮流');
$this->setDescription('潮流商品搜索,上衣,衬衫,TEE,卫衣,冲锋衣,风衣,羽绒服,裤子,休闲鞋,板鞋,配饰,复古眼镜');
$this->setWebNavHeader();
$list = SearchModel::searchData(array(), array(
'controller' => 'Search',
'action' => 'index',
'reviewNum' => 7, //浏览记录数
));
//统计前三个商品
$skn=array();
$arr=array();
if (isset($list['goods']) && !empty($list['goods'])) {
$arr = array_slice($list['goods'],0,3);
foreach ($arr as $key=>$value) {
$skn[] = $value['skn'];
}
$arr = array('skn'=>$skn);
}else{
$arr = array('skn'=>array());
}
$data = array(
'productListPage' => true, //初始化js
'list' => $list,
'criteo' => $arr
);
$data['list']['searchPage'] = true; //设置搜素页面标识,区分列表页-->特有的搜索页导航样式
if (isset($data['list']['goods']) && empty($data['list']['goods'])) {
$searchData['productListPage'] = true;
$searchData['search']['pathNav'] = isset($data['list']['pathNav']) ? $data['list']['pathNav'] : '';
$searchData['search']['keyWord'] = isset($data['list']['keyWord']) ? $data['list']['keyWord'] : '';
$searchData['search']['searchActionUrl'] = isset($data['list']['searchActionUrl']) ? $data['list']['searchActionUrl'] : '';
$searchData['search']['latestWalk'] = 7;
$this->_view->display('no-result', $searchData);
exit;
}
$this->_view->display('search', $data);
}
/**
* 搜索提示
*/
public function suggestAction()
{
$callback = $this->get('callback');
$query = rawurldecode($this->get('query'));
$size = rawurldecode($this->get('size',10));
if (empty($query)) {
$this->helpJsonCallbackResult($callback, 412, '搜索词为空');
}
if ($size > 50) {
$size = 10;
}
if ($query) {
$param['query'] = $query;
$param['size'] = $size;
$suggest = SearchModel::getSuggest($param);
}
$this->helpJsonCallbackResult($callback, 200, 'suggest', $suggest);
}
/**
* 根据分类id,获取分类尺码
*/
public function sortSizeAction()
{
if ($this->isAjax()) {
$condition['msort'] = $this->get('msort');
$size = SearchModel::getSortSize($condition);
$this->echoJson($size);
}
}
/**
* 搜索错误页
*/
public function errorAction()
{
$keyword = $this->get('query');
$data = SearchModel::searchError($keyword);
$this->setTitle('潮流商品搜索 | YOHO!有货');
$this->setKeywords('Yoho! 有货,潮流,时尚,流行,购物,B2C,正品,购物网站,网上购物,货到付款,品牌服饰,男士护肤,黑框眼镜,匡威,板鞋,i.t,izzue,5cm,eastpak,vans,lylescott,g-shock,new balance,lacoste,melissa,casio,卡西欧手表,舒雅,jasonwood,odm,AAAA,香港购物,日本潮流');
$this->setDescription('潮流商品搜索,上衣,衬衫,TEE,卫衣,冲锋衣,风衣,羽绒服,裤子,休闲鞋,板鞋,配饰,复古眼镜');
$this->setWebNavHeader();
$this->_view->display('no-result', $data);
}
}