Brand.php
6.9 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
<?php
namespace app\api\controller;
use app\common\controller\Api;
use think\Validate;
/**
* 品牌接口
*/
class Brand extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
protected $uid = '';
public function _initialize()
{
parent::_initialize();
$this->uid = $this->auth->getUserId();
}
/**
* @ApiTitle (品牌分类)
* @ApiSummary (品牌分类)
* @ApiMethod (GET)
* @ApiRoute (/api/brand/brandType)
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1574939519",
"data": {
"data": [
{
"id": 1,//品牌分类id
"image": "http://jinglong.springchunjia.cn/uploads/20191127/d36d8475bc3bdb999dff26d019c608ed.png",//图片路径
"name": "HEDRMAR1",//品牌名称
"address": "葡萄牙1"//品牌产地
},
{
"id": 2,
"image": "http://jinglong.springchunjia.cn/uploads/20191127/c53f07984e6d64d00e9bf1c9fb6ebf72.png",
"name": "HEDRMAR2",
"address": "葡萄牙2"
}
],
"images": [//右侧轮播图
{
"id": 5,
"image": "/uploads/20191127/d36d8475bc3bdb999dff26d019c608ed.png",//图片
"url": "/pages/index/brandDetail/brandDetail?id=1"//路径
},
{
"id": 4,
"image": "/uploads/20191207/7a9772ee5e3947c8ad0e8bff2069e1ac.jpg",
"url": ""
},
]
}
})
*/
public function brandType(){
if($this->request->isGet()){
$arr = [];
$res = Common::selectSoftData('btype','id,image,name,address');
foreach ($res as &$value){
$value['image'] = $this->auth->absolutionUrlOne($value['image']);
}
$arr['data'] = $res;
//品牌专区轮播图
$res1 = Common::selectData('btbanner','id,image,url');
foreach ($res1 as &$value1){
$value1['image'] = $this->auth->absolutionUrlOne($value1['image']);
}
$arr['images'] = $res1;
$this->success('成功',$arr);
}else{
$this->error('请求方式错误');
}
}
/**
* @ApiTitle (品牌详情)
* @ApiSummary (品牌详情)
* @ApiMethod (GET)
* @ApiRoute (/api/brand/brandDetail)
*
* @ApiParams (name="b_id", type="inter", required=true, description="品牌分类id")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1575007401",
"data": {
"id": 1,//品牌id
"image": "http://jinglong.springchunjia.cn/uploads/20191127/d36d8475bc3bdb999dff26d019c608ed.png",//品牌图片路径
"name": "HEDRMAR1",//品牌名称
"address": "葡萄牙1",//品牌所属地
"introduce": "超百年历史的葡萄牙餐具",//品牌简介
"brand_explain": "",//品牌详情(富文本)
"tag": [//品牌标签
"日式简约",
"隐秘乡奢",
"家庭情侣"
],
"file": "http://jinglong.springchunjia.cn/uploads/20191127/05d216e117e11bd3de352c155b42eaaa.mp4",//视频路径
"image_long": "http://jinglong.springchunjia.cn/uploads/20191127/bf35ec1b42a6d1c95355ce22fa633a43.jpg"//长图路径
}
})
*/
public function brandDetail(){
if($this->request->isGet()){
$b_id = $this->request->get('b_id');
$rule = config('verify.brand_detail');
$validate = new Validate($rule['rule'],$rule['msg']);
if (!$validate->check(['b_id'=>$b_id])) {
$this->error($validate->getError());
}
$res = Common::findSoftWhereData('btype',['id'=>$b_id],'createtime,updatetime,deletetime',true);
if($res){
$res['image'] = $this->auth->absolutionUrlOne($res['image']);
$res['file'] = $this->auth->absolutionUrlOne($res['file']);
$res['image_long'] = $this->auth->absolutionUrlOne($res['image_long']);
$res['tag'] = explode('|',$res['tag']);
}
$this->success('成功',$res);
}else{
$this->error('请求方式错误');
}
}
/**
* @ApiTitle (品牌商品列表)
* @ApiSummary (品牌商品列表)
* @ApiMethod (GET)
* @ApiRoute (/api/brand/brandGoodsList)
*
* @ApiParams (name="b_id", type="inter", required=true, description="品牌id")
* @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 brandGoodsList(){
if($this->request->isGet()){
$b_id = $this->request->get('b_id');
$page = $this->request->get('page');
$rule = config('verify.brand_goods');
$validate = new Validate($rule['rule'],$rule['msg']);
if (!$validate->check(['b_id'=>$b_id,'page'=>$page])) {
$this->error($validate->getError());
}
$where = ['type'=>1,'t_id'=>$b_id];
$arr = Common::goodsList($where,$page,$this->uid);
$this->success('成功',$arr);
}else{
$this->error('请求方式错误');
}
}
}