1. Ego商城小程序接口文档
2024年10月28日大约 6 分钟
1. Ego商城小程序接口文档
1. 用户模块
1. 获取token
请求路径
- /api/v1/token/user
请求头
- Content-Type application/json
请求方法
- post
请求参数
格式:json
参数
- code: 小程序返回code
举例
{"code":"0d1w0d0w3gqAm335y11w3Fer6G0w0d0l"}
响应数据
{ "token": "1c0556cc3381a038bb3f7cc22e08b460" }
2. 校验token
请求路径
- /api/v1/token/verify
请求方法
- post
请求参数
格式:json
参数
- token: 后端返回的token
举例
{ "token":"1c0556cc3381a038bb3f7cc22e08b460" }
响应数据
{ "isValid": true }
3. 获取用户地址信息
请求路径
- /api/v1/address
请求头
- Content-Type application/json
- token 用户token
请求方法
- get
请求参数
- none
响应数据
{ "name": "张三", "mobile": "020-81167888", "province": "广东省", "city": "广州市", "country": "海珠区", "detail": "新港中路397号", "update_time": "1970-01-01 08:00:00" }
2. 首页模块
1. 获取轮播图
请求路径:
- /api/v1/banner/
- bannerId: 路径参数 eg: 1
- /api/v1/banner/
请求方法
- get
请求参数
- none
响应数据
{ "id": 1, "name": "首页置顶", "description": "首页轮播图", "update_time": "1970-01-01 08:00:00", "items": [ { "key_word": "6", "type": 1, "update_time": "1970-01-01 08:00:00", "img": { "url": "http://e.cn:10010/images/banner-4a.png", "update_time": "1970-01-01 08:00:00" } }, { "key_word": "25", "type": 1, "update_time": "1970-01-01 08:00:00", "img": { "url": "http://e.cn:10010/images/banner-2a.png", "update_time": "1970-01-01 08:00:00" } }, { "key_word": "11", "type": 1, "update_time": "1970-01-01 08:00:00", "img": { "url": "http://e.cn:10010/images/banner-3a.png", "update_time": "1970-01-01 08:00:00" } }, { "key_word": "21", "type": 1, "update_time": "1970-01-01 08:00:00", "img": { "url": "http://e.cn:10010/images/banner-5a.png", "update_time": "1970-01-01 08:00:00" } }, { "key_word": "10", "type": 1, "update_time": "1970-01-01 08:00:00", "img": { "url": "http://e.cn:10010/images/banner-1a.png", "update_time": "1970-01-01 08:00:00" } } ] }
2. 获取专栏栏位
请求路径
- /api/v1/theme?ids=
- ids: 路径参数; eg: 1,2,3
- /api/v1/theme?ids=
请求方法
- get
请求参数
- none
响应数据
[ { "id": 1, "name": "专题栏位一", "description": "美味水果世界", "update_time": "1970-01-01 08:00:00", "topic_img": { "url": "http://e.cn:10010/images/1@theme.png", "update_time": "1970-01-01 08:00:00" }, "head_img": { "url": "http://e.cn:10010/images/1@theme-head.png", "update_time": "1970-01-01 08:00:00" } }, { "id": 2, "name": "专题栏位二", "description": "新品推荐", "update_time": "1970-01-01 08:00:00", "topic_img": { "url": "http://e.cn:10010/images/2@theme.png", "update_time": "1970-01-01 08:00:00" }, "head_img": { "url": "http://e.cn:10010/images/2@theme-head.png", "update_time": "1970-01-01 08:00:00" } }, { "id": 3, "name": "专题栏位三", "description": "做个干物女", "update_time": "1970-01-01 08:00:00", "topic_img": { "url": "http://e.cn:10010/images/3@theme.png", "update_time": "1970-01-01 08:00:00" }, "head_img": { "url": "http://e.cn:10010/images/3@theme.png", "update_time": "1970-01-01 08:00:00" } } ]
3. 获取最近新品
请求路径
- /api/v1/product/recent
请求方法
- get
请求参数
- none
响应数据
[ { "id": 1, "name": "芹菜 半斤", "price": "0.01", "stock": 10, "main_img_url": "http://e.cn:10010/images/product-vg@1.png", "img_id": 13 }, { "id": 2, "name": "梨花带雨 3个", "price": "0.01", "stock": 984, "main_img_url": "http://e.cn:10010/images/product-dryfruit@1.png", "img_id": 10 }, { "id": 3, "name": "素米 327克", "price": "0.01", "stock": 996, "main_img_url": "http://e.cn:10010/images/product-rice@1.png", "img_id": 31 }, { "id": 4, "name": "红袖枸杞 6克*3袋", "price": "0.01", "stock": 998, "main_img_url": "http://e.cn:10010/images/product-tea@1.png", "img_id": 32 }, { "id": 5, "name": "春生龙眼 500克", "price": "0.01", "stock": 995, "main_img_url": "http://e.cn:10010/images/product-dryfruit@2.png", "img_id": 33 }, { "id": 6, "name": "小红的猪耳朵 120克", "price": "0.01", "stock": 997, "main_img_url": "http://e.cn:10010/images/product-cake@2.png", "img_id": 53 }, { "id": 7, "name": "泥蒿 半斤", "price": "0.01", "stock": 998, "main_img_url": "http://e.cn:10010/images/product-vg@2.png", "img_id": 68 }, { "id": 8, "name": "夏日芒果 3个", "price": "0.01", "stock": 995, "main_img_url": "http://e.cn:10010/images/product-dryfruit@3.png", "img_id": 36 }, { "id": 9, "name": "冬木红枣 500克", "price": "0.01", "stock": 996, "main_img_url": "http://e.cn:10010/images/product-dryfruit@4.png", "img_id": 37 }, { "id": 10, "name": "万紫千凤梨 300克", "price": "0.01", "stock": 996, "main_img_url": "http://e.cn:10010/images/product-dryfruit@5.png", "img_id": 38 }, { "id": 11, "name": "贵妃笑 100克", "price": "0.01", "stock": 994, "main_img_url": "http://e.cn:10010/images/product-dryfruit-a@6.png", "img_id": 39 }, { "id": 12, "name": "珍奇异果 3个", "price": "0.01", "stock": 999, "main_img_url": "http://e.cn:10010/images/product-dryfruit@7.png", "img_id": 40 }, { "id": 13, "name": "绿豆 125克", "price": "0.01", "stock": 999, "main_img_url": "http://e.cn:10010/images/product-rice@2.png", "img_id": 41 }, { "id": 14, "name": "芝麻 50克", "price": "0.01", "stock": 999, "main_img_url": "http://e.cn:10010/images/product-rice@3.png", "img_id": 42 }, { "id": 15, "name": "猴头菇 370克", "price": "0.01", "stock": 999, "main_img_url": "http://e.cn:10010/images/product-rice@4.png", "img_id": 43 } ]
3. 商品模块
1. 获取商品分类
请求路径
- /api/v1/category/all
- page: 路径参数;eg: 1
- /api/v1/category/all
请求方法
- get
请求参数
- none
响应数据
[ { "id": 2, "name": "果味", "topic_img_id": 6, "description": null, "update_time": "1970-01-01 08:00:00", "img": { "url": "http://e.cn:10010/images/category-dryfruit.png", "update_time": "1970-01-01 08:00:00" } }, { "id": 3, "name": "蔬菜", "topic_img_id": 5, "description": null, "update_time": "1970-01-01 08:00:00", "img": { "url": "http://e.cn:10010/images/category-vg.png", "update_time": "1970-01-01 08:00:00" } }, { "id": 4, "name": "炒货", "topic_img_id": 7, "description": null, "update_time": "1970-01-01 08:00:00", "img": { "url": "http://e.cn:10010/images/category-fry-a.png", "update_time": "1970-01-01 08:00:00" } }, { "id": 5, "name": "点心", "topic_img_id": 4, "description": null, "update_time": "1970-01-01 08:00:00", "img": { "url": "http://e.cn:10010/images/category-cake.png", "update_time": "1970-01-01 08:00:00" } }, { "id": 6, "name": "粗茶", "topic_img_id": 8, "description": null, "update_time": "1970-01-01 08:00:00", "img": { "url": "http://e.cn:10010/images/category-tea.png", "update_time": "1970-01-01 08:00:00" } }, { "id": 7, "name": "淡饭", "topic_img_id": 9, "description": null, "update_time": "1970-01-01 08:00:00", "img": { "url": "http://e.cn:10010/images/category-rice.png", "update_time": "1970-01-01 08:00:00" } } ]
2. 获取商品分类下的商品
请求路径
- /api/v1/product/by_category?id=
- category_id: 商品分类id; eg: 2
- /api/v1/product/by_category?id=
请求方法
- get
请求参数
- none
响应数据
[ { "id": 2, "name": "梨花带雨 3个", "price": "0.01", "stock": 984, "main_img_url": "http://e.cn:10010/images/product-dryfruit@1.png", "img_id": 10 }, { "id": 5, "name": "春生龙眼 500克", "price": "0.01", "stock": 995, "main_img_url": "http://e.cn:10010/images/product-dryfruit@2.png", "img_id": 33 }, { "id": 8, "name": "夏日芒果 3个", "price": "0.01", "stock": 995, "main_img_url": "http://e.cn:10010/images/product-dryfruit@3.png", "img_id": 36 }, { "id": 9, "name": "冬木红枣 500克", "price": "0.01", "stock": 996, "main_img_url": "http://e.cn:10010/images/product-dryfruit@4.png", "img_id": 37 }, { "id": 10, "name": "万紫千凤梨 300克", "price": "0.01", "stock": 996, "main_img_url": "http://e.cn:10010/images/product-dryfruit@5.png", "img_id": 38 }, { "id": 11, "name": "贵妃笑 100克", "price": "0.01", "stock": 994, "main_img_url": "http://e.cn:10010/images/product-dryfruit-a@6.png", "img_id": 39 }, { "id": 12, "name": "珍奇异果 3个", "price": "0.01", "stock": 999, "main_img_url": "http://e.cn:10010/images/product-dryfruit@7.png", "img_id": 40 }, { "id": 26, "name": "红衣青瓜 混搭160克", "price": "0.01", "stock": 999, "main_img_url": "http://e.cn:10010/images/product-dryfruit@8.png", "img_id": 56 } ]
3. 获取商品信息
请求路径
- /api/v1/product/
- pid: 路径参数,商品id; eg: 8
- /api/v1/product/
请求方法
- get
响应数据
{ "id": 8, "name": "夏日芒果 3个", "price": "0.01", "stock": 995, "main_img_url": "http://e.cn:10010/images/product-dryfruit@3.png", "summary": null, "img_id": 36, "imgs": [], "properties": [] }
4. 订单模块
1. 获取用户订单列表
请求路径
- /api/v1/order/by_user?page=
- page: 路径参数;eg: 1
- /api/v1/order/by_user?page=
请求头
- Content-Type application/json
- token 用户token
请求方法
- get
请求参数
- none
响应数据
{ "current_page": 1, "data": [ { "id": 8, "order_no": "G307780577258757", "create_time": "2023-03-07 16:34:17", "total_price": "0.02", "status": 1, "snap_img": "http://e.cn:10010/images/product-dryfruit@3.png", "snap_name": "夏日芒果 3个", "total_count": 2, "prepay_id": null }, { "id": 7, "order_no": "FA27534067155142", "create_time": "2022-10-27 14:50:06", "total_price": "0.02", "status": 1, "snap_img": "http://e.cn:10010/images/product-dryfruit@3.png", "snap_name": "夏日芒果 3个", "total_count": 2, "prepay_id": null }, { "id": 6, "order_no": "FA27519423955761", "create_time": "2022-10-27 14:25:42", "total_price": "0.02", "status": 1, "snap_img": "http://e.cn:10010/images/product-dryfruit@3.png", "snap_name": "夏日芒果 3个", "total_count": 2, "prepay_id": null }, { "id": 5, "order_no": "FA27359591681284", "create_time": "2022-10-27 09:59:19", "total_price": "0.02", "status": 1, "snap_img": "http://e.cn:10010/images/product-dryfruit-a@6.png", "snap_name": "贵妃笑 100克等", "total_count": 2, "prepay_id": null }, { "id": 4, "order_no": "FA27353928081136", "create_time": "2022-10-27 09:49:52", "total_price": "0.01", "status": 1, "snap_img": "http://e.cn:10010/images/product-dryfruit-a@6.png", "snap_name": "贵妃笑 100克", "total_count": 1, "prepay_id": null } ] }
2. 创建订单
请求路径
- /api/v1/order
请求头
- Content-Type application/json
- token 用户token
请求方法
- post
请求参数
格式:json
参数
- products:请求对象
- product_id: 商品id
- count: 数量
- products:请求对象
举例:
{"products":[{"product_id":8,"count":2}]}
响应数据
{ "order_no": "H822051460331210", "order_id": "9", "create_time": "2024-08-22 13:39:05", "pass": true }
3. 查看订单详情
请求路径
- /api/v1/order/
- order_id: 路径参数 订单id; eg: 9
- /api/v1/order/
请求头
- Content-Type application/json
- token 用户token
请求方法
- get
响应数据
{ "id": 9, "order_no": "H822051460331210", "create_time": "2024-08-22 13:39:05", "total_price": "0.02", "status": 1, "snap_img": "http://e.cn:10010/images/product-dryfruit@3.png", "snap_name": "夏日芒果 3个", "total_count": 2, "snap_items": [ { "id": 8, "name": "夏日芒果 3个", "main_img_url": "http://e.cn:10010/images/product-dryfruit@3.png", "count": 2, "totalPrice": 0.02, "price": "0.01", "counts": 2 } ], "snap_address": { "name": "张三", "mobile": "020-81167888", "province": "广东省", "city": "广州市", "country": "海珠区", "detail": "新港中路397号", "update_time": "1970-01-01 08:00:00" } }