Authored by uedxwg

Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop

@@ -9,6 +9,7 @@ var $ = require('jquery'), @@ -9,6 +9,7 @@ var $ = require('jquery'),
9 Hammer = require('yoho.hammer'); 9 Hammer = require('yoho.hammer');
10 10
11 var chosePanel = require('./chose-panel'), 11 var chosePanel = require('./chose-panel'),
  12 + dialog = require('../me/dialog'),
12 tip = require('../plugin/tip'); 13 tip = require('../plugin/tip');
13 14
14 var $cartContent = $('.cart-content'); 15 var $cartContent = $('.cart-content');
@@ -20,12 +21,56 @@ var navHammer, @@ -20,12 +21,56 @@ var navHammer,
20 21
21 var hasChecked = $('.cart-content:not(.hide) .icon-cb-checked').length > 0 ? true : false; //是否有选中商品 22 var hasChecked = $('.cart-content:not(.hide) .icon-cb-checked').length > 0 ? true : false; //是否有选中商品
22 23
  24 +function shouldSelectGift() {
  25 + var $freebie = $('.freebie');
  26 +
  27 + if ($freebie.length <= 0) {
  28 + return false;
  29 + }
  30 +
  31 + return true;
  32 +}
  33 +
  34 +function shouldLowStocks() {
  35 + var $lowStocks = $('.low-stocks'),
  36 + result = false;
  37 +
  38 + if ($lowStocks.length <= 0) {
  39 + return result;
  40 + }
  41 +
  42 + $lowStocks.each(function(idx, item) {
  43 + if ($(item).parent().parent().parent().siblings('.checkbox').hasClass('icon-cb-checked')) {
  44 + result = true;
  45 + return false;
  46 + }
  47 + });
  48 +
  49 + return result;
  50 +}
  51 +
  52 +function showChooseGifDialog() {
  53 + dialog.showDialog({
  54 + dialogText: '您还未选择赠品,是否去选择赠品',
  55 + hasFooter: {
  56 + leftBtnText: '我不要赠品',
  57 + rightBtnText: '去选择'
  58 + }
  59 + }, function() {
  60 + window.location.href = $('.freebie').find('a').attr('href');
  61 + }, function() {
  62 + window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
  63 + });
  64 +}
  65 +
