正在显示
7 个修改的文件
包含
310 行增加
和
35 行删除
1 | <?php | 1 | <?php |
2 | namespace app\activity\controller; | 2 | namespace app\activity\controller; |
3 | use cmf\controller\HomeBaseController; | 3 | use cmf\controller\HomeBaseController; |
4 | +use app\activity\model\ActivityModel; | ||
4 | use think\Db; | 5 | use think\Db; |
5 | 6 | ||
6 | /** | 7 | /** |
7 | * @title 活动模块 | 8 | * @title 活动模块 |
8 | */ | 9 | */ |
9 | -class ActivityController extends HomeBaseController { | 10 | +class ActivityController extends HomeBaseController |
11 | +{ | ||
12 | + | ||
10 | /** | 13 | /** |
11 | - * @title 接口返回参数说明 | 14 | + * @title 活动列表 |
15 | + * @description 默认访问接口 | ||
16 | + * @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ | ||
17 | + * @url /activity/Activity/_list | ||
18 | + * @method POST | ||
19 | + * | ||
20 | + * @return version:版本号 | ||
21 | + * @return code:错误码 | ||
22 | + */ | ||
23 | + public function _list() | ||
24 | + { | ||
25 | + //首页轮播图 | ||
26 | + $banner = Db::name('slide_item')->field('image,url')->where(['slide_id' => 1])->order('list_order')->select(); | ||
27 | + //分类 | ||
28 | + $type = Db::name('type')->field('type_name,type_url,type_icon')->order('listorder')->select(); | ||
29 | + //活动 | ||
30 | + $model = new ActivityModel; | ||
31 | + $activity = $model->activityList('', time(), session('user.id')); | ||
32 | + $result = [ | ||
33 | + 'banner' => $banner, | ||
34 | + 'type' => $type, | ||
35 | + 'activity' => $activity | ||
36 | + ]; | ||
37 | + // | ||
38 | + echo json_encode(['data' => $result, 'code' => 20000]); | ||
39 | + exit(); | ||
40 | + } | ||
41 | + | ||
42 | + /** | ||
43 | + * @title 活动详情 | ||
12 | * @description 默认访问接口 | 44 | * @description 默认访问接口 |
13 | * @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ | 45 | * @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ |
14 | * @url /activity/Activity/detail | 46 | * @url /activity/Activity/detail |
15 | * @method POST | 47 | * @method POST |
16 | * | 48 | * |
17 | - * @param name:id type:char require:1 default:lihan other: desc:活动id | 49 | + * @param name:id type:int require:1 default:lihan other: desc:活动id |
50 | + */ | ||
51 | + public function detail() | ||
52 | + { | ||
53 | + $request = request(); | ||
54 | + if ($request->isPost()) { | ||
55 | + $id = $request->param('id'); | ||
56 | + $activity = new ActivityModel; | ||
57 | + $info = $activity->activityDetail($id); | ||
58 | + if (!empty($info)) { | ||
59 | + echo json_encode(['data' => $info, 'code' => 20000]); | ||
60 | + exit(); | ||
61 | + } else { | ||
62 | + echo json_encode(['msg' => '暂无数据', 'code' => 40000]); | ||
63 | + exit(); | ||
64 | + } | ||
65 | + } | ||
66 | + } | ||
67 | + | ||
68 | + /** | ||
69 | + * @title 收藏 | ||
70 | + * @description 默认访问接口 | ||
71 | + * @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ | ||
72 | + * @url /activity/Activity/collectDo | ||
73 | + * @method POST | ||
74 | + * | ||
75 | + * @param name:id type:int require:1 default:2 other: desc:活动id | ||
76 | + */ | ||
77 | + public function collectDo() | ||
78 | + { | ||
79 | + $request = request(); | ||
80 | + if ($request->isPost()) { | ||
81 | + $collect = new ActivityModel; | ||
82 | + $activityId = $request->param('id'); | ||
83 | + $return = $collect->collect($activityId, session('user.id')); | ||
84 | + echo $return; | ||
85 | + exit(); | ||
86 | + } else { | ||
87 | + echo json_encode(['msg' => '非法操作', 'code' => 40000]); | ||
88 | + exit(); | ||
89 | + } | ||
90 | + } | ||
91 | + | ||
92 | + /** | ||
93 | + * @title 活动评价 | ||
94 | + * @description 默认访问接口 | ||
95 | + * @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ | ||
96 | + * @url /activity/Activity/comment | ||
97 | + * @method POST | ||
98 | + * | ||
99 | + * @param name:activity_id type:int require:1 default:14 other: desc:活动id | ||
100 | + * @param name:rank_synthetical type:int require:1 default:5 other: desc:综合评价等级 | ||
101 | + * @param name:rank_service type:int require:1 default:5 other: desc:服务评价等级 | ||
102 | + * @param name:rank_journey type:int require:1 default:5 other: desc:行程评价等级 | ||
103 | + * @param name:content type:text require:1 default:非常好 other: desc:评价内容 | ||
18 | */ | 104 | */ |
19 | - public function detail() { | ||
20 | - $request=request(); | ||
21 | - $id=$request->param('id'); | ||
22 | - $info=Db::name('activity')->where(['id'=>$id])->find(); | ||
23 | - $ | 105 | + public function comment() |
106 | + { | ||
107 | + $request = request(); | ||
108 | + if ($request->isPost()) { | ||
109 | + $post = $request->param(); | ||
110 | + $post['user_id'] = session('user.id'); | ||
111 | + $post['comment_time'] = time(); | ||
112 | + if (Db::name('activity_comment')->insert($post)) { | ||
113 | + echo json_encode(['msg' => '评价成功', 'code' => 20000]); | ||
114 | + exit(); | ||
115 | + } else { | ||
116 | + echo json_encode(['msg' => '评价失败', 'code' => 40000]); | ||
117 | + exit(); | ||
118 | + } | ||
119 | + } else { | ||
120 | + echo json_encode(['msg' => '非法操作', 'code' => 40000]); | ||
121 | + exit(); | ||
122 | + } | ||
24 | } | 123 | } |
25 | 124 | ||
26 | } | 125 | } |
app/activity/model/ActivityModel.php
0 → 100644
1 | +<?php | ||
2 | +/** | ||
3 | + * Created by PhpStorm. | ||
4 | + * User: yhbr | ||
5 | + * Date: 2018/9/4 | ||
6 | + * Time: 9:53 | ||
7 | + */ | ||
8 | + | ||
9 | +namespace app\activity\model; | ||
10 | +use think\Model; | ||
11 | +use think\Db; | ||
12 | + | ||
13 | +class ActivityModel extends Model | ||
14 | +{ | ||
15 | + | ||
16 | + /** | ||
17 | + * @param null $tId | ||
18 | + * @param $nowTime | ||
19 | + * @param $userId | ||
20 | + * @return false|\PDOStatement|string|\think\Collection | ||
21 | + * @throws \think\db\exception\DataNotFoundException | ||
22 | + * @throws \think\db\exception\ModelNotFoundException | ||
23 | + * @throws \think\exception\DbException | ||
24 | + */ | ||
25 | + public function activityList($tId = null, $nowTime, $userId) | ||
26 | + { | ||
27 | + $where = []; | ||
28 | + if ($tId != null) { | ||
29 | + $where['t_id'] = ['eq', $tId]; | ||
30 | + } | ||
31 | + $res = Db::name('activity')->field('id,name,thumb')->where($where)->select()->toArray(); | ||
32 | + //只显示还未到报名日期活动最近的一条行程 | ||
33 | + foreach ($res as $key => $item) { | ||
34 | + $item['is_collect'] = $this->isCollect($item['id'], $userId); | ||
35 | + $item['schedule'] = $this->latestSchedule($item['id'], $nowTime); | ||
36 | + $res[$key] = $item; | ||
37 | + if (empty($item['schedule'])) { | ||
38 | + unset($res[$key]); | ||
39 | + } | ||
40 | + } | ||
41 | + return array_values($res); | ||
42 | + } | ||
43 | + | ||
44 | + public function activityDetail($activityId) | ||
45 | + { | ||
46 | + $info = Db::name('activity')->field('banner,name,is_down_payment,down_price,content,notice')->where(['id' => $activityId])->find(); | ||
47 | + if (!empty($info)) { | ||
48 | + $arr = explode(',', $info['banner']); | ||
49 | + $banner = []; | ||
50 | + for ($i = 0; $i < count($arr); $i++) { | ||
51 | + $banner[$i] = $arr[$i]; | ||
52 | + } | ||
53 | + $info['banner'] = $banner; | ||
54 | + $info['schedule'] = $this->allSchedule($activityId); | ||
55 | + $info['comment_list'] = $this->getCommentListByActivityId($activityId); | ||
56 | + return $info; | ||
57 | + } else { | ||
58 | + return null; | ||
59 | + } | ||
60 | + } | ||
61 | + | ||
62 | + private function allSchedule($activityId) | ||
63 | + { | ||
64 | + $res = Db::name('activity_schedule')->field('start_time,end_time,price')->where(['activity_id' => $activityId])->select(); | ||
65 | + foreach ($res as $k => $v) { | ||
66 | + $v['start_time'] = date('Y-m-d', $v['start_time']); | ||
67 | + $v['end_time'] = date('Y-m-d', $v['end_time']); | ||
68 | + $res[$k] = $v; | ||
69 | + } | ||
70 | + return $res; | ||
71 | + } | ||
72 | + | ||
73 | + /** | ||
74 | + * 获取应显示的活动批次,距离当前最近的批次 | ||
75 | + * @param $activityId | ||
76 | + * @param $nowTime | ||
77 | + * @return array|false|\PDOStatement|string|Model | ||
78 | + * @throws \think\db\exception\DataNotFoundException | ||
79 | + * @throws \think\db\exception\ModelNotFoundException | ||
80 | + * @throws \think\exception\DbException | ||
81 | + */ | ||
82 | + private function latestSchedule($activityId, $nowTime) | ||
83 | + { | ||
84 | + $where['activity_id'] = ['eq', $activityId]; | ||
85 | + $where['deadline'] = ['gt', $nowTime]; | ||
86 | + $schedule = Db::name('activity_schedule')->field('start_time,price,real_join_num,addition_join_num,maximum')->where($where)->order('deadline')->select()->toArray(); | ||
87 | + foreach ($schedule as $k => $v) { | ||
88 | + $v['start_time'] = date('Y-m-d', $v['start_time']); | ||
89 | + $v['sales_num'] = $v['real_join_num'] + $v['addition_join_num']; | ||
90 | + $v['residue_num'] = $v['maximum'] - $v['sales_num']; | ||
91 | + unset($v['real_join_num']); | ||
92 | + unset($v['addition_join_num']); | ||
93 | + unset($v['maximum']); | ||
94 | + $schedule[$k] = $v; | ||
95 | + } | ||
96 | + if (!empty($schedule)) { | ||
97 | + return $schedule[0]; | ||
98 | + } else { | ||
99 | + return null; | ||
100 | + } | ||
101 | + } | ||
102 | + | ||
103 | + /** | ||
104 | + * 收藏活动 | ||
105 | + * @param $activityId | ||
106 | + * @param $userId | ||
107 | + * @return bool|string | ||
108 | + * @throws \think\Exception | ||
109 | + * @throws \think\exception\PDOException | ||
110 | + */ | ||
111 | + public function collect($activityId, $userId) | ||
112 | + { | ||
113 | + $where = [ | ||
114 | + 'user_id' => $userId, | ||
115 | + 'activity_id' => $activityId | ||
116 | + ]; | ||
117 | + $isCollected = Db::name('collect')->where($where)->value('id'); | ||
118 | + if ($isCollected) { | ||
119 | + if (Db::name('collect')->delete($isCollected)) { | ||
120 | + return json_encode(['msg' => '取消收藏', 'status' => true]); | ||
121 | + } else { | ||
122 | + return false; | ||
123 | + } | ||
124 | + } else { | ||
125 | + if (Db::name('collect')->insert(['user_id' => $userId, 'activity_id' => $activityId])) { | ||
126 | + return json_encode(['msg' => '收藏成功', 'status' => true]); | ||
127 | + } else { | ||
128 | + return false; | ||
129 | + } | ||
130 | + } | ||
131 | + } | ||
132 | + | ||
133 | + /** | ||
134 | + * 判断谁否收藏 | ||
135 | + * @param $activityId | ||
136 | + * @param $userId | ||
137 | + * @return int|string | ||
138 | + */ | ||
139 | + private function isCollect($activityId, $userId) | ||
140 | + { | ||
141 | + $isCollected = Db::name('collect')->where(['activity_id' => $activityId, 'user_id' => $userId])->count(); | ||
142 | + return $isCollected; | ||
143 | + } | ||
144 | + | ||
145 | + /** | ||
146 | + * 活动评价列表 | ||
147 | + * @param $activityId | ||
148 | + * @return false|\PDOStatement|string|\think\Collection | ||
149 | + * @throws \think\db\exception\DataNotFoundException | ||
150 | + * @throws \think\db\exception\ModelNotFoundException | ||
151 | + * @throws \think\exception\DbException | ||
152 | + */ | ||
153 | + private function getCommentListByActivityId($activityId) | ||
154 | + { | ||
155 | + $res = Db::name('activity_comment')->alias('c') | ||
156 | + ->field('c.rank_synthetical,c.comment_time,c.content,u.user_nickname,avatar') | ||
157 | + ->join('user u', 'c.user_id=u.id') | ||
158 | + ->where(['c.activity_id' => $activityId]) | ||
159 | + ->select(); | ||
160 | + foreach ($res as $k => $v) { | ||
161 | + $v['comment_time'] = date('Y.m.d', $v['comment_time']); | ||
162 | + $res[$k] = $v; | ||
163 | + } | ||
164 | + return $res; | ||
165 | + } | ||
166 | + | ||
167 | +} |
@@ -74,6 +74,7 @@ class ActivityController extends AdminBaseController { | @@ -74,6 +74,7 @@ class ActivityController extends AdminBaseController { | ||
74 | 'end_time' => strtotime($schedule[$i]['end_time']), | 74 | 'end_time' => strtotime($schedule[$i]['end_time']), |
75 | 'price' => $schedule[$i]['price'], | 75 | 'price' => $schedule[$i]['price'], |
76 | 'maximum' => $schedule[$i]['maximum'], | 76 | 'maximum' => $schedule[$i]['maximum'], |
77 | + 'deadline' => strtotime($schedule[$i]['deadline']) | ||
77 | ]; | 78 | ]; |
78 | } | 79 | } |
79 | if(Db::name('activity_schedule')->insertAll($data)) { | 80 | if(Db::name('activity_schedule')->insertAll($data)) { |
@@ -145,6 +146,7 @@ class ActivityController extends AdminBaseController { | @@ -145,6 +146,7 @@ class ActivityController extends AdminBaseController { | ||
145 | 'end_time' => strtotime($schedule[$i]['end_time']), | 146 | 'end_time' => strtotime($schedule[$i]['end_time']), |
146 | 'price' => $schedule[$i]['price'], | 147 | 'price' => $schedule[$i]['price'], |
147 | 'maximum' => $schedule[$i]['maximum'], | 148 | 'maximum' => $schedule[$i]['maximum'], |
149 | + 'deadline' => strtotime($schedule[$i]['deadline']) | ||
148 | ]; | 150 | ]; |
149 | } | 151 | } |
150 | if(Db::name('activity_schedule')->insertAll($data)) { | 152 | if(Db::name('activity_schedule')->insertAll($data)) { |
@@ -4,7 +4,7 @@ use cmf\controller\HomeBaseController; | @@ -4,7 +4,7 @@ use cmf\controller\HomeBaseController; | ||
4 | use Think\Db; | 4 | use Think\Db; |
5 | 5 | ||
6 | /** | 6 | /** |
7 | - * @title 萨米户外 | 7 | + * @title 出行人模块 |
8 | */ | 8 | */ |
9 | class EscortController extends HomeBaseController | 9 | class EscortController extends HomeBaseController |
10 | { | 10 | { |
@@ -13,8 +13,7 @@ class EscortController extends HomeBaseController | @@ -13,8 +13,7 @@ class EscortController extends HomeBaseController | ||
13 | { | 13 | { |
14 | header("Access-Control-Allow-Origin: *"); // 允许任意域名发起的跨域请求 | 14 | header("Access-Control-Allow-Origin: *"); // 允许任意域名发起的跨域请求 |
15 | header('Access-Control-Allow-Headers: X-Requested-With,X_Requested_With'); | 15 | header('Access-Control-Allow-Headers: X-Requested-With,X_Requested_With'); |
16 | - $this->userId = (empty($_POST['user_id'])) ? null : $_POST['user_id']; | ||
17 | - if (empty($this->userId)) { | 16 | + if (empty(session('user.id'))) { |
18 | echo json_encode(['msg' => '登陆失败', 'code' => 40001]); | 17 | echo json_encode(['msg' => '登陆失败', 'code' => 40001]); |
19 | exit(); | 18 | exit(); |
20 | } | 19 | } |
@@ -26,7 +25,6 @@ class EscortController extends HomeBaseController | @@ -26,7 +25,6 @@ class EscortController extends HomeBaseController | ||
26 | * @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ | 25 | * @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ |
27 | * @url /escort/Escort/add | 26 | * @url /escort/Escort/add |
28 | * @method POST | 27 | * @method POST |
29 | - * @module 出行人模块 | ||
30 | * | 28 | * |
31 | * @param name:name type:char require:1 default:lihan other: desc:出行人姓名 | 29 | * @param name:name type:char require:1 default:lihan other: desc:出行人姓名 |
32 | * @param name:sex type:tinyint require:1 default:0 other: 0 desc:出行人性别 0男 1女 | 30 | * @param name:sex type:tinyint require:1 default:0 other: 0 desc:出行人性别 0男 1女 |
@@ -40,7 +38,7 @@ class EscortController extends HomeBaseController | @@ -40,7 +38,7 @@ class EscortController extends HomeBaseController | ||
40 | { | 38 | { |
41 | $request = request(); | 39 | $request = request(); |
42 | if ($request->isPost()) { | 40 | if ($request->isPost()) { |
43 | - $userId = $this->userId; | 41 | + $userId = session('user.id'); |
44 | if (!empty($userId)) { | 42 | if (!empty($userId)) { |
45 | $post = $request->param(); | 43 | $post = $request->param(); |
46 | if (empty($post['name'])) { | 44 | if (empty($post['name'])) { |
@@ -83,7 +81,6 @@ class EscortController extends HomeBaseController | @@ -83,7 +81,6 @@ class EscortController extends HomeBaseController | ||
83 | * @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ | 81 | * @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ |
84 | * @url /escort/Escort/edit | 82 | * @url /escort/Escort/edit |
85 | * @method POST | 83 | * @method POST |
86 | - * @module 出行人模块 | ||
87 | * | 84 | * |
88 | * @param name:id type:int require:1 default:2 desc:出行人id | 85 | * @param name:id type:int require:1 default:2 desc:出行人id |
89 | * @param name:name type:char require:1 default:lihan other: desc:出行人姓名 | 86 | * @param name:name type:char require:1 default:lihan other: desc:出行人姓名 |
@@ -96,7 +93,7 @@ class EscortController extends HomeBaseController | @@ -96,7 +93,7 @@ class EscortController extends HomeBaseController | ||
96 | { | 93 | { |
97 | $request = request(); | 94 | $request = request(); |
98 | if ($request->isPost()) { | 95 | if ($request->isPost()) { |
99 | - $userId = $this->userId; | 96 | + $userId = session('user.id'); |
100 | if (!empty($userId)) { | 97 | if (!empty($userId)) { |
101 | $post = $request->param(); | 98 | $post = $request->param(); |
102 | if (empty($post['name'])) { | 99 | if (empty($post['name'])) { |
@@ -115,7 +112,6 @@ class EscortController extends HomeBaseController | @@ -115,7 +112,6 @@ class EscortController extends HomeBaseController | ||
115 | echo json_encode(['msg' => '请填写出行人微信号', 'code' => 40000]); | 112 | echo json_encode(['msg' => '请填写出行人微信号', 'code' => 40000]); |
116 | exit(); | 113 | exit(); |
117 | } | 114 | } |
118 | - $post['user_id'] = $userId; | ||
119 | if (Db::name('escort')->update($post)) { | 115 | if (Db::name('escort')->update($post)) { |
120 | echo json_encode(['msg' => '编辑成功', 'code' => 20000]); | 116 | echo json_encode(['msg' => '编辑成功', 'code' => 20000]); |
121 | exit(); | 117 | exit(); |
@@ -139,7 +135,6 @@ class EscortController extends HomeBaseController | @@ -139,7 +135,6 @@ class EscortController extends HomeBaseController | ||
139 | * @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ | 135 | * @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ |
140 | * @url /escort/Escort/del | 136 | * @url /escort/Escort/del |
141 | * @method POST | 137 | * @method POST |
142 | - * @module 出行人模块 | ||
143 | * | 138 | * |
144 | * @param name:id type:int require:1 default:2 desc:出行人id | 139 | * @param name:id type:int require:1 default:2 desc:出行人id |
145 | */ | 140 | */ |
@@ -147,7 +142,7 @@ class EscortController extends HomeBaseController | @@ -147,7 +142,7 @@ class EscortController extends HomeBaseController | ||
147 | { | 142 | { |
148 | $request = request(); | 143 | $request = request(); |
149 | if ($request->isPost()) { | 144 | if ($request->isPost()) { |
150 | - $userId = $this->userId; | 145 | + $userId = session('user.id'); |
151 | if (!empty($userId)) { | 146 | if (!empty($userId)) { |
152 | if (Db::name('escort')->delete($request->param('id'))) { | 147 | if (Db::name('escort')->delete($request->param('id'))) { |
153 | echo json_encode(['msg' => '删除成功', 'code' => 20000]); | 148 | echo json_encode(['msg' => '删除成功', 'code' => 20000]); |
@@ -172,9 +167,6 @@ class EscortController extends HomeBaseController | @@ -172,9 +167,6 @@ class EscortController extends HomeBaseController | ||
172 | * @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ | 167 | * @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ |
173 | * @url /escort/Escort/_list | 168 | * @url /escort/Escort/_list |
174 | * @method POST | 169 | * @method POST |
175 | - * @module 出行人模块 | ||
176 | - * | ||
177 | - * @param name:user_id type:int require:1 default:1 desc:用户id | ||
178 | * | 170 | * |
179 | * @return id:出行人id | 171 | * @return id:出行人id |
180 | * @return name:出行人姓名 | 172 | * @return name:出行人姓名 |
@@ -184,7 +176,7 @@ class EscortController extends HomeBaseController | @@ -184,7 +176,7 @@ class EscortController extends HomeBaseController | ||
184 | public function _list() | 176 | public function _list() |
185 | { | 177 | { |
186 | $request = request(); | 178 | $request = request(); |
187 | - $userId = $this->userId; | 179 | + $userId = session('user.id'); |
188 | if ($request->isPost()) { | 180 | if ($request->isPost()) { |
189 | $data = Db::name('escort')->field('id,name,tel,identity')->where(['user_id' => $userId])->select()->toArray(); | 181 | $data = Db::name('escort')->field('id,name,tel,identity')->where(['user_id' => $userId])->select()->toArray(); |
190 | if (!empty($data)) { | 182 | if (!empty($data)) { |
@@ -9,28 +9,37 @@ | @@ -9,28 +9,37 @@ | ||
9 | namespace app\portal\controller; | 9 | namespace app\portal\controller; |
10 | 10 | ||
11 | use cmf\controller\HomeBaseController; | 11 | use cmf\controller\HomeBaseController; |
12 | +use think\Db; | ||
13 | +use app\activity\model\ActivityModel; | ||
12 | use EasyWeChat\Foundation\Application; | 14 | use EasyWeChat\Foundation\Application; |
13 | 15 | ||
14 | /** | 16 | /** |
15 | * @title 欢迎页 | 17 | * @title 欢迎页 |
16 | * @description 欢迎使用在线接口文档 | 18 | * @description 欢迎使用在线接口文档 |
17 | */ | 19 | */ |
18 | -class IndexController extends HomeBaseController { | 20 | +class IndexController extends HomeBaseController |
21 | +{ | ||
22 | + | ||
23 | + function __construct() | ||
24 | + { | ||
25 | + session('user.id', 2); | ||
26 | + } | ||
27 | + | ||
19 | /** | 28 | /** |
20 | * @title 接口返回参数说明 | 29 | * @title 接口返回参数说明 |
21 | * @description 默认访问接口 | 30 | * @description 默认访问接口 |
22 | * @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ | 31 | * @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ |
23 | - * @url /portal/index/index | 32 | + * @url /portal/index/api |
24 | * @method GET | 33 | * @method GET |
25 | * | 34 | * |
26 | * @return version:版本号 | 35 | * @return version:版本号 |
27 | * @return code:错误码 | 36 | * @return code:错误码 |
28 | */ | 37 | */ |
29 | - public function index() | 38 | + public function api() |
30 | { | 39 | { |
31 | - $data=[ | 40 | + $data = [ |
32 | 'version' => '1.0.0', | 41 | 'version' => '1.0.0', |
33 | - 'code'=>[ | 42 | + 'code' => [ |
34 | '20000' => '默认成功返回码', | 43 | '20000' => '默认成功返回码', |
35 | '40000' => '默认错误返回码', | 44 | '40000' => '默认错误返回码', |
36 | '40001' => '未登录或登录失效', | 45 | '40001' => '未登录或登录失效', |
@@ -39,8 +48,14 @@ class IndexController extends HomeBaseController { | @@ -39,8 +48,14 @@ class IndexController extends HomeBaseController { | ||
39 | '40004' => '登录失败', | 48 | '40004' => '登录失败', |
40 | ] | 49 | ] |
41 | ]; | 50 | ]; |
42 | - echo json_encode(['msg'=>$data]); | 51 | + echo json_encode(['msg' => $data]); |
43 | exit(); | 52 | exit(); |
44 | } | 53 | } |
45 | 54 | ||
46 | -} | 55 | + |
56 | + public function index() | ||
57 | + { | ||
58 | + | ||
59 | + } | ||
60 | + | ||
61 | +} |
@@ -85,7 +85,7 @@ | @@ -85,7 +85,7 @@ | ||
85 | 85 | ||
86 | <input id="B" type="button" value="新增" style="display: none;"> | 86 | <input id="B" type="button" value="新增" style="display: none;"> |
87 | <div id="schedule" style="margin-bottom: 20px"> | 87 | <div id="schedule" style="margin-bottom: 20px"> |
88 | - <li id="li_0">开始时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[0][start_time]"> 结束时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[0][end_time]"> 价格:<input required autocomplete="off" class="form-control detail" type="text" name="schedule[0][price]"> 允许参加人数:<input required autocomplete="off" class="form-control detail" type="text" name="schedule[0][maximum]"> </li> | 88 | + <li id="li_0">开始时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[0][start_time]"> 结束时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[0][end_time]"> 价格:<input required autocomplete="off" class="form-control detail" type="text" name="schedule[0][price]"> 允许参加人数:<input required autocomplete="off" class="form-control detail" type="text" name="schedule[0][maximum]"> 报名截止时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[0][deadline]"></li> |
89 | </div> | 89 | </div> |
90 | 90 | ||
91 | <div class="form-group"> | 91 | <div class="form-group"> |
@@ -221,7 +221,7 @@ | @@ -221,7 +221,7 @@ | ||
221 | }else { | 221 | }else { |
222 | $("#B").show(); | 222 | $("#B").show(); |
223 | } | 223 | } |
224 | - var text='<li id="li_0">开始时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[0][start_time]"> 结束时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[0][end_time]"> 价格:<input required autocomplete="off" class="form-control detail" type="text" name="schedule[0][price]"> 允许参加人数:<input required autocomplete="off" class="form-control detail" type="text" name="schedule[0][maximum]"> <input id="B" type="button" value="新增" style="display: none;"></li>' | 224 | + var text='<li id="li_0">开始时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[0][start_time]"> 结束时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[0][end_time]"> 价格:<input required autocomplete="off" class="form-control detail" type="text" name="schedule[0][price]"> 允许参加人数:<input required autocomplete="off" class="form-control detail" type="text" name="schedule[0][maximum]"> <input id="B" type="button" value="新增" style="display: none;">报名截止时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[0][deadline]"></li>' |
225 | $("#schedule").html(text); | 225 | $("#schedule").html(text); |
226 | }) | 226 | }) |
227 | 227 | ||
@@ -243,7 +243,7 @@ | @@ -243,7 +243,7 @@ | ||
243 | $("#B").click(function () { | 243 | $("#B").click(function () { |
244 | var length=$("#schedule li").length; | 244 | var length=$("#schedule li").length; |
245 | var html=$("#schedule").html(); | 245 | var html=$("#schedule").html(); |
246 | - var text='<li id="li_'+length+'">开始时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule['+length+'][start_time]"> 结束时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule['+length+'][end_time]"> 价格:<input required autocomplete="off" class="form-control detail" type="text" name="schedule['+length+'][price]"> 允许参加人数:<input required autocomplete="off" class="form-control detail" type="text" name="schedule['+length+'][maximum]"> <input id="B" type="button" value="新增" style="display: none;"> <span><font color="red" onclick="clearHtml('+length+')">删除</font></span></li>' | 246 | + var text='<li id="li_'+length+'">开始时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule['+length+'][start_time]"> 结束时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule['+length+'][end_time]"> 价格:<input required autocomplete="off" class="form-control detail" type="text" name="schedule['+length+'][price]"> 允许参加人数:<input required autocomplete="off" class="form-control detail" type="text" name="schedule['+length+'][maximum]"> <input id="B" type="button" value="新增" style="display: none;">报名截止时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule['+length+'][deadline]"> <span><font color="red" onclick="clearHtml('+length+')">删除</font></span></li>' |
247 | $("#schedule").html(html+text); | 247 | $("#schedule").html(html+text); |
248 | }) | 248 | }) |
249 | 249 |
@@ -104,7 +104,7 @@ | @@ -104,7 +104,7 @@ | ||
104 | <input id="B" type="button" value="新增" <if condition="$info['date_type'] eq '0'">style="display: none";</if>> | 104 | <input id="B" type="button" value="新增" <if condition="$info['date_type'] eq '0'">style="display: none";</if>> |
105 | <div id="schedule" style="margin-bottom: 20px"> | 105 | <div id="schedule" style="margin-bottom: 20px"> |
106 | <foreach name="schedule" item="v" key="k"> | 106 | <foreach name="schedule" item="v" key="k"> |
107 | - <li id="li_{$k}">开始时间:<input value="{$v['start_time']|date='Y-m-d H:i:s', ###}" required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[{$k}][start_time]"> 结束时间:<input value="{$v['end_time']|date='Y-m-d H:i:s', ###}" required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[{$k}][end_time]"> 价格:<input value="{$v['price']}" required autocomplete="off" class="form-control detail" type="text" name="schedule[{$k}][price]"> 允许参加人数:<input value="{$v['maximum']}" required autocomplete="off" class="form-control detail" type="text" name="schedule[{$k}][maximum]"> <font color="red" onclick="clearHtml({$k})">删除</font></li> | 107 | + <li id="li_{$k}">开始时间:<input value="{$v['start_time']|date='Y-m-d H:i:s', ###}" required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[{$k}][start_time]"> 结束时间:<input value="{$v['end_time']|date='Y-m-d H:i:s', ###}" required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[{$k}][end_time]"> 价格:<input value="{$v['price']}" required autocomplete="off" class="form-control detail" type="text" name="schedule[{$k}][price]"> 允许参加人数:<input value="{$v['maximum']}" required autocomplete="off" class="form-control detail" type="text" name="schedule[{$k}][maximum]"> 报名截止时间:<input value="{$v.deadline|date='Y-m-d H:i:s', ###}" required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[{$k}][deadline]"> <font color="red" onclick="clearHtml({$k})">删除</font></li> |
108 | </foreach> | 108 | </foreach> |
109 | </div> | 109 | </div> |
110 | 110 | ||
@@ -248,7 +248,7 @@ | @@ -248,7 +248,7 @@ | ||
248 | }else { | 248 | }else { |
249 | $("#B").show(); | 249 | $("#B").show(); |
250 | } | 250 | } |
251 | - var text='<li id="li_0">开始时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[0][start_time]"> 结束时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[0][end_time]"> 价格:<input required autocomplete="off" class="form-control detail" type="text" name="schedule[0][price]"> 允许参加人数:<input required autocomplete="off" class="form-control detail" type="text" name="schedule[0][maximum]"> <input id="B" type="button" value="新增" style="display: none;"></li>' | 251 | + var text='<li id="li_0">开始时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[0][start_time]"> 结束时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[0][end_time]"> 价格:<input required autocomplete="off" class="form-control detail" type="text" name="schedule[0][price]"> 允许参加人数:<input required autocomplete="off" class="form-control detail" type="text" name="schedule[0][maximum]"> 报名截止时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule[0][deadline]"></li>' |
252 | $("#schedule").html(text); | 252 | $("#schedule").html(text); |
253 | }) | 253 | }) |
254 | 254 | ||
@@ -270,7 +270,7 @@ | @@ -270,7 +270,7 @@ | ||
270 | $("#B").click(function () { | 270 | $("#B").click(function () { |
271 | var length=$("#schedule li").length; | 271 | var length=$("#schedule li").length; |
272 | var html=$("#schedule").html(); | 272 | var html=$("#schedule").html(); |
273 | - var text='<li id="li_'+length+'">开始时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule['+length+'][start_time]"> 结束时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule['+length+'][end_time]"> 价格:<input required autocomplete="off" class="form-control detail" type="text" name="schedule['+length+'][price]"> 允许参加人数:<input required autocomplete="off" class="form-control detail" type="text" name="schedule['+length+'][maximum]"> <input id="B" type="button" value="新增" style="display: none;"> <span><font color="red" onclick="clearHtml('+length+')">删除</font></span></li>' | 273 | + var text='<li id="li_'+length+'">开始时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule['+length+'][start_time]"> 结束时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule['+length+'][end_time]"> 价格:<input required autocomplete="off" class="form-control detail" type="text" name="schedule['+length+'][price]"> 允许参加人数:<input required autocomplete="off" class="form-control detail" type="text" name="schedule['+length+'][maximum]"> 报名截止时间:<input required autocomplete="off" onclick="showDate()" class="form-control js-bootstrap-datetime detail" type="text" name="schedule['+length+'][deadline]"> <span><font color="red" onclick="clearHtml('+length+')">删除</font></span></li>' |
274 | $("#schedule").html(html+text); | 274 | $("#schedule").html(html+text); |
275 | }) | 275 | }) |
276 | 276 |
-
请 注册 或 登录 后发表评论