Authored by htoooth

Merge branch 'feature/3PartyAd'

/**
* 广告联盟接口
* Created by TaoHuang on 2016/11/8.
*/
'use strict';
const config = global.yoho.config;
const helpers = global.yoho.helpers;
const crypto = global.yoho.crypto;
const Fn = require('lodash/fp');
const _ = require('lodash');
const jump = (req, res) => {
let _QYH_UNION = req.query._QYH_UNION || '';
let target = req.query.target || '';
let encodeStr = Fn.pipe(decodeURIComponent, _.partial(crypto.encryption, null), encodeURIComponent);
res.cookie('_QYH_UNION', encodeStr(_QYH_UNION), {
domain: config.cookieDomain,
maxAge: 60 * 60 * 24 * 1000 // 一天
});
res.redirect(target || helpers.urlFormat(''));
};
module.exports = {
jump
};
... ...
/**
* sub app 3party-ad
* @author: htoooth<ht.anglenx@gmail.com>
* @date: 2016/11/08
*/
var express = require('express'),
path = require('path');
var app = express();
// set view engin
var doraemon = path.join(__dirname, '../../doraemon/views'); // parent view root
app.on('mount', function(parent) {
delete parent.locals.settings; // 不继承父 App 的设置
Object.assign(app.locals, parent.locals);
});
app.use(global.yoho.hbs({
extname: '.hbs',
defaultLayout: 'layout',
layoutsDir: doraemon,
partialsDir: [path.join(__dirname, 'views/partial')],
views: path.join(__dirname, 'views/action'),
helpers: global.yoho.helpers
}));
// router
app.use(require('./router'));
module.exports = app;
... ...
/**
* router of sub app 3party-ad
* @author: htoooth<ht.anglenx@gmail.com>
* @date: 2016/11/08
*/
'use strict';
const router = require('express').Router(); // eslint-disable-line
const cRoot = './controllers';
const ads = require(`${cRoot}/ads`); // 第三方广告平台对接
// Your controller here
router.get('/ads', ads.jump);
module.exports = router;
... ...
... ... @@ -15,7 +15,10 @@ module.exports = app => {
app.use('/product', require('./apps/product')); // 商品相关页面
app.use(require('./apps/passport')); // 登录注册
app.use('/home', require('./apps/home')); // 会员中心
app.use('/brands', require('./apps/brands'));
app.use('/guang', require('./apps/guang'));
app.use('/brands', require('./apps/brands')); // 品牌一览
app.use('/guang', require('./apps/guang')); // 逛
app.use('/cart', require('./apps/cart'));// 购物车
// 第三方,如广告联盟
app.use('/3party', require('./apps/3party'));
};
... ...