router.js 11.8 KB
/**
 * router of sub app product
 * @author: weiqingting<qingting.wei@yoho.cn>
 * @date: 2016/05/06
 */
'use strict';

const express = require('express');
const router = express.Router(); // eslint-disable-line
const cRoot = './controllers';
const captcha = require('../passport/controllers/captcha');
const csrf = require('../../doraemon/middleware/csrf')();


const newUserController = require(`${cRoot}/new-user`);

const tabsMiddleware = require(`${cRoot}/general-tabs`);
const indexController = require(`${cRoot}/index`);
const commentController = require(`${cRoot}/comment`);

const consultController = require(`${cRoot}/consult`);

// const complaintsController = require(`${cRoot}/complaints`);
const spreadController = require(`${cRoot}/spread`);
const messageController = require(`${cRoot}/message`);

const returnsController = require(`${cRoot}/returns`);

// const IndexController = require(`${cRoot}/index`);
const currencyController = require(`${cRoot}/currency`);
const personalController = require(`${cRoot}/qrcode`);

const redenvelopesController = require(`${cRoot}/redenvelopes`);
const vipController = require(`${cRoot}/vip`);

// const FavoriteController = require(`${cRoot}/favorite`);
const couponsController = require(`${cRoot}/coupons`);

const UserController = require(`${cRoot}/user`);
const bindController = require(`${cRoot}/3party-bind`);

const AccountController = require(`${cRoot}/account`);
const favoriteController = require(`${cRoot}/favorite`);
const ordersController = require(`${cRoot}/orders`);

const AddressController = require(`${cRoot}/address`);

const giftController = require(`${cRoot}/gift`);
const invoiceController = require(`${cRoot}/invoice`);

const meGiftController = require(`${cRoot}/me-gift`);


// 首页
router.get(['/index', '/'], tabsMiddleware.getCommonHeaderNew, indexController.index);
router.get('/index/newsAvatar', indexController.newsAvatar);
router.get('/index/async', indexController.asyncData);

// 查看二维码
router.get('/QRcode', tabsMiddleware.getCommonHeader, personalController.QRcode);

// 我的评论
router.get('/comment', tabsMiddleware.getCommonHeader, commentController.index);

router.post('/comment/saveComment', commentController.saveComment);

router.get('/comment/order', tabsMiddleware.getCommonHeader, commentController.commentList4Order);

// 我的咨询
router.get('/consult', tabsMiddleware.getCommonHeader, consultController.index);

// 我的投诉
// router.get('/complaints', [tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], complaintsController.index);
// router.post('/complaints/submit', complaintsController.submit);
// router.post('/complaints/cancel', complaintsController.cancel);

// 我的推广
router.get('/spread', tabsMiddleware.getCommonHeader, spreadController.index);
router.post('/spread/updateword', spreadController.updateword);

// 我的消息
router.get('/message', tabsMiddleware.getCommonHeader, messageController.index);

router.get('/message/detail', tabsMiddleware.getCommonHeader, messageController.detail);

router.get('/message/del', messageController.delMsg);
router.get('/message/read', messageController.readMsg);
router.get('/message/pickCoupon', messageController.pickCoupon);

// 我的退/换货
router.get('/returns', tabsMiddleware.getCommonHeader, returnsController.index);
router.get('/returns/refundrequest', tabsMiddleware.getCommonHeader, returnsController.refundApply);// 退货申请
router.post('/returns/saveRefund', tabsMiddleware.getCommonHeader, returnsController.saveRefund);// 提交退货
router.get('/returns/refundSuccess', tabsMiddleware.getCommonHeader, returnsController.refundSuccess);// 退货成功
router.get('/returns/refundDetail', tabsMiddleware.getCommonHeader, returnsController.refundDetail);// 退货详情
router.post('/returns/saveExchange', tabsMiddleware.getCommonHeader, returnsController.saveExchange);// 提交退货
router.get('/returns/exchangerequest', tabsMiddleware.getCommonHeader, returnsController.exchangeApply);// 换货申请
router.get('/returns/exchangeSuccess', tabsMiddleware.getCommonHeader, returnsController.exchangeSuccess);// 换货成功
router.get('/returns/exchangeDetail', tabsMiddleware.getCommonHeader, returnsController.exchangeDetail);// 换货详情
router.post('/returns/getDelivery', tabsMiddleware.getCommonHeader, returnsController.getDelivery);// 获取换货方式
router.post('/returns/cancelRefund', tabsMiddleware.getCommonHeader, returnsController.cancelRefund);// 取消退货
router.post('/returns/cancelChange', tabsMiddleware.getCommonHeader, returnsController.cancelChange);// 取消换货
router.post('/returns/setExpressNumber', tabsMiddleware.getCommonHeader, returnsController.setExpressNumber);// 设置快递
router.post('/returns/api/refundCompute', returnsController.refundCompute);

