IndexController.php 2.5 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 CommentController
{
    /*
* 长度处理
* */
    public function changeThisLen($text){
        $change_html = strip_tags(htmlspecialchars_decode($text));
        $sub_text_first = mb_substr($change_html,0,5,'utf-8');
        $sub_text = $sub_text_first;
        return $sub_text;
    }
//    首页
    public function index()
    {
//        轮播图
        $where_banner['status'] = array('neq',9);
        $banner = Db::name('Banner')->where($where_banner)->order('score desc')->select()->toArray();
        $this->assign('banner',$banner);
//        我要购买推荐商品
        $where_vehicle['status'] = array('neq',9);
        $where_vehicle['is_up'] = 1;
        $where_vehicle['type'] = 2;
        $vehicle = Db::name('Vehicle')->where($where_vehicle)->order('score desc')->field('id,name,pic')->select()->toArray();
        foreach ($vehicle as $k=>$v){
            $vehicle[$k]['name'] = $this->changeThisLen($v['name']);
        }
        $this->assign('vehicle',$vehicle);
        return $this->fetch('Index/index');
    }
//    租赁指南
    public function lease()
    {
        $where_art['type'] = 1;
        $where_art['status'] = array('neq',9);
        $art = Db::name('Art')->where($where_art)->find();
        if($art){
            $art['pic'] = cmf_get_image_url($art['pic']);
            $art['content'] = htmlspecialchars_decode($art['content']);
        }
        $this->assign('art',$art);
        return $this->fetch('Index/leasehold_guide');
    }
//    关于我们
    public function about()
    {
        $where_art['type'] = 2;
        $where_art['status'] = array('neq',9);
        $art = Db::name('Art')->where($where_art)->find();
        if($art){
            $art['pic'] = cmf_get_image_url($art['pic']);
            $art['content'] = htmlspecialchars_decode($art['content']);
        }
        $this->assign('art',$art);
        return $this->fetch('Index/about_us');
    }
}