Index.php
3.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
namespace app\api\controller;
use app\common\controller\Api;
use think\Db;
/**
* 分类接口**
*/
class Index extends Api
{
protected $noNeedLogin = [];
protected $noNeedRight = '*';
public function _initialize()
{
parent::_initialize();
}
/**
* @ApiTitle (获取分类列表)
* @ApiSummary (获取分类列表)
* @ApiMethod (GET)
* @ApiRoute (/api/index/getCategoryList)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiReturn ({
"code": 1,
"msg": "成功",
"time": "1553831004",
"data": [
{
"id": 1,
"name": "废纸",//分类名称
"image": "/uploads/20190319/4a4c015ca04593f70a4836da45f2dea4.jpg"
},
{
"id": 2,
"name": "废塑料",
"image": "/uploads/20190319/4d82786ab0f7866110519f221cbf29a6.jpg"
},
]
})
*/
public function getCategoryList(){
if($this->request->isGet()){
$data = Db::table('gc_category')
->where(['status'=>'normal'])
->field('id,name,image')
->order('id desc')
->select();
$this->success('成功', $data);
}else{
$this->error('请求方式错误');
}
}
/**
* @ApiTitle (获取首页banner图)
* @ApiSummary (获取首页banner图)
* @ApiMethod (GET)
* @ApiRoute (/api/index/getBanner)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiReturn ({
"code": 1,
"msg": "成功",
"time": "1553831004",
"data": [
{
"id": 1,
"image": "http://feipin.w.brotop.cn/uploads/20190319/4a4c015ca04593f70a4836da45f2dea4.jpg"//banner图
},
{
"id": 2,
"image": "http://feipin.w.brotop.cn/uploads/20190319/4d82786ab0f7866110519f221cbf29a6.jpg"
},
]
})
*/
public function getBanner(){
if($this->request->isGet()){
$data = Db::table('gc_banner')
->field('id,image')
->order('id desc')
->select();
$this->success('成功', $data);
}else{
$this->error('请求方式错误');
}
}
/**
* @ApiTitle (获取商城banner图)
* @ApiSummary (获取商城banner图)
* @ApiMethod (GET)
* @ApiRoute (/api/index/getGoodsBanner)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiReturn ({
"code": 1,
"msg": "成功",
"time": "1553831004",
"data": [
{
"id": 1,
"image": "http://feipin.w.brotop.cn/uploads/20190319/4a4c015ca04593f70a4836da45f2dea4.jpg"//banner图
},
{
"id": 2,
"image": "http://feipin.w.brotop.cn/uploads/20190319/4d82786ab0f7866110519f221cbf29a6.jpg"
},
]
})
*/
public function getGoodsBanner(){
if($this->request->isGet()){
$data = Db::table('gc_gbanner')
->field('id,image')
->order('id desc')
->select();
$this->success('成功', $data);
}else{
$this->error('请求方式错误');
}
}
}