IndexController.php 3.7 KB
<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: Dean <zxxjjforever@163.com>
// +----------------------------------------------------------------------
namespace api\home\controller;

use cmf\controller\RestBaseController;
/**
 * @title 首页
 */
class IndexController extends RestBaseController
{
    /**
     * @title 首页
     * @description 接口说明
     * @author 开发者
     * @url /api/home/index/index
     * @method GET
     *
     * @param name:language type:string require:0 default: other desc:语言切换(英文传递此字段(en),中文无需传递)
     *
     * @return rotation:轮播图@
     * @rotation id:轮播图id thumbnail:图片路径 link:立即查看链接
     *
     * @return about:关于我们@!
     * @about id:关于我们id thumbnail:图片路径 introduce:简介
     *
     * @return type:我们的产品@
     * @type id:产品id thumbnail:图片路径 name:分类名称 children_name:分类子名称
     *
     * @return advantage:我们的优势@
     * @advantage id:优势id title:标题 introduce:简介
     *
     * @return contact:联系我们@!
     * @contact id:联系我们id address:地址 mobile:电话 phone:手机 wx:微信 email:邮箱
     */
    public function index(){
        $language = $this->request->param('language');
        $arr = [];

        //轮播图
        $res_rotation = CommonController::selectNoPositionData('rotation','id,thumbnail,link');
        $arr['rotation'] = $res_rotation;

        //关于我们
        if(isset($language) && !empty($language)){
            //英文
            $field_about = 'id,thumbnail,introduce_en introduce';
        }else{
            //中文
            $field_about = 'id,thumbnail,introduce';
        }
        $res_about = CommonController::findData('about',['id'=>1],$field_about);
        $arr['about'] = $res_about;

        //我们的产品(系列)
        if(isset($language) && !empty($language)){
            //英文
            $field_type = 'id,pid,thumbnail,name_en name';
            $flag = 'name';
        }else{
            //中文
            $field_type = 'id,pid,thumbnail,name';
            $flag = 'name';
        }
        $res_type = CommonController::getSeriesType($field_type,$flag);
        $arr['type'] = $res_type;

        //我们的优势
        if(isset($language) && !empty($language)){
            //英文
            $field_advantage = 'id,title_en title,introduce_en introduce';
        }else{
            //中文
            $field_advantage = 'id,title,introduce';
        }
        $res_advantage = CommonController::selectLimitData('advantage',$field_advantage,3);
        $arr['advantage'] = $res_advantage;

        //联系我们
        if(isset($language) && !empty($language)){
            //英文
            $field_contact = 'id,address_en address,mobile,phone,wx,email';
        }else{
            //中文
            $field_contact = 'id,address,mobile,phone,wx,email';
        }
        $res_contact = CommonController::findData('contact',['id'=>1],$field_contact);
        $arr['contact'] = $res_contact;

        $this->success('成功',$arr);
    }

    /**
     * @title 七牛云域名
     * @description 接口说明
     * @author 开发者
     * @url /api/home/index/qiNiuDomain
     * @method GET
     *
     * @return domain:七牛云域名
     */
    public function qiNiuDomain(){
        //七牛域名
        $arr['domain'] = CommonController::domain;
        $this->success('成功',$arr);
    }

}