购物车
金色童年
获取购物车
Method and URL Structure
| Method |
Resource URL |
Description |
| GET |
/market/cart/ |
|
Request Paramaters
No Applicatated
cURL Example
curl -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'\ http://localhost/market/cart/
Reponse Data
| Name |
Description |
| pk |
购物车pk |
| profile |
用户profile |
| product_set |
产品列表 |
Product
| Name |
Description |
| amount |
总金额 |
| price |
价格 |
| quantity |
数量 |
| shop |
商铺 |
| cover |
封面 |
| name |
商品名 |
Response
{ "pk": 14, "profile": { "owner": 20, "nickname": "nickname", "avatar_url": "", "slogan": "" }, "product_set": [ { "product": { "pk": 4, "category": 2, "category_name": "测试分类第二", "name": "第三个商品", "price": "0.01", "desc": "这是第三个商品", "evaluate_count": 0, "cover": "http://pic.childhood.haorenao.cn/83db4d07280cdcb305e38f8529b2c374_z.jpg", "desc_files": "http://pic.childhood.haorenao.cn/f8831e6824bc0fb22df180402d2ce7e5_j.jpg,http://pic.childhood.haorenao.cn/7888ec69d6b3a8f9fb3fc057199c93ef_q.jpg", "file_list": [ "http://pic.childhood.haorenao.cn/f8831e6824bc0fb22df180402d2ce7e5_j.jpg", "http://pic.childhood.haorenao.cn/7888ec69d6b3a8f9fb3fc057199c93ef_q.jpg" ], "shop": { "pk": 7, "owner": 11, "name": "NoName", "avatar_url": "http://pic.xinlue.haorenao.cn/4cf212b6cf1e453c78112aeb923d73ba_e.JPG", "region": "华东地区", "province": "北京市", "city": "北京市", "district": "丰台区", "address": "方庄芳城路7号", "linkman": "0755-12345678", "desc": "no", "position": "39.869373,116.427681" } }, "quantity": 4, "amount": 0.04, "created": "2016-10-16T19:23:59.660080" }, { "product": { "pk": 3, "category": 2, "category_name": "测试分类第二", "name": "第二个商品", "price": "0.01", "desc": "这是第二个商品", "evaluate_count": 0, "cover": "http://pic.childhood.haorenao.cn/83db4d07280cdcb305e38f8529b2c374_z.jpg", "desc_files": "http://pic.childhood.haorenao.cn/f8831e6824bc0fb22df180402d2ce7e5_j.jpg,http://pic.childhood.haorenao.cn/7888ec69d6b3a8f9fb3fc057199c93ef_q.jpg", "file_list": [ "http://pic.childhood.haorenao.cn/f8831e6824bc0fb22df180402d2ce7e5_j.jpg", "http://pic.childhood.haorenao.cn/7888ec69d6b3a8f9fb3fc057199c93ef_q.jpg" ], "shop": { "pk": 7, "owner": 11, "name": "NoName", "avatar_url": "http://pic.xinlue.haorenao.cn/4cf212b6cf1e453c78112aeb923d73ba_e.JPG", "region": "华东地区", "province": "北京市", "city": "北京市", "district": "丰台区", "address": "方庄芳城路7号", "linkman": "0755-12345678", "desc": "no", "position": "39.869373,116.427681" } }, "quantity": 7, "amount": 0.07, "created": "2016-10-16T19:23:40.038726" } ]}
购物车添加、减少、删除、选中商品
数量不能减少到 0,数量等于 1不能再减少, 可以用 remove 删除商品。
Method and URL Structure
| Method |
Resource URL |
Description |
| PUT |
/market/cart/add/ |
添加到购物车数量加一 |
| PUT |
/market/cart/subtract/ |
减少一个数量 |
| PUT |
/market/cart/remove/ |
从购物车移除商品 |
| PUT |
/market/cart/select/ |
选中一个商品(再发一次就取消选中) |
Request Data
{ "product": 1234,}
Response
{ "pk":1, "profile":{ "owner":1, "nickname":"xiaoming", "avatar_url":"http://www.example.com/xiaoming.jpg", "slogan":"xiaoming's slogan" }, "product_set":[ "product" { "pk":21, "quantity": 4, "category":36, "category_name":"C1", "name":"Product Three", "price":"99.9", "amount":399.6, "desc":"test desc", "evaluate_count":0, "cover":"http://cover.example.com/cover.png", "file_list":[ "http://img.example.com/file1.png", "http://img.example.com/fil2.jpg" ], "shop": { "pk":8, "owner":13, "name":"店三", "avatar_url":"http://pic.example.com/0.jpg", "region":"华东地区", "province":"上海", "city":"上海市", "district":"浦东新区", "address":"云里路", "linkman":"13212345671", "desc":"店铺介绍", } }, ..]}
清空购物车
Method and URL Structure
| Method |
Resource URL |
Description |
| DELETE |
/market/cart/clear/ |
清空购物车 |
| PUT |
/market/cart/cancel_all_select |
取消所有的选中 |
| PUT |
/market/cart/select_all |
选中所有的 |