router.get('/returns/success', returnsController.index);

// router.get('/index', [tabsMiddleware.getCommonHeader, tabsMiddleware.getHomeNav], IndexController.index);

/* 我的有货币 */
router.get('/currency', tabsMiddleware.getCommonHeader, currencyController.index);

/* 我的红包 */
router.get('/redenvelopes', tabsMiddleware.getCommonHeader, redenvelopesController.index);

/* 我的VIP */
router.get('/vip', tabsMiddleware.getCommonHeader, vipController.index);
router.get('/vip/details', tabsMiddleware.getCommonHeader, vipController.details);

/* 我的优惠卷 */
router.get('/coupons', tabsMiddleware.getCommonHeader, couponsController.index);

/** ******************************* 我的收藏开始 *****************************************/
// 我的收藏
router.get('/favorite', tabsMiddleware.getCommonHeader, favoriteController.index);

// 品牌页新品到着
router.get('/favorite/newproduct', favoriteController.newProduct);

// 降价提醒
router.get('/favorite/reduction', tabsMiddleware.getCommonHeader, favoriteController.reduction);

// 设置降价提醒
router.get('/favorite/notice', favoriteController.notice);

// 取消降价提醒
router.get('/favorite/cancelnotice', favoriteController.cancelNotice);

// 取消收藏
router.get('/favorite/cancel', favoriteController.cancel);

/** ******************************* 我的收藏结束 *****************************************/

/** ******************************* 我的订单开始 *****************************************/
router.get('/orders', tabsMiddleware.getCommonHeader, ordersController.index);

// 重新加入购物车
router.post('/orders/readd', ordersController.reBuy);

// 删除订单
router.post('/orders/delorder', ordersController.del);

// 修改地址
router.post('/orders/modifyAddress', ordersController.modifyAddress);

// 确认订单
router.post('/orders/confirmOrder', ordersController.confirm);

// 取消订单
router.post('/orders/cancelOrder', ordersController.cancel);

// 订单详情
router.get('/orders/detail', tabsMiddleware.getCommonHeader, ordersController.detail);

// 物流信息
router.get('/orders/express', ordersController.express);

// 申请退款
router.get('/orders/refund', ordersController.refund);

// 申请退款原因
router.get('/orders/refundreason', ordersController.refundReason);

/** ******************************* 我的订单结束 *****************************************/


// router.get('/coupons', CouponsController.index);
router.get('/user', csrf, tabsMiddleware.getCommonHeader, UserController.index);

router.post('/user/edituserinfo', UserController.editUserInfo);

router.post('/user/editusercontactinfo', UserController.editUserContactInfo);

router.post('/user/edituserhabitsinfo', UserController.editUserHabitsInfo);

router.post('/user/edituserlikebrand', UserController.editUserLikeBrand);

router.post('/user/isbrandname', UserController.isBrandName);

// 二维码登录
// router.post('/passport/login/qrcode/refresh', bindController.local.qrcode.refresh);           // 刷新二维码
// router.post('/passport/login/qrcode/check', bindController.local.qrcode.check);       // 验证二维码的状态

