Index.php
6.5 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
<?php
namespace app\api\controller;
use app\common\controller\Api;
use think\Db;
/**
* 首页接口
*/
class Index extends Api
{
protected $noNeedLogin = ['index','banner','about','kefu','teacher','teacher_detail','center','zan'];
protected $noNeedRight = ['*'];
/**
* @ApiTitle (首页顶部图片)
* @ApiSummary (首页顶部图片)
* @ApiMethod (POST)
* @ApiRoute (/api/index/index)
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
"id"://ID
"image"://图片
}
})
*/
public function index()
{
$qiniu = get_addon_config('qiniu')['cdnurl'];
$data = Db::name('image')->where('id',1)->field('id,image')->find();
$data['image'] = $qiniu.$data['image'];
$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()
{
$qiniu = get_addon_config('qiniu')['cdnurl'];
$data = Db::name('banner')
->field('id,image,url')
->order('id desc')
->limit(5)
->select();
foreach ($data as &$v){
$v['image'] = $qiniu.$v['image'];
}
$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()
{
$qiniu = get_addon_config('qiniu')['cdnurl'];
$data = Db::name('about')
->where('id',1)
->field('id,image,content')
->find();
$data['image'] = $qiniu.$data['image'];
$this->success('success',$data);
}
/**
* @ApiTitle (联系客服/下载APP)
* @ApiSummary (联系客服/下载APP)
* @ApiMethod (POST)
* @ApiRoute (/api/index/kefu)
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
"id"://ID
"downloadimage"://下载APP图片
"image"://联系客服图片
"work"://工作时长
"phone"://客服电话1
"phone1"://客服电话2
}
})
*/
public function kefu()
{
$qiniu = get_addon_config('qiniu')['cdnurl'];
$data = Db::name('kefu')
->where('id',1)
->field('createtime',true)
->find();
$data['downloadimage'] = $qiniu.$data['downloadimage'];
$data['image'] = $qiniu.$data['image'];
$this->success('success',$data);
}
/**
* @ApiTitle (首页师资力量)
* @ApiSummary (首页师资力量)
* @ApiMethod (POST)
* @ApiRoute (/api/index/teacher)
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
"id"://ID
"name"://名称
"image"://头像
"title"://头衔
"age_num"://从业年限
"order_num"://成单量
"good_num"://好评率
"desc"://擅长领域
"createtime"://创建时间
}
})
*/
public function teacher()
{
$qiniu = get_addon_config('qiniu')['cdnurl'];
$data = Db::name('teacher')
->field('updatetime',true)
->order('createtime desc')
->select();
foreach ($data as &$v){
$v['image'] = $qiniu.$v['image'];
$v['age_num'] = $v['age_num'].'年';
$v['order_num'] = $v['order_num'].'单';
$v['createtime'] = datetime('Y-m-d H:i:s',$v['createtime']);
}
$this->success('success',$data);
}
/**
* @ApiTitle (老师详情)
* @ApiSummary (老师详情)
* @ApiMethod (POST)
* @ApiRoute (/api/index/teacher_detail)
*
* @ApiParams (name="teacher_id", type="int", required=true, description="老师ID")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
"id"://ID
"name"://名称
"image"://头像
"title"://头衔
"age_num"://从业年限
"order_num"://成单量
"good_num"://好评率
"desc"://擅长领域
"createtime"://创建时间
}
})
*/
public function teacher_detail()
{
$qiniu = get_addon_config('qiniu')['cdnurl'];
$teacher_id = $this->request->param('teacher_id');
if(empty($teacher_id)){
$this->error('缺少必要参数');
}
$data = Db::name('teacher')->field('updatetime',true)->where('id',$teacher_id)->find();
$data['age_num'] = $data['age_num'].'年';
$data['order_num'] = $data['order_num'].'单';
$data['image'] = $qiniu.$data['image'];
$data['createtime'] = date('Y-m-d H:i:s',$data['createtime']);
$this->success('success',$data);
}
/**
* @ApiTitle (系统中心)
* @ApiSummary (系统中心)
* @ApiMethod (POST)
* @ApiRoute (/api/index/center)
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
"id"://ID
"name"://名称
"image"://图标
"url"://跳转链接
"createtime"://创建时间
}
})
*/
public function center()
{
$qiniu = get_addon_config('qiniu')['cdnurl'];
$data = Db::name('center')
->field('updatetime',true)
->order('id desc')
->select();
foreach ($data as &$v){
$v['image'] = $qiniu.$v['image'];
$v['createtime'] = date('Y-m-d H:i:s',$v['createtime']);
}
$this->success('success',$data);
}
/**
* @ApiTitle (设置自动暂停)
* @ApiSummary (设置自动暂停)
* @ApiMethod (POST)
* @ApiRoute (/api/index/zan)
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
"id"://ID
"stopnum"://暂停间隔
"switch"://是否开启1开启0关闭
}
})
*/
public function zan()
{
$data = Db::name('set')->where('id',1)->field('stopnum,switch')->find();
$data['stopnum'] = $data['stopnum'] * 60;
$this->success('success',$data);
}
}