Authored by yyq

sub domain

... ... @@ -39,6 +39,7 @@ global.utils = path.resolve('./utils');
app.locals.devEnv = app.get('env') === 'development';
app.locals.version = pkg.version;
app.set('subdomain offset', 2);
app.set('view engine', '.hbs');
app.set('views', './doraemon/views');
app.engine('.hbs', hbs({
... ... @@ -84,6 +85,7 @@ const logger = global.yoho.logger;
// dispatcher
try {
const subDomain = require('./doraemon/middleware/sub-domain');
const mobileCheck = require('./doraemon/middleware/mobile-check');
const user = require('./doraemon/middleware/user');
const seo = require('./doraemon/middleware/seo');
... ... @@ -92,6 +94,7 @@ try {
const setPageInfo = require('./doraemon/middleware/set-pageinfo');
// YOHO 前置中间件
app.use(subDomain());
app.use(mobileCheck());
app.use(setYohoData());
app.use(user());
... ...
... ... @@ -71,10 +71,14 @@ exports.new = (req, res, next) => {
* @return {[type]} [description]
*/
exports.brand = (req, res, next) => {
let brandDomain = req.brandDomain || 'sctest1';
let brandDomain = req.params.brandDomain;
let shopId = req.query.shopId;
let resData = {};
if (!brandDomain) {
return next();
}
// shopId存在,直接走店铺
if (shopId) {
return shop(shopId, req, res, next);
... ... @@ -82,6 +86,7 @@ exports.brand = (req, res, next) => {
// 获取品牌信息
list.getBrandInfo({domain: brandDomain}).then(brandInfo => {
switch (parseInt(brandInfo.type, 10)) {
case 1:
// 搜索
... ...
... ... @@ -70,7 +70,7 @@ router.get('/list/index', list.index);
router.get('/list/new', list.new);
// 品牌页
router.get('/list/brand', list.brand);
router.get('/brand/:brandDomain', list.brand);
router.get('/shoplist', list.shopList); // 店铺列表页
router.post('/shop/togglecollect', favorite.collectShop); // 店铺收藏
... ...
/**
* 匹配subdomain
* @author: 杨延青<yanqing.yang@yoho.cn>
* @date: 2016/6/16
*/
'use strict';
module.exports = () => {
return (req, res, next) => {
if (req.subdomains.length) {
switch (req.subdomains) {
case 'www': // 主站
case 'new': // 原新版
case 'search': // 搜索
case 'guang': // 逛
case 'list': // 商品列表
case 'sale': // 促销
case 'shop': // 商家入驻
case 'item':// 商品详情页
break;
default: // 其它(识别为品牌)
req.url = `/product/brand/${req.subdomains[0]}`;
break;
}
}
next();
};
};
... ...

13 KB | W: | H:

13.8 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
... ... @@ -146,7 +146,7 @@
.coupon-title {
width: 162px;
height: 100%;
background: url(product/coupon-title.png);
background: url('/product/coupon-title.png');
}
}
... ... @@ -266,7 +266,7 @@
color: #ffc513;
text-align: center;
line-height: 57px;
background: url(product/hat.png);
background: url('/product/hat.png');
}
}
... ...