Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yoho-blk
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
1
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
jinhu.tung
9 years ago
Commit
0b30e64b49350de0532e87726e57b5ef1e89575d
2 parents
beccf7be
c79df398
error and style
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
29 deletions
apps/shopping/controllers/cart.js
public/img/sprite.img.png
public/scss/shopping/_breadcrumb.css
apps/shopping/controllers/cart.js
View file @
0b30e64
...
...
@@ -9,7 +9,7 @@
const
cartModel
=
require
(
'../models/cart'
);
const
_
=
require
(
'lodash'
);
exports
.
index
=
(
req
,
res
)
=>
{
exports
.
index
=
(
req
,
res
,
next
)
=>
{
const
shoppingKey
=
req
.
cookies
.
_SPK
||
null
;
const
uid
=
req
.
user
.
uid
||
null
;
...
...
@@ -28,14 +28,12 @@ exports.index = (req, res) => {
// code 500
res
.
send
(
result
);
}
}).
catch
((
err
)
=>
{
res
.
send
(
err
);
});
}).
catch
(
next
);
};
// 修改数量
exports
.
changeProductNum
=
(
req
,
res
)
=>
{
exports
.
changeProductNum
=
(
req
,
res
,
next
)
=>
{
const
changeType
=
req
.
body
.
changeType
;
// const changeTo = req.body.changeTo;
...
...
@@ -52,7 +50,7 @@ exports.changeProductNum = (req, res) => {
sku
,
goodTpye
}).
then
(
result
=>
{
console
.
log
(
'changeProductNum-INCREASE-result:'
,
result
);
//
console.log('changeProductNum-INCREASE-result:', result);
if
(
result
.
code
===
200
)
{
cartModel
.
getCartData
(
shoppingKey
,
uid
).
then
(
cartData
=>
{
res
.
json
(
_
.
merge
(
...
...
@@ -63,7 +61,7 @@ exports.changeProductNum = (req, res) => {
}
else
{
res
.
json
(
result
);
}
});
})
.
catch
(
next
)
;
}
else
if
(
changeType
===
'DECREASE'
)
{
cartModel
.
modifyProductNum
({
...
...
@@ -73,7 +71,7 @@ exports.changeProductNum = (req, res) => {
sku
,
goodTpye
}).
then
(
result
=>
{
console
.
log
(
'changeProductNum-DECREASE-result:'
,
JSON
.
stringify
(
result
));
//
console.log('changeProductNum-DECREASE-result:', JSON.stringify(result));
if
(
result
.
code
===
200
)
{
cartModel
.
getCartData
(
shoppingKey
,
uid
).
then
(
cartData
=>
{
res
.
json
(
_
.
merge
(
...
...
@@ -84,12 +82,12 @@ exports.changeProductNum = (req, res) => {
}
else
{
res
.
json
(
result
);
}
});
})
.
catch
(
next
)
;
}
};
// 删除商品
exports
.
removeProduct
=
(
req
,
res
)
=>
{
exports
.
removeProduct
=
(
req
,
res
,
next
)
=>
{
const
params
=
{};
const
uid
=
req
.
user
.
uid
;
const
shoppingKey
=
req
.
cookies
.
_SPK
;
...
...
@@ -107,16 +105,16 @@ exports.removeProduct = (req, res) => {
_
.
merge
(
params
,
{
product_sku_list
:
productSkuList
});
}
console
.
log
(
'remove---params:'
,
params
);
//
console.log('remove---params:', params);
cartModel
.
removeGoods
(
params
).
then
(
result
=>
{
console
.
log
(
'remove-result:'
,
result
);
//
console.log('remove-result:', result);
res
.
json
(
_
.
merge
(
cartModel
.
filterCartData
(
result
,
uid
),
{
code
:
result
.
code
,
message
:
result
.
message
}));
});
})
.
catch
(
next
)
;
};
// 收藏商品
exports
.
sendToFavorite
=
(
req
,
res
)
=>
{
exports
.
sendToFavorite
=
(
req
,
res
,
next
)
=>
{
const
params
=
{};
const
uid
=
req
.
user
.
uid
;
const
productSkuList
=
req
.
body
.
skuList
;
...
...
@@ -134,7 +132,7 @@ exports.sendToFavorite = (req, res) => {
cartModel
.
transferToFavorite
(
params
).
then
(
result
=>
{
console
.
log
(
'transferToFavorite-result:'
,
result
);
res
.
json
(
_
.
merge
(
cartModel
.
filterCartData
(
result
,
uid
),
{
code
:
result
.
code
,
message
:
result
.
message
}));
});
})
.
catch
(
next
)
;
};
// 编辑商品颜色和尺寸
...
...
@@ -158,7 +156,7 @@ exports.editProduct = (req, res) => {
};
// 添加商品到购物车
exports
.
addToCart
=
(
req
,
res
)
=>
{
exports
.
addToCart
=
(
req
,
res
,
next
)
=>
{
const
productSku
=
req
.
body
.
productSku
;
const
buyNumber
=
req
.
body
.
buyNumber
;
...
...
@@ -170,11 +168,11 @@ exports.addToCart = (req, res) => {
}).
then
((
result
)
=>
{
res
.
cookie
(
'_SPK'
,
result
.
data
.
shopping_key
,
{
maxAge
:
1000
*
60
*
60
*
24
*
365
,
httpOnly
:
true
,
path
:
'/'
});
res
.
json
(
result
);
});
})
.
catch
(
next
)
;
};
// 购物车商品选择与取消选择
exports
.
toggleSelectGoods
=
(
req
,
res
)
=>
{
exports
.
toggleSelectGoods
=
(
req
,
res
,
next
)
=>
{
const
params
=
{};
const
uid
=
req
.
user
.
uid
;
const
shoppingKey
=
req
.
cookies
.
_SPK
;
...
...
@@ -201,23 +199,23 @@ exports.toggleSelectGoods = (req, res) => {
cartModel
.
toggleSelectGoods
(
params
).
then
(
result
=>
{
res
.
json
(
_
.
merge
(
cartModel
.
filterCartData
(
result
,
uid
),
{
code
:
result
.
code
,
message
:
result
.
message
}));
});
})
.
catch
(
next
)
;
};
// 去结算检查库存
exports
.
checkStorage
=
(
req
,
res
)
=>
{
exports
.
checkStorage
=
(
req
,
res
,
next
)
=>
{
const
shoppingKey
=
req
.
cookies
.
_SPK
||
null
;
const
uid
=
req
.
user
.
uid
||
null
;
cartModel
.
getCartData
(
shoppingKey
,
uid
).
then
((
result
)
=>
{
// console.log('Cart current Data:', JSON.stringify(result, '', 4))
res
.
json
(
_
.
merge
(
cartModel
.
filterCartData
(
result
,
uid
),
{
code
:
result
.
code
,
message
:
result
.
message
}));
});
})
.
catch
(
next
)
;
};
// 修改购物车商品颜色和尺寸
exports
.
modifyProduct
=
(
req
,
res
)
=>
{
exports
.
modifyProduct
=
(
req
,
res
,
next
)
=>
{
const
uid
=
req
.
user
&&
req
.
user
.
uid
;
const
shoppingKey
=
req
.
cookies
.
_SPK
;
...
...
@@ -238,7 +236,7 @@ exports.modifyProduct = (req, res) => {
}
else
{
res
.
json
(
result
);
}
});
})
.
catch
(
next
)
;
};
...
...
public/img/sprite.img.png
0 → 100644
View file @
0b30e64
3.5 KB
public/scss/shopping/_breadcrumb.css
View file @
0b30e64
.yoho-sign-header
.center-content
{
border-bottom
:
none
;
}
.blk-cart-page
,
.shopping-order-page
{
.blk-cart-page
{
.cart-bc
{
width
:
100%
;
position
:
relative
;
background
:
#999
;
top
:
-2px
;
}
.breadcrumb
{
...
...
Please
register
or
login
to post a comment