Merge branch 'feature/shoppingCart' of http://git.yoho.cn/fe/yohobuy-node into feature/shoppingCart
Showing
6 changed files
with
17 additions
and
46 deletions
@@ -60,8 +60,6 @@ const setShoppingCookie = (req, res) => { | @@ -60,8 +60,6 @@ const setShoppingCookie = (req, res) => { | ||
60 | _r: 1 | 60 | _r: 1 |
61 | }); | 61 | }); |
62 | } | 62 | } |
63 | - }).finally(() => { | ||
64 | - return; | ||
65 | }); | 63 | }); |
66 | }; | 64 | }; |
67 | 65 | ||
@@ -151,12 +149,10 @@ const cartAdd = (req, res) => { | @@ -151,12 +149,10 @@ const cartAdd = (req, res) => { | ||
151 | } | 149 | } |
152 | 150 | ||
153 | if (result && result.code === 200) { | 151 | if (result && result.code === 200) { |
154 | - return setShoppingCookie(req, res).then(() => { | ||
155 | - return res.send(result); | ||
156 | - }); | ||
157 | - } else { | ||
158 | - res.send(result); | 152 | + yield setShoppingCookie(req, res); |
159 | } | 153 | } |
154 | + | ||
155 | + res.send(result); | ||
160 | })(); | 156 | })(); |
161 | }; | 157 | }; |
162 | 158 | ||
@@ -179,7 +175,7 @@ const cartTotal = (req, res) => { | @@ -179,7 +175,7 @@ const cartTotal = (req, res) => { | ||
179 | /** | 175 | /** |
180 | * 购物车商品选择与取消 | 176 | * 购物车商品选择与取消 |
181 | */ | 177 | */ |
182 | -const selectProduct = (req, res) => { | 178 | +const selectProduct = (req, res, next) => { |
183 | 179 | ||
184 | let uid = req.user.uid; | 180 | let uid = req.user.uid; |
185 | let productId = req.body.skuList; | 181 | let productId = req.body.skuList; |
@@ -190,11 +186,7 @@ const selectProduct = (req, res) => { | @@ -190,11 +186,7 @@ const selectProduct = (req, res) => { | ||
190 | service.selectGoods(uid, productId, shoppingKey, hasPromotion, cartDelList) | 186 | service.selectGoods(uid, productId, shoppingKey, hasPromotion, cartDelList) |
191 | .then(ret => { | 187 | .then(ret => { |
192 | res.send(ret); | 188 | res.send(ret); |
193 | - }).catch(() => { | ||
194 | - res.send({ | ||
195 | - code: 400 | ||
196 | - }); | ||
197 | - }); | 189 | + }).catch(next); |
198 | }; | 190 | }; |
199 | 191 | ||
200 | /** | 192 | /** |
@@ -241,11 +233,6 @@ const removeProduct = (req, res) => { | @@ -241,11 +233,6 @@ const removeProduct = (req, res) => { | ||
241 | 233 | ||
242 | if (ret && ret.code === 200) { | 234 | if (ret && ret.code === 200) { |
243 | yield setShoppingCookie(req, res); | 235 | yield setShoppingCookie(req, res); |
244 | - | ||
245 | - /* res.cookie('cart-del-list', cartDelList, { | ||
246 | - domain: '.yohobuy.com', | ||
247 | - path: '/' | ||
248 | - });*/ | ||
249 | } | 236 | } |
250 | 237 | ||
251 | return res.send(ret); | 238 | return res.send(ret); |
@@ -321,12 +308,6 @@ const getTogetherProduct = (req, res) => { | @@ -321,12 +308,6 @@ const getTogetherProduct = (req, res) => { | ||
321 | co(function * () { | 308 | co(function * () { |
322 | 309 | ||
323 | let page = req.query.page; | 310 | let page = req.query.page; |
324 | - | ||
325 | - /* let ret = { | ||
326 | - code: 200, | ||
327 | - message: '凑单商品' | ||
328 | - };*/ | ||
329 | - | ||
330 | let ret = yield service.getTogetherProduct(page); | 311 | let ret = yield service.getTogetherProduct(page); |
331 | 312 | ||
332 | return res.send(ret); | 313 | return res.send(ret); |
@@ -363,12 +344,6 @@ const getIncreasePurchase = (req, res) => { | @@ -363,12 +344,6 @@ const getIncreasePurchase = (req, res) => { | ||
363 | co(function * () { | 344 | co(function * () { |
364 | 345 | ||
365 | let page = req.query.page; | 346 | let page = req.query.page; |
366 | - | ||
367 | - /* let ret = { | ||
368 | - code: 200, | ||
369 | - message: '凑单商品' | ||
370 | - };*/ | ||
371 | - | ||
372 | let ret = yield service.getTogetherProduct(page); | 347 | let ret = yield service.getTogetherProduct(page); |
373 | 348 | ||
374 | return res.send(ret); | 349 | return res.send(ret); |
@@ -207,9 +207,8 @@ const formatCartGoods = (cartGoods, isAdvanceCart, inValid, isOffShelves, analys | @@ -207,9 +207,8 @@ const formatCartGoods = (cartGoods, isAdvanceCart, inValid, isOffShelves, analys | ||
207 | } | 207 | } |
208 | 208 | ||
209 | // 商品链接 | 209 | // 商品链接 |
210 | - let cnAlphaBet = it.cn_alphabet ? it.cn_alphabet : md5(it.product_name); | ||
211 | - | ||
212 | - goods.link = helpers.urlFormat(`/product/pro_${it.product_id}_${it.goods_id}/${cnAlphaBet}.html`, null, 'item'); | 210 | + // let cnAlphaBet = it.cn_alphabet ? it.cn_alphabet : md5(it.product_name); |
211 | + goods.link = helpers.getUrlBySkc(it.product_id, it.goods_id, it.cn_alphabet); | ||
213 | 212 | ||
214 | return goods; | 213 | return goods; |
215 | }); | 214 | }); |
@@ -307,10 +306,8 @@ const formatPriceGiftOne = (it) => { | @@ -307,10 +306,8 @@ const formatPriceGiftOne = (it) => { | ||
307 | 306 | ||
308 | // 商品链接 | 307 | // 商品链接 |
309 | if (g.goods_id) { | 308 | if (g.goods_id) { |
310 | - let cnAlphaBet = g.cn_alphabet ? g.cn_alphabet : md5(g.product_name); | ||
311 | - | ||
312 | - goods.subjoinLink = helpers.urlFormat(`/product/pro_${g.product_id}_${g.goods_id}/${cnAlphaBet}.html`, | ||
313 | - null, 'item'); | 309 | + // let cnAlphaBet = g.cn_alphabet ? g.cn_alphabet : md5(g.product_name); |
310 | + goods.subjoinLink = helpers.getUrlBySkc(g.product_id, g.goods_id, g.cn_alphabet); | ||
314 | } else { | 311 | } else { |
315 | let uri = `/product/show_${g.product_id}_${g.product_skn}/${makeToken(g.product_skn)}.html`; | 312 | let uri = `/product/show_${g.product_id}_${g.product_skn}/${makeToken(g.product_skn)}.html`; |
316 | 313 |
@@ -11,7 +11,8 @@ const co = Promise.coroutine; | @@ -11,7 +11,8 @@ const co = Promise.coroutine; | ||
11 | const _ = require('lodash'); | 11 | const _ = require('lodash'); |
12 | const api = global.yoho.API; | 12 | const api = global.yoho.API; |
13 | const helpers = global.yoho.helpers; | 13 | const helpers = global.yoho.helpers; |
14 | -const md5 = require('md5'); | 14 | + |
15 | +// const md5 = require('md5'); | ||
15 | 16 | ||
16 | const ERROR_400_MESSAGE = '系统繁忙,请稍候再试!'; | 17 | const ERROR_400_MESSAGE = '系统繁忙,请稍候再试!'; |
17 | const productAPI = require('./product-api'); | 18 | const productAPI = require('./product-api'); |
@@ -743,11 +744,11 @@ const getRecommendProduct = (channel, uid, udid, page) => { | @@ -743,11 +744,11 @@ const getRecommendProduct = (channel, uid, udid, page) => { | ||
743 | }; | 744 | }; |
744 | 745 | ||
745 | // 商品链接 | 746 | // 商品链接 |
746 | - let cnAlphaBet = it.cn_alphabet ? it.cn_alphabet : md5(it.product_name); | 747 | + // let cnAlphaBet = it.cn_alphabet ? it.cn_alphabet : md5(it.product_name); |
747 | let firstGoods = it.goods_list && it.goods_list[0]; | 748 | let firstGoods = it.goods_list && it.goods_list[0]; |
748 | let productSkc = firstGoods && firstGoods.product_skc; | 749 | let productSkc = firstGoods && firstGoods.product_skc; |
749 | 750 | ||
750 | - item.href = helpers.url(`/product/pro_${it.product_id}_${productSkc}/${cnAlphaBet}.html`, null, 'item'); | 751 | + item.href = helpers.getUrlBySkc(it.product_id, productSkc, it.cn_alphabet); |
751 | 752 | ||
752 | if (it.sales_price !== it.market_price) { | 753 | if (it.sales_price !== it.market_price) { |
753 | it.marketPrice = chelper.transPrice(it.market_price); | 754 | it.marketPrice = chelper.transPrice(it.market_price); |
@@ -973,10 +974,8 @@ const getMiniCartData = (uid, shoppingKey) => { | @@ -973,10 +974,8 @@ const getMiniCartData = (uid, shoppingKey) => { | ||
973 | product_sku: g.product_sku, | 974 | product_sku: g.product_sku, |
974 | promotion_id: g.promotion_id | 975 | promotion_id: g.promotion_id |
975 | }; | 976 | }; |
976 | - let cnAlphaBet = g.cn_alphabet ? g.cn_alphabet : md5(g.product_name); | ||
977 | - let uri = `/product/pro_${g.product_id}_${g.goods_id}/${cnAlphaBet}.html`; | ||
978 | 977 | ||
979 | - goods.product_url = helpers.urlFormat(uri, null, 'item'); | 978 | + goods.product_url = helpers.getUrlBySkc(g.product_id, g.goods_id, g.cn_alphabet); |
980 | return goods; | 979 | return goods; |
981 | }); | 980 | }); |
982 | 981 |
@@ -90,7 +90,7 @@ | @@ -90,7 +90,7 @@ | ||
90 | 90 | ||
91 | {{#ordinaryCart}} | 91 | {{#ordinaryCart}} |
92 | {{#pools}} | 92 | {{#pools}} |
93 | - <div class="promotion-pool" data-role="promotion-pool"> | 93 | + <div class="promotion-pool {{#unless @first}}mt20{{/unless}}" data-role="promotion-pool"> |
94 | {{#if promotionInfos}} | 94 | {{#if promotionInfos}} |
95 | <div class="gift-sell mt20"> | 95 | <div class="gift-sell mt20"> |
96 | {{#promotionInfos}} | 96 | {{#promotionInfos}} |
@@ -196,7 +196,7 @@ Cart = { | @@ -196,7 +196,7 @@ Cart = { | ||
196 | if (!$.isEmptyObject(selectArray)) { | 196 | if (!$.isEmptyObject(selectArray)) { |
197 | var content = '<div><i class="iconfont"></i>清除失效商品</div><p>确定要清除失效商品吗?</p>'; // eslint-disable-line | 197 | var content = '<div><i class="iconfont"></i>清除失效商品</div><p>确定要清除失效商品吗?</p>'; // eslint-disable-line |
198 | new RConfirm(content, function() { // eslint-disable-line | 198 | new RConfirm(content, function() { // eslint-disable-line |
199 | - capi.cartItemDel(selectArray, true, PromotionArray); | 199 | + capi.cartItemDel(selectArray, true); |
200 | }).show(); | 200 | }).show(); |
201 | } else { | 201 | } else { |
202 | var content = '<div class="alert-main"><i class="iconfont"></i>购物车中没有失效商品!</div>'; // eslint-disable-line | 202 | var content = '<div class="alert-main"><i class="iconfont"></i>购物车中没有失效商品!</div>'; // eslint-disable-line |
@@ -242,7 +242,7 @@ function addcart(data, cookieList) { | @@ -242,7 +242,7 @@ function addcart(data, cookieList) { | ||
242 | }); | 242 | }); |
243 | } | 243 | } |
244 | } else { | 244 | } else { |
245 | - new Alert(d.message === '' ? '加入购物车失败哦~~' : d.message).show(); | 245 | + new Alert(!d.message ? '加入购物车失败哦~~' : d.message).show(); |
246 | } | 246 | } |
247 | }); | 247 | }); |
248 | } | 248 | } |
-
Please register or login to post a comment