From 1567cbd2b9a54a0e0763f65aa5cdfca54af1b128 Mon Sep 17 00:00:00 2001
From: liangzhifeng <zhifeng.liang@yoho.cn>
Date: Sun, 20 Dec 2015 17:21:14 +0800
Subject: [PATCH] 购物车修改

---
 static/js/cart/cart.js                                  |  5 +++++
 static/js/cart/chose-panel.js                           | 20 +++++++++-----------
 static/js/cart/gift-advance.js                          |  7 +++++--
 template/m.yohobuy.com/partials/cart/cart-content.phtml |  2 +-
 template/m.yohobuy.com/partials/cart/chose-panel.phtml  |  2 +-
 5 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/static/js/cart/cart.js b/static/js/cart/cart.js
index 1e7bf70..38ba42f 100644
--- a/static/js/cart/cart.js
+++ b/static/js/cart/cart.js
@@ -14,6 +14,7 @@ var chosePanel = require('./chose-panel'),
 var $cartContent = $('.cart-content');
 
 var navHammer,
+    $advanceBuy = $('.advance-buy'),
     cartType = $('#cartType').val();
 
 var hasChecked = $('.cart-goods .icon-cb-checked').length > 0 ? true : false; //是否有选中商品
@@ -56,6 +57,10 @@ if ($('.cart-nav').length > 0) {
     }, 3000);
 }
 
+$('.advance-buy').on('touchend', function() {
+    window.location.href = '/cart/index/advanceBuy?cartType=' + cartType;
+});
+
 $('.btn-balance').on('touchend', function() {
     if (hasChecked) {
         window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
diff --git a/static/js/cart/chose-panel.js b/static/js/cart/chose-panel.js
index a3b2c4e..daedcdc 100644
--- a/static/js/cart/chose-panel.js
+++ b/static/js/cart/chose-panel.js
@@ -17,9 +17,6 @@ var $chosePanel = $('#chose-panel'),
     $num,
     $chosed,
     $imgsThumb,
-
-    // re = /\d+/,
-
     $leftNum,
     leftNum,
     confirming,
@@ -31,6 +28,7 @@ var $chosePanel = $('#chose-panel'),
     $curSizeBlock,
     $sizeRowList,
     cbFn,
+    cartType,
     $allChoseItems,
     $yohoPage = $('.yoho-page');
 
@@ -41,10 +39,10 @@ function init() {
     hasChooseColor = false;
     hasChooseSize = false;
     $curSizeBlock = null;
-    $imgsThumb = $('.chose-panel').find('.thumb'),
-    $allChoseItems = $('.chose-items'),
-    $sizeRowList = $('.size-list ul'),
-    $leftNum = $('#left-num'),
+    $imgsThumb = $('.chose-panel').find('.thumb');
+    $allChoseItems = $('.chose-items');
+    $sizeRowList = $('.size-list ul');
+    $leftNum = $('#left-num');
     $firstRow = $sizeRowList.eq(0);
     $firstRow.toggleClass('hide');
     $curSizeRow = $firstRow;
@@ -77,7 +75,7 @@ function show(html, cb) {
 //隐藏当前Panel
 function hide() {
     $('.chose-panel').hide();
-    cbFn = null;
+    //cbFn = null;
 }
 
 //修改加入购物车的文字和背景
@@ -168,7 +166,6 @@ $yohoPage.on('touchstart', '.color-list .block', function(e) {
         // 之前选中的尺码去掉勾选样式
         if ($preSiblingBlock.length > 0) {
             $preSiblingBlock.removeClass('chosed');
-
         }
 
         curSizeBlock = $curSizeRow.children().get(scindex);
@@ -328,7 +325,8 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
                 productSku: productSku,
                 buyNumber: buyNumber,
                 promotionId: promotionId,
-                isEdit: isEdit
+                isEdit: isEdit,
+                cartType: cartType
             }
         }).done(function(res) {
             loading.hideLoadingMask();
@@ -338,7 +336,7 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
                 hide();
 
                 if (cbFn) {
-                    cbFn(res.location);
+                    cbFn();
                 }
             }
             if (res.message) {
diff --git a/static/js/cart/gift-advance.js b/static/js/cart/gift-advance.js
index 026f646..1dc08fb 100644
--- a/static/js/cart/gift-advance.js
+++ b/static/js/cart/gift-advance.js
@@ -10,7 +10,8 @@ var $ = require('jquery'),
     loading = require('../plugin/loading'),
     chosePanel = require('./chose-panel');
 
-var $page = $('.gift-advance-page');
+var $page = $('.gift-advance-page'),
+    queryString = $.queryString();
 
 lazyLoad($('.lazy'));
 
@@ -24,7 +25,9 @@ function getProductInfo(skn, promotionId) {
             tip.show('网络错误');
             return;
         }
-        chosePanel.show(html);
+        chosePanel.show(html, function(){
+            window.location.href = '/cart/index/orderEnsure?cartType=' + queryString.cartType;
+        });
     }, function() {
         tip.show('网络错误');
     }).always(function() {
diff --git a/template/m.yohobuy.com/partials/cart/cart-content.phtml b/template/m.yohobuy.com/partials/cart/cart-content.phtml
index e88ccd4..6684c4f 100644
--- a/template/m.yohobuy.com/partials/cart/cart-content.phtml
+++ b/template/m.yohobuy.com/partials/cart/cart-content.phtml
@@ -25,7 +25,7 @@
             <li class="advance-buy">
                 <span class="iconfont">&#xe61b;</span>
                 加价购
-                <a href="/cart/index/advanceBuy">
+                <a href="">
                     <span class="count">{{advanceBuyCount}}</span>
                     <span class="iconfont icon-right-arrow">&#xe614;</span>
                 </a>
diff --git a/template/m.yohobuy.com/partials/cart/chose-panel.phtml b/template/m.yohobuy.com/partials/cart/chose-panel.phtml
index b9d6b6c..56fb6c3 100644
--- a/template/m.yohobuy.com/partials/cart/chose-panel.phtml
+++ b/template/m.yohobuy.com/partials/cart/chose-panel.phtml
@@ -37,7 +37,7 @@
 
                     <ul class="size-row clearfix hide">
                         {{# size}}
-                        <li class="block {{#if chosed}}chosed{{/if}} {{#unless sizeNum}}zero-stock{{/unless}}" data-id={{id}} data-colorid="{{colorId}}" data-num="{{sizeNum}}" data-numstr="{{colorNumStr}}" data-skuid="{{skuId}}" data-goodid="{{goodsId}}">
+                        <li class="block {{#if chosed}}chosed{{/if}} {{#unless sizeNum}}zero-stock{{/unless}}" data-id="{{id}}" data-colorid="{{colorId}}" data-num="{{sizeNum}}" data-numstr="{{colorNumStr}}" data-skuid="{{skuId}}" data-goodid="{{goodsId}}">
                             {{name}}
                         </li>
                         {{/ size}}
--
libgit2 0.24.0