// 微信登录
router.get('/bind/wechat', bindController.wechat.login); // 微信登录, 兼容 PHP 的路径
router.get('/bind/wechat/callback', bindController.wechat.callback);

// sina登录
router.get('/bind/sina', bindController.sina.login);
router.get('/bind/sina/callback', bindController.sina.callback);

// qq登录
router.get('/bind/qq', bindController.qq.login);
router.get('/bind/qq/callback', bindController.qq.callback);

// alipay登录
router.get('/bind/alipay', bindController.alipay.login);
router.get('/bind/alipay/callback', bindController.alipay.callback);

// douban登录
router.get('/bind/douban', bindController.douban.login);

// router.get('/bind/douban/callback', bindController.douban.callback);

// renren登录
router.get('/bind/renren', bindController.renren.login);
router.get('/bind/renren/callback', bindController.renren.callback);

router.post('/cancelbind/:type', csrf, bindController.cancelBind);

// 账号安全
router.get('/account', tabsMiddleware.getCommonHeader, AccountController.index);

router.get('/account/userpwd', tabsMiddleware.getCommonHeader, captcha.required, AccountController.userPwd);

router.get('/account/email', tabsMiddleware.getCommonHeader, captcha.required, AccountController.userEmail);

router.get('/account/mobile', tabsMiddleware.getCommonHeader, captcha.required, AccountController.userMobile);

router.post('/account/checkpassword', tabsMiddleware.getCommonHeader, AccountController.checkPassword);

router.post('/account/verifypassword', tabsMiddleware.getCommonHeader, AccountController.verifyPassword);

router.post('/account/modifypwd', tabsMiddleware.getCommonHeader, AccountController.modifyPwd);

router.post('/account/sendemail', captcha.requiredAPI, AccountController.sendEmail);

router.post('/account/checkemail', tabsMiddleware.getCommonHeader, AccountController.checkEmail);

router.post('/account/modifyemail', tabsMiddleware.getCommonHeader, AccountController.modifyEmail);

router.get('/account/sendemailsuccess', tabsMiddleware.getCommonHeader, AccountController.sendEmailSuccess);

router.get('/account/mailresult', tabsMiddleware.getCommonHeader, AccountController.mailResult);

router.post('/account/checkmobile', AccountController.checkMobile);

router.post('/account/checkmobilemsg', AccountController.checkMobileMsg);

router.post('/account/sendmobilemsg', captcha.requiredAPI, AccountController.sendMobileMsg);

router.post('/account/modifymobile', AccountController.modifyMobile);

// 地址管理

router.get('/address', tabsMiddleware.getCommonHeader, AddressController.index);

router.get('/address/area', UserController.getProviceList);

router.get('/address/editAddress', AddressController.editAddress);

router.post('/address/saveAddress', AddressController.saveAddress);

router.get('/address/delAddress', AddressController.delAddress);

router.get('/address/defaultAddress', AddressController.defaultAddress);

// 兑换礼品卡

router.get('/gift', tabsMiddleware.getCommonHeader, captcha.required, giftController.index);

router.post('/gift/exchange', giftController.exchange);

// 我的发票
router.get('/invoice', tabsMiddleware.getCommonHeader, invoiceController.index);
router.get('/invoice/detail', invoiceController.detail);
router.post('/invoice/supply', invoiceController.supply);

// 是否新客(仅操作cookie)
router.get('/newuser', newUserController.check);

// 我的礼品卡
router.get('/megift', tabsMiddleware.getCommonHeader, meGiftController.index);
router.post('/megift/sendEmailCode', meGiftController.sendEmailCode);// 发送邮箱验证码
router.post('/megift/verifyEmail', meGiftController.verifyEmail);// 验证邮箱验证码
// 检查是否绑定手机号、发验证码
router.post('/megift/smsBind', meGiftController.smsBind);
router.post('/megift/changeMobile', meGiftController.changeMobile);// 修改绑定手机
router.post('/megift/activateGift', meGiftController.activateGift);// 激活礼品卡
router.get('/megift/detail', meGiftController.detail);// 消费明细

module.exports = router;