Common.php
1.92 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
<?php
use Action\WebAction;
use Index\HomeModel;
use Plugin\Cache;
use Configs\CacheConfig;
class CommonController extends WebAction
{
/**
* 获取首页资源品牌
*/
public function getIndexResourceBrandAction()
{
// 首页资源品牌,采用内存存储
$type = $this->get('type');
$data = array();
if (! empty($type)) {
$key = CacheConfig::KEY_INDEX_BRANDS_LIST_DATA . '_' . $type;
// array('logoBrand'=>'','moreBrand'=>'')
$data = Cache::get($key);
}
echo $this->echoJson($data);
}
/**
* 新品上架 接口数据
*
* @param string channel 当前频道
* @param int pageIndex 当前页数
* @param int pageCount 一页显示个数
*/
public function getNewArrivalAction()
{
$result = $data = array();
do {
/* 判断是不是AJAX请求 */
if (! $this->isAjax()) {
break;
}
$channels = array(
HomeModel::COOKIE_NAME_BOYS,
HomeModel::COOKIE_NAME_GIRLS,
HomeModel::COOKIE_NAME_KIDS,
HomeModel::COOKIE_NAME_LIFESTYLE
);
$channel = $this->post('type', '');
$pageIndex = $this->post('pageIndex', 1);
$pageCount = $this->post('pageCount', 8);
if (! in_array($channel, $channels)) {
break;
} else {
$data = HomeModel::getNewArrival($channel);
}
$result = array_slice($data, ($pageIndex - 1) * $pageCount, $pageCount);
if (empty($result)) {
break;
}
$result = array(
'code' => 200,
'commodity' => $result
);
} while (false);
$this->echoJson($result);
}
}