Showing
17 changed files
with
329 additions
and
1 deletions
apps/shopping/controllers/cart.js
0 → 100644
1 | +/** | ||
2 | + * 购物车 controller | ||
3 | + * @author: jinhu.dong<jinhu.dong@yoho.cn> | ||
4 | + * @date: 2016/07/04 | ||
5 | + */ | ||
6 | + | ||
7 | +'use strict'; | ||
8 | + | ||
9 | +const cartModel = require('../models/cart'); | ||
10 | +const _ = require('lodash'); | ||
11 | + | ||
12 | +exports.index = (req, res) => { | ||
13 | + cartModel.getCartInfo().then((result) => { | ||
14 | + | ||
15 | + res.render('cart', _.merge({ | ||
16 | + module: 'shopping', | ||
17 | + page: 'cart' | ||
18 | + }, result[0], result[1], result[2])); | ||
19 | + | ||
20 | + }).catch((err) => { | ||
21 | + res.send(err); | ||
22 | + }); | ||
23 | +}; |
apps/shopping/controllers/order.js
0 → 100644
apps/shopping/controllers/pay.js
0 → 100644
apps/shopping/index.js
0 → 100644
1 | +/** | ||
2 | + * sub app shopping | ||
3 | + * @author: jinhu.dong<jinhu.dong@yoho.cn> | ||
4 | + * @date: 2016/07/04 | ||
5 | + */ | ||
6 | + | ||
7 | +var express = require('express'), | ||
8 | + path = require('path'), | ||
9 | + hbs = require('express-handlebars'); | ||
10 | + | ||
11 | +var app = express(); | ||
12 | + | ||
13 | +// set view engin | ||
14 | +var doraemon = path.join(__dirname, '../../doraemon/views'); // parent view root | ||
15 | + | ||
16 | +app.on('mount', function(parent) { | ||
17 | + delete parent.locals.settings; // 不继承父 App 的设置 | ||
18 | + Object.assign(app.locals, parent.locals); | ||
19 | +}); | ||
20 | + | ||
21 | +app.set('views', path.join(__dirname, 'views/action')); | ||
22 | +app.engine('.hbs', hbs({ | ||
23 | + extname: '.hbs', | ||
24 | + defaultLayout: 'layout', | ||
25 | + layoutsDir: doraemon, | ||
26 | + partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`], | ||
27 | + helpers: 'helpers' | ||
28 | +})); | ||
29 | + | ||
30 | +// router | ||
31 | +app.use(require('./router')); | ||
32 | + | ||
33 | +module.exports = app; |
apps/shopping/models/cart.js
0 → 100644
1 | +/** | ||
2 | + * 购物车模型 model | ||
3 | + * @author: jinhu.dong<jinhu.dong@yoho.cn> | ||
4 | + * @date: 2016/07/04 | ||
5 | + */ | ||
6 | +'use strict'; | ||
7 | + | ||
8 | +var Promise = require('bluebird'); | ||
9 | + | ||
10 | +// const ServiceAPI = require(`${global.library}/api`).ServiceAPI; | ||
11 | +// const sign = require(`${global.library}/sign`); | ||
12 | +// const logger = require(`${global.library}/logger`); | ||
13 | +// const headerModel = require('../../../doraemon/models/header'); | ||
14 | + | ||
15 | +// var api = new ServiceAPI(); | ||
16 | + | ||
17 | +// 获取预售商品 | ||
18 | +const getPreSaleProducts = () => { | ||
19 | + return Promise.resolve({ | ||
20 | + preSalePros: [{ | ||
21 | + productName: 'Alle nove 小方领长袖衬衫【哥本哈根】' | ||
22 | + }] | ||
23 | + }); | ||
24 | +}; | ||
25 | + | ||
26 | +// 获取普通商品 | ||
27 | +const getNormalProducts = () => { | ||
28 | + return Promise.resolve({ | ||
29 | + commonPros: [{ gender: '1', | ||
30 | + tags: ['Object'], | ||
31 | + status: 1, | ||
32 | + smallSortId: 115, | ||
33 | + vip1Price: 379.04999999999995, | ||
34 | + isGlobal: 'N', | ||
35 | + vip3Price: 351.12, | ||
36 | + isOutlets: 2, | ||
37 | + isDiscount: 'Y', | ||
38 | + brandDomain: 'allenove', | ||
39 | + isSpecial: 'N', | ||
40 | + goodsList: ['Object'], | ||
41 | + isAdvance: 'N', | ||
42 | + productId: 286137, | ||
43 | + vipDiscountType: 1, | ||
44 | + salesNum: 0, | ||
45 | + cnAlphabet: 'ALLENOVE95S12SaiWeiLiYa', | ||
46 | + productSkn: 51160999, | ||
47 | + shelveTime: 1455616165, | ||
48 | + vip2Price: 359.1, | ||
49 | + editTime: 1455616165, | ||
50 | + isNew: 'N', | ||
51 | + isLimited: 'N', | ||
52 | + brandName: 'Alle nove', | ||
53 | + maxSortId: 1, | ||
54 | + productName: 'Alle nove 暗扣领长袖衬衫【塞维利亚】', | ||
55 | + brandId: 1007, | ||
56 | + defaultImages: 'http://img10.static.yhbimg.com/goodsimg/2015/10/21/03/01d7c265b0fa3fe1a582a73ad9175eab69.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80', | ||
57 | + stockNumber: 23, | ||
58 | + storageNum: 23, | ||
59 | + isSoonSoldOut: false, | ||
60 | + middleSortId: 12, | ||
61 | + salesPrice: 399, | ||
62 | + isPromotion: 101, | ||
63 | + marketPrice: 1299, | ||
64 | + vipPrice: 0, | ||
65 | + id: 51160999, | ||
66 | + thumb: 'http://img10.static.yhbimg.com/goodsimg/2015/10/21/03/01d7c265b0fa3fe1a582a73ad9175eab69.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80', | ||
67 | + url: 'http://www.yohobuy.com/product/pro_286137_367987/ALLENOVE95S12SaiWeiLiYa.html', | ||
68 | + brandUrl: '//allenove.yohobuy.com' }] | ||
69 | + }); | ||
70 | +}; | ||
71 | + | ||
72 | +// 获取失效商品 | ||
73 | +const getInvalidProducts = () => { | ||
74 | + return Promise.resolve({ | ||
75 | + invalidPros: [{ gender: '1', | ||
76 | + tags: ['Object'], | ||
77 | + status: 1, | ||
78 | + smallSortId: 115, | ||
79 | + vip1Price: 379.04999999999995, | ||
80 | + isGlobal: 'N', | ||
81 | + vip3Price: 351.12, | ||
82 | + isOutlets: 2, | ||
83 | + isDiscount: 'Y', | ||
84 | + brandDomain: 'allenove', | ||
85 | + isSpecial: 'N', | ||
86 | + goodsList: ['Object'], | ||
87 | + isAdvance: 'N', | ||
88 | + productId: 286139, | ||
89 | + vipDiscountType: 1, | ||
90 | + salesNum: 0, | ||
91 | + cnAlphabet: 'ALLENOVE95S13PuLuoWangSi', | ||
92 | + productSkn: 51161000, | ||
93 | + shelveTime: 1455616165, | ||
94 | + vip2Price: 359.1, | ||
95 | + editTime: 1455616165, | ||
96 | + isNew: 'N', | ||
97 | + isLimited: 'N', | ||
98 | + brandName: 'Alle nove', | ||
99 | + maxSortId: 1, | ||
100 | + productName: 'Alle nove 复古圆领长袖衬衫【普罗旺斯】', | ||
101 | + brandId: 1007, | ||
102 | + defaultImages: 'http://img12.static.yhbimg.com/goodsimg/2015/10/21/03/02705334cacca0a06edec049918290f7b3.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80', | ||
103 | + stockNumber: 12, | ||
104 | + storageNum: 12, | ||
105 | + isSoonSoldOut: false, | ||
106 | + middleSortId: 12, | ||
107 | + salesPrice: 399, | ||
108 | + isPromotion: 101, | ||
109 | + marketPrice: 1299, | ||
110 | + vipPrice: 0, | ||
111 | + id: 51161000, | ||
112 | + thumb: 'http://img12.static.yhbimg.com/goodsimg/2015/10/21/03/02705334cacca0a06edec049918290f7b3.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80', | ||
113 | + url: 'http://www.yohobuy.com/product/pro_286139_367989/ALLENOVE95S13PuLuoWangSi.html', | ||
114 | + brandUrl: '//allenove.yohobuy.com' }] | ||
115 | + }); | ||
116 | +}; | ||
117 | + | ||
118 | +// 移入收藏夹 | ||
119 | +exports.transferToFavorite = () => { | ||
120 | + // TODO | ||
121 | +}; | ||
122 | + | ||
123 | +// 获取购物车信息 | ||
124 | +exports.getCartInfo = () => { | ||
125 | + return Promise.all([ | ||
126 | + getPreSaleProducts(), | ||
127 | + getNormalProducts(), | ||
128 | + getInvalidProducts() | ||
129 | + ]); | ||
130 | +}; |
apps/shopping/models/order.js
0 → 100644
apps/shopping/models/pay.js
0 → 100644
1 | + |
apps/shopping/router.js
0 → 100644
1 | +/** | ||
2 | + * router of sub app shopping | ||
3 | + * @author: jinhu.dong<jinhu.dong@yoho.cn> | ||
4 | + * @date: 2016/07/04 | ||
5 | + */ | ||
6 | + | ||
7 | +'use strict'; | ||
8 | + | ||
9 | +const router = require('express').Router(); // eslint-disable-line | ||
10 | +const cRoot = './controllers'; | ||
11 | + | ||
12 | +// cart related controllers | ||
13 | +const cartCtrl = require(`${cRoot}/cart`); | ||
14 | + | ||
15 | +router.get('/cart', cartCtrl.index); | ||
16 | + | ||
17 | + | ||
18 | +module.exports = router; |
apps/shopping/views/action/cart.hbs
0 → 100644
1 | +<div class="cart-bc"> | ||
2 | + <ul class="breadcrumb"> | ||
3 | + <li class="level-1 current"><a href="/">我的购物袋<em></em><i></i></a></li> | ||
4 | + <li class="level-2"><a href="/vehicles/">填写核对订单信息<em></em><i></i></a></li> | ||
5 | + <li class="level-3"><a href="/vehicles/vans/">成功提交订单<em></em><i></i></a></li> | ||
6 | + </ul> | ||
7 | +</div> |
apps/shopping/views/partial/common/info.hbs
0 → 100644
@@ -10,5 +10,7 @@ module.exports = app => { | @@ -10,5 +10,7 @@ module.exports = app => { | ||
10 | app.use('/partial', require('./apps/partial')); // 组件demo | 10 | app.use('/partial', require('./apps/partial')); // 组件demo |
11 | 11 | ||
12 | // 业务模块 | 12 | // 业务模块 |
13 | - //app.use('/passport', require('./apps/passport')); | 13 | + // app.use('/passport', require('./apps/passport')); |
14 | + | ||
15 | + app.use('/shopping', require('./apps/shopping')); // 购物车 | ||
14 | }; | 16 | }; |
public/js/shopping/cart.page.js
0 → 100644
1 | + |
public/scss/shopping/_breadcrumb.css
0 → 100644
1 | +.cart-bc { | ||
2 | + width: 100%; | ||
3 | + position: relative; | ||
4 | + background: #999; | ||
5 | +} | ||
6 | + | ||
7 | +.breadcrumb { | ||
8 | + list-style: none; | ||
9 | + overflow: hidden; | ||
10 | + margin: 0; | ||
11 | + padding: 0; | ||
12 | + height: 34px; | ||
13 | + | ||
14 | + .current { | ||
15 | + background: #1b1b1b; | ||
16 | + color: #fff; | ||
17 | + z-index: 1; | ||
18 | + | ||
19 | + i { | ||
20 | + border-color: #fff transparent #fff #1b1b1b; | ||
21 | + } | ||
22 | + } | ||
23 | + | ||
24 | + li { | ||
25 | + float: left; | ||
26 | + width: 365px; | ||
27 | + text-align: center; | ||
28 | + position: relative; | ||
29 | + z-index: 2; | ||
30 | + font-weight: bold; | ||
31 | + font-size: 14px; | ||
32 | + line-height: 32px; | ||
33 | + | ||
34 | + &:last-child { | ||
35 | + i { | ||
36 | + right: -17px; | ||
37 | + } | ||
38 | + } | ||
39 | + | ||
40 | + a { | ||
41 | + color: #fff; | ||
42 | + width: 100%; | ||
43 | + display: inline-block; | ||
44 | + position: relative; | ||
45 | + z-index: 0; | ||
46 | + } | ||
47 | + | ||
48 | + em { | ||
49 | + position: absolute; | ||
50 | + right: -24px; | ||
51 | + top: -8px; | ||
52 | + width: 0; | ||
53 | + height: 0; | ||
54 | + line-height: 0; | ||
55 | + border-width: 24px 0 24px 24px; | ||
56 | + border-color: transparent transparent transparent #fff; | ||
57 | + border-style: dashed dashed dashed solid; | ||
58 | + } | ||
59 | + | ||
60 | + i { | ||
61 | + position: absolute; | ||
62 | + right: -6px; | ||
63 | + top: 0; | ||
64 | + width: 0; | ||
65 | + height: 0; | ||
66 | + line-height: 0; | ||
67 | + border-width: 17px 0 17px 17px; | ||
68 | + border-color: #fff transparent #fff #999; | ||
69 | + border-style: dashed dashed dashed solid; | ||
70 | + z-index: 1000; | ||
71 | + } | ||
72 | + } | ||
73 | + | ||
74 | + .level-1 { | ||
75 | + width: 375px; | ||
76 | + } | ||
77 | + | ||
78 | + .level-2 { | ||
79 | + width: 400px; | ||
80 | + } | ||
81 | + | ||
82 | + .level-3 { | ||
83 | + width: 375px; | ||
84 | + } | ||
85 | +} |
public/scss/shopping/_index.css
0 → 100644
public/scss/shopping/_info_bar.css
0 → 100644
-
Please register or login to post a comment