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
<?php
// 获取首页数据
require_once ("../user_include.inc");
ErrorLogger::doOutput("Compass...ajax_get_top_dat.php....Start.", 0);
//获取参数
$unionId = ParamUtil::getRequestString("unionId");
//用户所在【省市区】
$province = ParamUtil::getRequestString("province");
$city = ParamUtil::getRequestString("city");
$district = ParamUtil::getRequestString("district");
$result = array();
//参数检查
if(empty($unionId)) {
$result["message"] = "参数错误!";
responseNG($result);
}
//判断用户是否存在
$param = array();
$param['unionid'] = $unionId;
$param['delete_flg'] = false;
$userList = UserMst::getList($param,'id','desc', 0, 1);
if(empty($userList)) {
$result["message"] = "用户不存在!";
responseNG($result);
}
$userMst = $userList[0];
//判断用户身份分别获取数据
$volunteerEventList = array();
$familyEventList = array();
$socialEventList = array();
$mediaList = array();
//志愿者活动[当前所在区域的第一条志愿者活动]
$param = array();
$param['province'] = $province;
$param['city'] = $city;
$param['district'] = $district;
$param['status'] = "OK";
$param['delete_flg'] = false;
//社会用户和机构用户的时候,添加【是否允许社会人士参加】
if($userMst->role == 5 || $userMst->role == 6) {
$param['include_social_user'] = true;
}
$tmpVolunteerEventList = VolunteerEventDat::getList($param,'id','desc', 0, 1);
//设置状态和招募范围
foreach($tmpVolunteerEventList as $tmp) {
$tmp->status_title = "征集中";
$tmp->scope = "校内";
if($tmp->include_social_user) {
$tmp->scope = "校内.社会人士";
}
$volunteerEventList[] = $tmp;
}
//家园用户只显示本校的亲子活动
if($userMst->role == 1) {
//本校亲子活动
$param = array();
$param['school_no'] = $userMst->school_no;
$param['original_source'] = $userMst->original_source;
$param['delete_flg'] = false;
$familyEventList = FamilyEventDat::getList($param,'id','desc', 0, 1);
}
//家校用户只显示本校社会实践
if($userMst->role == 2 ) {
$param = array();
$param['school_no'] = $userMst->school_no;
$param['original_source'] = $userMst->original_source;
$param['delete_flg'] = false;
$socialEventList = SocialEventDat::getList($param,'id','desc', 0, 1);
}
//教育局领导、社会用户、机构用户根据年龄段选择活动
if($userMst->role == 4 || $userMst->role == 5 || $userMst->role == 6) {
//3~6岁[亲子活动]
if($userMst->child_age == 1) {
$param = array();
$param['delete_flg'] = false;
$familyEventList = FamilyEventDat::getList($param,'id','desc', 0, 1);
}
//7岁以上[社会实践]
if($userMst->child_age == 2) {
$param = array();
$param['delete_flg'] = false;
$socialEventList = SocialEventDat::getList($param,'id','desc', 0, 1);
}
}
//公益课堂
$param = array();
$param['delete_flg'] = false;
$mediaList = CourseMediaDat::getList($param,'id','desc', 0, 3);
//组装返回数据
$result["volunteerEventList"] = $volunteerEventList;
$result["familyEventList"] = $familyEventList;
$result["socialEventList"] = $socialEventList;
$result["mediaList"] = $mediaList;
ErrorLogger::doOutput("Compass...ajax_get_top_dat.php....End.", 0);
//返回结果
responseOK($result);
function responseNG($result) {
$result = array("status"=>"NG", "result"=>$result);
print json_encode($result);
exit;
}
function responseOK($result) {
$result = array("status"=>"OK", "result"=>$result);
print json_encode($result);
exit;
}
?>