Authored by htoooth

Merge remote-tracking branch 'origin/release/1.0' into release/1.0

@@ -9,12 +9,12 @@ @@ -9,12 +9,12 @@
9 const cartModel = require('../models/cart'); 9 const cartModel = require('../models/cart');
10 const _ = require('lodash'); 10 const _ = require('lodash');
11 11
  12 +// 购物车首页
12 exports.index = (req, res, next) => { 13 exports.index = (req, res, next) => {
13 const shoppingKey = req.cookies._SPK || null; 14 const shoppingKey = req.cookies._SPK || null;
14 const uid = req.user.uid || null; 15 const uid = req.user.uid || null;
15 16
16 cartModel.getCartData(shoppingKey, uid).then((result) => { 17 cartModel.getCartData(shoppingKey, uid).then((result) => {
17 - // console.log('Cart current Data:', JSON.stringify(result, '', 4))  
18 if (result.code === 200) { 18 if (result.code === 200) {
19 res.display('cart', _.merge({ 19 res.display('cart', _.merge({
20 module: 'shopping', 20 module: 'shopping',
@@ -32,11 +32,9 @@ exports.index = (req, res, next) => { @@ -32,11 +32,9 @@ exports.index = (req, res, next) => {
32 }; 32 };
33 33
34 34
35 -// 修改数量 35 +// 通过stepper修改购物车商品数量
36 exports.changeProductNum = (req, res, next) => { 36 exports.changeProductNum = (req, res, next) => {
37 const changeType = req.body.changeType; 37 const changeType = req.body.changeType;
38 -  
39 - // const changeTo = req.body.changeTo;  
40 const uid = req.user.uid; 38 const uid = req.user.uid;
41 const shoppingKey = req.cookies._SPK; 39 const shoppingKey = req.cookies._SPK;
42 const sku = req.body.sku; 40 const sku = req.body.sku;
@@ -50,7 +48,6 @@ exports.changeProductNum = (req, res, next) => { @@ -50,7 +48,6 @@ exports.changeProductNum = (req, res, next) => {
50 sku, 48 sku,
51 goodTpye 49 goodTpye
52 }).then(result => { 50 }).then(result => {
53 - // console.log('changeProductNum-INCREASE-result:', result);  
54 if (result.code === 200) { 51 if (result.code === 200) {
55 cartModel.getCartData(shoppingKey, uid).then(cartData => { 52 cartModel.getCartData(shoppingKey, uid).then(cartData => {
56 res.json(_.merge( 53 res.json(_.merge(
@@ -62,7 +59,6 @@ exports.changeProductNum = (req, res, next) => { @@ -62,7 +59,6 @@ exports.changeProductNum = (req, res, next) => {
62 res.json(result); 59 res.json(result);
63 } 60 }
64 }).catch(next); 61 }).catch(next);
65 -  
66 } else if (changeType === 'DECREASE') { 62 } else if (changeType === 'DECREASE') {
67 cartModel.modifyProductNum({ 63 cartModel.modifyProductNum({
68 decreaseNum: 1, // 默认是1 64 decreaseNum: 1, // 默认是1
@@ -71,7 +67,6 @@ exports.changeProductNum = (req, res, next) => { @@ -71,7 +67,6 @@ exports.changeProductNum = (req, res, next) => {
71 sku, 67 sku,
72 goodTpye 68 goodTpye
73 }).then(result => { 69 }).then(result => {
74 - // console.log('changeProductNum-DECREASE-result:', JSON.stringify(result));  
75 if (result.code === 200) { 70 if (result.code === 200) {
76 cartModel.getCartData(shoppingKey, uid).then(cartData => { 71 cartModel.getCartData(shoppingKey, uid).then(cartData => {
77 res.json(_.merge( 72 res.json(_.merge(
@@ -105,10 +100,7 @@ exports.removeProduct = (req, res, next) => { @@ -105,10 +100,7 @@ exports.removeProduct = (req, res, next) => {
105 _.merge(params, {product_sku_list: productSkuList}); 100 _.merge(params, {product_sku_list: productSkuList});
106 } 101 }
107 102
108 - // console.log('remove---params:', params);  
109 -  
110 cartModel.removeGoods(params).then(result => { 103 cartModel.removeGoods(params).then(result => {
111 - // console.log('remove-result:', result);  
112 res.json(_.merge(cartModel.filterCartData(result, uid), {code: result.code, message: result.message})); 104 res.json(_.merge(cartModel.filterCartData(result, uid), {code: result.code, message: result.message}));
113 }).catch(next); 105 }).catch(next);
114 }; 106 };
@@ -127,34 +119,12 @@ exports.sendToFavorite = (req, res, next) => { @@ -127,34 +119,12 @@ exports.sendToFavorite = (req, res, next) => {
127 _.merge(params, {product_sku_list: productSkuList}); 119 _.merge(params, {product_sku_list: productSkuList});
128 } 120 }
129 121
130 - console.log('transferToFavorite---params:', params);  
131 -  
132 cartModel.transferToFavorite(params).then(result => { 122 cartModel.transferToFavorite(params).then(result => {
133 console.log('transferToFavorite-result:', result); 123 console.log('transferToFavorite-result:', result);
134 res.json(_.merge(cartModel.filterCartData(result, uid), {code: result.code, message: result.message})); 124 res.json(_.merge(cartModel.filterCartData(result, uid), {code: result.code, message: result.message}));
135 }).catch(next); 125 }).catch(next);
136 }; 126 };
137 127
138 -// 编辑商品颜色和尺寸  
139 -exports.editProduct = (req, res) => {  
140 - res.json({  
141 - code: '0',  
142 - defaultColor: '蓝',  
143 - defaultSize: 'M',  
144 - defaultImg: 'http://img10.static.yhbimg.com/goodsimg/2015/10/21/02/0128dc014524ccf208b4f6f7760c9b9cf2.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',  
145 - colors: [{  
146 - color: '蓝',  
147 - rgb: '#1b3c78',  
148 - pic: 'http://img10.static.yhbimg.com/goodsimg/2015/10/21/02/0128dc014524ccf208b4f6f7760c9b9cf2.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80'  
149 - }, {  
150 - color: '黑',  
151 - rgb: '#000',  
152 - pic: 'http://img12.static.yhbimg.com/goodsimg/2015/10/21/05/024f60a070ab61981c139684f147d41f17.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80'  
153 - }],  
154 - sizes: ['S', 'M', 'L', 'XL', 'XXL', 'XXXL']  
155 - });  
156 -};  
157 -  
158 // 添加商品到购物车 128 // 添加商品到购物车
159 exports.addToCart = (req, res, next) => { 129 exports.addToCart = (req, res, next) => {
160 const productSku = req.body.productSku; 130 const productSku = req.body.productSku;
@@ -195,21 +165,18 @@ exports.toggleSelectGoods = (req, res, next) => { @@ -195,21 +165,18 @@ exports.toggleSelectGoods = (req, res, next) => {
195 _.merge(params, {product_sku_list: productSkuList}); 165 _.merge(params, {product_sku_list: productSkuList});
196 } 166 }
197 167
198 - console.log('toggleSelectGoods---params:', params);  
199 -  
200 cartModel.toggleSelectGoods(params).then(result => { 168 cartModel.toggleSelectGoods(params).then(result => {
201 res.json(_.merge(cartModel.filterCartData(result, uid), {code: result.code, message: result.message})); 169 res.json(_.merge(cartModel.filterCartData(result, uid), {code: result.code, message: result.message}));
202 }).catch(next); 170 }).catch(next);
203 }; 171 };
204 172
205 173
206 -// 去结算检查库存 174 +// 点击去结算时检查库存
207 exports.checkStorage = (req, res, next) => { 175 exports.checkStorage = (req, res, next) => {
208 const shoppingKey = req.cookies._SPK || null; 176 const shoppingKey = req.cookies._SPK || null;
209 const uid = req.user.uid || null; 177 const uid = req.user.uid || null;
210 178
211 cartModel.getCartData(shoppingKey, uid).then((result) => { 179 cartModel.getCartData(shoppingKey, uid).then((result) => {
212 - // console.log('Cart current Data:', JSON.stringify(result, '', 4))  
213 res.json(_.merge(cartModel.filterCartData(result, uid), {code: result.code, message: result.message})); 180 res.json(_.merge(cartModel.filterCartData(result, uid), {code: result.code, message: result.message}));
214 }).catch(next); 181 }).catch(next);
215 }; 182 };
@@ -222,10 +189,7 @@ exports.modifyProduct = (req, res, next) => { @@ -222,10 +189,7 @@ exports.modifyProduct = (req, res, next) => {
222 // swapData => [{"buy_number":"1","selected":"Y","new_product_sku":"735172","old_product_sku":"735171"}] 189 // swapData => [{"buy_number":"1","selected":"Y","new_product_sku":"735172","old_product_sku":"735171"}]
223 const swapData = req.body.swapData; 190 const swapData = req.body.swapData;
224 191
225 - // console.log("swap data....", {swapData, shoppingKey, uid})  
226 -  
227 cartModel.modifyProduct({swapData, shoppingKey, uid}).then((result) => { 192 cartModel.modifyProduct({swapData, shoppingKey, uid}).then((result) => {
228 - // console.log('swap result...:', JSON.stringify(result, '', 4))  
229 if (result.code === 200) { 193 if (result.code === 200) {
230 cartModel.getCartData(shoppingKey, uid).then(cartData => { 194 cartModel.getCartData(shoppingKey, uid).then(cartData => {
231 res.json(_.merge( 195 res.json(_.merge(
@@ -238,5 +202,3 @@ exports.modifyProduct = (req, res, next) => { @@ -238,5 +202,3 @@ exports.modifyProduct = (req, res, next) => {
238 } 202 }
239 }).catch(next); 203 }).catch(next);
240 }; 204 };
241 -  
242 -  
@@ -83,8 +83,6 @@ const addToCart = (options) => { @@ -83,8 +83,6 @@ const addToCart = (options) => {
83 * } 83 * }
84 */ 84 */
85 const getCartData = (shoppingKey, uid) => { 85 const getCartData = (shoppingKey, uid) => {
86 - // console.log('SPK:', shoppingKey);  
87 - // console.log('uid:', uid);  
88 let params = { 86 let params = {
89 method: 'app.Shopping.cart' 87 method: 'app.Shopping.cart'
90 }; 88 };
@@ -168,7 +166,6 @@ const toggleSelectGoods = (params) => { @@ -168,7 +166,6 @@ const toggleSelectGoods = (params) => {
168 }); 166 });
169 }); 167 });
170 */ 168 */
171 -  
172 return api.get('', params); 169 return api.get('', params);
173 }; 170 };
174 171
@@ -248,8 +245,6 @@ const filterCartData = (result, uid) => { @@ -248,8 +245,6 @@ const filterCartData = (result, uid) => {
248 // 预售商品 245 // 预售商品
249 if (result.data && result.data.advance_cart_data) { 246 if (result.data && result.data.advance_cart_data) {
250 advancedCartData = result.data.advance_cart_data; 247 advancedCartData = result.data.advance_cart_data;
251 -  
252 - // console.log('---------------advance------:', advancedCartData.goods_list.length);  
253 totalAdvanceMoney = advancedCartData.shopping_cart_data.last_order_amount; 248 totalAdvanceMoney = advancedCartData.shopping_cart_data.last_order_amount;
254 advancedGoods = _.concat(advancedGoods, advancedCartData.goods_list); 249 advancedGoods = _.concat(advancedGoods, advancedCartData.goods_list);
255 invalidGoods = _.concat(invalidGoods, advancedCartData.off_shelves_goods_list); 250 invalidGoods = _.concat(invalidGoods, advancedCartData.off_shelves_goods_list);
@@ -274,8 +269,6 @@ const filterCartData = (result, uid) => { @@ -274,8 +269,6 @@ const filterCartData = (result, uid) => {
274 // 普通商品 269 // 普通商品
275 if (result.data && result.data.ordinary_cart_data) { 270 if (result.data && result.data.ordinary_cart_data) {
276 ordinaryCartData = result.data.ordinary_cart_data; 271 ordinaryCartData = result.data.ordinary_cart_data;
277 -  
278 - // console.log('---------------ordinary------:', ordinaryCartData.goods_list.length);  
279 totalOrdinaryMoney = ordinaryCartData.shopping_cart_data.last_order_amount; 272 totalOrdinaryMoney = ordinaryCartData.shopping_cart_data.last_order_amount;
280 ordinaryGoods = _.concat(ordinaryGoods, ordinaryCartData.goods_list); 273 ordinaryGoods = _.concat(ordinaryGoods, ordinaryCartData.goods_list);
281 invalidGoods = _.concat(invalidGoods, ordinaryCartData.off_shelves_goods_list); 274 invalidGoods = _.concat(invalidGoods, ordinaryCartData.off_shelves_goods_list);
@@ -298,9 +291,6 @@ const filterCartData = (result, uid) => { @@ -298,9 +291,6 @@ const filterCartData = (result, uid) => {
298 }); 291 });
299 } 292 }
300 293
301 - // console.log('ordinaryGoods:', ordinaryGoods);  
302 -  
303 -  
304 return _.merge(resData, { 294 return _.merge(resData, {
305 hasGoods: advancedGoods.length || ordinaryGoods.length || invalidGoods.length, 295 hasGoods: advancedGoods.length || ordinaryGoods.length || invalidGoods.length,
306 preSalePros: advancedGoods.length ? _.groupBy(advancedGoods, 'brand_id') : [], 296 preSalePros: advancedGoods.length ? _.groupBy(advancedGoods, 'brand_id') : [],
@@ -314,7 +304,7 @@ const filterCartData = (result, uid) => { @@ -314,7 +304,7 @@ const filterCartData = (result, uid) => {
314 }; 304 };
315 305
316 /** 306 /**
317 - * 增减购物车商品数量 307 + * 修改购物车商品数量
318 * @function modifyProductNum 308 * @function modifyProductNum
319 * @param { Number } uid 用户ID 309 * @param { Number } uid 用户ID
320 * @param { String } sku 商品SKU 310 * @param { String } sku 商品SKU
@@ -372,9 +362,6 @@ const modifyProductNum = (options) => { @@ -372,9 +362,6 @@ const modifyProductNum = (options) => {
372 }); 362 });
373 363
374 return getCartData(shoppingKey, uid).then(function(result) { 364 return getCartData(shoppingKey, uid).then(function(result) {
375 - // console.log('getCartData--pre-callback-result:', JSON.stringify(result, '', 4));  
376 - // console.log('modifyProductNum---params:', params);  
377 -  
378 if (goodType === 'advance') { 365 if (goodType === 'advance') {
379 // 检查库存量 366 // 检查库存量
380 // 同步 367 // 同步
@@ -456,6 +443,14 @@ const modifyProductNum = (options) => { @@ -456,6 +443,14 @@ const modifyProductNum = (options) => {
456 }); 443 });
457 }; 444 };
458 445
  446 +/**
  447 + * 修改商品颜色和尺寸
  448 + * @function modifyProduct
  449 + * @param { Number } uid 用户ID
  450 + * @param { String } swapData 商品修改信息
  451 + * @param { String } shoppingKey 未登录用户唯一识别码
  452 + * @return { Object } 接口返回单个商品修改结果
  453 + */
459 const modifyProduct = (options) => { 454 const modifyProduct = (options) => {
460 let params = { 455 let params = {
461 method: 'app.Shopping.swap' 456 method: 'app.Shopping.swap'
@@ -19,7 +19,6 @@ router.get('/cart', cartCtrl.index); @@ -19,7 +19,6 @@ router.get('/cart', cartCtrl.index);
19 router.post('/cart/product/change_num', cartCtrl.changeProductNum); 19 router.post('/cart/product/change_num', cartCtrl.changeProductNum);
20 router.delete('/cart/product/remove', cartCtrl.removeProduct); 20 router.delete('/cart/product/remove', cartCtrl.removeProduct);
21 router.post('/cart/product/send_to_favorite', cartCtrl.sendToFavorite); 21 router.post('/cart/product/send_to_favorite', cartCtrl.sendToFavorite);
22 -router.get('/cart/product/:productId/edit', cartCtrl.editProduct);  
23 router.post('/cart/add', cartCtrl.addToCart); 22 router.post('/cart/add', cartCtrl.addToCart);
24 router.post('/cart/toggleSelectGoods', cartCtrl.toggleSelectGoods); 23 router.post('/cart/toggleSelectGoods', cartCtrl.toggleSelectGoods);
25 router.get('/cart/checkStorage', cartCtrl.checkStorage); 24 router.get('/cart/checkStorage', cartCtrl.checkStorage);
@@ -9,7 +9,6 @@ @@ -9,7 +9,6 @@
9 {{> cart/empty-cart}} 9 {{> cart/empty-cart}}
10 {{/if}} 10 {{/if}}
11 </div> 11 </div>
12 - {{!-- <button id="add_to_cart1">添加到购物车 1413600 number 1</button> --}}  
13 </div> 12 </div>
14 13
15 <script id="edit-color-size-tpl" type="text/html"> 14 <script id="edit-color-size-tpl" type="text/html">
  1 +<div class="cart-removed-list">
  2 + <div class="info-bar">
  3 + <p class="info-text">已删除商品,您可以重新购买或移入收藏:</p>
  4 + </div>
  5 + <div class="removed-products">
  6 + <ul>
  7 + <li class="removed-product">
  8 + <div class="product-name">TEEBACOO虎头字母短袖T恤</div>
  9 + <div class="product-price">¥ 373.00</div>
  10 + <div class="bought-num">2</div>
  11 + <div class="actions">
  12 + <span class="buy-again">重新购买</span>
  13 + <span class="send-to-favorite">移入收藏夹</span>
  14 + </div>
  15 + </li>
  16 + <li class="removed-product">
  17 + <div class="product-name">NIKIE AIR FORCE1</div>
  18 + <div class="product-price">¥ 373.00</div>
  19 + <div class="bought-num">2</div>
  20 + <div class="actions">
  21 + <span class="buy-again">重新购买</span>
  22 + <span class="send-to-favorite">移入收藏夹</span>
  23 + </div>
  24 + </li>
  25 + </ul>
  26 + </div>
  27 +</div>
  1 +/**
  2 + * [购物流程] 购物袋
  3 + * @author: jinhu.dong<jinhu.dong@yoho.cn>
  4 + * @date: 2016/7/1
  5 + */
  6 +
1 var $ = require('yoho-jquery'); 7 var $ = require('yoho-jquery');
2 var Cart = require('./cart/cart'); 8 var Cart = require('./cart/cart');
3 var Stepper = require('./cart/stepper'); 9 var Stepper = require('./cart/stepper');
4 10
5 $(function() { 11 $(function() {
6 var $this; 12 var $this;
  13 + var editable = true;
7 14
8 // 关闭info-bar 15 // 关闭info-bar
9 $('.info-bar .close').on('click', function() { 16 $('.info-bar .close').on('click', function() {
@@ -54,16 +61,25 @@ $(function() { @@ -54,16 +61,25 @@ $(function() {
54 }).delegate('.editable', 'click', function() { 61 }).delegate('.editable', 'click', function() {
55 $this = $(this); 62 $this = $(this);
56 63
57 - // 编辑商品颜色和属性  
58 - Cart.editColorOrSize(  
59 - $this.attr('data-productId'),  
60 - $this.attr('data-productSkn'),  
61 - $this.find('.default-color').text(),  
62 - $this.find('.default-size').text()); 64 + if (editable) {
  65 + editable = false;
63 66
64 - $('body').on('click', function() {  
65 - $('.edit-color-size').remove();  
66 - }); 67 + // 编辑商品颜色和属性
  68 + Cart.editColorOrSize(
  69 + $this.attr('data-productId'),
  70 + $this.attr('data-productSkn'),
  71 + $this.find('.default-color').text(),
  72 + $this.find('.default-size').text(), function() {
  73 + editable = true;
  74 + });
  75 +
  76 + $('body').off('click').on('click', function() {
  77 + if ($('.edit-color-size').length) {
  78 + $('.edit-color-size').remove();
  79 + editable = true;
  80 + }
  81 + });
  82 + }
67 }).delegate('#checkout_btn', 'click', function(e) { 83 }).delegate('#checkout_btn', 'click', function(e) {
68 e.preventDefault(); 84 e.preventDefault();
69 if ($('.chk-group').length) { 85 if ($('.chk-group').length) {
@@ -67,6 +67,7 @@ var Cart = { @@ -67,6 +67,7 @@ var Cart = {
67 /* 67 /*
68 * 取消全选 68 * 取消全选
69 * @function [toggleCheckAllPros] 69 * @function [toggleCheckAllPros]
  70 + * @params { Boolean } checked 选择,取消选择
70 */ 71 */
71 toggleCheckAllPros: function(checked) { 72 toggleCheckAllPros: function(checked) {
72 var data = [], 73 var data = [],
@@ -93,6 +94,7 @@ var Cart = { @@ -93,6 +94,7 @@ var Cart = {
93 /* 94 /*
94 * 根据服务端JSON,刷新购物车信息 95 * 根据服务端JSON,刷新购物车信息
95 * @function [refreshCart] 96 * @function [refreshCart]
  97 + * @params { Object } data 最新购物车数据
96 */ 98 */
97 refreshCart: function(data) { 99 refreshCart: function(data) {
98 var template; 100 var template;
@@ -103,8 +105,6 @@ var Cart = { @@ -103,8 +105,6 @@ var Cart = {
103 105
104 if (num1 && num2) { 106 if (num1 && num2) {
105 return num1 * num2; 107 return num1 * num2;
106 - } else {  
107 - console.error('multiplication needs two number parameters');  
108 } 108 }
109 }); 109 });
110 110
@@ -130,6 +130,7 @@ var Cart = { @@ -130,6 +130,7 @@ var Cart = {
130 /* 130 /*
131 * 选择与取消选择 131 * 选择与取消选择
132 * @function [toggleSelectGoods] 132 * @function [toggleSelectGoods]
  133 + * @params { Array } data 选择与取消选择商品信息
133 */ 134 */
134 toggleSelectGoods: function(data) { 135 toggleSelectGoods: function(data) {
135 $.ajax({ 136 $.ajax({
@@ -152,7 +153,8 @@ var Cart = { @@ -152,7 +153,8 @@ var Cart = {
152 153
153 /* 154 /*
154 * 单选每一个商品判断是否需要全选 155 * 单选每一个商品判断是否需要全选
155 - * @function [toggleCheckAll] 156 + * @function [toggleCheck]
  157 + * @params { Object } target 单个商品
156 */ 158 */
157 toggleCheck: function(target) { 159 toggleCheck: function(target) {
158 var $this = $(target), 160 var $this = $(target),
@@ -220,8 +222,8 @@ var Cart = { @@ -220,8 +222,8 @@ var Cart = {
220 }, 222 },
221 223
222 /* 224 /*
223 - * 删除商品  
224 - * @function [removePro] 225 + * 商品移入收藏夹
  226 + * @function [sendToFavorite]
225 * @params { Array } products 商品列表 227 * @params { Array } products 商品列表
226 */ 228 */
227 sendToFavorite: function(products) { 229 sendToFavorite: function(products) {
@@ -254,8 +256,16 @@ var Cart = { @@ -254,8 +256,16 @@ var Cart = {
254 } 256 }
255 }, 257 },
256 258
257 - // 编辑商品的颜色和尺寸  
258 - editColorOrSize: function(productId, skn, defaultColor, defaultSize) { 259 + /*
  260 + * 修改商品颜色和尺寸
  261 + * @function [editColorOrSize]
  262 + * @params { String } productId 商品ID
  263 + * @params { String } skn 商品skn
  264 + * @params { String } defaultColor 商品默认颜色
  265 + * @params { String } defaultSize 商品默认尺寸
  266 + * @params { Function } setEditable 编辑商品回调
  267 + */
  268 + editColorOrSize: function(productId, skn, defaultColor, defaultSize, setEditable) {
259 var template; 269 var template;
260 var index = 0; 270 var index = 0;
261 var colors; 271 var colors;
@@ -321,10 +331,8 @@ var Cart = { @@ -321,10 +331,8 @@ var Cart = {
321 }); 331 });
322 332
323 // helpers end 333 // helpers end
324 -  
325 template = hbs.compile($('#edit-color-size-tpl').html()); 334 template = hbs.compile($('#edit-color-size-tpl').html());
326 335
327 -  
328 editTarget.append( 336 editTarget.append(
329 template({ 337 template({
330 colors: filterSet, 338 colors: filterSet,
@@ -352,12 +360,14 @@ var Cart = { @@ -352,12 +360,14 @@ var Cart = {
352 success: function(newCartData) { 360 success: function(newCartData) {
353 editTarget.find('.edit-color-size').remove(); 361 editTarget.find('.edit-color-size').remove();
354 Util.refreshCart(newCartData); 362 Util.refreshCart(newCartData);
  363 + setEditable();
355 } 364 }
356 }); 365 });
357 return false; 366 return false;
358 }).delegate('#cancel', 'click', function(e) { 367 }).delegate('#cancel', 'click', function(e) {
359 e.preventDefault(); 368 e.preventDefault();
360 editTarget.find('.edit-color-size').remove(); 369 editTarget.find('.edit-color-size').remove();
  370 + setEditable();
361 return false; 371 return false;
362 }).delegate('.edit-color-size', 'click', function(e) { 372 }).delegate('.edit-color-size', 'click', function(e) {
363 e.preventDefault(); 373 e.preventDefault();
@@ -390,6 +400,11 @@ var Cart = { @@ -390,6 +400,11 @@ var Cart = {
390 400
391 }, 401 },
392 402
  403 + /*
  404 + * 点击结算时检查商品库存
  405 + * @function [checkStorage]
  406 + * @params { Function } callback 检查完回调函数
  407 + */
393 checkStorage: function(callback) { 408 checkStorage: function(callback) {
394 Util.ajax({ 409 Util.ajax({
395 url: '/shopping/cart/checkStorage', 410 url: '/shopping/cart/checkStorage',
@@ -9,7 +9,13 @@ var Util = require('./util'); @@ -9,7 +9,13 @@ var Util = require('./util');
9 var $ = require('yoho-jquery'); 9 var $ = require('yoho-jquery');
10 10
11 var Stepper = { 11 var Stepper = {
12 - // 减少商品数量 12 + /*
  13 + * 减少商品数量
  14 + * @function [decrease]
  15 + * @params { String } goodType 商品类型
  16 + * @params { String } sku 商品sku
  17 + * @params { String } currNum 商品当前购买数量
  18 + */
13 decrease: function(goodType, sku, currNum) { 19 decrease: function(goodType, sku, currNum) {
14 if (parseInt(currNum, 10) <= 1) { 20 if (parseInt(currNum, 10) <= 1) {
15 // return callback(1); 21 // return callback(1);
@@ -32,7 +38,12 @@ var Stepper = { @@ -32,7 +38,12 @@ var Stepper = {
32 38
33 }, 39 },
34 40
35 - // 增加商品数量 41 + /*
  42 + * 增加商品数量
  43 + * @function [increase]
  44 + * @params { String } goodType 商品类型
  45 + * @params { String } sku 商品sku
  46 + */
36 increase: function(goodType, sku) { 47 increase: function(goodType, sku) {
37 Util.ajax({ 48 Util.ajax({
38 url: '/shopping/cart/product/change_num', 49 url: '/shopping/cart/product/change_num',
@@ -50,6 +61,10 @@ var Stepper = { @@ -50,6 +61,10 @@ var Stepper = {
50 }); 61 });
51 }, 62 },
52 63
  64 + /*
  65 + * 初始化
  66 + * @function [init]
  67 + */
53 init: function() { 68 init: function() {
54 var _this = this, 69 var _this = this,
55 $target, 70 $target,
@@ -123,4 +138,3 @@ var Stepper = { @@ -123,4 +138,3 @@ var Stepper = {
123 }; 138 };
124 139
125 module.exports = Stepper; 140 module.exports = Stepper;
126 -  
@@ -9,6 +9,12 @@ var _alert = dialog.Alert; @@ -9,6 +9,12 @@ var _alert = dialog.Alert;
9 var hbs = require('yoho-handlebars'); 9 var hbs = require('yoho-handlebars');
10 10
11 var Util = { 11 var Util = {
  12 +
  13 + /*
  14 + * ajax请求封装
  15 + * @function [ajax]
  16 + * @params { Object } options ajax请求参数
  17 + */
12 ajax: function(options) { 18 ajax: function(options) {
13 $.ajax({ 19 $.ajax({
14 type: options.type || 'GET', 20 type: options.type || 'GET',
@@ -33,6 +39,8 @@ var Util = { @@ -33,6 +39,8 @@ var Util = {
33 /* 39 /*
34 * 根据服务端JSON,刷新购物车信息 40 * 根据服务端JSON,刷新购物车信息
35 * @function [refreshCart] 41 * @function [refreshCart]
  42 + * @params { Object } data 最新购物车数据
  43 + * @params { Function } callback 购物车刷新后回调
36 */ 44 */
37 refreshCart: function(data, callback) { 45 refreshCart: function(data, callback) {
38 var template; 46 var template;
@@ -49,8 +57,6 @@ var Util = { @@ -49,8 +57,6 @@ var Util = {
49 57
50 if (num1 && num2) { 58 if (num1 && num2) {
51 return num1 * num2; 59 return num1 * num2;
52 - } else {  
53 - console.error('multiplication needs two number parameters');  
54 } 60 }
55 }); 61 });
56 62
@@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
7 @import "tooltip"; /* 提示 */ 7 @import "tooltip"; /* 提示 */
8 @import "edit-color-size"; /* 编辑颜色和属性 */ 8 @import "edit-color-size"; /* 编辑颜色和属性 */
9 @import "statement"; /* 结算模块 */ 9 @import "statement"; /* 结算模块 */
  10 +@import "removed-products"; /* 删除商品模块 */
10 11
11 /* 支付流程-订单结算 */ 12 /* 支付流程-订单结算 */
12 @import "order"; 13 @import "order";
  1 +.blk-cart-page {
  2 + .cart-removed-list {
  3 + .info-bar {
  4 + background: #fff;
  5 + margin-bottom: 12px;
  6 + }
  7 + }
  8 +
  9 + .removed-product {
  10 + padding: 9px 30px;
  11 + background: #f0f0f0;
  12 + margin-bottom: 20px;
  13 + position: relative;
  14 + font-size: 14px;
  15 +
  16 + div {
  17 + display: inline-block;
  18 + }
  19 +
  20 + .actions {
  21 + position: absolute;
  22 + right: 30px;
  23 + }
  24 +
  25 + .buy-again {
  26 + margin-right: 20px;
  27 + }
  28 +
  29 + span {
  30 + &:hover {
  31 + cursor: pointer;
  32 + color: #379ed6;
  33 + }
  34 + }
  35 + }
  36 +
  37 + .product-name {
  38 + width: 549px;
  39 + }
  40 +
  41 + .product-price {
  42 + width: 150px;
  43 + }
  44 +
  45 + .bought-num {
  46 + width: 100px;
  47 + text-align: center;
  48 + }
  49 +}