AudienceController.php 6.2 KB
<?php
/**
 * 观众中心
 * Author : xiaojie
 * DateTime: 2018/12/06 11:35
 */
namespace app\portal\controller;

use app\portal\model\ExhibitorsModel;
use app\portal\model\PageModel;
use app\portal\model\PortalCategoryModel;
use app\portal\model\ShowModel;
use cmf\controller\HomeBaseController;
use think\Session;


class AudienceController extends HomeBaseController
{
    /**
     * 观众预登记
     * portal/audience/stand
     */
    public function stand()
    {
        return $this->fetch();
    }

    /**
     * 展位图
     * portal/audience/floorplan
     */
    public function floorplan()
    {
        $cate_id = 30;
        $pageModel = new PageModel();
        $info = $pageModel->where('cate_id',$cate_id)->find();
        $this->setPageNum($info['id']);
        //所在位置
        $location = [
            [
                'location' => '观众中心',
                'url' => 'javascript:;'
            ],
            [
                'location' => '展位图',
                'url' => url('portal/audience/floorplan')
            ]
        ];
        $this->assign('info',$info);
        $this->assign('location',$location);
        return $this->fetch(':page');
    }

    /**
     * 往届观众
     * portal/audience/past
     */
    public function past()
    {
        $cate_id = 31;
        $cateModel = new PortalCategoryModel();
        $showModel = new ShowModel();
        $list = $showModel->where('id',$cate_id)->paginate(57);
        //分类信息
        $info = $cateModel->where('id',$cate_id)->find();
        //增加阅读量
        $this->setCateNum($cate_id);
        //所在位置
        $location = [
            [
                'location' => '观众中心',
                'url' => 'javascript:;'
            ],
            [
                'location' => '往届观众',
                'url' => url('portal/audience/past')
            ]
        ];

        $this->assign('list',$list);
        $this->assign('location',$location);
        $this->assign('info',$info);
        return $this->fetch();
    }


    /**
     * 买家集群
     * portal/audience/buyer
     */
    public function buyer()
    {
//        $cate_id = 32;
//        $cateModel = new PortalCategoryModel();
//        $showModel = new ShowModel();
//        $list = $showModel->getList($cate_id);
//        //分类信息
//        $info = $cateModel->where('id',$cate_id)->find();
//        //增加阅读量
//        $this->setCateNum($cate_id);
//        //所在位置
//        $location = [
//            [
//                'location' => '观众中心',
//                'url' => 'javascript:;'
//            ],
//            [
//                'location' => '买家集群',
//                'url' => url('portal/audience/buyer')
//            ]
//        ];
//        $this->assign('list',$list);
//        $this->assign('location',$location);
//        $this->assign('info',$info);
//        return $this->fetch();
        $keyword = $this->request->param('keyword','');
        $showModel = new ShowModel();
        $list = $showModel->getList(32,$keyword,16);
        $page = $this->getPageStyle($list);
        //所在位置
        $location = [
            [
                'location' => '观众中心',
                'url' => 'javascript:;'
            ],
            [
                'location' => '买家集群',
                'url' => 'javascript:;'
            ]
        ];
        $this->assign('list',$list);
        $this->assign('location',$location);
        $this->assign('page',$page);
        $this->assign('keyword',empty($keyword)?'':$keyword);
        return $this->fetch();
    }

    /**
     * 观众预登记提交
     * portal/audience/ajax_stand_add
     */
    public function ajax_stand_add()
    {
        $user_mobile = Session::get('user_mobile');
        if(empty($user_mobile)){
            $this->apiResponse(0,'请登录后在操作');
        }
        $param = $this->request->param();
        if(empty($param['name']) or !isset($param['name'])){
            $this->apiResponse(0,'姓名不能为空');
        }
        if(empty($param['mobile']) or !isset($param['mobile'])){
            $this->apiResponse(0,'手机号不能为空');
        }
        if(empty($param['post']) or !isset($param['post'])){
            $this->apiResponse(0,'职务不能为空');
        }
        if(empty($param['company_name']) or !isset($param['company_name'])){
            $this->apiResponse(0,'公司名称不能为空');
        }
        if(empty($param['phone']) or !isset($param['phone'])){
            $this->apiResponse(0,'办公电话不能为空');
        }
//        if(empty($param['address']) or !isset($param['address'])){
//            $this->apiResponse(0,'公司地址不能为空');
//        }
        if(empty($param['qq']) or !isset($param['qq'])){
            $this->apiResponse(0,'联系QQ不能为空');
        }
        if(empty($param['address_detail']) or !isset($param['address_detail'])){
            $this->apiResponse(0,'详细地址不能为空');
        }
        if(empty($param['category']) or !isset($param['category'])){
            $this->apiResponse(0,'参观调查不能为空');
        }
        if(empty($param['objective']) or !isset($param['objective'])){
            $this->apiResponse(0,'此行的目的不能为空');
        }
        if(empty($param['interest']) or !isset($param['interest'])){
            $this->apiResponse(0,'您感兴趣的展品不能为空');
        }
        if(empty($param['understand']) or !isset($param['understand'])){
            $this->apiResponse(0,'您如何得知我们的展会不能为空');
        }
        if(!in_array(7,$param['objective'])){
            $param['objective_data'] = '';
        }else{
            if(empty($param['objective_data'])){
                $this->error('请填写此行目的');
            }
        }
        if(!in_array(10,$param['understand'])){
            $param['understand_data'] = '';
        }else{
            if(empty($param['understand_data'])){
                $this->error('请填写得知方式');
            }
        }
        $exhibitorsModel = new ExhibitorsModel();
        $res = $exhibitorsModel->save($param);
        if($res){
            $this->apiResponse(1,'提交成功');
        }
        $this->apiResponse(0,'请稍后重试');
    }

}