Info.php
6.01 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
<?php
use Action\WebAction;
use WebPlugin\Helpers;
use Guang\InfoModel;
use Guang\IndexModel;
use LibModels\Web\Guang\InfoData;
class InfoController extends WebAction
{
/**
* 逛详情页
*/
public function indexAction()
{
$id = $this->param('id','');
if(empty($id)) {
$id = $this->get('id');
}
$page = $this->get('page', 1);//评论分页
$col = $this->get('col', 0);//收藏
$pjax = $this->get("_pjax");
$limit = 20; //评论每页显示条数
if ($pjax) {
$this->_view->display('comment', InfoModel::commentList($id, $page, $limit));
exit;
}
$uid = $this->getUid();
$udid = $this->getUdid();
//登陆后自动收藏
if ($col == 1 && $uid > 0) {
InfoData::setFavorite($id, $uid);
}
$gender = Helpers::getGenderByCookie();
$channel = Helpers::getChannelNameByCookie();
$info = InfoModel::articleInfo($id, $uid, $udid, $page, $gender, $channel, $limit);
// 判断参数是否有效, 无效会跳转到错误页面
if (!is_numeric($id) || !isset($info['header']) ) {
$this->error();
}
$data = array(
'guangDetailPage' => true,
'pathNav' => $info['pathNav'],
'guang' => array(
'id' => $id,
'header' => isset($info['header']) ? $info['header']: array(),
'content' => isset($info['content']) ? $info['content'] : array(),
'brands' => isset($info['brands']) ? $info['brands'] : array(),
'userInfo' => isset($info['userInfo']) ? $info['userInfo'] : array(),
'tag' => isset($info['tag']) ? $info['tag'] : array(),
//分享
'shareImg' => $info['header']['shareImg'],
'sharedTitle' => $info['header']['title'],
'shareDesc' => $info['header']['desc'],
'weixinUrl' => $info['header']['weixinUrl'],
'relatedPost' => isset($info['relatedPost']) ? $info['relatedPost'] : array(),
'commentInfo' => $this->getSession('comment_'.$udid),
'comment' => isset($info['comment']) ? $info['comment'] : array(),
'exRecos' => isset($info['exRecos']) ? $info['exRecos'] : array(),
'hotTags' => isset($info['hotTags']) ? $info['hotTags'] : array(),
'ads' => IndexModel::getAds($channel),
)
);
$this->setTitle($info['header']['title'].' | YOHO!BUY有货 | 年轻人潮流购物中心,中国潮流购物风向标,官方授权正品保证');
$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($channel);
$this->_view->display('info', $data);
}
/**
* 添加评论
*/
public function commentAction()
{
$id = $this->post('id');
$uid = $this->getUid();
$udid = $this->getUdid();
$comment = $this->post('comment');
$limit = 20;
if (!$uid) {
//评论内容存session
$this->setSession('comment_'.$udid, $comment);
$this->helpJsonResult(401, '', '');
}
$result = InfoData::addComment($id, $uid, $comment);
if (isset($result['code']) && $result['code'] == 200) {
if ($this->getSession('comment_'.$udid)) {
$this->setSession('comment_'.$udid, '');
}
$commentInfo = InfoModel::commentList($id, 1, $limit);
$data['content'] = $this->_view->render('comment', $commentInfo);
$data['count'] = $commentInfo['comment']['commentNum'];
$this->helpJsonResult(200, '评论成功', $data);
} else {
$this->helpJsonResult(400, '评论失败', '');
}
}
/**
* 赞
*/
public function praiseAction()
{
$id = $this->get('id');
$udid = $this->getUdid();
$result = InfoData::setPraise($id, $udid);
if (isset($result['code']) && $result['code'] == 200) {
$this->helpJsonResult(200, '!', $result['data']);
} else {
$this->helpJsonResult(400, '', '');
}
}
/**
* 取消赞
*/
public function cancelPraiseAction()
{
$id = $this->get('id');
$udid = $this->getUdid();
$result = InfoData::cancelPraise($id, $udid);
if (isset($result['code']) && $result['code'] == 200) {
$this->helpJsonResult(200, '', $result['data']);
} else {
$this->helpJsonResult(400, '', '');
}
}
/**
* 收藏
*/
public function collectAction()
{
$id = $this->get('id');
$uid = $this->getUid();
if (!$uid) {
$this->helpJsonResult(401, '', '');
}
$result = InfoData::setFavorite($id, $uid);
if (isset($result['code']) && $result['code'] == 200) {
$this->helpJsonResult(200, '', '');
} else {
$this->helpJsonResult(400, '', '');
}
}
/**
* 取消收藏
*/
public function cancelCollectAction()
{
$id = $this->get('id');
$uid = $this->getUid();
$result = InfoData::cancelFavorite($id, $uid);
if (isset($result['code']) && $result['code'] == 200) {
$this->helpJsonResult(200, '', '');
} else {
$this->helpJsonResult(400, '', '');
}
}
}