Index.php 1.8 KB
<?php

namespace app\api\controller;

use app\common\controller\Api;
use think\Db;

/**
 * 首页接口
 */
class Index extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * @ApiTitle    (首页顶部图片)
     * @ApiSummary  (首页顶部图片)
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/index/index)
     *
     * @ApiReturn({
    "code": 1,
    "msg": "成功",
    "time": "1571492001",
    "data": {
    "id"://ID
    "image"://图片
    }
    })
     */
    public function index()
    {
        $data = Db::name('image')->where('id',1)->field('id,image')->find();
        $this->success('success',$data);
    }

    /**
     * @ApiTitle    (首页轮播图片)
     * @ApiSummary  (首页轮播图片)
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/index/banner)
     *
     * @ApiReturn({
    "code": 1,
    "msg": "成功",
    "time": "1571492001",
    "data": {
    "id"://ID
    "image"://图片
    "url"://链接
    }
    })
     */
    public function banner()
    {
        $data = Db::name('banner')
            ->field('id,image,url')
            ->order('id desc')
            ->limit(5)
            ->select();
        foreach ($data as &$v){

        }
        $this->success('success',$data);
    }

    /**
     * @ApiTitle    (首页平台简介)
     * @ApiSummary  (首页平台简介)
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/index/about)
     *
     * @ApiReturn({
    "code": 1,
    "msg": "成功",
    "time": "1571492001",
    "data": {
    "id"://ID
    "content"://平台简介内容
    }
    })
     */
    public function about()
    {
        $data = Db::name('about')
            ->where('id',1)
            ->field('id,content')
            ->find();
        $this->success('success',$data);
    }
}