<?php
/**
 * Created by PhpStorm.
 * User: 中闽 < 1464674022@qq.com >
 * Date: 2019/12/5
 * Time: 17:44
 */

namespace app\api\controller;


use app\api\controller\base\Base;
use app\common\model\Announcement;
use app\common\model\ConfigOption;

class Index extends Base
{
    public function index()
    {
        $this->json_success('success', ['ip' => $this->request->ip()]);
    }

    //首页接口
    public function site()
    {
        $banners = (new ConfigOption())->where(['pid' => 1, 'status' => ConfigOption::STATUS_OPEN])->order('sort desc')->select();
        $boxs = (new ConfigOption())->where(['pid' => 2, 'status' => ConfigOption::STATUS_OPEN])->order('sort desc')->select();
        $announcements = (new Announcement())->order('id desc')->limit(3)->select();
        return [
            "banners" => $banners,//轮播图
            "boxs" => $boxs,//模块
//            "contact_us" => "",
            "announcements" => $announcements,//公告
        ];
    }
}
