Index.php
12.0 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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
<?php
namespace app\api\controller;
use app\common\controller\Api;
use think\Validate;
/**
* 首页接口
*/
class Index extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
protected $uid = '';
protected $flag = '';
public function _initialize()
{
parent::_initialize();
$this->uid = $this->auth->getUserId();
$this->flag = config('verify.flag');
}
/**
* @ApiTitle (首页)
* @ApiSummary (首页)
* @ApiMethod (GET)
* @ApiRoute (/api/index/index)
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1574935164",
"data": {
"res_banner": [//轮播图
{
"id": 1,//轮播图id
"image": ""//图片路径
"url": ""//跳转链接
},
{
"id": 2,
"image": "http://jinglong.springchunjia.cn/uploads/20191127/79e122b17786dbf0365a1018e27872d7.png"
},
],
"res_advert": {//活动广告位(没有则不显示)
"id": 1,//id
"image": "http://jinglong.springchunjia.cn/uploads/20191127/febfea9a34c918cb2f100f669ede2547.png"//图片路径
"url": ""//跳转链接
},
"res_design": [//设计师作品
{
"id": 7,//商品id
"name": "MONENT 动感系列",//商品名称
"introduce": "轻波款,为客厅缀上霞光淡雾",//商品简介
"sale_price": 2299,//商品价格
"image": "http://jinglong.springchunjia.cn/uploads/20191127/05d216e117e11bd3de352c155b42eaaa.mp4?vframe/jpg/offset/2"//图片路径
},
{
"id": 1,
"name": "MONENT 动感系列",
"introduce": "轻波款,为客厅缀上霞光淡雾",
"sale_price": 2599,
"image": "http://jinglong.springchunjia.cn/uploads/20191127/05d216e117e11bd3de352c155b42eaaa.mp4?vframe/jpg/offset/2"
},
],
"res_u_list": [//用户晒单
{
"id": 2,//晒单id
"images": [//图片路径(取第一个即可)
"http://jinglong.springchunjia.cn/uploads/20191127/febfea9a34c918cb2f100f669ede2547.png",
"http://jinglong.springchunjia.cn/uploads/20191127/042a3256122af7b10e26efb5e7649904.png"
],
"title": "超越百年历史的葡萄牙餐具",//晒单标题
"nickname": "桃花岛岛主",//用户昵称
"address": "上海"//用户归属地
}
],
"res_b_type": [//大牌专区
{
"id": 1,//品牌id
"image": "http://jinglong.springchunjia.cn/uploads/20191127/d36d8475bc3bdb999dff26d019c608ed.png",//图片路径
"name": "HEDRMAR1",//品牌名称
"address": "葡萄牙1",//品牌归属地
"introduce": "超百年历史的葡萄牙餐具"//品牌简介
},
{
"id": 2,
"image": "http://jinglong.springchunjia.cn/uploads/20191127/c53f07984e6d64d00e9bf1c9fb6ebf72.png",
"name": "HEDRMAR2",
"address": "葡萄牙2",
"introduce": "超百年历史的葡萄牙餐具"
},
]
}
})
*/
public function index(){
if($this->request->isGet()){
$arr = [];
//轮播图
$res_banner = Common::selectWhereData('banner',['status'=>'normal'],'id,image,url');
foreach ($res_banner as &$b_value){
$b_value['image'] = $this->auth->absolutionUrlOne($b_value['image']);
}
$arr['res_banner'] = $res_banner;
//首页广告位
$res_advert = Common::findWhereData('advert',['type'=>0,'status'=>'normal'],'id,image,url');
if($res_advert){
$res_advert['image'] = $this->auth->absolutionUrlOne($res_advert['image']);
}
$arr['res_advert'] = $res_advert;
//设计师作品
$res_design = Common::selectSoftWhereLimitData('goods',['is_design'=>$this->flag[1]],'id,name,introduce,sale_price1 sale_price,file,image','sort desc');
foreach ($res_design as &$d_value){
//获取视频帧
$d_value['image'] = [$this->auth->absolutionUrlOne($d_value['image'])];
$sale_price = Common::salePrice($d_value['sale_price']);
if($sale_price){
$d_value['sale_price'] = $sale_price[0];
}else{
$d_value['sale_price'] = '';
}
unset($d_value['file']);
}
$arr['res_design'] = $res_design;
//用户晒单
$res_u_list = Common::selectSoftWhereLimitData('ulist',['status'=>'normal'],'id,images,title,nickname,address','id desc');
foreach ($res_u_list as &$u_value){
$u_value['images'] = $this->auth->absolutionUrl($u_value['images']);
}
$arr['res_u_list'] = $res_u_list;
//大牌专区
$brand_limit = config('verify.brand_limit');
$res_b_type = Common::selectSoftLimitData('btype','id,image,name,address,introduce',$brand_limit);
foreach ($res_b_type as &$t_value){
$t_value['image'] = $this->auth->absolutionUrlOne($t_value['image']);
}
$arr['res_b_type'] = $res_b_type;
$this->success('成功',$arr);
}else{
$this->error('请求方式错误');
}
}
/**
* @ApiTitle (弹窗广告位)
* @ApiSummary (弹窗广告位)
* @ApiMethod (GET)
* @ApiRoute (/api/index/popupAdvert)
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1574989615",
"data": {//没有则不显示
"id": 2,//弹窗广告位id
"image": "http://jinglong.springchunjia.cn/uploads/20191127/0b20812d4f80307dd1025db71d690395.png"//图片路径
"url": ""//跳转链接
}
})
*/
public function popupAdvert(){
if($this->request->isGet()){
$res = Common::findWhereData('advert',['type'=>1,'status'=>'normal'],'id,image,url');
if($res){
$res['image'] = $this->auth->absolutionUrlOne($res['image']);
}
$this->success('成功',$res);
}else{
$this->error('请求方式错误');
}
}
/**
* @ApiTitle (推荐商品列表)
* @ApiSummary (推荐商品列表)
* @ApiMethod (GET)
* @ApiRoute (/api/index/recommendGoodsList)
*
* @ApiParams (name="page", type="inter", required=true, description="分页页码")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1574941706",
"data": {
"data": [
{
"id": 7,//商品id
"image": "http://jinglong.springchunjia.cn/uploads/20191128/8a677f5a0418059bf1b974c50026af13.png",//图片路径
"name": "MONENT 动感系列",//商品名称(含有标记红色标签)
"tag": [//商品标签
"日式简约",
"隐秘乡奢",
"家庭情侣"
],
"style": [//商品规格
"主餐匙,茶匙各1件",
"古堡灰"
],
"sale_price": 2299//销售价格
"expense_price": //运费(0:显示包运费标签)
"is_new_tag": 0//新人价格标签(0:不显示,1:显示)
},
{
"id": 4,
"image": "http://jinglong.springchunjia.cn/uploads/20191128/93971e55b83d1a09c1831f8197514305.png",
"name": "MONENT 动感系列",
"tag": [
"AB级",
"ABX级",
"ABN级"
],
"sale_price": 2599
},
],
"total_page": 1
}
})
*/
public function recommendGoodsList(){
if($this->request->isGet()){
$page = $this->request->get('page');
$rule = config('verify.page');
$validate = new Validate($rule['rule'],$rule['msg']);
if (!$validate->check(['page'=>$page])) {
$this->error($validate->getError());
}
$where = ['is_recommend'=>$this->flag[1]];
$arr = Common::goodsList($where,$page,$this->uid);
$this->success('成功',$arr);
}else{
$this->error('请求方式错误');
}
}
/**
* @ApiTitle (晒单详情)
* @ApiSummary (晒单详情)
* @ApiMethod (GET)
* @ApiRoute (/api/index/uListDetail)
*
* @ApiParams (name="u_list_id", type="inter", required=true, description="晒单id")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1575010422",
"data": {
"id": 2,//晒单id
"g_id": 6,//商品id
"images": [//图片路径
"http://jinglong.springchunjia.cn/uploads/20191127/febfea9a34c918cb2f100f669ede2547.png",
"http://jinglong.springchunjia.cn/uploads/20191127/042a3256122af7b10e26efb5e7649904.png"
],
"files": [//视频路径
"http://feifangu.qiniu.brotop.cn/uploads/20191217/05d216e117e11bd3de352c155b42eaaa.mp4",
"http://feifangu.qiniu.brotop.cn/uploads/20191217/05d216e117e11bd3de352c155b42eaaa.mp4"
],
"title": "超越百年历史的葡萄牙餐具",//晒单标题
"nickname": "桃花岛岛主",//用户昵称
"address": "上海"//用户归属地
"image": "http://jinglong.springchunjia.cn/uploads/20191128/0869f5de4808a04e7a3bceccff0c1132.png",//头像路径
"detail": ,//详情(富文本)
"goods": {//商品
"image": "http://jinglong.springchunjia.cn/uploads/20191128/8a677f5a0418059bf1b974c50026af13.png",//图片
"name": "MONENT 动感系列",//商品名称
"introduce": "轻波款,为客厅缀上霞光淡雾"//商品简介
}
}
})
*/
public function uListDetail(){
if($this->request->isGet()){
$u_list_id = $this->request->get('u_list_id');
$rule = config('verify.u_list_detail');
$validate = new Validate($rule['rule'],$rule['msg']);
if (!$validate->check(['u_list_id'=>$u_list_id])) {
$this->error($validate->getError());
}
$res = Common::findSoftWhereData('ulist',['id'=>$u_list_id],'createtime,updatetime,deletetime',true);
if($res){
$res['image'] = $this->auth->absolutionUrlOne($res['image']);
$res['images'] = $this->auth->absolutionUrl($res['images']);
if(!empty($res['files'])){
$res['files'] = $this->auth->absolutionUrl($res['files']);
}else{
$res['files'] = [];
}
$res_goods = Common::findSoftWhereData('goods',['id'=>$res['g_id']],'image,name,introduce');
$res['goods'] = '';
if($res_goods){
$res_goods['image'] = $this->auth->absolutionUrlOne($res_goods['image']);
$res['goods'] = $res_goods;
}
}
$this->success('成功',$res);
}else{
$this->error('请求方式错误');
}
}
}