Merge branch 'feature/3PartyAd'
Showing
7 changed files
with
85 additions
and
2 deletions
apps/3party/controllers/ads.js
0 → 100644
1 | +/** | ||
2 | + * 广告联盟接口 | ||
3 | + * Created by TaoHuang on 2016/11/8. | ||
4 | + */ | ||
5 | + | ||
6 | +'use strict'; | ||
7 | + | ||
8 | +const config = global.yoho.config; | ||
9 | +const helpers = global.yoho.helpers; | ||
10 | +const crypto = global.yoho.crypto; | ||
11 | + | ||
12 | +const Fn = require('lodash/fp'); | ||
13 | +const _ = require('lodash'); | ||
14 | + | ||
15 | +const jump = (req, res) => { | ||
16 | + let _QYH_UNION = req.query._QYH_UNION || ''; | ||
17 | + let target = req.query.target || ''; | ||
18 | + let encodeStr = Fn.pipe(decodeURIComponent, _.partial(crypto.encryption, null), encodeURIComponent); | ||
19 | + | ||
20 | + res.cookie('_QYH_UNION', encodeStr(_QYH_UNION), { | ||
21 | + domain: config.cookieDomain, | ||
22 | + maxAge: 60 * 60 * 24 * 1000 // 一天 | ||
23 | + }); | ||
24 | + | ||
25 | + res.redirect(target || helpers.urlFormat('')); | ||
26 | +}; | ||
27 | + | ||
28 | +module.exports = { | ||
29 | + jump | ||
30 | +}; |
apps/3party/index.js
0 → 100644
1 | +/** | ||
2 | + * sub app 3party-ad | ||
3 | + * @author: htoooth<ht.anglenx@gmail.com> | ||
4 | + * @date: 2016/11/08 | ||
5 | + */ | ||
6 | + | ||
7 | +var express = require('express'), | ||
8 | + path = require('path'); | ||
9 | + | ||
10 | +var app = express(); | ||
11 | + | ||
12 | +// set view engin | ||
13 | +var doraemon = path.join(__dirname, '../../doraemon/views'); // parent view root | ||
14 | + | ||
15 | +app.on('mount', function(parent) { | ||
16 | + delete parent.locals.settings; // 不继承父 App 的设置 | ||
17 | + Object.assign(app.locals, parent.locals); | ||
18 | +}); | ||
19 | + | ||
20 | +app.use(global.yoho.hbs({ | ||
21 | + extname: '.hbs', | ||
22 | + defaultLayout: 'layout', | ||
23 | + layoutsDir: doraemon, | ||
24 | + partialsDir: [path.join(__dirname, 'views/partial')], | ||
25 | + views: path.join(__dirname, 'views/action'), | ||
26 | + helpers: global.yoho.helpers | ||
27 | +})); | ||
28 | + | ||
29 | +// router | ||
30 | +app.use(require('./router')); | ||
31 | + | ||
32 | +module.exports = app; |
apps/3party/models/.gitkeeper
0 → 100644
apps/3party/router.js
0 → 100644
1 | +/** | ||
2 | + * router of sub app 3party-ad | ||
3 | + * @author: htoooth<ht.anglenx@gmail.com> | ||
4 | + * @date: 2016/11/08 | ||
5 | + */ | ||
6 | + | ||
7 | +'use strict'; | ||
8 | + | ||
9 | +const router = require('express').Router(); // eslint-disable-line | ||
10 | +const cRoot = './controllers'; | ||
11 | + | ||
12 | +const ads = require(`${cRoot}/ads`); // 第三方广告平台对接 | ||
13 | + | ||
14 | +// Your controller here | ||
15 | + | ||
16 | +router.get('/ads', ads.jump); | ||
17 | + | ||
18 | +module.exports = router; |
apps/3party/views/action/.gitkeeper
0 → 100644
apps/3party/views/partial/.gitkeeper
0 → 100644
@@ -15,7 +15,10 @@ module.exports = app => { | @@ -15,7 +15,10 @@ module.exports = app => { | ||
15 | app.use('/product', require('./apps/product')); // 商品相关页面 | 15 | app.use('/product', require('./apps/product')); // 商品相关页面 |
16 | app.use(require('./apps/passport')); // 登录注册 | 16 | app.use(require('./apps/passport')); // 登录注册 |
17 | app.use('/home', require('./apps/home')); // 会员中心 | 17 | app.use('/home', require('./apps/home')); // 会员中心 |
18 | - app.use('/brands', require('./apps/brands')); | ||
19 | - app.use('/guang', require('./apps/guang')); | 18 | + app.use('/brands', require('./apps/brands')); // 品牌一览 |
19 | + app.use('/guang', require('./apps/guang')); // 逛 | ||
20 | app.use('/cart', require('./apps/cart'));// 购物车 | 20 | app.use('/cart', require('./apps/cart'));// 购物车 |
21 | + | ||
22 | + // 第三方,如广告联盟 | ||
23 | + app.use('/3party', require('./apps/3party')); | ||
21 | }; | 24 | }; |
-
Please register or login to post a comment