|
@@ -47,18 +47,15 @@ class Product extends Api{
|
|
|
// 接收参数
|
|
|
$name = request('name','');
|
|
|
$limit = request('limit',10);
|
|
|
+ $typeId = request('type_id',0);
|
|
|
// 显示
|
|
|
$map = [['status','=','0'],['stock','>',0]];
|
|
|
// 分类ID
|
|
|
if( $name ) $map[] = ['name','like','%'.$name.'%'];
|
|
|
- // 是否有城市
|
|
|
- $wherIn = empty($custom['city_id']) ? [1] : [1,$custom['city_id']];
|
|
|
+ if( $typeId ) $map[] = ['type_id','=',$typeId];
|
|
|
// 获取分页信息
|
|
|
$Paginator = $Model->query()
|
|
|
- ->join('product_city','product_city.product_id','=','product.id')
|
|
|
->where($map)
|
|
|
- ->whereIn('product_city.city_id',$wherIn)
|
|
|
- ->groupBy('product_id')
|
|
|
->orderBy('product.sort')
|
|
|
->orderBy('product.id')
|
|
|
->paginate($limit,['product.id','product.sort','product.name','product.thumb','product.spec','product.price','product.market_price','product.stock']);
|
|
@@ -373,6 +370,8 @@ class Product extends Api{
|
|
|
$uid = $this->checkLogin();
|
|
|
// 获取产品类型
|
|
|
$list = $ProductType->getList();
|
|
|
+ // 转数组
|
|
|
+ $list = array_values($list);
|
|
|
// 返回结果
|
|
|
return json_send(['code'=>'success','msg'=>'获取成功','data'=>$list]);
|
|
|
}
|