WillController.class.php
4.2 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
<?php
/**
* Created by PhpStorm.
* User: 29925
* Date: 2018/4/9
* Time: 9:33
*/
namespace Portal\Controller;
use Common\Controller\HomebaseController;
class WillController extends HomebaseController {
protected $posts_model;
function _initialize() {
parent::_initialize();
$this->posts_model = D("Portal/Posts");
$this->will_mission_model = D("Common/WillMission");
$this->will_events_model = D("Common/WillEvents");
$this->will_produce_model = D("Common/WillProduce");
}
// 入会说明
public function explain() {
$post=$this->posts_model->where(array("id=10"))->find();
$smeta = json_decode($post['smeta'], true);
$post['thumb'] = $smeta['thumb'];
$this->assign($post);
$this->display();
}
// 任务发布列表
public function mission_list() {
$this->assign('list', $this->will_mission_model->getList());
$this->display();
}
// 任务发布详情
public function mission_detail() {
$id = I("get.id",0,'intval');
$this->assign($this->will_mission_model->getInfo($id));
$this->display();
}
// 近期活动列表
public function events_list() {
$this->assign('list', $this->will_events_model->getList());
$this->display();
}
// 近期活动详情
public function events_detail() {
$id = I("get.id",0,'intval');
$this->assign($this->will_events_model->getInfo($id));
$this->display();
}
// 双创项目列表
public function produce_list() {
$this->assign('list', $this->will_produce_model->getList());
$this->display();
}
// 双创项目详情
public function produce_detail() {
$id = I("get.id",0,'intval');
$this->assign($this->will_produce_model->getInfo($id));
$this->display();
}
// 入会申请提交
public function submit() {
if(IS_AJAX) {
$post =I('post.');
$user_id = $post['user_id'] = 1;
// $user_id = $post['user_id'] = sp_get_current_userid();
// if(!$user_id) {
// $this->ajaxReturn(array('status'=>false,'msg'=>'用户未登录'));
// }
$post['images'] = implode(',',I('post.images'));
$post['ctime'] = $post['utime'] = time();
$will_produce_apply_model = D('Common/WillProduceApply');
if(!$will_produce_apply_model->create($post)) {
$this->ajaxReturn(array('status'=>false,'msg'=>$will_produce_apply_model->getError()));
}
if(count(I('post.images'))<3 || count(I('post.images'))>5) {
$this->ajaxReturn(array('status'=>false,'msg'=>'图片数量不符'));
}
$will_id = $will_produce_apply_model->add($post);
if(!$will_id) {
$this->ajaxReturn(array('status'=>false,'msg'=>'提交失败'));
}
$this->ajaxReturn(array('status'=>true,'msg'=>'提交成功','data'=>$will_id));
} else {
$this->error('非法操作');
}
}
//上传图片
public function personalUpload() {
if(IS_POST){
list($status, $info, $link, $attachmentId) = $this->uploadCommon('image', C('UPLOAD_MATERIAL_IMAGE_MAX_SIZE'), 'personal', false);
if ($status) {
echo json_encode(array('status' => true, 'data' => $info, 'file'=>sp_get_image_preview_url($info)));exit;
} else {
echo json_encode(array('status' => false, 'msg'=>$info));exit;
}
} else {
$this->error('非法操作');
}
}
//上传附件
public function personalUploadAtt() {
if(IS_POST){
list($status, $info, $link, $attachmentId) = $this->uploadCommon('file', C('UPLOAD_MAX_SIZE'), 'file', false);
if ($status) {
echo json_encode(array('status' => true, 'data' => $info, 'file'=>sp_get_image_preview_url($info)));exit;
} else {
echo json_encode(array('status' => false, 'msg'=>$info));exit;
}
} else {
$this->error('非法操作');
}
}
}