You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.6 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?php
namespace app\integral\controller\api;
class Product extends Base
{
/**
* 获取一级分类
* @date 2022-11-08
*/
public function listCategory()
{
$product_logic = new \app\integral\logic\Product();
$result = $product_logic->listCategory();
return json($result);
}
/**
* 获取商品列表
* @param int $param ['category_id'] 分类ID
* @param string $param ['keyword'] 关键字
* @param int $param ['is_recommend'] 是否推荐 0--不限制 1--已推荐
* @param int $param ['order'] 排序 1--综合排序(发布时间倒序) 2--价格升序 3--价格降序 4--积分升序 5--积分降序 6--销量降序不排序不传该字段默认1排序
* @param int $param ['page'] 第X页
* @date 2022-11-09
*/
public function listProduct()
{
$param = input('post.');
$validate = [
'page' => 'require',
];
$this->validate($param, $validate);
$product_logic = new \app\integral\logic\Product();
$result = $product_logic->listProduct($param['category_id'], $param['keyword'],$param['is_recommend'],$param['order'],$param['page']);
return json($result);
}
/**
* 获取商品详情
* @param int $param ['id'] 产品ID
* @date 2022-11-09
*/
public function getProduct()
{
$param = input('post.');
$product_logic = new \app\integral\logic\Product();
$result = $product_logic->getProduct($param['product_id']);
return json($result);
}
}