router.js 1.29 KB
/**
 * router of sub app shopping
 * @author: jinhu.dong<jinhu.dong@yoho.cn>
 * @date: 2016/07/04
 */

'use strict';

const router = require('express').Router(); // eslint-disable-line
const cRoot = './controllers';
const auth = require(`${global.middleware}/auth`);

const cartCtrl = require(`${cRoot}/cart`);  // 购物车
const order = require(`${cRoot}/order`);    // 下单
const pay = require(`${cRoot}/pay`);      // 支付

// 购物车
router.get('/cart', cartCtrl.index);
router.post('/cart/product/change_num', cartCtrl.changeProductNum);
router.delete('/cart/product/remove', cartCtrl.removeProduct);
router.post('/cart/product/send_to_favorite', cartCtrl.sendToFavorite);
router.post('/cart/add', cartCtrl.addToCart);
router.post('/cart/toggleSelectGoods', cartCtrl.toggleSelectGoods);
router.get('/cart/checkStorage', cartCtrl.checkStorage);
router.put('/cart/updateProduct', cartCtrl.modifyProduct);
router.get('/cart/data', cartCtrl.getCartData);

// 结算
router.get('/order', auth, order.index);
router.get('/order/compute', auth, order.compute);
router.post('/order/submit', auth, order.orderSub);

// 支付
router.get('/pay/online', auth, pay.online);

router.post('/pay/online/go', auth, pay.toPay);

// 支付回调
router.get('/pay/callback/:type', auth, pay.callback);

module.exports = router;