Browse Source

活动列表详情

15954078560 2 years ago
parent
commit
b160bc5dda
2 changed files with 66 additions and 10 deletions
  1. 62 9
      application/api/controller/Index.php
  2. 4 1
      application/common/controller/Api.php

+ 62 - 9
application/api/controller/Index.php

@@ -23,15 +23,6 @@ class Index extends Api
     {
         $this->success('请求成功');
     }
-
-    //轮播图
-    public function banner()
-    {
-        $list = Db::name('banner')->field('id, title, image, url')->order('weigh', 'desc')->select();
-
-        $list = list_domain_image($list, ['image']);
-        $this->success('轮播图', $list);
-    }
     
     //接线员
     public function operator()
@@ -359,9 +350,71 @@ class Index extends Api
     }
 
 
+    //轮播图
+    public function banner()
+    {
+        $list = Db::name('banner')->field('id, title, image, url')->order('weigh', 'desc')->select();
+
+        $this->success('轮播图', $list);
+    }
+
+    //活动列表
+    public function activelist() {
+        $type = input('type', 0, 'intval'); //分类:1=休闲,2=中度
+        $keyword = input('keyword', '', 'trim'); //关键字
+
+        $where['signupendtime'] = ['gt', time()];
+        $where['status'] = 0;
+        if ($type) {
+            $where['type'] = $type;
+        }
+        if ($keyword !== '') {
+            $where['title|desc|remark|collectionplace|leader'] = ['like', '%'.$keyword.'%'];
+        }
+
+        $list = Db::name('active')->field('id, type, title, desc, remark, image, price, maxperson, currentperson')
+            ->where($where)->page($this->page, $this->pagenum)->order('createtime', 'desc')->select();
+
+        foreach ($list as &$v) {
+            if ($v['maxperson'] <= $v['currentperson']) {
+                $v['is_full'] = 1;
+            } else {
+                $v['is_full'] = 0;
+            }
+        }
+
+        $this->success('活动列表', $list);
+    }
+
+    //活动详情
+    public function activeinfo() {
+        $id = input('id', 0, 'intval');
+        if (!$id) {
+            $this->error('参数缺失');
+        }
+
+        $info = Db::name('active')->find($id);
+        if (!$info) {
+            $this->error('数据不存在');
+        }
 
+        $info['starttime'] = date('Y-m-d H:i', $info['starttime']);
+        $info['endtime'] = date('Y-m-d H:i', $info['endtime']);
+        $info['collectiontime'] = date('Y-m-d H:i', $info['collectiontime']);
+        $info['signupendtime'] = date('Y-m-d H:i', $info['signupendtime']);
+        $info['refundendtime'] = date('Y-m-d H:i', $info['refundendtime']);
+        //查询已报名列表
+        $active_people = Db::name('active_people')->where(['active_id' => $id])->field('user_id, name, createtime')->select();
+        $user = Db::name('user');
+        foreach ($active_people as &$v) {
+            $v['avatar'] = $user->where(['id' => $v['user_id']])->value('avatar');
+            $v['createtime'] = date('Y-m-d H:i:s', $v['createtime']);
+        }
 
+        $info['active_people'] = $active_people;
 
+        $this->success('招标详情', $info);
+    }
 
 
 

+ 4 - 1
application/common/controller/Api.php

@@ -67,6 +67,8 @@ class Api
 
     //分页
     protected $page;
+    //每页展示数量
+    protected $pagenum;
 
     /**
      * 构造方法
@@ -77,7 +79,8 @@ class Api
     {
         $this->request = is_null($request) ? Request::instance() : $request;
 
-        $this->page = input('page', 1);
+        $this->page = input('page', 1, 'intval');
+        $this->pagenum = input('pagenum', 10, 'intval');
 
         // 控制器初始化
         $this->_initialize();