1
|
<?php
|
1
|
<?php
|
2
|
use Action\WebAction;
|
2
|
use Action\WebAction;
|
3
|
use Index\HomeModel;
|
3
|
use Index\HomeModel;
|
|
|
4
|
+use Configs\WebCacheConfig;
|
4
|
use LibModels\Web\Home\IndexData;
|
5
|
use LibModels\Web\Home\IndexData;
|
5
|
use WebPlugin\Cache;
|
6
|
use WebPlugin\Cache;
|
6
|
-use Configs\WebCacheConfig;
|
|
|
7
|
-use Api\Yohobuy;
|
|
|
8
|
use WebPlugin\Images;
|
7
|
use WebPlugin\Images;
|
9
|
use WebPlugin\Helpers;
|
8
|
use WebPlugin\Helpers;
|
10
|
|
9
|
|
|
@@ -16,15 +15,27 @@ class CommonController extends WebAction |
|
@@ -16,15 +15,27 @@ class CommonController extends WebAction |
16
|
*/
|
15
|
*/
|
17
|
public function getIndexResourceBrandAction()
|
16
|
public function getIndexResourceBrandAction()
|
18
|
{
|
17
|
{
|
|
|
18
|
+ $data = array();
|
|
|
19
|
+
|
|
|
20
|
+ do {
|
|
|
21
|
+ if (!$this->isAjax()) {
|
|
|
22
|
+ break;
|
|
|
23
|
+ }
|
|
|
24
|
+
|
|
|
25
|
+ $type = $this->get('type');
|
|
|
26
|
+ if (empty($type)) {
|
|
|
27
|
+ break;
|
|
|
28
|
+ }
|
|
|
29
|
+ }
|
|
|
30
|
+ while (false);
|
19
|
// 首页资源品牌,采用内存存储
|
31
|
// 首页资源品牌,采用内存存储
|
20
|
$type = $this->get('type');
|
32
|
$type = $this->get('type');
|
21
|
- $data = array();
|
|
|
22
|
if (! empty($type)) {
|
33
|
if (! empty($type)) {
|
23
|
$key = WebCacheConfig::KEY_WEB_INDEX_BRANDS_LIST_DATA . '_' . $type;
|
34
|
$key = WebCacheConfig::KEY_WEB_INDEX_BRANDS_LIST_DATA . '_' . $type;
|
24
|
// array('logoBrand'=>'','moreBrand'=>'')
|
35
|
// array('logoBrand'=>'','moreBrand'=>'')
|
25
|
$data = Cache::get($key);
|
36
|
$data = Cache::get($key);
|
26
|
}
|
37
|
}
|
27
|
- echo $this->echoJson($data);
|
38
|
+ $this->echoJson($data);
|
28
|
}
|
39
|
}
|
29
|
|
40
|
|
30
|
/**
|
41
|
/**
|
|
@@ -36,7 +47,7 @@ class CommonController extends WebAction |
|
@@ -36,7 +47,7 @@ class CommonController extends WebAction |
36
|
*/
|
47
|
*/
|
37
|
public function getNewArrivalAction()
|
48
|
public function getNewArrivalAction()
|
38
|
{
|
49
|
{
|
39
|
- $result = $data = array();
|
50
|
+ $result = array();
|
40
|
do {
|
51
|
do {
|
41
|
/* 判断是不是AJAX请求 */
|
52
|
/* 判断是不是AJAX请求 */
|
42
|
if (! $this->isAjax()) {
|
53
|
if (! $this->isAjax()) {
|
|
@@ -53,23 +64,29 @@ class CommonController extends WebAction |
|
@@ -53,23 +64,29 @@ class CommonController extends WebAction |
53
|
$pageCount = (int) $this->post('pageCount', 8);
|
64
|
$pageCount = (int) $this->post('pageCount', 8);
|
54
|
if (! in_array($channel, $channels)) {
|
65
|
if (! in_array($channel, $channels)) {
|
55
|
break;
|
66
|
break;
|
56
|
- } else {
|
|
|
57
|
- $data = HomeModel::getNewArrival($channel);
|
|
|
58
|
}
|
67
|
}
|
59
|
- if($pageIndex < 0) {
|
68
|
+
|
|
|
69
|
+ $data = HomeModel::getNewArrival($channel);
|
|
|
70
|
+ if (empty($data)) {
|
|
|
71
|
+ break;
|
|
|
72
|
+ }
|
|
|
73
|
+
|
|
|
74
|
+ if ($pageIndex < 0) {
|
60
|
$pageIndex = 0;
|
75
|
$pageIndex = 0;
|
61
|
}
|
76
|
}
|
62
|
- if($pageCount < 0 || $pageCount > 50) {
|
77
|
+ if ($pageCount < 0 || $pageCount > 50) {
|
63
|
$pageCount = 20;
|
78
|
$pageCount = 20;
|
64
|
}
|
79
|
}
|
65
|
- $result = array_slice($data, $pageIndex, $pageCount);
|
|
|
66
|
- if (empty($result)) {
|
80
|
+ $data = array_slice($data, $pageIndex, $pageCount);
|
|
|
81
|
+ if (empty($data)) {
|
67
|
break;
|
82
|
break;
|
68
|
}
|
83
|
}
|
69
|
$result = array(
|
84
|
$result = array(
|
70
|
'code' => 200,
|
85
|
'code' => 200,
|
71
|
- 'goods' => $result
|
86
|
+ 'goods' => $data
|
72
|
);
|
87
|
);
|
|
|
88
|
+ $data = array();
|
|
|
89
|
+
|
73
|
} while (false);
|
90
|
} while (false);
|
74
|
|
91
|
|
75
|
$this->echoJson($result);
|
92
|
$this->echoJson($result);
|