diff --git a/application/api/controller/Goods.php b/application/api/controller/Goods.php index c0ed6e1..9df92ac 100755 --- a/application/api/controller/Goods.php +++ b/application/api/controller/Goods.php @@ -56,6 +56,7 @@ class Goods extends Api * @ApiSummary (推荐商品列表) * @ApiMethod (POST) * @ApiRoute (/api/goods/getRecommendGoods) + * @ApiParams (name=limit, type=string, required=false, description="显示条数 默认10条") * @ApiReturn({ "code": 1, "msg": "请求成功", @@ -77,10 +78,12 @@ class Goods extends Api */ public function getRecommendGoods() { + $limit = $this->request->param('limit')?$this->request->param('limit'):10; $where['g.is_recommend'] = 1; - $data = $this->goodsModel->selectData($where, 10,$this->lang); - + $list = $this->goodsModel->selectData($where, $limit,$this->lang); + $data['image'] = cdnurl(config('site.index_recommend_image')); + $data['list'] = $list; $this->success('请求成功', $data); } @@ -90,6 +93,7 @@ class Goods extends Api * @ApiSummary (商品列表) * @ApiMethod (POST) * @ApiRoute (/api/goods/getGoodsList) + * @ApiParams (name=type, type=string, required=false, description="类型:1=普通商品,2=推荐商品 默认全部") * @ApiParams (name=page, type=string, required=false, description="页数") * @ApiReturn({ "code": 1, @@ -118,6 +122,7 @@ class Goods extends Api $limit = Config::get('paginate.index_rows'); $where = []; + $type = $this->request->param('type'); $keyword = $this->request->param('keyword'); if ($keyword){ $where['g.ch_name|g.en_name|g.ch_content|g.en_content'] = ['like','%'.$keyword.'%']; @@ -125,6 +130,11 @@ class Goods extends Api if ($this->userId) $this->keywordLogModel->save(['user_id'=>$this->userId,'content'=>$keyword,'createtime'=>time()]); } + if(!empty($type) && $type == 2){ + $where['g.is_recommend'] = 1; + }elseif(!empty($type) && $type == 1){ + $where['g.is_recommend'] = 2; + } $data = $this->goodsModel->selectPageData($where,$page,$limit,$this->lang); $this->success('请求成功', $data); } diff --git a/application/extra/site.php b/application/extra/site.php index 3441370..2d9ee83 100755 --- a/application/extra/site.php +++ b/application/extra/site.php @@ -50,4 +50,5 @@ return array ( 'en_vip_text' => '<p>会员特权英文</p>', 'en_withdraw_deposit_text' => '<p>会员特权英文</p>', 'en_distribution_text' => '<p>会员特权英文</p>', + 'index_recommend_image' => '/uploads/20200526/a677bd6b92fca41ed1a5be015a14f8a0.png', ); \ No newline at end of file diff --git a/public/api.html b/public/api.html index 27f9f0e..614eba3 100755 --- a/public/api.html +++ b/public/api.html @@ -9418,7 +9418,24 @@ <div class="panel panel-default"> <div class="panel-heading"><strong>参数</strong></div> <div class="panel-body"> - 无 + <table class="table table-hover"> + <thead> + <tr> + <th>名称</th> + <th>类型</th> + <th>必选</th> + <th>描述</th> + </tr> + </thead> + <tbody> + <tr> + <td>limit</td> + <td>string</td> + <td>否</td> + <td>显示条数 默认10条</td> + </tr> + </tbody> + </table> </div> </div> <div class="panel panel-default"> @@ -9436,7 +9453,8 @@ <div class="panel-body"> <form enctype="application/x-www-form-urlencoded" role="form" action="/api/goods/getRecommendGoods" method="POST" name="form21" id="form21"> <div class="form-group"> - 无 + <label class="control-label" for="limit">limit</label> + <input type="string" class="form-control input-sm" id="limit" placeholder="显示条数 默认10条" name="limit"> </div> <div class="form-group"> <button type="submit" class="btn btn-success send" rel="21">提交</button> @@ -9538,6 +9556,12 @@ </thead> <tbody> <tr> + <td>type</td> + <td>string</td> + <td>否</td> + <td>类型:1=普通商品,2=推荐商品 默认全部</td> + </tr> + <tr> <td>page</td> <td>string</td> <td>否</td> @@ -9562,6 +9586,10 @@ <div class="panel-body"> <form enctype="application/x-www-form-urlencoded" role="form" action="/api/goods/getGoodsList" method="POST" name="form22" id="form22"> <div class="form-group"> + <label class="control-label" for="type">type</label> + <input type="string" class="form-control input-sm" id="type" placeholder="类型:1=普通商品,2=推荐商品 默认全部" name="type"> + </div> + <div class="form-group"> <label class="control-label" for="page">page</label> <input type="string" class="form-control input-sm" id="page" placeholder="页数" name="page"> </div> @@ -12827,7 +12855,7 @@ <div class="row mt0 footer"> <div class="col-md-6" align="left"> - Generated on 2020-05-21 17:02:37 </div> + Generated on 2020-05-26 15:11:09 </div> <div class="col-md-6" align="right"> <a href="./" target="_blank">E-MP market</a> </div>