正在显示
5 个修改的文件
包含
166 行增加
和
16 行删除
@@ -33,7 +33,7 @@ class ActivityController extends HomeBaseController | @@ -33,7 +33,7 @@ class ActivityController extends HomeBaseController | ||
33 | $model = new ActivityModel; | 33 | $model = new ActivityModel; |
34 | $t_id = request()->param('t_id'); | 34 | $t_id = request()->param('t_id'); |
35 | $keyword = request()->param('keyword'); | 35 | $keyword = request()->param('keyword'); |
36 | - $activity = $model->activityList($t_id, time(), session('user.id'), $keyword); | 36 | + $activity = $model->activityList($t_id, time(), session('user.id'), $keyword, '', ''); |
37 | $result = [ | 37 | $result = [ |
38 | 'banner' => $banner, | 38 | 'banner' => $banner, |
39 | 'type' => $type, | 39 | 'type' => $type, |
@@ -180,4 +180,42 @@ class ActivityController extends HomeBaseController | @@ -180,4 +180,42 @@ class ActivityController extends HomeBaseController | ||
180 | return $res; | 180 | return $res; |
181 | } | 181 | } |
182 | 182 | ||
183 | + /** | ||
184 | + * @title Ajax切换批次显示信息 | ||
185 | + * @description 默认访问接口 | ||
186 | + * @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ | ||
187 | + * @url /activity/Activity/alterSchedule | ||
188 | + * @method POST | ||
189 | + * | ||
190 | + * @param name:schedule_id type:int require:1 default:56 other: desc:批次id | ||
191 | + */ | ||
192 | + public function alterSchedule() | ||
193 | + { | ||
194 | + $request = request(); | ||
195 | + if ($request->isPost()) { | ||
196 | + $schedule_id = $request->param('schedule_id'); | ||
197 | + $data = Db::name('activity_schedule') | ||
198 | + ->field('id as schedule_id,price,start_time,end_time,real_join_num,addition_join_num,maximum') | ||
199 | + ->where(['id' => $schedule_id]) | ||
200 | + ->find(); | ||
201 | + if (!empty($data)) { | ||
202 | + $data['start_time'] = date('Y.m.d', $data['start_time']); | ||
203 | + $data['end_time'] = date('Y.m.d', $data['end_time']); | ||
204 | + $data['sales_num'] = $data['real_join_num'] + $data['addition_join_num']; | ||
205 | + $data['residue_num'] = $data['maximum'] - $data['sales_num']; | ||
206 | + unset($data['real_join_num']); | ||
207 | + unset($data['addition_join_num']); | ||
208 | + unset($data['maximum']); | ||
209 | + echo json_encode(['data' => $data, 'code' => 20000]); | ||
210 | + exit(); | ||
211 | + } else { | ||
212 | + echo json_encode(['msg' => '未知错误', 'code' => 40000]); | ||
213 | + exit(); | ||
214 | + } | ||
215 | + } else { | ||
216 | + echo json_encode(['msg' => '非法操作', 'code' => 40000]); | ||
217 | + exit(); | ||
218 | + } | ||
219 | + } | ||
220 | + | ||
183 | } | 221 | } |
@@ -18,12 +18,14 @@ class ActivityModel extends Model | @@ -18,12 +18,14 @@ class ActivityModel extends Model | ||
18 | * @param $nowTime | 18 | * @param $nowTime |
19 | * @param $userId | 19 | * @param $userId |
20 | * @param null $keyword | 20 | * @param null $keyword |
21 | + * @param null $isNew | ||
22 | + * @param null $isHot | ||
21 | * @return array | 23 | * @return array |
22 | * @throws \think\db\exception\DataNotFoundException | 24 | * @throws \think\db\exception\DataNotFoundException |
23 | * @throws \think\db\exception\ModelNotFoundException | 25 | * @throws \think\db\exception\ModelNotFoundException |
24 | * @throws \think\exception\DbException | 26 | * @throws \think\exception\DbException |
25 | */ | 27 | */ |
26 | - public function activityList($tId = null, $nowTime, $userId, $keyword = null) | 28 | + public function activityList($tId = null, $nowTime, $userId, $keyword = null, $isNew = null, $isHot = null) |
27 | { | 29 | { |
28 | $where = []; | 30 | $where = []; |
29 | if ($tId != null) { | 31 | if ($tId != null) { |
@@ -32,6 +34,12 @@ class ActivityModel extends Model | @@ -32,6 +34,12 @@ class ActivityModel extends Model | ||
32 | if ($keyword != null) { | 34 | if ($keyword != null) { |
33 | $where['name'] = ['like', "%$keyword%"]; | 35 | $where['name'] = ['like', "%$keyword%"]; |
34 | } | 36 | } |
37 | + if ($isNew != null) { | ||
38 | + $where['is_new'] = ['eq', 1]; | ||
39 | + } | ||
40 | + if ($isHot != null) { | ||
41 | + $where['is_hot'] = ['eq', 1]; | ||
42 | + } | ||
35 | $res = Db::name('activity')->field('id,name,thumb')->where($where)->select()->toArray(); | 43 | $res = Db::name('activity')->field('id,name,thumb')->where($where)->select()->toArray(); |
36 | //只显示还未到报名日期活动最近的一条行程 | 44 | //只显示还未到报名日期活动最近的一条行程 |
37 | foreach ($res as $key => $item) { | 45 | foreach ($res as $key => $item) { |
@@ -70,8 +78,8 @@ class ActivityModel extends Model | @@ -70,8 +78,8 @@ class ActivityModel extends Model | ||
70 | ->where(['activity_id' => $activityId]) | 78 | ->where(['activity_id' => $activityId]) |
71 | ->select(); | 79 | ->select(); |
72 | foreach ($res as $k => $v) { | 80 | foreach ($res as $k => $v) { |
73 | - $v['start_time'] = date('Y-m-d', $v['start_time']); | ||
74 | - $v['end_time'] = date('Y-m-d', $v['end_time']); | 81 | + $v['start_time'] = date('Y.m.d', $v['start_time']); |
82 | + $v['end_time'] = date('Y.m.d', $v['end_time']); | ||
75 | $v['sales_num'] = $v['real_join_num'] + $v['addition_join_num']; | 83 | $v['sales_num'] = $v['real_join_num'] + $v['addition_join_num']; |
76 | $v['residue_num'] = $v['maximum'] - $v['sales_num']; | 84 | $v['residue_num'] = $v['maximum'] - $v['sales_num']; |
77 | unset($v['real_join_num']); | 85 | unset($v['real_join_num']); |
@@ -20,15 +20,51 @@ class NewsController extends HomeBaseController | @@ -20,15 +20,51 @@ class NewsController extends HomeBaseController | ||
20 | * @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ | 20 | * @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ |
21 | * @url /news/News/newsList | 21 | * @url /news/News/newsList |
22 | * @method POST | 22 | * @method POST |
23 | + * | ||
24 | + * @param name:t_id type:int require:1 default:11 other: desc:分类id | ||
23 | */ | 25 | */ |
24 | public function newsList() | 26 | public function newsList() |
25 | { | 27 | { |
26 | - | 28 | + $news_type = Db::name('portal_category')->field('id as t_id,name,more')->where(['parent_id' => 10])->select(); |
29 | + foreach ($news_type as $k => $v) { | ||
30 | + $arr = json_decode($v['more'], true); | ||
31 | + $v['thumb'] = cmf_get_image_url($arr['thumbnail']); | ||
32 | + unset($v['more']); | ||
33 | + $news_type[$k] = $v; | ||
34 | + } | ||
35 | + $t_id = (request()->param('t_id') == null) ? $news_type[0]['t_id'] : request()->param('t_id'); | ||
36 | + $news_list = Db::name('portal_category_post')->alias('c') | ||
37 | + ->field('c.post_id as id,p.post_title,p.post_hits,more') | ||
38 | + ->join('portal_post p', 'p.id=c.post_id') | ||
39 | + ->where(['c.category_id' => $t_id]) | ||
40 | + ->select(); | ||
41 | + $collect = Db::name('collect_news')->field('post_id')->where(['user_id' => session('user.id')])->select(); | ||
42 | + foreach ($collect as $k => $v) { | ||
43 | + $temp[$k] = $v['post_id']; | ||
44 | + } | ||
45 | + foreach ($news_list as $k => $v) { | ||
46 | + $arr = json_decode($v['more'], true); | ||
47 | + $v['thumb'] = cmf_get_image_url($arr['thumbnail']); | ||
48 | + unset($v['more']); | ||
49 | + if (in_array($v['id'], $temp)) { | ||
50 | + $v['is_collect'] = 1; | ||
51 | + } else { | ||
52 | + $v['is_collect'] = 0; | ||
53 | + } | ||
54 | + $news_list[$k] = $v; | ||
55 | + } | ||
56 | + $return = [ | ||
57 | + 'news_type' => $news_type, | ||
58 | + 'type_name' => Db::name('portal_category')->where(['id' => $t_id])->value('name'), | ||
59 | + 'news_list' => $news_list | ||
60 | + ]; | ||
61 | + echo json_encode(['data' => $return, 'code' => 20000]); | ||
62 | + exit(); | ||
27 | } | 63 | } |
28 | 64 | ||
29 | /** | 65 | /** |
30 | * @title 新闻详情 | 66 | * @title 新闻详情 |
31 | - * @description 接口说明 | 67 | + * @description 接口说明(指定id为购买协议) |
32 | * @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ | 68 | * @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ |
33 | * @url /news/News/detail | 69 | * @url /news/News/detail |
34 | * @method GET | 70 | * @method GET |
@@ -38,6 +74,8 @@ class NewsController extends HomeBaseController | @@ -38,6 +74,8 @@ class NewsController extends HomeBaseController | ||
38 | public function detail() | 74 | public function detail() |
39 | { | 75 | { |
40 | $id = request()->param('id'); | 76 | $id = request()->param('id'); |
77 | + //阅读量+1 | ||
78 | + Db::name('portal_post')->where(['id'=>$id])->setInc('post_hits', 1); | ||
41 | $news = Db::name('portal_post')->field('post_title,post_content,published_time')->where(['id' => $id])->find(); | 79 | $news = Db::name('portal_post')->field('post_title,post_content,published_time')->where(['id' => $id])->find(); |
42 | $news['published_time'] = date('Y/m/d', $news['published_time']); | 80 | $news['published_time'] = date('Y/m/d', $news['published_time']); |
43 | $news['post_content'] = html_entity_decode($news['post_content']); | 81 | $news['post_content'] = html_entity_decode($news['post_content']); |
@@ -19,13 +19,6 @@ use EasyWeChat\Foundation\Application; | @@ -19,13 +19,6 @@ use EasyWeChat\Foundation\Application; | ||
19 | */ | 19 | */ |
20 | class IndexController extends HomeBaseController | 20 | class IndexController extends HomeBaseController |
21 | { | 21 | { |
22 | - | ||
23 | - function __construct() | ||
24 | - { | ||
25 | - session('user.id', 2); | ||
26 | - echo session('user.id'); | ||
27 | - } | ||
28 | - | ||
29 | /** | 22 | /** |
30 | * @title 接口返回参数说明 | 23 | * @title 接口返回参数说明 |
31 | * @description 默认访问接口 | 24 | * @description 默认访问接口 |
@@ -54,9 +47,36 @@ class IndexController extends HomeBaseController | @@ -54,9 +47,36 @@ class IndexController extends HomeBaseController | ||
54 | } | 47 | } |
55 | 48 | ||
56 | 49 | ||
50 | + /** | ||
51 | + * @title 首页 | ||
52 | + * @description 默认访问接口 | ||
53 | + * @author sᴏᴜʟ ᴏғ ᴄɪɴᴅᴇʀ | ||
54 | + * @url /portal/Index/index | ||
55 | + * @method GET | ||
56 | + * | ||
57 | + * @return version:版本号 | ||
58 | + * @return code:错误码 | ||
59 | + */ | ||
57 | public function index() | 60 | public function index() |
58 | { | 61 | { |
59 | - | 62 | + //首页轮播图 |
63 | + $banner = Db::name('slide_item')->field('image,url')->where(['slide_id' => 1])->order('list_order')->select(); | ||
64 | + //分类 | ||
65 | + $type = Db::name('type')->field('type_name,type_url,type_icon')->order('listorder')->select(); | ||
66 | + //活动 | ||
67 | + $model = new ActivityModel; | ||
68 | + $t_id = request()->param('t_id'); | ||
69 | + $keyword = request()->param('keyword'); | ||
70 | + $is_new = $model->activityList($t_id, time(), session('user.id'), $keyword, 1, ''); | ||
71 | + $is_hot = $model->activityList($t_id, time(), session('user.id'), $keyword, '', 1); | ||
72 | + $result = [ | ||
73 | + 'banner' => $banner, | ||
74 | + 'type' => $type, | ||
75 | + 'is_new' => $is_new, | ||
76 | + 'is_hot' => $is_hot | ||
77 | + ]; | ||
78 | + echo json_encode(['data' => $result, 'code' => 20000]); | ||
79 | + exit(); | ||
60 | } | 80 | } |
61 | 81 | ||
62 | } | 82 | } |
1 | <?php return array ( | 1 | <?php return array ( |
2 | '户外频道/:id' => | 2 | '户外频道/:id' => |
3 | array ( | 3 | array ( |
4 | - 0 => 'portal/Article/index?cid=8', | 4 | + 0 => 'portal/Article/index?cid=10', |
5 | + 1 => | ||
6 | + array ( | ||
7 | + ), | ||
8 | + 2 => | ||
9 | + array ( | ||
10 | + 'id' => '\d+', | ||
11 | + 'cid' => '\d+', | ||
12 | + ), | ||
13 | + ), | ||
14 | + '购买协议/:id' => | ||
15 | + array ( | ||
16 | + 0 => 'portal/Article/index?cid=9', | ||
17 | + 1 => | ||
18 | + array ( | ||
19 | + ), | ||
20 | + 2 => | ||
21 | + array ( | ||
22 | + 'id' => '\d+', | ||
23 | + 'cid' => '\d+', | ||
24 | + ), | ||
25 | + ), | ||
26 | + '旅行报道/:id' => | ||
27 | + array ( | ||
28 | + 0 => 'portal/Article/index?cid=11', | ||
5 | 1 => | 29 | 1 => |
6 | array ( | 30 | array ( |
7 | ), | 31 | ), |
@@ -13,7 +37,29 @@ | @@ -13,7 +37,29 @@ | ||
13 | ), | 37 | ), |
14 | '户外频道' => | 38 | '户外频道' => |
15 | array ( | 39 | array ( |
16 | - 0 => 'portal/List/index?id=8', | 40 | + 0 => 'portal/List/index?id=10', |
41 | + 1 => | ||
42 | + array ( | ||
43 | + ), | ||
44 | + 2 => | ||
45 | + array ( | ||
46 | + 'id' => '\d+', | ||
47 | + ), | ||
48 | + ), | ||
49 | + '购买协议' => | ||
50 | + array ( | ||
51 | + 0 => 'portal/List/index?id=9', | ||
52 | + 1 => | ||
53 | + array ( | ||
54 | + ), | ||
55 | + 2 => | ||
56 | + array ( | ||
57 | + 'id' => '\d+', | ||
58 | + ), | ||
59 | + ), | ||
60 | + '旅行报道' => | ||
61 | + array ( | ||
62 | + 0 => 'portal/List/index?id=11', | ||
17 | 1 => | 63 | 1 => |
18 | array ( | 64 | array ( |
19 | ), | 65 | ), |
-
请 注册 或 登录 后发表评论