Message.php
4.86 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
<?php
use Action\WebAction;
use WebPlugin\Helpers;
use Home\UserModel;
use Home\MessageModel;
use LibModels\Web\Home\MessageData;
use WebPlugin\Paging;
/**
* 个人中心——我的消息
*/
class messageController extends WebAction
{
/**
* 我的信息
*/
public function indexAction()
{
//判断是否登录
$uid = $this->auditJumpLogin(true, Helpers::url('/home/message'));
//头部导航
$channel = Helpers::getChannelNameByCookie();
$this->setWebNavHeader($channel);
//分页
$page = $this->get('page', 1);
$size = 10;
//获取消息列表
$inboxlist = MessageModel::getInboxList($uid, $page, $size);
$data = array(
//面包屑-左侧导航
'path' => UserModel::getCenterCrumb('我的信息'),
'userThumb' => UserModel::getUserHeadImg($uid),
'homeNav' => UserModel::getCenterLeftNav('我的信息', $uid),
'messages' => $inboxlist['messages'],
'pager' => $inboxlist['pager'],
);
$this->_view->display('message', array('meMessagePage' => true, 'message' => $data));
}
/**
* 消息详细
*/
public function contentAction()
{
//判断是否登录
$uid = $this->auditJumpLogin();
//头部导航
$channel = Helpers::getChannelNameByCookie();
$this->setWebNavHeader($channel);
$id = $this->get('id', '');
$page = $this->get('page', 1);
$size = 10;
$content = MessageModel::getContentData($uid, $page, $size, $id);
$data = array(
'path' => UserModel::getCenterCrumb('我的信息'),
'userThumb' => UserModel::getUserHeadImg($uid),
'homeNav' => UserModel::getCenterLeftNav('我的信息', $uid),
'message' => $content,
);
$this->_view->display('message-content', array('meMessagePage' => true, 'message' => $data));
}
/**
* 删除消息
*/
public function delMessageAction()
{
$result = array('code' => 400, 'message' => '', 'data' => '');
do {
if (!$this->isAjax()) {
break;
}
//获取相关参数
$uid = $this->getUid(true);
$id = $this->get('id', '');
if (!$uid || !$id) {
$result = array('code' => 400, 'message' => '缺少参数', 'data' => '');
$this->echoJson($result);
break;
}
$messages = MessageData::delMessageData($uid, $id);
if (isset($messages['code']) && $messages['code'] == 200) {
$page = $this->get('page', 1);
$size = 10;
$inboxlist = MessageModel::getInboxList($uid, $page, $size); //重新获取消息列表
$result['messages'] = $inboxlist['messages'];
$result['pager'] = $inboxlist['pager'];
$this->_view->display('message-list', array('messages' => $result));
}
else {
$result = array('code' => 400, 'message' => '删除失败', 'data' => '');
$this->echoJson($result);
}
}
while (false);
}
/**
* 批量设置消息为已读
*/
public function readMessageAction()
{
$result = array('code' => 400, 'message' => '', 'data' => '');
do {
if (!$this->isAjax()) {
break;
}
//获取相关信息
$uid = $this->getUid(true);
$ids = $this->get('id', '');
if (!$uid || !$ids) {
$result = array('code' => 400, 'message' => '缺失必填项', 'data' => '');
break;
}
$result = MessageData::setRead($uid, $ids);
if (!isset($result['code'])) {
break;
}
}
while (false);
$this->echoJson($result);
}
/**
* 领取生日券
*/
public function pickCouponAction()
{
$result = array('code' => 400, 'message' => '', 'data' => '');
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
break;
}
//获取相关参数
$uid = $this->getUid(true);
$id = $this->get('id', '');
if (!$uid || !$id) {
$result = array('code' => 400, 'message' => '缺失必填项', 'data' => '');
break;
}
$result =MessageData::getBirthCoupon($uid, $id);
if (!isset($result['code'])) {
break;
}
}
while (false);
$this->echoJson($result);
}
}