所有的请求 接口都会响应统一的数据格式(json格式)
eg
{
"status_code": 0, // 所有的status_code 为0 代表成功
"message": null, //返回响应的提示消息
"data": {
"data_filed": "asd" // 前段需要展示的数据
}
}
首页接口
获取用户token
接口说明
因为小程序不使用cookie 所以需要用户登录后操作的操作都需要带上后端
接口返回的token
请求方式
post
请求参数
参数名 类型 是否必须
auth_code string 是
请求url
user/gettoken
相应数据
{
"status_code": 0,
"message": null,
"data": {
"token": "123123123123123"
}
}
获取首页数据
接口说明
获取首页展示数据
请求地址
/index
请求参数
无
响应数据
{
"status_code": 0,
"message": "",
"data": {
"banner": ["1.jpg", "1.jpg", "1.jpg"],//轮播图
"message": [{
"type": 1, //1 返现 2 反卷
"phone": "150 302203740",
"price": "200 \u5143"
}, {
"type": 2,
"phone": "150 302203740",
"price": "200 \u5143"
}],
"excellent_goods": [{ // // 名优商品
"product_id": 1, // 商品id
"pic_url": "http:\/\/www.baidu.com\/1.jpg",
"price": "128.00 \u5143" 价格
}, {
"product_id": 1,
"pic_url": "http:\/\/www.baidu.com\/1.jpg",
"price": "128.00 \u5143"
}, {
"product_id": 1,
"pic_url": "http:\/\/www.baidu.com\/1.jpg",
"price": "128.00 \u5143"
}],
"special_goods": [{
"product_id": 1,
"pic_url": "http:\/\/www.baidu.com\/1.jpg",
"price": "128.00 \u5143"
}, {
"product_id": 1,
"pic_url": "http:\/\/www.baidu.com\/1.jpg",
"price": "128.00 \u5143"
}, {
"product_id": 1,
"pic_url": "http:\/\/www.baidu.com\/1.jpg",
"price": "128.00 \u5143"
}]
}
}
获取商品详情页
接口说明
获取商品详情页数据
请求地址
/goods/info
请求参数
product_id 首页数据中的 商品id
响应数据
{
"status_code": 0,
"message": "",
"data": {
"product_info": { //商品信息
"product_id": 12,
"product_name": "小米 手机",
"stock": "12 件",
"sales_volume": "1222 件",
"description": "详情",
"price": "123元",
"banner": ["1,jpg", "2.jpg"],
"video": "123.mp4",
"content": ["1,jpg", "2.jpg"],
},
"is_collection": "1", 是否收藏 1 收藏 2 未收藏,
"flag": "1", 1 特推 2 名优
"product_attr": [{
"product_id": 2,
"attr_name": "颜色",
"attr_values": ["红色", "蓝色", "粉色"]
}, {
"product_id": 2,
"attr_name": "容量",
"attr_values": ["12G", "24G", "48G"]
}],
"product_value": {
"12G,粉色": {
"product_id": 2,
"suk": "12G,粉色",
"stock": 12,
"sales": 0,
"price": "100.00",
"image": "http://localhost/public/uploads/attach/2019/02/26/5c74aa8e7bf3e.png",
"unique": "bfaf34b2",
"cost": "121.00"
},
"12G,红色": {
"product_id": 2,
"suk": "12G,红色",
"stock": 12,
"sales": 0,
"price": "100.00",
"image": "http://localhost/public/uploads/attach/2019/02/26/5c74aa8e7bf3e.png",
"unique": "ba9be73a",
"cost": "121.00"
},
"12G,蓝色": {
"product_id": 2,
"suk": "12G,蓝色",
"stock": 12,
"sales": 0,
"price": "100.00",
"image": "http://localhost/public/uploads/attach/2019/02/26/5c74aa8e7bf3e.png",
"unique": "f6582b9d",
"cost": "121.00"
},
"24G,粉色": {
"product_id": 2,
"suk": "24G,粉色",
"stock": 12,
"sales": 0,
"price": "100.00",
"image": "http://localhost/public/uploads/attach/2019/02/26/5c74aa8e7bf3e.png",
"unique": "d3050a70",
"cost": "121.00"
},
"24G,红色": {
"product_id": 2,
"suk": "24G,红色",
"stock": 0,
"sales": 12,
"price": "100.00",
"image": "http://localhost/public/uploads/attach/2019/02/26/5c74aa8e7bf3e.png",
"unique": "84d41ab3",
"cost": "121.00"
},
"24G,蓝色": {
"product_id": 2,
"suk": "24G,蓝色",
"stock": 12,
"sales": 0,
"price": "100.00",
"image": "http://localhost/public/uploads/attach/2019/02/26/5c74aa8e7bf3e.png",
"unique": "b2f7264f",
"cost": "121.00"
},
"48G,粉色": {
"product_id": 2,
"suk": "48G,粉色",
"stock": 12,
"sales": 0,
"price": "100.00",
"image": "http://localhost/public/uploads/attach/2019/02/26/5c74aa8e7bf3e.png",
"unique": "4f8372a1",
"cost": "121.00"
},
"48G,红色": {
"product_id": 2,
"suk": "48G,红色",
"stock": 12,
"sales": 0,
"price": "100.00",
"image": "http://localhost/public/uploads/attach/2019/02/26/5c74aa8e7bf3e.png",
"unique": "af388d95",
"cost": "121.00"
},
"48G,蓝色": {
"product_id": 2,
"suk": "48G,蓝色",
"stock": 12,
"sales": 0,
"price": "100.00",
"image": "http://localhost/public/uploads/attach/2019/02/26/5c74aa8e7bf3e.png",
"unique": "c25ee482",
"cost": "121.00"
}
},
"comment": {
"sum": "12",
"good_comment": "99%",
"list": [{
"name": "zhangsan",
"head_pic": "头像地址",
"level": "1",
"sku": "红色 128G",
"pic": ["1.jpg"],
"time": "2019-08-05",
"content": "不错"
}]
}
}
}
评论列表
请求地址
/comment/list
请求方式
get
请求参数
product_id 必须
page 不传默认显示第一页
响应数据
{
"status_code": 0,
"message": "",
"data": {
"good_comment_rate": " 好评率",
"all_comment_num": "所有评论数",
"good_comment": "好评数",
"middle_comment": "中评数",
"bad_comment": "差评数",
"total_page": "总页数",
"comment_list": [{
"head_pic": "头像地址",
"start_num": "星星数",
"name": "名字",
"date": "时间",
"sku": "规格",
"content": "评论内容",
"pic": ["图片1"],
"reply": {
"name": "回复人名字",
"content": "回复内容"
}
}]
}
}
获取商品搜索历史
请求地址
/goods/history
请求参数
无
请求方式
get
响应数据
{
"status_code": 0,
"message": "",
"data": ["水果", "手机"]
}
搜索商品
请求地址
/goods/serach
请求参数
goods_name 商品名字 type 搜索类型 不传默认 综合 sale 代表销量 new 代表最新 最多显示30条
请求方式
get
响应数据
{
"status_code": 0,
"message": "",
"data": [{
"name": "商品名",
"pic": "商品图片",
"price": "商品价格",
"sales": "商品销量",
"product_attr": [{
"product_id": 2,
"attr_name": "颜色",
"attr_values": ["红色", "蓝色", "粉色"]
}, {
"product_id": 2,
"attr_name": "容量",
"attr_values": ["12G", "24G", "48G"]
}],
"product_value": {
"12G,粉色": {
"product_id": 2,
"suk": "12G,粉色",
"stock": 12,
"sales": 0,
"price": "100.00",
"image": "http://localhost/public/uploads/attach/2019/02/26/5c74aa8e7bf3e.png",
"unique": "bfaf34b2",
"cost": "121.00"
},
"12G,红色": {
"product_id": 2,
"suk": "12G,红色",
"stock": 12,
"sales": 0,
"price": "100.00",
"image": "http://localhost/public/uploads/attach/2019/02/26/5c74aa8e7bf3e.png",
"unique": "ba9be73a",
"cost": "121.00"
},
"12G,蓝色": {
"product_id": 2,
"suk": "12G,蓝色",
"stock": 12,
"sales": 0,
"price": "100.00",
"image": "http://localhost/public/uploads/attach/2019/02/26/5c74aa8e7bf3e.png",
"unique": "f6582b9d",
"cost": "121.00"
},
"24G,粉色": {
"product_id": 2,
"suk": "24G,粉色",
"stock": 12,
"sales": 0,
"price": "100.00",
"image": "http://localhost/public/uploads/attach/2019/02/26/5c74aa8e7bf3e.png",
"unique": "d3050a70",
"cost": "121.00"
},
"24G,红色": {
"product_id": 2,
"suk": "24G,红色",
"stock": 0,
"sales": 12,
"price": "100.00",
"image": "http://localhost/public/uploads/attach/2019/02/26/5c74aa8e7bf3e.png",
"unique": "84d41ab3",
"cost": "121.00"
},
"24G,蓝色": {
"product_id": 2,
"suk": "24G,蓝色",
"stock": 12,
"sales": 0,
"price": "100.00",
"image": "http://localhost/public/uploads/attach/2019/02/26/5c74aa8e7bf3e.png",
"unique": "b2f7264f",
"cost": "121.00"
},
"48G,粉色": {
"product_id": 2,
"suk": "48G,粉色",
"stock": 12,
"sales": 0,
"price": "100.00",
"image": "http://localhost/public/uploads/attach/2019/02/26/5c74aa8e7bf3e.png",
"unique": "4f8372a1",
"cost": "121.00"
},
"48G,红色": {
"product_id": 2,
"suk": "48G,红色",
"stock": 12,
"sales": 0,
"price": "100.00",
"image": "http://localhost/public/uploads/attach/2019/02/26/5c74aa8e7bf3e.png",
"unique": "af388d95",
"cost": "121.00"
},
"48G,蓝色": {
"product_id": 2,
"suk": "48G,蓝色",
"stock": 12,
"sales": 0,
"price": "100.00",
"image": "http://localhost/public/uploads/attach/2019/02/26/5c74aa8e7bf3e.png",
"unique": "c25ee482",
"cost": "121.00"
}
}
}]
}
获取商品分类
请求地址
/goods/class
请求方式
get
请求参数
无
响应数据
{
"status_code": 0,
"message": "",
"data": [{
"class_name": "分类名字",
"class_id": "分类id"
}]
}
获取商品通过分类id
请求地址
/goods/class
请求方式
get
请求参数
class_id 必填 page 不必填 默认为1
响应数据
{
"status_code": 0,
"message": "",
"data": {
"goods": {
"name": "商品名",
"pic": "商品图片",
"price": "商品价格",
"sales": "商品销量",
"product_attr": [{
"product_id": 2,
"attr_name": "颜色",
"attr_values": ["红色", "蓝色", "粉色"]
}, {
"product_id": 2,
"attr_name": "容量",
"attr_values": ["12G", "24G", "48G"]
}],
"product_value": {
"12G,粉色": {
"product_id": 2,
"suk": "12G,粉色",
"stock": 12,
"sales": 0,
"price": "100.00",
"image": "http://localhost/public/uploads/attach/2019/02/26/5c74aa8e7bf3e.png",
"unique": "bfaf34b2",
"cost": "121.00"
},
"12G,红色": {
"product_id": 2,
"suk": "12G,红色",
"stock": 12,
"sales": 0,
"price": "100.00",
"image": "http://localhost/public/uploads/attach/2019/02/26/5c74aa8e7bf3e.png",
"unique": "ba9be73a",
"cost": "121.00"
},
"12G,蓝色": {
"product_id": 2,
"suk": "12G,蓝色",
"stock": 12,
"sales": 0,
"price": "100.00",
"image": "http://localhost/public/uploads/attach/2019/02/26/5c74aa8e7bf3e.png",
"unique": "f6582b9d",
"cost": "121.00"
},
"24G,粉色": {
"product_id": 2,
"suk": "24G,粉色",
"stock": 12,
"sales": 0,
"price": "100.00",
"image": "http://localhost/public/uploads/attach/2019/02/26/5c74aa8e7bf3e.png",
"unique": "d3050a70",
"cost": "121.00"
},
"24G,红色": {
"product_id": 2,
"suk": "24G,红色",
"stock": 0,
"sales": 12,
"price": "100.00",
"image": "http://localhost/public/uploads/attach/2019/02/26/5c74aa8e7bf3e.png",
"unique": "84d41ab3",
"cost": "121.00"
},
"24G,蓝色": {
"product_id": 2,
"suk": "24G,蓝色",
"stock": 12,
"sales": 0,
"price": "100.00",
"image": "http://localhost/public/uploads/attach/2019/02/26/5c74aa8e7bf3e.png",
"unique": "b2f7264f",
"cost": "121.00"
},
"48G,粉色": {
"product_id": 2,
"suk": "48G,粉色",
"stock": 12,
"sales": 0,
"price": "100.00",
"image": "http://localhost/public/uploads/attach/2019/02/26/5c74aa8e7bf3e.png",
"unique": "4f8372a1",
"cost": "121.00"
},
"48G,红色": {
"product_id": 2,
"suk": "48G,红色",
"stock": 12,
"sales": 0,
"price": "100.00",
"image": "http://localhost/public/uploads/attach/2019/02/26/5c74aa8e7bf3e.png",
"unique": "af388d95",
"cost": "121.00"
},
"48G,蓝色": {
"product_id": 2,
"suk": "48G,蓝色",
"stock": 12,
"sales": 0,
"price": "100.00",
"image": "http://localhost/public/uploads/attach/2019/02/26/5c74aa8e7bf3e.png",
"unique": "c25ee482",
"cost": "121.00"
}
}
},
"total_page": "总页数"
}
}
商品收藏
请求地址
/goods/collection
请求方式
get
请求参数
product_id 商品id
响应数据
{
"status_code": 0, // 代表成功
"message": null, //返回响应的提示消息
"data": {
}
}
商品取消收藏
请求地址
/goods/uncollection
请求方式
get
请求参数
product_id 商品id
响应数据
{
"status_code": 0, // 代表成功
"message": null, //返回响应的提示消息
"data": {
}
}
添加到购物车
请求地址
/goods/addcart
请求方式
post
请求参数
prodect_id 必传参数 商品id num 必传参数 商品数量 unique 商品的唯一识别码 也就是说 如果选择了商品的属性 那么此参数必须
响应数据
{
"status_code": 0, // 代表成功
"message": null, //返回响应的提示消息
"data": {
}
我的购物车
请求地址
/goods/cartlist
请求方式
post
请求参数
prodect_id 必传参数 商品id num 必传参数 商品数量 unique 商品的唯一识别码 也就是说 如果选择了商品的属性 那么此参数必须
响应数据
{
status_code: 0,
message: "",
data: {
cart_count: "购物车数量",
cart_info: [{
cart_id: "购物车id",
num: "商品数量",
product_id: "商品id",
product_name: "商品名字",
pic: "商品图片",
price: "商品价格",
sku: "商品sku"
}]
}
}
变化购物车数量
请求地址 /goods/changecart
请求参数 type : add 为增加 reduce 为减少
cart_id
-请求方式
post
响应数据
{
"status_code": 0, // 代表成功
"message": null, //返回响应的提示消息
"data": {
}
删除购物车
请求地址
goods/delcart
请求参数
cart_id
请求方式
post
响应数据
{
"status_code": 0, // 代表成功
"message": null, //返回响应的提示消息
"data": {
}
用户点击立即购买下单
请求地址
/order/makecart
请求方式
post
请求参数
product_id 必填
uninq 如果选择了属性 那么此参数必填
num 商品数量
响应数据
{
status_code: 0,
message: "",
data: {
cart_id: "购物车id"
}
}
用户创建订单页面
请求地址
/order/confirmorder
请求方式
get
请求参数
cart_id 购物车id 用逗号隔开
响应数据
{
"status_code": 0,
"message": "",
"data": {
"cart_id": "1,2,3",
"address": {
"id": "1",
"real_name": "姓名",
"phone": "手机号",
"province": "广东省",
"city": "广州市",
"district": "海珠区",
"detail": "详细地址"
},
"product_info": [{
"product_name": "商品名字",
"num": "3",
"price": "12.00",
"sku": " 小米 红色 ",
"pic": "图片地址"
}],
"postage": {
"is_need": "是否需要邮费 1 需要 2 不需要 3 到付",
"postage_price": "邮费价格"
},
"coupon": [{
"can_use": "1 可以",
"type": "1 是折扣 2是抵钱",
"num": "数量",
"use_time": "有效期",
"name": "名字",
"id": "优惠券id",
"real": "真实的折扣或者钱数",
"content": "介绍 如 最多抵扣钱",
"max_price": "最多可抵扣钱数"
}]
}
}
用户地址 获取
请求地址
/user/addresslist
请求方式
get
-请求参数
无
响应数据
{
status_code: 0,
message: "",
data: [
[{
id: 1,
uid: 1,
real_name: "张三",
phone: "手机号",
province: "广东省",
city: "广州市",
district: "海珠区",
detail: "详细地址",
post_code: 100000,
is_default: 0 // 是否默认地址
}]
]
}
用户地址 设置默认
请求地址
/user/addressdefult
请求方式
post
-请求参数
address_id
响应数据
{
status_code: 0,
message: "",
data:
}
用户地址删除
请求地址
/user/addressdel
请求方式
post
-请求参数
address_id
响应数据
{
status_code: 0,
message: "",
data:
}
用户地址添加
请求地址
/user/addressadd
请求方式
post
-请求参数
province 省 city 市 district 区 is_default 是否默认 1 为默认 其他为不是
real_name 真实姓名
post_code 邮编 非必须
phone 手机号
detail 详细地址 id 如果id 为0 是新增 然后又值 是修改
响应数据
{
status_code: 0,
message: "",
data:
}
讨论区 列表
请求方式
get
请求地址
task/list
请求方式
get
-请求参数
page 页码 默认为1
fid 分类id 默认为 1
响应数据
{
status_code: 0,
message: "",
data: {
class: [{
id: 1,
name: "分享推广",
count: 120
},
{
id: 1,
name: "咨询",
count: 120
}
],
list: [{
id: 1,
ask: "问题",
answer: "回答",
reply_count: "回复数",
update_at: "更新时间"
}],
total_page: "总页数"
}
}
问题详情页
请求方式
get
请求地址
task/info
请求参数
task_id
响应数据
{
status_code: 0,
message: "",
data: {
ask: {
title: "提问内容 ",
add_time: "提问时间"
},
answer: [{
can_reply: "是否可以回答 1 可以 2 不可以",
can_del: "是否可以删除 1可以 2不可以",
head_pic: "头像地址",
name: "姓名",
content: "内容",
time: "时间"
}]
}
}
用户删除问题详情页评论
请求地址
/task/del
请求方式
post
-请求参数
task_id
响应数据
{
status_code: 0,
message: "",
data:
}
用户添加问题详情页评论
请求地址
/task/add
请求方式
post
-请求参数
task_id 问题id
content 内容
响应数据
{
status_code: 0,
message: "",
data:
}
用户提交订单
请求方式
post
请求地址
order/commit
请求方式
get
-请求参数
address_id 地址id
cart_id 购物车id coupon [[‘id’=>‘数量’]]
message ‘留言’
响应数据
{
status_code: 0,
message: "",
data: 提交给微信 那几个字段
}
我的
请求地址
/center/index
请求方式
post
-请求参数
无
响应数据
{
"status_code": 0,
"message": "",
"data": {
"user": {
"name": "",
"head_pic": "头像地址"
},
"order": {
"wait_pay": "代付款",
"wait_take_over": "带收货",
"wait_comment": "待评价",
"wait_after_sale": "带售后"
}
}
}
我的消息
请求地址
/center/index
请求方式
post
-请求参数
page 页码
响应数据
{
"status_code": 0,
"message": "",
"data": {
"total_page": "总页数",
"list": [{
"head_url": "头像地址",
"name": "名字",
"time": "时间",
"content": "内容"
}, {
"head_url": "头像地址",
"name": "名字",
"time": "时间",
"content": "内容"
}]
}
}
全部订单
请求地址
/order/orderlist
请求方式
post
-请求参数
page 页码
type '状态 可不传 -3 待支付 ;1:待收货;2:已收货;3:待评价; ’
响应数据
{
"status_code": 0,
"message": "",
"data": [{
"order_id": "订单号",
"order_status": "-3 待支付 -1 : 申请退款 -2 : 退货成功 0:待发货;1:待收货;2:已收货;3:待评价;-1:已退款",
"sum_price": "总价",
"postage": {
"is_need": "是否需要邮费 1 需要 2 不需要 3 到付",
"postage_price": "邮费价格"
},
"goods_info": {
"goods_name": "商品名字",
"pic": "图片地址",
"price": "价格",
"id": "商品id",
"sku": "商品属性",
"num": "商品名字"
}
}]
}
用户提交订单 点击去支付按钮
请求方式
post
请求地址
order/commitfromwaitpay
请求方式
post
-请求参数
order_id 订单id
响应数据
{
status_code: 0,
message: "",
data: 提交给微信 那几个字段
}
订单详情页
请求方式
post
请求地址
order/showinfo
请求方式
post
-请求参数
order_id 订单id
响应数据
上传图片
请求方式
post
请求地址
common/uploadpic
请求方式
post
-请求参数
pic 图片key
响应数据
{
status_code: 0,
message: "",
data: picurl 图片地址
}
评论订单
请求方式
post
请求地址
order/comment
请求方式
post
-请求参数
pic 图片 [‘1.jpg’,‘2.jpg’]
content 评论内容 quality 数字 1-5 serveice_quality 数字 1-5
响应数据
{"status_code":0,"message":"","data":[
优惠券列表
请求方式
get
请求地址
coupon/list
请求方式
get
-请求参数
type 1 未使用 2 已经使用 3 已经过期
响应数据
{"status_code":0,"message":"","data": [{
"can_use": "1 可以",
"type": "1 是折扣 2是抵钱",
"num": "数量",
"use_time": "有效期",
"name": "名字",
"id": "优惠券id",
"real": "真实的折扣或者钱数",
"content": "介绍 如 最多抵扣钱",
"max_price": "最多可抵扣钱数"
}]}
地址管理 请求上面的地址的数据就可以了
推广信息
请求方式
get
请求地址
extension/info
请求方式
get
-请求参数
响应数据
{
"status_code": 0,
"message": "",
"data": {
"sum_price": "累计佣金数",
"already_refund": "已返卷",
"wait_refund": "带返卷"
}
}
推广列表
请求方式
get
请求地址
extension/info
请求方式
get
-请求参数
响应数据
{
"status_code": 0,
"message": "",
"data": {
"fans_num": "粉丝数量",
"list": [{
"head_pic": "头像地址",
"name": "名字",
"register_time": "注册时间",
"price": "消费金额"
}]
}
}
用户收藏
请求方式
get
请求地址
user/collection
请求方式
get
-请求参数
响应数据
{
"status_code": 0,
"message": "",
"data": {
"sum": "2",
"list": [{
"name": "名字",
"pic_url": "图片地址",
"sale_num": "销量",
"price": "价格",
"0": "id"
}]
}
}
删除订单
请求方式
post
请求地址
order/delorder
请求方式
post
-请求参数
order_id 订单id
响应数据
{"status_code":0,"message":"","data":[]}
演示地址:demo.crmeb.net
账号:demo 密码 crmeb.com
下载地址:源码免费下载http://github.crmeb.net/u/ruanjKF