// 成功
{
"success": true,
"data": {
//...
}
}
// 失败
{
"success": false,
"data": {
//...
}
}
// 成功
{
"success": true,
"data": {
restaurants: [{
id: 0,
name: "name1",
address: "address",
latitude: "29.303453",
longitude: "120.235432",
img: ""
}, {
id: 1,
name: "name2",
address: "address",
latitude: "29.303453",
longitude: "120.235432",
img: ""
}]
}
}
// 失败
{
"success": false,
"data": {
errorcode: 1000,
msg: "XXX Error"
}
}
[GET] api/restaurant/<name>|<id>
key |
type |
description |
name |
String |
餐厅名称 |
rate |
float |
餐厅评分 |
sale |
int |
餐厅总销量 |
worktime |
String |
营业时间,格式:hh:mm-hh:mm |
discount |
Array<Discount> |
折扣列表,折扣表示方法见Discount |
key |
type |
description |
errorcode |
int |
错误码 |
msg |
String |
错误信息 |
Discount 用 Object 类型来表示,属性如下表。
key |
type |
description |
type |
int |
折扣类型 |
class |
int |
所属类别(同类别优惠不可同享) |
requireAmount (option) |
float |
优惠所需达到的消费金额 |
minusAmount (option) |
float |
优惠金额 |
specialAmount (option) |
float |
特价,定价 |
rate (option) |
float |
折扣百分比 |
couponAmount |
float |
返还优惠券金额 |
// 成功
{
"success": true,
"data": {
name: "name",
rate: 100,
sale: 2399,
worktime: "08:00-23:00",
discount:[{
type: 0,
class: 0,
requireAmount: 20,
minusAmount:5
}, {
type: 0,
class: 0,
requireAmount: 30,
minusAmount: 10
}]
}
}
// 失败
{
"success": false,
"data": {
errorcode: 1000,
msg: "XXX Error"
}
}
[GET] api/restaurant/<name>|<id>/dishes
key |
type |
description |
cataName |
String |
类名 |
items |
Array |
该类下的菜品 |
key |
type |
description |
id |
int |
菜品id |
name |
String |
菜品名 |
img |
String |
菜品图像链接 |
orginPrice |
float |
菜品原价 |
salePrice |
float |
菜品折后价 |
rate |
int |
好评率 |
options |
Array |
选项 |
key |
type |
description |
name |
String |
选项类别名 |
options |
Array |
可选项 |
key |
type |
description |
name |
String |
选项名 |
active |
bool |
如果该选项为默认选项,则这里为true |
// 成功
{
"success": true,
"data": {
"content": [{
"cataName": "catagory1",
"items": [{
"id": 0,
"name": "name1",
"img": "url",
"originPrice": 8.88,
"salePrice": 6.66,
"rate": 100,
"options": [{
"name": "option-name-1",
"options": [{
"name": "option1",
"active": true
}, {
"name": "option2",
"active": false
}]
}, {
"name": "option-name-2",
"options": [{
"name": "option1",
"active": true
}, {
"name": "option2",
"active": false
}]
}]
}]
}]
}
}
// 失败
{
"success": false,
"data": {
errorcode: 1000,
msg: "XXX Error"
}
}
[POST] api/order/add2cart
key |
type |
description |
token |
String |
用户id |
content |
String |
购物车内容 |
key |
type |
description |
id |
int |
菜品id |
amount |
int |
菜品数量 |
options |
Object |
选项 |
info |
string |
地址id |
time |
text |
时间 |
extra |
text |
备注 |
[POST]
//Notice: content是字符串,使用json格式
//options中是选项名以及对应的选中的选项
{
token: "userid",
content: `[{
id: 0,
amount: 1,
options: {
"option-name-1": "option1",
"option-name-2": "option2"
}
}, {
id: 1,
amount: 10,
options: {
"option-name-1": "option1",
"option-name-2": "option2"
}
}]`
}
//成功
{
success: true,
data: {}
}
//失败
{
success: false,
data: {
errorcode: 1000,
msg: "error message"
}
}
[GET] api/order/cart?token=userid
// 成功
{
success: true,
data: {
content: [{
id: 0,
amount: 1,
name: "test",
originPrice: 22.2,
salePrice: 18.88,
options: {
"option-name-1": "option1",
"option-name-2": "option2"
}
}, {
id: 1,
amount: 1,
name: "test",
originPrice: 22.2,
salePrice: 18.88,
options: {
"option-name-1": "option1",
"option-name-2": "option2"
}
}]
}
}
//失败
{
success: false,
data: {
errorcode: 1000,
msg: "xxx error"
}
}
[GET] api/order/discount?token=userid
//成功
{
success: true,
data: {
discount: {
type: 0,
requireAmount: 20,
minusAmount: 10
}
}
}
//失败
{
success: false,
data: {
errorcode: 1000,
msg: "xxx error"
}
}
[GET] api/order/redpack?token=userid
//成功
{
success: true,
data: {
redpack: {
id: 1, //红包id
requireAmount: 10,
minusAmount: 5,
type: 0 //红包类型
}
}
}
//失败
{
success: false,
data: {
errorcode: 1000,
msg: "xxx error"
}
}
[GET] api/redpacks?token=userid
//成功
{
success: true,
data: {
redpacks: [{
id: 1, //红包id
requireAmount: 10,
minusAmount: 5,
type: 0 //红包类型
}, {
id: 2, //红包id
requireAmount: 10,
minusAmount: 5,
type: 0 //红包类型
}]
}
}
//失败
{
success: false,
data: {
errorcode: 1000,
msg: "xxx error"
}
}
[GET] api/order/address?token=userid
如果没有设置过收货地址,随便返回一个收货地址。
如果当前用户没有收货地址,作为错误返回。
//成功
{
success: true,
data: {
address: {
id: 1, //地址id
name: "leo", //用户姓名
phone: "13566669999",
address: "xxx省xx市xx区xx路xx号"
}
}
}
//失败
{
success: false,
data: {
errorcode: 1000,
msg: "xxx error"
}
}
[POST]
{
token: "userid"
id: 1 //地址id
}
//成功
{
success: true,
data: {}
}
//失败
{
success: false,
data: {
errorcode: 1000,
msg: "xxx error"
}
}
[GET] api/addresses?token=userid
//成功
{
success: true,
data: {
addresses: [{
id: 1, //地址id
name: "leo", //用户姓名
phone: "13566669999",
address: "xxx省xx市xx区xx路xx号",
avalible: true //是否超出范围
}, {
id: 2, //地址id
name: "leo", //用户姓名
phone: "13566669999",
address: "xxx省xx市xx区xx路xx号",
avalible: false //是否超出范围
}]
}
}
//失败
{
success: false,
data: {
errorcode: 1000,
msg: "xxx error"
}
}
// 这里的id是地址的id
[GET] api/address/<id>
//成功
{
success: true,
data: {
address: {
id: 1, //地址id
name: "leo", //用户姓名
phone: "13566669999",
address: "xxx省xx市xx区xx路xx号"
}
}
}
//失败
{
success: false,
data: {
errorcode: 1000,
msg: "xxx error"
}
}
key |
type |
description |
name |
String |
用户姓名 |
phone |
String |
用户电话 |
address |
String |
用户地址 |
[PUT]
{
token: "userid"
name: "leo",
phone: "13566669999",
address: "xxx省xx市xx区xx路xx号"
}
//成功
{
success: true,
data: {
id: 1 //地址id
}
}
//失败
{
success: false,
data: {
errorcode: 1000,
msg: "xxx error"
}
}
[POST]
{
id: 1, //修改的地址id
name: "leo",
phone: "13566669999",
address: "xxx省xx市xx区xx路xx号"
}
//成功
{
success: true,
data: {}
}
//失败
{
success: false,
data: {
errorcode: 1000,
msg: "xxx error"
}
}
//成功
{
success: true,
data: {}
}
//失败
{
success: false,
data: {
errorcode: 1000,
msg: "xxx error"
}
}
[POST]
{
username: "username",
password: "passwd"
}
// 成功
{
success: true,
data: { // 根据这个token来判断登陆状态,需要在数据库记录
token: token, // 之后的每次请求都会附上这个token
expireTime: 3600 // 过期时间,单位为秒
}
}
// 失败
{
success: false,
data: {
errorcode: 1000,
msg: 'xxx error'
}
}