IndexController.php 2.1 KB
<?php
// +----------------------------------------------------------------------
// | bronet [ 以客户为中心 以奋斗者为本 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
namespace app\portal\controller;

use cmf\controller\HomeBaseController;
use EasyWeChat\Foundation\Application;
use think\Db;

class IndexController extends HomeBaseController
{

    public function _initialize(){

      parent::_initialize();
      $data = Db::name('slide_item') -> where('slide_id',3) -> find();
      $this -> assign('logo',$data);

      $shuju = Db::name('nav_menu') -> select();
      $data2 = $this -> daohang($shuju);

      $this -> assign('data2',$data2);

    }

    public function daohang($data,$pid=0){

      $arr = [];
      foreach ($data as $key => $value) {
         if($value['parent_id'] == $pid){
            $value['son'] = $this -> daohang($data,$value['id']);
            $arr[] = $value;

         }
      }
      return $arr;


    }

    //首页显示
    public function index()
    {

        $lunbo1 = Db::name('slide_item') -> where('slide_id',5) -> select();
        $this -> assign('lunbo1',$lunbo1);

        $lunbo2 = Db::name('slide_item') -> where('slide_id',6) -> select();
        $this -> assign('lunbo2',$lunbo2);

        $lunbo3 = Db::name('slide_item') -> where('slide_id',7) -> select();
        $this -> assign('lunbo3',$lunbo3);

        $lunbo = Db::name('slide_item') -> where('slide_id',4) -> select();
        $this -> assign('lunbo',$lunbo);
        return $this->fetch(':index');

    }

    //底部联系人添加
    public function fadd(){

      $data['name'] = input('post.name');
      $data['phone'] = input('post.phone');
      $data['content'] = input('post.content');
      $shuju = Db::name('contacts') -> insert($data);
      if($shuju){
        return true;
      }else{
        return false;
      }

    }
}