客戶購物 [免驗證] - hexschool/vue-course-api-wiki GitHub Wiki
取得商品列表
[API]: /api/:api_path/products?page=:page
[參數]: @api_path = 'thisismycourse2'
@page 當前第幾頁(分頁參數)
[方法]: get
[成功回應]:
{
"success": true,
"products": [
{
"category": "衣服3",
"content": "這是內容",
"description": "Sit down please 名設計師設計",
"id": "-L9tH8jxVb2Ka_DYPwng",
"imageUrl": "test.testtest",
"is_enabled": 1,
"num": 1,
"origin_price": 100,
"price": 600,
"title": "[賣]動物園造型衣服3",
"unit": "個"
}
],
"pagination": {
"total_pages": 1,
"current_page": 1,
"has_pre": false,
"has_next": false,
"category": null
},
"messages": []
}
取得商品列表_all
[API]: /api/:api_path/products/all
[參數]: @api_path = 'thisismycourse2'
[方法]: get
[成功回應]:
{
"success": true,
"products": [
{
"category": "衣服3",
"content": "這是內容",
"description": "Sit down please 名設計師設計",
"id": "-L9tH8jxVb2Ka_DYPwng",
"imageUrl": "test.testtest",
"is_enabled": 1,
"num": 1,
"origin_price": 100,
"price": 600,
"title": "[賣]動物園造型衣服3",
"unit": "個"
}
],
"messages": []
}
單一商品細節
[API]: /api/:api_path/product/:id
[說明]: @api_path = 'thisismycourse2'
@id = '-L9tH8jxVb2Ka_DYPwng'
[方法]: get
[成功回應]:
{
"success": true,
"product": {
"category": "衣服3",
"content": "這是內容",
"description": "Sit down please 名設計師設計",
"id": "-L9tH8jxVb2Ka_DYPwng",
"imageUrl": "test.testtest",
"is_enabled": 1,
"num": 1,
"origin_price": 100,
"price": 600,
"title": "[賣]動物園造型衣服3",
"unit": "個"
}
}
[失敗回應]: 產品未啟用
{
"success": false,
"message": "產品未啟用"
}
[失敗回應]: 找不到產品
{
"success": false,
"message": "找不到產品"
}
加入購物車
[API]: /api/:api_path/cart
[方法]: post
[參數]: { "data": { "product_id":"-L9tH8jxVb2Ka_DYPwng","qty":1 } }
[成功回傳]:
{
"success": true,
"message": "已加入購物車",
"data": {
"product_id": "-L9tH8jxVb2Ka_DYPwng",
"qty": 1,
"id": "-LAl5v_2MhWeh3linQxx",
"total": 600,
"final_total": 600,
"product": {
"category": "衣服3",
"content": "這是內容",
"description": "Sit down please 名設計師設計",
"id": "-L9tH8jxVb2Ka_DYPwng",
"imageUrl": "test.testtest",
"is_enabled": 1,
"num": 1,
"origin_price": 500,
"price": 600,
"title": "[賣]動物園造型衣服3",
"unit": "個"
}
}
}
刪除某一筆購物車資料
[API]: /api/:api_path/cart/:id
[方法]: delete
[成功回傳]:
{
"success": true,
"message": "已刪除"
}
取得購物車列表
[API]: /api/:api_path/cart
[方法]: get
[成功回傳]:
{
"success": true,
"data": {
"carts": [
{
"coupon": {
"code": "testCode",
"due_date": 6547658,
"id": "-L9uIs5EfPibJpwwTMhN",
"is_enabled": 1,
"percent": 60,
"title": "超級特惠價格"
},
"id": "-LATwKkmvteWHjkmtp6m",
"product": {
"category": "衣服3",
"content": "這是內容",
"description": "Sit down please 名設計師設計",
"id": "-L9tH8jxVb2Ka_DYPwng",
"imageUrl": "test.testtest",
"is_enabled": 1,
"num": 1,
"origin_price": 500,
"price": 600,
"title": "[賣]動物園造型衣服3",
"unit": "個"
},
"product_id": "-L9tH8jxVb2Ka_DYPwng",
"qty": 2
},
{
"coupon": {
"code": "testCode",
"due_date": 6547658,
"id": "-L9uIs5EfPibJpwwTMhN",
"is_enabled": 1,
"percent": 60,
"title": "超級特惠價格"
},
"final_total": 2160,
"id": "-LATwxc_bIJu-AR4AlNj",
"product": {
"category": "衣服3",
"content": "這是內容",
"description": "Sit down please 名設計師設計",
"id": "-L9tH8jxVb2Ka_DYPwng",
"imageUrl": "test.testtest",
"is_enabled": 1,
"num": 1,
"origin_price": 500,
"price": 600,
"title": "[賣]動物園造型衣服3",
"unit": "個"
},
"product_id": "-L9tH8jxVb2Ka_DYPwng",
"qty": 6,
"total": 3600
}
],
"total": 3600,
"final_total": 2160
},
"messages": []
}
套用優惠券
percent 會轉數字格式
[API]: /api/:api_path/coupon
[方法]: post
[說明]: Coupon 套用時,全部統一套用
[參數]: @api_path: 'thisismycourse2'
{
"data": {
"code": "testCode"
}
}
[成功回應]:
{
"success": true,
"message": "已套用優惠券:testCode",
"data": {
"final_total": 2160
}
}
[失敗回應]: 找不到優惠券
{
"success": false,
"message": "找不到優惠券!"
}
[失敗回應]: 過期
{
"success": false,
"message": "優惠券無法使用或已過期"
}
結帳頁面
[API]: /api/:api_path/order
[方法]: post
[說明]: 建立訂單後會把所選的購物車資訊刪除, user 物件為必要
[參數]: @api_path: 'thisismycourse2'
{
"data": {
"user": {
"name": "test",
"email": "[email protected]",
"tel": "0912346768",
"address": "kaohsiung"
},
"message": "這是留言"
}
}
[成功回傳]:
{
"success": true,
"message": "已建立訂單",
"total": 100,
"create_at": 1523539519,
"orderId": "-L9tH8jxVb2Ka_DYPwng"
}
[失敗回傳]: message 未填寫
{
"success": false,
"messages": "說明欄位為必填"
}
[失敗回傳]: 無 user 物件
{
"success": false,
"message": "尚無用戶資料"
}
取得訂單列表
[API]: /api/:api_path/orders?page=:page
[方法]: get
[參數]:
@api_path = 'thisismycourse2'
@page 當前第幾頁(分頁參數)
[成功回傳]:
{
"success": true,
"orders": [
{
"create_at": 1523539519,
"id": "-L9u11NAE0m0SpSBUDIq",
"is_paid": false,
"message": "這是留言",
"payment_method": "credit_card",
"products": [
{
"id": "L8nBrq8Ym4ARI1Kog4t",
"product_id": "-L8moRfPlDZZ2e-1ritQ",
"qty": "3"
}
],
"user": {
"address": "kaohsiung",
"email": "[email protected]",
"name": "test",
"tel": "0912346768"
},
"num": 1
}
],
"pagination": {
"total_pages": 1,
"current_page": 1,
"has_pre": false,
"has_next": false,
"category": null
},
"messages": []
}
取得某一筆訂單
[API]: /api/:api_path/order/:order_id
[參數]:
@api_path: 'thisismycourse2'
@order_id: '-L9u2EUkQSoEmW7QzGLF'
[方法]: get
[成功回傳]:
{
"success": true,
"order": {
"create_at": 1523539834,
"id": "-L9u2EUkQSoEmW7QzGLF",
"is_paid": false,
"message": "這是留言",
"payment_method": "credit_card",
"products": [
{
"id": "L8nBrq8Ym4ARI1Kog4t",
"product_id": "-L8moRfPlDZZ2e-1ritQ",
"qty": "3"
}
],
"total": 100,
"user": {
"address": "kaohsiung",
"email": "[email protected]",
"name": "test",
"tel": "0912346768"
}
}
}
結帳付款
[API]: /api/:api_path/pay/:order_id
[方法]: post
[參數]:
@api_path: 'thisismycourse2'
@order_id: 訂單編號
[成功回傳]:
{
"success": true,
"message": "付款完成"
}