如下:這是創建的一個類
<?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
}
]
}
差一點就被挫折打敗!!!!!!
加油 ->我是最棒的。麼