商品列表

接口描述
  • 商品列表
请求URL
  • /api/goods
请求方式
  • GET
query 参数
参数名 必选 类型 说明
page int 分页
title string 商品名模糊搜索
category_id int 分类搜索
sales int 销量排序,值为1, 倒序
recommend int 推荐, 值为1,获取推荐商品
price int 价格排序,值为1, 倒序
comments_count int 评论数排序,值为1, 倒序

sales recommend price comments_count 这四个排序字段,每次只传一个, 值为1。也可以四个参数都传,但是只能有一个值为1, 其他的为0。如果有多个参数的值为1, 结果可能不会达到预期。

返回参数

goods 分页相关数据

参数名 必含 类型 说明
current_page int 当前页
from int 起始量
to int 结束量
first_page_url string 第一页url
next_page_url string 下一页url
prev_page_url string 上一页url
path string 资源路径
per_page int 每页数量
data array 商品数据见下表

goods 商品详情

参数名 必含 类型 说明
id string 自增长主键ID
category_id string 分类
title string 标题
price string 价格
sales string 销量
cover string 封面图
cover_url string 封面图url
updated_at timestamp 修改时间
comments_count int 评论数量
collects_count int 收藏人数

categories 分类数据

参数名 必含 类型 说明
id int 自增长主键ID
pid int 父级id
name string 标题
level int 层级
status int 是否启用 0不启用 1启用
children array 子级

子级字段与父级字段一样, 分类最多只有3层

recommend_goods 推荐商品-PC适用

