Index.php
2.93 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
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;
}
}