TP5实现轮播图接口及展示信息

如下:这是创建的一个类

<?php

namespace app\index\controller;

use controller\BasicIndex;

use think\Db;

class Photo extends BasicIndex
{
	//轮播
	public function Plantingmap()
    {
 
       $list = Db::name('Adver')
            ->where(array('status' => 1,'type'=>0))->order('id desc')
            ->limit(request()->post('size', 5))
            ->select();
        $json = json_encode($list);
        return $json;
    }

    //广告
    public function Advertisement()
    {
       $re = Db::name('adver')
       			->where('status',1)
       			->paginate(4);
       $json = json_encode($re);
       return $json;
    }
}

接口文档如下所示:

###轮播图####

请求地址:http://www.ysshopcode.hk/index/photo/Plantingmap
请求方式:get
数据格式:json
请求数据:
	img 轮播图
	url 图片链接
	
返回的json格式:
----------json<--------------	
[
  {
    "id": 19,
    "title": "大萨达撒多",
    "img": "http://www.ysshopcode.hk/static/upload/1a0219794a214c3c/2737c816c58382d8.png",
    "url": "http://www.baidu.com",
    "adminid": 10000,
    "addtime": 1566971601,
    "endtime": 0,
    "status": 1,
    "type": 0
  },
  {
    "id": 17,
    "title": "2",
    "img": "http://qtc.com/static/upload/98f08bbb2b610be8/ea76f05bdd80d9df.jpg",
    "url": "http://www.map.com",
    "adminid": 10000,
    "addtime": 1566089502,
    "endtime": 0,
    "status": 1,
    "type": 0
  }
]



###广告####

请求地址:http://www.ysshopcode.hk/index/photo/Advertisement
请求方式:get
数据格式:json
请求数据:
	title 标题
	img 图片
	adminid 发布者
	addtime 创建时间
返回的json格式:
----------json<--------------
{
  "total": 4,
  "per_page": 3,
  "current_page": 1,
  "last_page": 2,
  "data": Array[3][
    {
      "id": 16,
      "title": "1",
      "img": "http://qtc.com/static/upload/331c378683f15819/034c65ec83b282ed.jpg",
      "url": "1",
      "adminid": 10000,
      "addtime": 1566089488,
      "endtime": 0,
      "status": 1,
      "type": 0
    },
    {
      "id": 17,
      "title": "2",
      "img": "http://qtc.com/static/upload/98f08bbb2b610be8/ea76f05bdd80d9df.jpg",
      "url": "2",
      "adminid": 10000,
      "addtime": 1566089502,
      "endtime": 0,
      "status": 1,
      "type": 0
    }
  ]
}

差一点就被挫折打败!!!!!!
加油 ->我是最棒的。么

你可能感兴趣的:(TP5,TP5)