Index.php
5.45 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<?php
namespace Guang;
use LibModels\Wap\Guang\ListData;
use Plugin\Helpers;
/**
*
* @name IndexModel
* @package models/Guang
* @copyright yoho.inc
* @version 1.0 (2015-10-27 11:31:49)
* @author fei.hong <fei.hong@yoho.cn>
*/
class IndexModel
{
/**
* 获取逛首页分类内容列表
*
* @param string $gender "1,3"表示男, "2,3"表示女
* @param int channel APP客户端标识 1表示男,2:表示女,3:潮童,4:创意生活
* @param int type 分类ID 0:最新,1:话题,2:搭配,3:潮人,4:潮品,5:小贴士
* @param int $uid 用户ID
* @param string $udid 客户端唯一标识
* @param int $page 分页第几页, 默认第1页
* @return array
*/
public static function getArticleGroup($gender, $type, $uid, $udid, $page = 1)
{
// 逛首页的分类名称列表
$category = ListData::category();
$articleGroup = array();
switch ($gender) {
case '1,3': // 男
$articleGroup = ListData::articleGroup($category['data'], '1,3', $uid, $udid, $page);
break;
case '2,3': // 女
$articleGroup = ListData::articleGroup($category['data'], '2,3', $uid, $udid, $page);
break;
default: // 其它所有
$articleGroup = ListData::articleGroup($category['data'], '1,2,3', $uid, $udid, $page);
break;
}
$data = array();
$build = array();
// 模板中使用JS的标识
$data['guangHome'] = true;
// 顶部的分类列表
foreach ($category['data'] as $value) {
$build = array();
$build['typeId'] = $value['id'];
$build['type'] = $value['name'];
$build['focus'] = ($value['id'] == $type);
$data['navs'][] = $build;
}
$data['guang']['swiper'] = array();
$data['guang']['infos'] = array();
foreach ($articleGroup as $id => $value) {
// 判断是否有内容
if (empty($value['list'])) {
continue;
}
// 轮番广告
if ($id == 0) {
$build = array();
foreach ($value['list']['adlist'] as $banner) {
$build['url'] = Helpers::getFilterUrl($banner['url']);
$build['img'] = Helpers::getImageUrl($banner['src'], 830, 327);
$data['guang']['swiper'][] = $build;
}
}
// 内容列表
$build = array();
$build['show'] = ($id == $type);
foreach ($value['list']['artList'] as $article) {
$build['info'][] = Helpers::formatArticle($article, true, false);
}
$data['guang']['infos'][] = $build;
}
// 分页需要参数
$data['guang']['gender'] = $gender;
$category = array();
return $data;
}
/**
* 获取逛首页分类内容列表
*
* @param string $gender "1,3"表示男, "2,3"表示女
* @param int channel APP客户端标识 1表示男,2:表示女,3:潮童,4:创意生活
* @param int type 分类ID 0:最新,1:话题,2:搭配,3:潮人,4:潮品,5:小贴士
* @param int $uid 用户ID
* @param string $udid 客户端唯一标识
* @param int $page 分页第几页, 默认第1页
* @return array
*/
public static function getArticle($gender, $type, $uid, $udid, $page = 1)
{
// 逛首页的分类名称列表
$category = ListData::category();
$article = array();
switch ($gender) {
case '1,3': // 男
$article = ListData::article('1,3', $type, $uid, $udid, $page);
break;
case '2,3': // 女
$article = ListData::article('2,3', $type, $uid, $udid, $page);
break;
default: // 其它所有
$article = ListData::article('1,2,3', $type, $uid, $udid, $page);
break;
}
$data = array();
$build = array();
// 模板中使用JS的标识
$data['guangHome'] = true;
// 顶部的分类列表
if (!empty($category['data'])) {
foreach ($category['data'] as $value) {
$build = array();
$build['typeId'] = $value['id'];
$build['type'] = $value['name'];
$build['focus'] = ($value['id'] == $type);
$data['navs'][] = $build;
$data['guang']['infos'][] = array(
'show' => $build['focus'],
'info' => array(),
);
}
}
// 广告列表
if (!empty($article['data']['list']['adlist'])) {
foreach ($article['data']['list']['adlist'] as $value) {
$build = array();
$build['url'] = Helpers::getFilterUrl($value['url']);
$build['img'] = Helpers::getImageUrl($value['src'], 830, 327);
$data['guang']['swiper'][] = $build;
}
}
// 内容列表
if (!empty($article['data']['list']['artList'])) {
$type = intval($type);
foreach ($article['data']['list']['artList'] as $value) {
$data['guang']['infos'][$type]['info'][] = Helpers::formatArticle($value, true, false, true);
}
}
$category = array();
$article = array();
return $data;
}
}