参数名 必含 类型 说明
id int 自增长主键ID
title string 标题
price int 价格
cover string 封面图
cover_url string 封面图url
collects_count int 收藏人数
comments_count int 评论人数
返回示例
  • 状态码 200 请求成功
{
    "goods": {
        "current_page": 1,
        "data": [
            {
                "id": 236,
                "title": "Qui est assumenda.",
                "price": 954,
                "cover": "http://placeimg.com/640/480/any",
                "category_id": 63,
                "sales": 0,
                "updated_at": "2021-09-17T01:49:18.000000Z",
                "comments_count": 2,
                "cover_url": "http://placeimg.com/640/480/any"
            },
            {
                "id": 235,
                "title": "Cum dignissimos aut.",
                "price": 92,
                "cover": "http://placeimg.com/640/480/any",
                "category_id": 70,
                "sales": 0,
                "updated_at": "2021-09-17T01:49:18.000000Z",
                "comments_count": 1,
                "cover_url": "http://placeimg.com/640/480/any"
            },
            {
                "id": 253,
                "title": "Ut omnis et.",
                "price": 884,
                "cover": "http://placeimg.com/640/480/any",
                "category_id": 63,
                "sales": 0,
                "updated_at": "2021-09-17T01:49:18.000000Z",
                "comments_count": 0,
                "cover_url": "http://placeimg.com/640/480/any"
            },
            {
                "id": 300,
                "title": "Magnam repellat.",
                "price": 992,
                "cover": "http://placeimg.com/640/480/any",
                "category_id": 64,
                "sales": 0,
                "updated_at": "2021-09-17T01:49:18.000000Z",
                "comments_count": 0,
                "cover_url": "http://placeimg.com/640/480/any"
            },
            {
                "id": 257,
                "title": "Ipsa soluta sint.",
                "price": 965,
                "cover": "http://placeimg.com/640/480/any",
                "category_id": 73,
                "sales": 0,
                "updated_at": "2021-09-17T01:49:18.000000Z",
                "comments_count": 0,
                "cover_url": "http://placeimg.com/640/480/any"
            },
            {
                "id": 272,
                "title": "Porro quia aut.",
                "price": 155,
                "cover": "http://placeimg.com/640/480/any",
                "category_id": 70,
                "sales": 0,
                "updated_at": "2021-09-17T01:49:18.000000Z",
                "comments_count": 0,
                "cover_url": "http://placeimg.com/640/480/any"
            },
            {
                "id": 285,
                "title": "Ut id et error.",
                "price": 811,
                "cover": "http://placeimg.com/640/480/any",
                "category_id": 70,
                "sales": 0,
                "updated_at": "2021-09-17T01:49:18.000000Z",
                "comments_count": 0,
                "cover_url": "http://placeimg.com/640/480/any"
            },
            {
                "id": 264,
                "title": "Sed officia.",
                "price": 470,
                "cover": "http://placeimg.com/640/480/any",
                "category_id": 70,
                "sales": 0,
                "updated_at": "2021-09-17T01:49:18.000000Z",
                "comments_count": 0,
                "cover_url": "http://placeimg.com/640/480/any"
            },
            {
                "id": 273,
                "title": "Et omnis quos et.",
                "price": 277,
                "cover": "http://placeimg.com/640/480/any",
                "category_id": 66,
                "sales": 0,
                "updated_at": "2021-09-17T01:49:18.000000Z",
                "comments_count": 0,
                "cover_url": "http://placeimg.com/640/480/any"
            },
            {
                "id": 286,
                "title": "Qui nam quos error.",
                "price": 62,
                "cover": "http://placeimg.com/640/480/any",
                "category_id": 63,
                "sales": 0,
                "updated_at": "2021-09-17T01:49:18.000000Z",
                "comments_count": 0,
                "cover_url": "http://placeimg.com/640/480/any"
            },
            {
                "id": 237,
                "title": "Placeat perferendis.",
                "price": 170,
                "cover": "http://placeimg.com/640/480/any",
                "category_id": 64,
                "sales": 0,
                "updated_at": "2021-09-17T01:49:18.000000Z",
                "comments_count": 0,
                "cover_url": "http://placeimg.com/640/480/any"
            },
            {
                "id": 265,
                "title": "Occaecati error.",
                "price": 47,
                "cover": "http://placeimg.com/640/480/any",
                "category_id": 64,
                "sales": 0,
                "updated_at": "2021-09-17T01:49:18.000000Z",
                "comments_count": 0,
                "cover_url": "http://placeimg.com/640/480/any"
            },
            {
                "id": 276,
                "title": "Similique aut quod.",
                "price": 726,
                "cover": "http://placeimg.com/640/480/any",
                "category_id": 70,
                "sales": 0,
                "updated_at": "2021-09-17T01:49:18.000000Z",
                "comments_count": 0,
                "cover_url": "http://placeimg.com/640/480/any"
            },
            {
                "id": 287,
                "title": "Eius assumenda sint.",
                "price": 963,
                "cover": "http://placeimg.com/640/480/any",
                "category_id": 67,
                "sales": 0,
                "updated_at": "2021-09-17T01:49:18.000000Z",
                "comments_count": 0,
                "cover_url": "http://placeimg.com/640/480/any"
            },
            {
                "id": 240,
                "title": "Possimus et nihil.",
                "price": 259,
                "cover": "http://placeimg.com/640/480/any",
                "category_id": 64,
                "sales": 0,
                "updated_at": "2021-09-17T01:49:18.000000Z",
                "comments_count": 0,
                "cover_url": "http://placeimg.com/640/480/any"
            },
            {
                "id": 267,
                "title": "Magnam magnam sint.",
                "price": 333,
                "cover": "http://placeimg.com/640/480/any",
                "category_id": 66,
                "sales": 0,
                "updated_at": "2021-09-17T01:49:18.000000Z",
                "comments_count": 0,
                "cover_url": "http://placeimg.com/640/480/any"
            },
            {
                "id": 277,
                "title": "Accusantium sit.",
                "price": 45,
                "cover": "http://placeimg.com/640/480/any",
                "category_id": 70,
                "sales": 0,
                "updated_at": "2021-09-17T01:49:18.000000Z",
                "comments_count": 0,
                "cover_url": "http://placeimg.com/640/480/any"
            },
            {
                "id": 289,
                "title": "Animi enim in eum.",
                "price": 149,
                "cover": "http://placeimg.com/640/480/any",
                "category_id": 74,
                "sales": 0,
                "updated_at": "2021-09-17T01:49:18.000000Z",
                "comments_count": 0,
                "cover_url": "http://placeimg.com/640/480/any"
            },
            {
                "id": 241,
                "title": "Iure qui maiores.",
                "price": 896,
                "cover": "http://placeimg.com/640/480/any",
                "category_id": 70,
                "sales": 0,
                "updated_at": "2021-09-17T01:49:18.000000Z",
                "comments_count": 0,
                "cover_url": "http://placeimg.com/640/480/any"
            },
            {
                "id": 268,
                "title": "Aspernatur sapiente.",
                "price": 883,
                "cover": "http://placeimg.com/640/480/any",
                "category_id": 73,
                "sales": 0,
                "updated_at": "2021-09-17T01:49:18.000000Z",
                "comments_count": 0,
                "cover_url": "http://placeimg.com/640/480/any"
            }
        ],
        "first_page_url": "http://api.test/api/goods?comments_count=1&page=1",
        "from": 1,
        "next_page_url": "http://api.test/api/goods?comments_count=1&page=2",
        "path": "http://api.test/api/goods",
        "per_page": 20,
        "prev_page_url": null,
        "to": 20
    },
    "recommend_goods": [
        {
            "id": 87,
            "title": "Qui quia qui.",
            "price": 994,
            "cover": "http://placeimg.com/640/480/any",
            "comments_count": 0,
            "cover_url": "http://placeimg.com/640/480/any"
        },
        {
            "id": 84,
            "title": "Impedit libero.",
            "price": 35,
            "cover": "http://placeimg.com/640/480/any",
            "comments_count": 0,
            "cover_url": "http://placeimg.com/640/480/any"
        },
        {
            "id": 59,
            "title": "Est aut.",
            "price": 599,
            "cover": "http://placeimg.com/640/480/any",
            "comments_count": 0,
            "cover_url": "http://placeimg.com/640/480/any"
        },
        {
            "id": 101,
            "title": "Blanditiis qui.",
            "price": 511,
            "cover": "http://placeimg.com/640/480/any",
            "comments_count": 0,
            "cover_url": "http://placeimg.com/640/480/any"
        },
        {
            "id": 161,
            "title": "Aut maiores illum.",
            "price": 109,
            "cover": "http://placeimg.com/640/480/any",
            "comments_count": 0,
            "cover_url": "http://placeimg.com/640/480/any"
        },
        {
            "id": 112,
            "title": "Sunt et unde eius.",
            "price": 446,
            "cover": "http://placeimg.com/640/480/any",
            "comments_count": 0,
            "cover_url": "http://placeimg.com/640/480/any"
        },
        {
            "id": 104,
            "title": "Laborum numquam.",
            "price": 157,
            "cover": "http://placeimg.com/640/480/any",
            "comments_count": 0,
            "cover_url": "http://placeimg.com/640/480/any"
        },
        {
            "id": 92,
            "title": "Esse tempora et.",
            "price": 40,
            "cover": "http://placeimg.com/640/480/any",
            "comments_count": 0,
            "cover_url": "http://placeimg.com/640/480/any"
        },
        {
            "id": 89,
            "title": "Odit voluptatibus.",
            "price": 412,
            "cover": "http://placeimg.com/640/480/any",
            "comments_count": 0,
            "cover_url": "http://placeimg.com/640/480/any"
        },
        {
            "id": 291,
            "title": "Reiciendis et.",
            "price": 79,
            "cover": "http://placeimg.com/640/480/any",
            "comments_count": 0,
            "cover_url": "http://placeimg.com/640/480/any"
        }
    ],
    "categories": [
        {
            "id": 61,
            "pid": 0,
            "name": "电子数码",
            "level": 1,
            "status": 1,
            "children": [
                {
                    "id": 62,
                    "pid": 61,
                    "name": "手机",
                    "level": 2,
                    "status": 1,
                    "children": [
                        {
                            "id": 63,
                            "pid": 62,
                            "name": "华为",
                            "level": 3,
                            "status": 1
                        },
                        {
                            "id": 64,
                            "pid": 62,
                            "name": "小米",
                            "level": 3,
                            "status": 1
                        }
                    ]
                },
                {
                    "id": 65,
                    "pid": 61,
                    "name": "电脑",
                    "level": 2,
                    "status": 1,
                    "children": [
                        {
                            "id": 66,
                            "pid": 65,
                            "name": "联想",
                            "level": 3,
                            "status": 1
                        },
                        {
                            "id": 67,
                            "pid": 65,
                            "name": "戴尔",
                            "level": 3,
                            "status": 1
                        }
                    ]
                }
            ]
        },
        {
            "id": 68,
            "pid": 0,
            "name": "服装衣帽",
            "level": 1,
            "status": 1,
            "children": [
                {
                    "id": 69,
                    "pid": 68,
                    "name": "男装",
                    "level": 2,
                    "status": 1,
                    "children": [
                        {
                            "id": 70,
                            "pid": 69,
                            "name": "海澜之家",
                            "level": 3,
                            "status": 1
                        },
                        {
                            "id": 71,
                            "pid": 69,
                            "name": "Nike",
                            "level": 3,
                            "status": 1
                        }
                    ]
                },
                {
                    "id": 72,
                    "pid": 68,
                    "name": "女装",
                    "level": 2,
                    "status": 1,
                    "children": [
                        {
                            "id": 73,
                            "pid": 72,
                            "name": "欧时力",
                            "level": 3,
                            "status": 1
                        },
                        {
                            "id": 74,
                            "pid": 72,
                            "name": "Only",
                            "level": 3,
                            "status": 1
                        }
                    ]
                }
            ]
        }
    ]
}