|
@@ -119,7 +119,8 @@ class Goods extends Base
|
|
|
}
|
|
|
$row->coupon = $couponList;
|
|
|
|
|
|
- $row->visible(explode(',', 'id,title,subtitle,category_id,price,marketprice,sales,views,image,content,images,sku_spec,sku,comment,is_collect,guarantee,attributes,favor_rate,coupon'));
|
|
|
+ $row->visible(explode(',', 'id,title,description,category_id,
|
|
|
+ price,sales,views,image,content,images,sku_spec,sku,comment,is_collect,guarantee,attributes,favor_rate,coupon'));
|
|
|
$row = $row->toArray();
|
|
|
$row['content'] = \addons\shop\library\Service::formatTplToUniapp($row['content']);
|
|
|
$this->success('获取成功', $row);
|
|
@@ -131,6 +132,12 @@ class Goods extends Base
|
|
|
$param = $this->request->param();
|
|
|
$pageNum = (int)$this->request->param('pageNum', 10);
|
|
|
$orderby = $this->request->param('orderby', 'weigh');
|
|
|
+ // 使用验证器 验证 orderby weigh:权重;sales:销量;price:价格;views:浏览数;comments:评论数
|
|
|
+ $validate = new \addons\shop\validate\Goods();
|
|
|
+ $validate->scene('lists')->check($param);
|
|
|
+ if ($validate->getError()) {
|
|
|
+ $this->error($validate->getError());
|
|
|
+ }
|
|
|
$orderway = $this->request->param('orderway', 'desc');
|
|
|
|
|
|
$list = GoodsModel::where(function ($query) use ($param) {
|