Authored by jinhu.tung

init shopping cart products

... ... @@ -11,22 +11,36 @@ const _ = require('lodash');
exports.index = (req, res) => {
cartModel.getCartInfo().then((result) => {
console.log('proLength:', result[0].length && result[1].length && result[2].length);
const mock = {
loggedIn: true,
prosNum: result[0].length && result[1].length && result[2].length,
selectedGoods: {
prePros: result[0],
normalPros: result[1],
noMorePros: result[2]
}
prosNum: result[0].preSalePros.length && result[1].commonPros.length && result[2].invalidPros.length
};
if (result[0].preSalePros) {
_.merge(mock, {
preSalePros: result[0].preSalePros
});
}
if (result[1].commonPros) {
_.merge(mock, {
commonPros: result[1].commonPros
});
}
if (result[2].invalidPros) {
_.merge(mock, {
invalidPros: result[2].invalidPros
});
}
console.log(mock);
res.display('cart', _.merge({
module: 'shopping',
page: 'cart'
}, result[0], result[1], result[2],
mock));
}, mock));
}).catch((err) => {
res.send(err);
... ...
... ... @@ -24,7 +24,7 @@ app.engine('.hbs', hbs({
defaultLayout: 'layout',
layoutsDir: doraemon,
partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`],
helpers: 'helpers'
helpers: global.yoho.helpers
}));
// router
... ...
... ... @@ -18,8 +18,46 @@ var Promise = require('bluebird');
const getPreSaleProducts = () => {
return Promise.resolve({
preSalePros: [{
productName: 'Alle nove 小方领长袖衬衫【哥本哈根】'
}]
gender: '1',
tags: '[Object]',
status: 1,
smallSortId: 115,
vip1Price: 379.04999999999995,
isGlobal: 'N',
vip3Price: 351.12,
isOutlets: 2,
isDiscount: 'Y',
brandDomain: 'allenove',
isSpecial: 'N',
goodsList: '[Object]',
isAdvance: 'N',
productId: 286135,
vipDiscountType: 1,
salesNum: 0,
cnAlphabet: 'ALLENOVE95S11GeBenHaGen',
productSkn: 51160998,
shelveTime: 1455616165,
vip2Price: 359.1,
editTime: 1455616165,
isNew: 'N',
isLimited: 'N',
brandName: 'Alle nove',
maxSortId: 1,
productName: 'Alle nove 小方领长袖衬衫【哥本哈根】',
brandId: 1007,
defaultImages: 'http://img13.static.yhbimg.com/goodsimg/2015/10/21/05/0279bf8ab67a6c962b08e37b3a13ce3401.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
stockNumber: 29,
storageNum: 29,
isSoonSoldOut: false,
middleSortId: 12,
salesPrice: 399,
isPromotion: 101,
marketPrice: 1299,
vipPrice: 0,
id: 51160998,
thumb: 'http://img13.static.yhbimg.com/goodsimg/2015/10/21/05/0279bf8ab67a6c962b08e37b3a13ce3401.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
url: 'http://www.yohobuy.com/product/pro_286135_367985/ALLENOVE95S11GeBenHaGen.html',
brandUrl: '//allenove.yohobuy.com' }]
});
};
... ...
<div class="home-page">
<div class="center-content">
<div class="blk-page center-content">
{{> common/bc-nav}}
{{> common/info}}
{{ selectedGoods.length }}
... ...
{{> common/cart-list-header}}
{{> common/cart-list-body}}
{{> common/statement}}
\ No newline at end of file
... ...
{{#prePros}}
预售商品
{{/prePros}}
{{# if preSalePros}}
<div class="cart-pro-list">
<div class="title">
<span class="main">预售商品</span>
<span class="note">不同上市期的商品我们将为您先到先发</span>
</div>
<div class="pro-list">
{{#each preSalePros}}
<ul>
<li class="chk">
<label class="toggle-chk-item">
<span class="iconfont checkbox not-checked">&#xe601;</span>
<span class="iconfont checkbox checked">&#xe602;</span>
</label>
</li>
<li>
<img src="{{image defaultImages 100 134}}" alt="{{productName}}">
</li>
<li class="pro-info">
<div class="brand-name">{{brandName}}</div>
<div class="pro-name">{{productName}}</div>
<div class="size">尺寸: USB</div>
<div class="published-at">上市期: 2016年8月</div>
</li>
<li class="price-num">
<span class="price sale-price">¥{{salesPrice}}</span>
{{> common/stepper }}
</li>
<li class="total-price-action">
<span class="price item-total-price">¥1289.00</span>
<div class="actions">
<div class="remove-item action"><span class="iconfont">&#xe614;</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
<div class="send-to-favorite action">移入收藏夹</div>
</div>
</li>
</ul>
{{/each}}
</div>
</div>
{{/ if}}
{{#normalPros }}
普通商品
{{/normalPros}}
{{# commonPros }}
{{#noMorePros}}
库存不足
{{/noMorePros}}
{{/ commonPros}}
{{# invalidPros}}
{{/ invalidPros}}
... ...
<div class="stepper">
<div class="minus action">
<span class="iconfont">&#xe621;</span>
</div>
<div class="num">
<input type="text" class="input" />
</div>
<div class="plus action">
<span class="iconfont">&#xe61f;</span>
</div>
</div>
\ No newline at end of file
... ...
.cart-pro-list {
.title {
border-bottom: 1px solid #eee;
font-size: 16px;
font-weight: bold;
color: #1b1b1b;
padding-left: 30px;
padding-bottom: 17px;
width: 100%;
.note {
font-size: 14px;
color: #999;
font-weight: normal;
}
}
ul {
height: 180px;
border-bottom: 1px solid #eee;
padding: 24px 30px;
li {
float: left;
height: 134px;
}
.chk {
padding: 58px 60px 58px 0;
}
.toggle-chk-item {
span {
font-weight: bold;
}
.not-checked {
color: #999;
}
}
.checked {
display: none;
}
.chk-all {
.checked {
display: inline-block;
}
.not-checked {
display: none;
}
}
.iconfont {
font-size: 16px;
line-height: 16px;
}
.pro-info {
width: 342px;
padding-left: 42px;
font-size: 12px;
font-weight: bold;
.brand-name {
margin-bottom: 19px;
}
.pro-name {
height: 30px;
width: 234px;
word-wrap: break-word;
margin-bottom: 13px;
}
.size {
margin-bottom: 13px;
}
.published-at {
margin-bottom: 13px;
}
}
.price {
display: inline-block;
padding: 59px 0;
font-size: 16px;
font-weight: bold;
}
.price-num {
width: 300px;
padding-left: 50px;
position: relative;
.stepper {
position: absolute;
right: 15px;
padding: 52px 0;
}
}
.total-price-action {
width: 270px;
padding-left: 50px;
position: relative;
.actions {
position: absolute;
right: 0;
display: inline-block;
height: 51px;
padding: 42px 0;
}
.action {
margin-bottom: 24px;
font-size: 13px;
}
}
}
}
... ...
... ... @@ -2,4 +2,6 @@
@import "info_bar"; /* 信息提示 */
@import "empty_cart"; /* 空购物车 */
@import "cart_header"; /* 购物车标题头部 */
@import "stepper"; /* 增减数量 */
@import "cart_products"; /* 购物车商品 */
@import "statement"; /* 结算模块 */
... ...
.stepper {
display: inline-block;
div {
float: left;
}
.action {
width: 20px;
height: 28px;
text-align: center;
border: 1px solid #eee;
color: #999;
&:hover {
background-color: #666;
cursor: pointer;
color: #fff;
}
.iconfont {
font-size: 14px;
line-height: 28px;
height: 14px;
display: inline-block;
}
}
.input {
margin: 0 5px;
width: 38px;
height: 28px;
text-align: center;
}
}
... ...