Showing
12 changed files
with
188 additions
and
55 deletions
framework @ e9d066dd
@@ -123,7 +123,7 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { | @@ -123,7 +123,7 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { | ||
123 | i; | 123 | i; |
124 | 124 | ||
125 | var $siblingBlock = $this.closest('.block-list').siblings(':first'), | 125 | var $siblingBlock = $this.closest('.block-list').siblings(':first'), |
126 | - currentNumArray = $this.data('numstr').split('/'); | 126 | + currentNumArray = ($this.data('numstr') + '').split('/'); |
127 | 127 | ||
128 | $this.siblings('.chosed').removeClass('chosed'); | 128 | $this.siblings('.chosed').removeClass('chosed'); |
129 | $this.toggleClass('chosed'); | 129 | $this.toggleClass('chosed'); |
@@ -163,7 +163,7 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { | @@ -163,7 +163,7 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) { | ||
163 | }); | 163 | }); |
164 | } | 164 | } |
165 | 165 | ||
166 | - numArray = $chosed.data('numstr').split('/'); | 166 | + numArray = ($chosed.data('numstr') + '').split('/'); |
167 | $siblingBlock.find('.block').removeClass('zero-stock'); | 167 | $siblingBlock.find('.block').removeClass('zero-stock'); |
168 | for (i = 0; i < numArray.length; i++) { | 168 | for (i = 0; i < numArray.length; i++) { |
169 | if (0 === numArray[i] - 0) { | 169 | if (0 === numArray[i] - 0) { |
@@ -36,6 +36,9 @@ function getProductInfo(skn, promotionId) { | @@ -36,6 +36,9 @@ function getProductInfo(skn, promotionId) { | ||
36 | return; | 36 | return; |
37 | } | 37 | } |
38 | console.log(res); | 38 | console.log(res); |
39 | + if (!panelTmpl) { | ||
40 | + return; | ||
41 | + } | ||
39 | if (res.code === 200) { | 42 | if (res.code === 200) { |
40 | $chosePanel.html(panelTmpl(res.data)); | 43 | $chosePanel.html(panelTmpl(res.data)); |
41 | chosePanel.show(); | 44 | chosePanel.show(); |
@@ -12,17 +12,10 @@ var $ = require('jquery'), | @@ -12,17 +12,10 @@ var $ = require('jquery'), | ||
12 | var dialog = require('../me/dialog'), | 12 | var dialog = require('../me/dialog'), |
13 | tip = require('../plugin/tip'); | 13 | tip = require('../plugin/tip'); |
14 | 14 | ||
15 | -var $names; | 15 | +var $names, |
16 | + $selectAllBtn = $('.balance .iconfont'); | ||
16 | 17 | ||
17 | -//var $curDelPanel; | ||
18 | - | ||
19 | -////删除面板显示后任何点击行为都将触发隐藏面板 | ||
20 | -//function docTouchEvt() { | ||
21 | -// $curDelPanel && $curDelPanel.addClass('hide'); | ||
22 | -// | ||
23 | -// // | ||
24 | -// $(document).off('touchstart', docTouchEvt); | ||
25 | -//} | 18 | +var requesting = false; |
26 | 19 | ||
27 | ellipsis.init(); | 20 | ellipsis.init(); |
28 | 21 | ||
@@ -167,30 +160,122 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { | @@ -167,30 +160,122 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { | ||
167 | // }); | 160 | // }); |
168 | //}) | 161 | //}) |
169 | 162 | ||
170 | -$('.down').on('touchend', function() { | ||
171 | - chosePanel.show(); | ||
172 | -}); | ||
173 | -$('.cut').on('touchend', function() { | ||
174 | - var id = $(this).closest('.shopping-cart-good').data('id'); | ||
175 | - | 163 | +function requestUpdateAllGoodsCheckStatus(theGoods, successHandeler) { |
164 | + if (requesting) { | ||
165 | + return; | ||
166 | + } | ||
167 | + requesting = true; | ||
176 | $.ajax({ | 168 | $.ajax({ |
177 | - type: 'GET', | ||
178 | - url: '/cart/index/modify', | 169 | + url: 'select', |
170 | + type: 'post', | ||
179 | data: { | 171 | data: { |
180 | - old_product_sku: id, | ||
181 | - new_product_sku: id, | ||
182 | - buy_number: '0', | ||
183 | - selected: 'Y' | 172 | + skuList: JSON.stringify(theGoods) |
184 | }, | 173 | }, |
185 | - success: function(data) { | ||
186 | - if (data.code === 200) { | ||
187 | - window.history.go(0); | 174 | + success: function(res) { |
175 | + if (res.code === 200) { | ||
176 | + successHandeler(); | ||
177 | + } else { | ||
178 | + tip.show(res.message); | ||
188 | } | 179 | } |
189 | }, | 180 | }, |
190 | - error: function() { | ||
191 | - tip.show('网络错误'); | 181 | + error: function(err) { |
182 | + tip.show('网络异常'); | ||
183 | + }, | ||
184 | + complete: function() { | ||
185 | + requesting = false; | ||
192 | } | 186 | } |
193 | }); | 187 | }); |
188 | +} | ||
189 | + | ||
190 | +function didUpdateAllGoodsCheckStatus() { | ||
191 | + var $checkedBoxs = $('.shopping-cart-good .icon-cb-checked'), | ||
192 | + $uncheckedBoxs = $('.shopping-cart-good .icon-checkbox'); | ||
193 | + | ||
194 | + var shouldSelectAll; | ||
195 | + | ||
196 | + if ($selectAllBtn.hasClass('icon-cb-checked')) { | ||
197 | + $selectAllBtn.removeClass('icon-cb-checked').addClass('icon-checkbox'); | ||
198 | + shouldSelectAll = true; | ||
199 | + } else { | ||
200 | + $selectAllBtn.removeClass('icon-checkbox').addClass('icon-cb-checked'); | ||
201 | + shouldSelectAll = false; | ||
202 | + } | ||
203 | + | ||
204 | + if (!shouldSelectAll) { | ||
205 | + $uncheckedBoxs.each(function(idx, uncheckedBox) { | ||
206 | + $(uncheckedBox).removeClass('icon-checkbox').addClass('icon-cb-checked'); | ||
207 | + }); | ||
208 | + } else { | ||
209 | + $checkedBoxs.each(function(idx, checkedBox) { | ||
210 | + $(checkedBox).removeClass('icon-cb-checked').addClass('icon-checkbox'); | ||
211 | + }); | ||
212 | + } | ||
213 | +} | ||
214 | + | ||
215 | +function bottomCheckBoxHandeler(isSelected, type, handlerAfterTouch) { | ||
216 | + var goodInfo = {}; | ||
217 | + var $goods = $('.cart-content:not(.hide) .shopping-cart-good'); | ||
218 | + var $good = null; | ||
219 | + var goodsList = []; | ||
194 | 220 | ||
221 | + function GoodInfo(properties) { | ||
222 | + this.goods_type = properties.goods_type; | ||
223 | + this.buy_number = properties.buy_number; | ||
224 | + this.product_sku = properties.product_sku; | ||
225 | + this.selected = properties.selected; | ||
226 | + } | ||
227 | + | ||
228 | + goodInfo.goods_type = type; | ||
229 | + goodInfo.selected = isSelected ? 'Y' : 'N'; | ||
230 | + | ||
231 | + $goods.each(function(idx, good) { | ||
232 | + $good = $(good); | ||
233 | + | ||
234 | + goodInfo.product_sku = $(good).data('id'); | ||
235 | + goodInfo.buy_number = $good.find('.count').eq(0).text().trim().replace('×', ''); | ||
236 | + | ||
237 | + goodsList.push(new GoodInfo(goodInfo)); | ||
238 | + }); | ||
239 | + console.log(goodsList); | ||
240 | + | ||
241 | + requestUpdateAllGoodsCheckStatus(goodsList, handlerAfterTouch); | ||
242 | +} | ||
243 | + | ||
244 | +//获取当前购物车类型 | ||
245 | +function getCartType() { | ||
246 | + var $navItem = $('.cart-nav ').find('li'), | ||
247 | + type = 'ordinary'; | ||
248 | + | ||
249 | + if ($navItem.eq(0).hasClass('active')) { | ||
250 | + type = 'ordinary'; | ||
251 | + } else { | ||
252 | + type = 'advance'; | ||
253 | + } | ||
254 | + | ||
255 | + return type; | ||
256 | +} | ||
257 | + | ||
258 | +//是否要全选 | ||
259 | +function willBeSelected() { | ||
260 | + var isSelected = true; | ||
261 | + var $this = $(this); | ||
262 | + | ||
263 | + if ($this.hasClass('icon-cb-checked')) { | ||
264 | + isSelected = true; | ||
265 | + } else { | ||
266 | + isSelected = false; | ||
267 | + } | ||
268 | + | ||
269 | + return isSelected; | ||
270 | +} | ||
271 | + | ||
272 | +//全选按钮点击事件 | ||
273 | +$selectAllBtn.on('touchend', function() { | ||
274 | + bottomCheckBoxHandeler(willBeSelected(), getCartType(), didUpdateAllGoodsCheckStatus); | ||
275 | +}); | ||
276 | + | ||
277 | +$('.down').on('touchend', function() { | ||
278 | + chosePanel.show(); | ||
195 | }); | 279 | }); |
196 | 280 | ||
281 | + |
@@ -80,7 +80,7 @@ optHammer.on('tap', function(e) { | @@ -80,7 +80,7 @@ optHammer.on('tap', function(e) { | ||
80 | } else { | 80 | } else { |
81 | tip.show(res.message || '网络错误'); | 81 | tip.show(res.message || '网络错误'); |
82 | } | 82 | } |
83 | - window.location.reload(); | 83 | + window.location.href = '/home/orders'; |
84 | }).fail(function() { | 84 | }).fail(function() { |
85 | tip.show('网络错误'); | 85 | tip.show('网络错误'); |
86 | }); | 86 | }); |
@@ -40,10 +40,10 @@ | @@ -40,10 +40,10 @@ | ||
40 | height: 25rem / $pxConvertRem; | 40 | height: 25rem / $pxConvertRem; |
41 | color: #fff; | 41 | color: #fff; |
42 | text-align: center; | 42 | text-align: center; |
43 | - background: #a1ce4e; | 43 | + background: #eb76aa; |
44 | 44 | ||
45 | &:before { | 45 | &:before { |
46 | - content: '赠品'; | 46 | + content: '加价购'; |
47 | display: block; | 47 | display: block; |
48 | font-size: 12px; | 48 | font-size: 12px; |
49 | line-height: 25rem / $pxConvertRem; | 49 | line-height: 25rem / $pxConvertRem; |
@@ -56,6 +56,7 @@ | @@ -56,6 +56,7 @@ | ||
56 | } | 56 | } |
57 | 57 | ||
58 | .name { | 58 | .name { |
59 | + margin-bottom: 20rem / $pxConvertRem; | ||
59 | width: 440rem / $pxConvertRem; | 60 | width: 440rem / $pxConvertRem; |
60 | font-size: 28rem / $pxConvertRem; | 61 | font-size: 28rem / $pxConvertRem; |
61 | } | 62 | } |
@@ -114,10 +115,10 @@ | @@ -114,10 +115,10 @@ | ||
114 | background: #f8f8f8; | 115 | background: #f8f8f8; |
115 | } | 116 | } |
116 | 117 | ||
117 | - .advance-block .tag { | ||
118 | - background: #eb76aa; | 118 | + .gift-block .tag { |
119 | + background: #a1ce4e; | ||
119 | &:before { | 120 | &:before { |
120 | - content: '加价购'; | 121 | + content: '赠品'; |
121 | } | 122 | } |
122 | } | 123 | } |
123 | } | 124 | } |
@@ -11,7 +11,12 @@ | @@ -11,7 +11,12 @@ | ||
11 | {{/ advanceBuy}} | 11 | {{/ advanceBuy}} |
12 | {{else}} | 12 | {{else}} |
13 | {{# freebie}} | 13 | {{# freebie}} |
14 | + <div class="advance-block gift-block" data-promotion-id="{{promotionId}}"> | ||
15 | + <p class="title">{{title}}</p> | ||
16 | + {{#goods}} | ||
14 | {{> cart/gift-advance-good}} | 17 | {{> cart/gift-advance-good}} |
18 | + {{/goods}} | ||
19 | + </div> | ||
15 | {{/ freebie}} | 20 | {{/ freebie}} |
16 | {{/if}} | 21 | {{/if}} |
17 | 22 |
@@ -7,11 +7,13 @@ | @@ -7,11 +7,13 @@ | ||
7 | <p class="name row">{{name}}</p> | 7 | <p class="name row">{{name}}</p> |
8 | <p class="row"> | 8 | <p class="row"> |
9 | <span class="price"> | 9 | <span class="price"> |
10 | - ¥{{price}} | 10 | + ¥{{#if price}}{{price}}{{else}}{{marketPrice}}{{/if}} |
11 | </span> | 11 | </span> |
12 | + {{#if price}} | ||
12 | <span class="price market-price"> | 13 | <span class="price market-price"> |
13 | ¥{{marketPrice}} | 14 | ¥{{marketPrice}} |
14 | </span> | 15 | </span> |
16 | + {{/if}} | ||
15 | <span class="count"> | 17 | <span class="count"> |
16 | ×{{count}} | 18 | ×{{count}} |
17 | </span> | 19 | </span> |
@@ -6,6 +6,9 @@ | @@ -6,6 +6,9 @@ | ||
6 | {{#navHome}} | 6 | {{#navHome}} |
7 | <a href="{{.}}" class="iconfont nav-home"></a> | 7 | <a href="{{.}}" class="iconfont nav-home"></a> |
8 | {{/navHome}} | 8 | {{/navHome}} |
9 | + {{#navPhone}} | ||
10 | + <a href="{{.}}" class="iconfont nav-home"></a> | ||
11 | + {{/navPhone}} | ||
9 | {{#navTitle}} | 12 | {{#navTitle}} |
10 | <p class="nav-title">{{.}}</p> | 13 | <p class="nav-title">{{.}}</p> |
11 | {{/navTitle}} | 14 | {{/navTitle}} |
@@ -849,10 +849,11 @@ class HomeController extends AbstractAction | @@ -849,10 +849,11 @@ class HomeController extends AbstractAction | ||
849 | } | 849 | } |
850 | 850 | ||
851 | $this->setTitle('订单详情'); | 851 | $this->setTitle('订单详情'); |
852 | - $this->setNavHeader('订单详情'); | 852 | + $this->setNavHeader('订单详情', true, false); |
853 | 853 | ||
854 | $this->_view->display('order-detail', array( | 854 | $this->_view->display('order-detail', array( |
855 | 'orderDetailPage' => true, | 855 | 'orderDetailPage' => true, |
856 | + 'navPhone' => 'tel:400-889-9646', | ||
856 | 'orderDetail' => $orderDetail, | 857 | 'orderDetail' => $orderDetail, |
857 | )); | 858 | )); |
858 | } | 859 | } |
@@ -582,18 +582,14 @@ class CartModel | @@ -582,18 +582,14 @@ class CartModel | ||
582 | { | 582 | { |
583 | $data = array(); | 583 | $data = array(); |
584 | 584 | ||
585 | - // 品牌信息 | ||
586 | - if (isset($productData['brand_info']) && !empty($productData['brand_info'])) { | ||
587 | - $data['thumb'] = Helpers::getImageUrl($productData['brand_info']['brand_ico'], 120, 120); | ||
588 | - } | ||
589 | - | ||
590 | $data['name'] = $productData['product_name']; | 585 | $data['name'] = $productData['product_name']; |
591 | - $data['price'] = $productData['market_price']; | ||
592 | - $data['salePrice'] = $productData['sales_price']; | 586 | + $data['price'] = Helpers::transPrice($productData['market_price']); |
587 | + $data['salePrice'] = Helpers::transPrice($productData['sales_price']); | ||
593 | 588 | ||
594 | if (isset($productData['storage_sum'])) { | 589 | if (isset($productData['storage_sum'])) { |
595 | $data['storage'] = $productData['storage_sum']; | 590 | $data['storage'] = $productData['storage_sum']; |
596 | } | 591 | } |
592 | + $data['num'] = 1; | ||
597 | if ($num !== null) { | 593 | if ($num !== null) { |
598 | $data['num'] = $num; | 594 | $data['num'] = $num; |
599 | } | 595 | } |
@@ -606,25 +602,62 @@ class CartModel | @@ -606,25 +602,62 @@ class CartModel | ||
606 | $oneColor = array(); | 602 | $oneColor = array(); |
607 | $sizes = array(); | 603 | $sizes = array(); |
608 | $oneSize = array(); | 604 | $oneSize = array(); |
605 | + $thumbImageList = array(); | ||
606 | + $colorNum = 0; | ||
607 | + $totalStorageNum = 0; // 总库存数 | ||
608 | + $colorStorageGroup = array(); // 颜色分组的库存总数集合, 多个之间用/分隔 | ||
609 | foreach ($goodsList as $val) { | 609 | foreach ($goodsList as $val) { |
610 | - // 颜色 | ||
611 | - $oneColor = array(); | ||
612 | - $oneColor['id'] = $val['color_id']; | ||
613 | - $oneColor['name'] = $val['color_name']; | 610 | + $colorNum = 0; |
611 | + $sizeStorageStr = ''; | ||
614 | 612 | ||
615 | // 尺码 | 613 | // 尺码 |
616 | foreach ($val['size_list'] as $one) { | 614 | foreach ($val['size_list'] as $one) { |
617 | $oneSize = array(); | 615 | $oneSize = array(); |
618 | $oneSize['id'] = $one['size_id']; | 616 | $oneSize['id'] = $one['size_id']; |
617 | + $oneSize['skuId'] = $one['product_sku']; | ||
618 | + $oneSize['goodsId'] = $val['goods_id']; | ||
619 | + $oneSize['colorId'] = $val['color_id']; | ||
619 | $oneSize['name'] = $one['size_name']; | 620 | $oneSize['name'] = $one['size_name']; |
620 | - } | 621 | + $oneSize['sizeNum'] = $one['storage_number']; |
622 | + | ||
623 | + $colorNum += $one['storage_number']; | ||
624 | + $sizeStorageStr .= $one['storage_number'] . '/'; | ||
625 | + | ||
621 | $sizes[] = $oneSize; | 626 | $sizes[] = $oneSize; |
622 | 627 | ||
623 | - $oneColor['sizes'] = $sizes; | 628 | + $colorStorageGroup[$one['size_name']][$val['color_name']] = $one['storage_number']; |
629 | + } | ||
630 | + | ||
631 | + // 统计尺码对应的各个颜色的库存量 | ||
632 | + foreach ($sizes as &$sizeArr) { | ||
633 | + $sizeArr['colorNumStr'] = implode('/', array_values($colorStorageGroup[ $sizeArr['name'] ]) ); | ||
634 | + } | ||
635 | + | ||
636 | + // 颜色 | ||
637 | + $oneColor = array(); | ||
638 | + $oneColor['id'] = $val['color_id']; | ||
639 | + $oneColor['skcId'] = $val['product_skc']; | ||
640 | + $oneColor['name'] = $val['color_name']; | ||
641 | + $oneColor['goodsName'] = $productData['product_name']; | ||
642 | + $oneColor['colorNum'] = $colorNum; | ||
643 | + $oneColor['sizeNumStr'] = rtrim($sizeStorageStr, '/'); | ||
624 | $colors[] = $oneColor; | 644 | $colors[] = $oneColor; |
645 | + | ||
646 | + // 缩略图 | ||
647 | + foreach ($val['images_list'] as $image) { | ||
648 | + $thumbImageList[] = array( | ||
649 | + 'img' => Helpers::getImageUrl($image['image_url'], 60, 60) | ||
650 | + ); | ||
651 | + } | ||
652 | + | ||
653 | + // 商品库存总数 | ||
654 | + $totalStorageNum += $colorNum; | ||
625 | } | 655 | } |
626 | 656 | ||
657 | + $data['thumbs'] = $thumbImageList; | ||
627 | $data['colors'] = $colors; | 658 | $data['colors'] = $colors; |
659 | + $data['sizes'] = $sizes; | ||
660 | + $data['totalNum'] = $totalStorageNum; | ||
628 | } | 661 | } |
629 | 662 | ||
630 | return $data; | 663 | return $data; |
@@ -668,7 +701,7 @@ class CartModel | @@ -668,7 +701,7 @@ class CartModel | ||
668 | // 失效商品列表 | 701 | // 失效商品列表 |
669 | $notValidGoods = Helpers::formatCartGoods($data['sold_out_goods_list']); | 702 | $notValidGoods = Helpers::formatCartGoods($data['sold_out_goods_list']); |
670 | if (!empty($notValidGoods)) { | 703 | if (!empty($notValidGoods)) { |
671 | - $result['$notValidGoods'] = $notValidGoods; | 704 | + $result['notValidGoods'] = $notValidGoods; |
672 | } | 705 | } |
673 | 706 | ||
674 | // 赠品和加价购商品 | 707 | // 赠品和加价购商品 |
@@ -78,7 +78,7 @@ class IndexController extends AbstractAction | @@ -78,7 +78,7 @@ class IndexController extends AbstractAction | ||
78 | $result = array(); | 78 | $result = array(); |
79 | 79 | ||
80 | if ($this->isAjax()) { | 80 | if ($this->isAjax()) { |
81 | - $productId = $this->post('id', 0); | 81 | + $productId = $this->post('skuList', 0); |
82 | $uid = $this->getUid(true); | 82 | $uid = $this->getUid(true); |
83 | $shoppingKey = $this->getSession('shoppingKey'); | 83 | $shoppingKey = $this->getSession('shoppingKey'); |
84 | $result = CartModel::selectGoods($uid, $productId, $shoppingKey); | 84 | $result = CartModel::selectGoods($uid, $productId, $shoppingKey); |
@@ -207,11 +207,11 @@ class IndexController extends AbstractAction | @@ -207,11 +207,11 @@ class IndexController extends AbstractAction | ||
207 | { | 207 | { |
208 | $result = array(); | 208 | $result = array(); |
209 | 209 | ||
210 | - if ($this->isAjax()) { | 210 | +// if ($this->isAjax()) { |
211 | $skn = $this->get('skn', null); | 211 | $skn = $this->get('skn', null); |
212 | $promotionId = $this->get('promotionId', null); | 212 | $promotionId = $this->get('promotionId', null); |
213 | $result = CartModel::giftProductData($skn, $promotionId); | 213 | $result = CartModel::giftProductData($skn, $promotionId); |
214 | - } | 214 | +// } |
215 | 215 | ||
216 | if (empty($result)) { | 216 | if (empty($result)) { |
217 | echo ' '; | 217 | echo ' '; |
-
Please register or login to post a comment