Complaints.php
3.32 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
<?php
use Action\WebAction;
use LibModels\Web\Home\ComplaintsData;
use Home\ComplaintsModel;
use Home\UserModel;
use WebPlugin\Paging;
use WebPlugin\Helpers;
/**
* 个人中心-我的投诉
*/
class ComplaintsController extends WebAction
{
public function indexAction()
{
//判断是否登录
$uid = $this->auditJumpLogin();
//头部导航
$channel = Helpers::getChannelNameByCookie();
$this->setWebNavHeader($channel);
//面包屑-左侧导航
$path = UserModel::getCenterCrumb('我的投诉');
$leftNav = UserModel::getCenterLeftNav('我的投诉',$uid);
//分页
$page = $this->get('page', 1);
$limit = 10;
$paging = new Paging('yoho');
$complaints = ComplaintsModel::getComplaintsList($uid, $page, $limit);
$total = isset($complaints['pager']['total']) ? $complaints['pager']['total'] : 0;
$pageTotal = isset($complaints['pager']['pageTotal']) ? $complaints['pager']['pageTotal'] : 0;
$page = isset($complaints['pager']['page']) ? $complaints['pager']['page'] : 0;
unset($complaints['pager']);
$paging->setTotal($total)->setSize($limit)->setQuery(array('page' => $page));
$data = array(
'path' => $path,
'userThumb' => UserModel::getUserHeadImg($uid),
'homeNav' => $leftNav,
'complaints' => $complaints,
'pager' => array(
'hasCheckAll' => false,
'count' => $total,
'curPage' => $page,
'totalPages' => $pageTotal,
'pagerHtml' => $paging->view(false)
)
);
$this->_view->display('complaints', array('meComplaintsPage' => true, 'complaints' => $data));
}
/**
* 添加投诉-ajax
*/
public function addComplaintsAction()
{
$data = array('code' => 400, 'message' => '', 'data' => '');
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
break;
}
$params['uid'] = $this->auditJumpLogin();
$params['title'] = trim($this->post('title', ''));
$params['customer'] = trim($this->post('customer', ''));
$params['complaintsType'] = $this->post('complaintsType', '');
$params['orderCode'] = trim($this->post('orderCode', ''));
$params['content'] = trim($this->post('content', ''));
$data = ComplaintsData::addComplaints($params);
if (!isset($data['code'])) {
break;
}
}
while (false);
$this->echoJson($data);
}
/**
* 撤销投诉-ajax
*/
public function cancelComplaintsAction()
{
$data = array('code' => 400, 'message' => '', 'data' => '');
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
break;
}
$uid = $this->auditJumpLogin();
$id = $this->post('id', '');
$data = ComplaintsData::cancelComplaints($uid, $id);
if (!isset($data['code'])) {
break;
}
}
while (false);
$this->echoJson($data);
}
}