23 require('./good'); 66 require('./good');
24 67
25 lazyLoad($('img.lazy')); 68 lazyLoad($('img.lazy'));
26 69
27 if ('advance' === cartType) { 70 if ('advance' === cartType) {
28 $cartContent.toggleClass('hide'); 71 $cartContent.toggleClass('hide');
  72 + $('presell-cart-nav').addClass('active');
  73 + $('common-cart-nav').removeClass('active');
29 } 74 }
30 75
31 if ($('.cart-nav').length > 0) { 76 if ($('.cart-nav').length > 0) {
@@ -39,8 +84,10 @@ if ($('.cart-nav').length > 0) { @@ -39,8 +84,10 @@ if ($('.cart-nav').length > 0) {
39 84
40 if (cartType === 'ordinary') { 85 if (cartType === 'ordinary') {
41 cartType = 'advance'; 86 cartType = 'advance';
  87 + $('#cartType').val('advance');
42 } else { 88 } else {
43 cartType = 'ordinary'; 89 cartType = 'ordinary';
  90 + $('#cartType').val('ordinary');
44 } 91 }
45 92
46 $this.siblings('.active').removeClass('active'); 93 $this.siblings('.active').removeClass('active');
@@ -83,7 +130,11 @@ if ($('.freebie').length > 0) { @@ -83,7 +130,11 @@ if ($('.freebie').length > 0) {
83 //}); 130 //});
84 131
85 $('.btn-balance').on('touchend', function() { 132 $('.btn-balance').on('touchend', function() {
86 - if ($('.low-stocks').length > 0) { 133 + if (shouldSelectGift()) {
  134 + showChooseGifDialog();
  135 + return false;
  136 + }
  137 + if (shouldLowStocks()) {
87 tip.show('库存不足无法结算'); 138 tip.show('库存不足无法结算');
88 return false; 139 return false;
89 } 140 }
@@ -99,7 +150,7 @@ $('.chose').on('touchend', function() { @@ -99,7 +150,7 @@ $('.chose').on('touchend', function() {
99 chosePanel.show(); 150 chosePanel.show();
100 }); 151 });
101 152
102 -if ($('.cart-zero').length > 0) { 153 +if ($('.shopping-cart-good').length <= 0) {
103 require('../product/recommend-for-you'); 154 require('../product/recommend-for-you');
104 } 155 }
105 156
@@ -14,7 +14,6 @@ var dialog = require('../me/dialog'), @@ -14,7 +14,6 @@ var dialog = require('../me/dialog'),
14 orderInfo = require('./order-info').orderInfo; 14 orderInfo = require('./order-info').orderInfo;
15 15
16 var $selectAllBtn = $('.balance .checkbox'), 16 var $selectAllBtn = $('.balance .checkbox'),
17 - cartType = $('#cartType').val(),  
18 requesting = false; 17 requesting = false;
19 18
20 ellipsis.init(); 19 ellipsis.init();
@@ -43,7 +42,7 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { @@ -43,7 +42,7 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
43 var goodsList = [], 42 var goodsList = [],
44 goodInfo = {}; 43 goodInfo = {};
45 44
46 - goodInfo.goods_type = cartType; 45 + goodInfo.goods_type = $('#cartType').val();
47 goodInfo.selected = $this.hasClass('icon-cb-checked') ? 'N' : 'Y'; 46 goodInfo.selected = $this.hasClass('icon-cb-checked') ? 'N' : 'Y';
48 goodInfo.product_sku = id; 47 goodInfo.product_sku = id;
49 goodInfo.buy_number = $good.find('.count').eq(0).text().trim().replace('×', ''); 48 goodInfo.buy_number = $good.find('.count').eq(0).text().trim().replace('×', '');
@@ -62,7 +61,7 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { @@ -62,7 +61,7 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
62 } else { 61 } else {
63 $this.removeClass('icon-checkbox').addClass('icon-cb-checked'); 62 $this.removeClass('icon-checkbox').addClass('icon-cb-checked');
64 } 63 }
65 - window.history.go(0); 64 + window.location.href = '/cart/index/index?cartType=' + $('#cartType').val();
66 } else if (data.code === 400) { 65 } else if (data.code === 400) {
67 tip.show('网络异常'); 66 tip.show('网络异常');
68 } 67 }
@@ -186,7 +185,7 @@ function bottomCheckBoxHandeler(isSelected, type, handlerAfterTouch) { @@ -186,7 +185,7 @@ function bottomCheckBoxHandeler(isSelected, type, handlerAfterTouch) {
186 185
187 //全选按钮点击事件 186 //全选按钮点击事件
188 $selectAllBtn.on('touchend', function() { 187 $selectAllBtn.on('touchend', function() {
189 - bottomCheckBoxHandeler($(this).hasClass('icon-cb-checked'), cartType, didUpdateAllGoodsCheckStatus); 188 + bottomCheckBoxHandeler($(this).hasClass('icon-cb-checked'), $('#cartType').val(), didUpdateAllGoodsCheckStatus);
190 }); 189 });
191 190
192 $('.down').on('touchend', function() { 191 $('.down').on('touchend', function() {
@@ -97,12 +97,6 @@ function orderCompute() { @@ -97,12 +97,6 @@ function orderCompute() {
97 if ($.type(res) !== 'object') { 97 if ($.type(res) !== 'object') {
98 window.location.reload(); 98 window.location.reload();
99 } else { 99 } else {
100 - /*if (res.order_amount) {  
101 - res.order_amount = (+res.order_amount).toFixed(2);  
102 - }  
103 - if (res.discount_amount) {  
104 - res.discount_amount = (+res.discount_amount).toFixed(2);  
105 - }*/  
106 if (res.last_order_amount) { 100 if (res.last_order_amount) {
107 res.last_order_amount = (+res.last_order_amount).toFixed(2); 101 res.last_order_amount = (+res.last_order_amount).toFixed(2);
108 } 102 }
@@ -128,6 +122,10 @@ function submitOrder() { @@ -128,6 +122,10 @@ function submitOrder() {
128 var invoiceText = $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'), 122 var invoiceText = $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'),
129 msg = $('#msg').find('input').val() || orderInfo('msg'); 123 msg = $('#msg').find('input').val() || orderInfo('msg');
130 124
  125 + if (orderInfo('deliveryId') === 2 && !$addressWrap.data('support')) {
  126 + tip.show('当前地址不支持顺丰快递');
  127 + return;
  128 + }
131 if (isSubmiting) { 129 if (isSubmiting) {
132 return false; 130 return false;
133 } 131 }
@@ -3,7 +3,8 @@ @@ -3,7 +3,8 @@
3 * @author: xuqi<qi.xu@yoho.cn> 3 * @author: xuqi<qi.xu@yoho.cn>
4 * @date: 2015/10/21 4 * @date: 2015/10/21
5 */ 5 */
6 -var $ = require('jquery'); 6 +var $ = require('jquery'),
  7 + Hammer = require('yoho.hammer');
7 8
8 var $footer = $('#yoho-footer'), 9 var $footer = $('#yoho-footer'),
9 $yohoPage = $('.yoho-page'), 10 $yohoPage = $('.yoho-page'),
@@ -131,6 +132,8 @@ function reMarginFooter(fixedElement) { @@ -131,6 +132,8 @@ function reMarginFooter(fixedElement) {
131 132
132 var user = getUser(); 133 var user = getUser();
133 134
  135 + var backToTopHammer;
  136 +
134 rePosFooter(); //计算底部位置 137 rePosFooter(); //计算底部位置
135 138
136 if (user === 0) { 139 if (user === 0) {
@@ -151,10 +154,15 @@ function reMarginFooter(fixedElement) { @@ -151,10 +154,15 @@ function reMarginFooter(fixedElement) {
151 ); 154 );
152 } 155 }
153 156
154 - $op.find('.back-to-top').on('touchend', function() {  
155 - $(window).scrollTop(0);  
156 - return false;  
157 - }); 157 + if ($op.find('.back-to-top').length > 0) {
  158 + backToTopHammer = new Hammer($op.find('.back-to-top')[0]);
  159 + backToTopHammer.on('tap', function(e) {
  160 + $(window).scrollTop(0);
  161 + e.srcEvent.preventDefault();
  162 + return false;
  163 + });
  164 + }
  165 +
158 $footer.removeClass('hide'); 166 $footer.removeClass('hide');
159 }()); 167 }());
160 168
@@ -15,7 +15,7 @@ function downLoadApp() { @@ -15,7 +15,7 @@ function downLoadApp() {
15 var appUrl = 'http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho&g_f=995445'; 15 var appUrl = 'http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho&g_f=995445';
16 var clickedAt = new Date(); 16 var clickedAt = new Date();
17 17
18 - setTimeout(function () { 18 + setTimeout(function() {
19 if ((new Date()) - clickedAt < 2000) { 19 if ((new Date()) - clickedAt < 2000) {
20 window.location = appUrl; 20 window.location = appUrl;
21 } 21 }
@@ -33,7 +33,7 @@ dialogTpl = '<div id="dialog-wrapper" class="dialog-wrapper">' + @@ -33,7 +33,7 @@ dialogTpl = '<div id="dialog-wrapper" class="dialog-wrapper">' +
33 33
34 dialogTemplate = Handlebars.compile(dialogTpl); 34 dialogTemplate = Handlebars.compile(dialogTpl);
35 35
36 -exports.showDialog = function(data, callback) { 36 +exports.showDialog = function(data, callback, callbackForLeft) {
37 37
38 var dialogStr = dialogTemplate(data), 38 var dialogStr = dialogTemplate(data),
39 $dialogBox, 39 $dialogBox,
@@ -76,6 +76,9 @@ exports.showDialog = function(data, callback) { @@ -76,6 +76,9 @@ exports.showDialog = function(data, callback) {
76 dialogWrapperHammer.on('tap', function(event) { 76 dialogWrapperHammer.on('tap', function(event) {
77 77
78 if ($(event.target).hasClass('dialog-left-btn')) { 78 if ($(event.target).hasClass('dialog-left-btn')) {
  79 + if (typeof callbackForLeft === 'function') {
  80 + callbackForLeft();
  81 + }
79 $dialogWrapper.fadeOut(); 82 $dialogWrapper.fadeOut();
80 } else if ($(event.target).hasClass('dialog-right-btn')) { 83 } else if ($(event.target).hasClass('dialog-right-btn')) {
81 callback(); 84 callback();
@@ -20,12 +20,12 @@ @@ -20,12 +20,12 @@
20 {{#if cartNav}} 20 {{#if cartNav}}
21 <ul class="cart-nav clearfix"> 21 <ul class="cart-nav clearfix">
22 <li class="active"> 22 <li class="active">
23 - <span> 23 + <span id="common-cart-nav">
24 普通商品({{commonGoodsCount}}) 24 普通商品({{commonGoodsCount}})
25 </span> 25 </span>
26 </li> 26 </li>
27 <li> 27 <li>
28 - <span> 28 + <span id="presell-cart-nav">
29 预售商品({{presellGoodsCount}}) 29 预售商品({{presellGoodsCount}})
30 </span> 30 </span>
31 <div id="presell-tip" class="presell-tip"> 31 <div id="presell-tip" class="presell-tip">
@@ -346,7 +346,8 @@ class CartModel @@ -346,7 +346,8 @@ class CartModel
346 $result['phoneNum'] = isset($address['mobile']) ? $address['mobile'] : $payReturn['delivery_address']['mobile']; 346 $result['phoneNum'] = isset($address['mobile']) ? $address['mobile'] : $payReturn['delivery_address']['mobile'];
347 $result['area'] = isset($address['area']) ? $address['area'] : $payReturn['delivery_address']['area']; 347 $result['area'] = isset($address['area']) ? $address['area'] : $payReturn['delivery_address']['area'];
348 $result['address'] = isset($address['address']) ? $address['address'] : $payReturn['delivery_address']['address']; 348 $result['address'] = isset($address['address']) ? $address['address'] : $payReturn['delivery_address']['address'];
349 - $result['isSupport'] = ($payReturn['delivery_address']['is_support'] === 'Y'); 349 + $isSupport = isset($address['is_support']) ? $address['is_support'] : $payReturn['delivery_address']['is_support'];
  350 + $result['isSupport'] = $isSupport === 'Y';
350 } 351 }
351 352
352 // 配送方式 353 // 配送方式