Authored by hf

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

@@ -561,9 +561,10 @@ class Helpers @@ -561,9 +561,10 @@ class Helpers
561 * 561 *
562 * @param array $cartGoods 购物车商品列表 562 * @param array $cartGoods 购物车商品列表
563 * @param boolean $isValid 是否是可用商品(非失效商品),默认是 563 * @param boolean $isValid 是否是可用商品(非失效商品),默认是
  564 + * @param bool $isAdvanceCart 是否是预售购物车(和上市期有关)
564 * @return array 处理之后的购物车商品数据 565 * @return array 处理之后的购物车商品数据
565 */ 566 */
566 - public static function formatCartGoods($cartGoods, $isValid = true) 567 + public static function formatCartGoods($cartGoods, $isAdvanceCart, $isValid = true)
567 { 568 {
568 $arr = array(); 569 $arr = array();
569 570
@@ -592,7 +593,7 @@ class Helpers @@ -592,7 +593,7 @@ class Helpers
592 $oneGoods['isAdvanceBuy'] = true; 593 $oneGoods['isAdvanceBuy'] = true;
593 } 594 }
594 // 上市期 595 // 上市期
595 - if (!empty($value['expect_arrival_time'])) { 596 + if ($isAdvanceCart && !empty($value['expect_arrival_time'])) {
596 $oneGoods['appearDate'] = $value['expect_arrival_time']; 597 $oneGoods['appearDate'] = $value['expect_arrival_time'];
597 } 598 }
598 // 商品链接 599 // 商品链接
@@ -628,7 +629,6 @@ class Helpers @@ -628,7 +629,6 @@ class Helpers
628 $oneGoods['id'] = $single['product_skn']; 629 $oneGoods['id'] = $single['product_skn'];
629 $oneGoods['name'] = $single['product_name']; 630 $oneGoods['name'] = $single['product_name'];
630 $oneGoods['thumb'] = !empty($single['goods_images']) ? Images::getImageUrl($single['goods_images'], 120, 160) : ''; 631 $oneGoods['thumb'] = !empty($single['goods_images']) ? Images::getImageUrl($single['goods_images'], 120, 160) : '';
631 - $oneGoods['appearDate'] = '12月'; // 目前app接口没有返回该数据  
632 $oneGoods['price'] = self::transPrice($single['last_price']); 632 $oneGoods['price'] = self::transPrice($single['last_price']);
633 $oneGoods['marketPrice'] = self::transPrice($single['market_price']); 633 $oneGoods['marketPrice'] = self::transPrice($single['market_price']);
634 $oneGoods['count'] = $single['storage_number']; 634 $oneGoods['count'] = $single['storage_number'];
@@ -16,6 +16,7 @@ var dispatchModeHammer, @@ -16,6 +16,7 @@ var dispatchModeHammer,
16 dispatchTimeHammer, 16 dispatchTimeHammer,
17 $invoice = $('.invoice'), 17 $invoice = $('.invoice'),
18 $price = $('.price-cal'), 18 $price = $('.price-cal'),
  19 + $couponUse = $('.coupon-use.used'),
19 payType, 20 payType,
20 priceTmpl = Handlebars.compile($('#tmpl-price').html()), 21 priceTmpl = Handlebars.compile($('#tmpl-price').html()),
21 queryString = $.queryString(), 22 queryString = $.queryString(),
@@ -27,6 +28,11 @@ if (window.getUid() !== orderInfo('uid')) { @@ -27,6 +28,11 @@ if (window.getUid() !== orderInfo('uid')) {
27 order.init(); 28 order.init();
28 } 29 }
29 30
  31 +if ($couponUse.data('value') !== orderInfo('couponValue')) {
  32 + orderInfo('couponCode', null);
  33 + orderInfo('couponValue', null);
  34 +}
  35 +
30 function dispacthTapEvt(e) { 36 function dispacthTapEvt(e) {
31 var $cur = $(e.target).closest('li'); 37 var $cur = $(e.target).closest('li');
32 38
@@ -110,10 +116,25 @@ function orderCompute() { @@ -110,10 +116,25 @@ function orderCompute() {
110 } 116 }
111 117
112 function submitOrder() { 118 function submitOrder() {
113 - if (orderInfo('invoice') && !orderInfo('invoiceText')) { 119 + var invoiceText = $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'),
  120 + msg = $('#msg').find('input').val() || orderInfo('msg');
  121 +
  122 + if (orderInfo('invoice')) {
  123 + if (!invoiceText) {
114 tip.show('请输入发票抬头'); 124 tip.show('请输入发票抬头');
115 return; 125 return;
116 } 126 }
  127 + if (invoiceText.length > 30) {
  128 + tip.show('发票抬头不得超过30个汉字');
  129 + return;
  130 + }
  131 + }
  132 + if (msg) {
  133 + if (msg.length > 40) {
  134 + tip.show('留言不得超过40个汉字');
  135 + return;
  136 + }
  137 + }
117 loading.showLoadingMask(); 138 loading.showLoadingMask();
118 $.ajax({ 139 $.ajax({
119 method: 'POST', 140 method: 'POST',
@@ -123,9 +144,9 @@ function submitOrder() { @@ -123,9 +144,9 @@ function submitOrder() {
123 cartType: queryString.cartType || queryString.carttype || 'ordinary', 144 cartType: queryString.cartType || queryString.carttype || 'ordinary',
124 deliveryId: orderInfo('deliveryId'), 145 deliveryId: orderInfo('deliveryId'),
125 deliveryTimeId: orderInfo('deliveryTimeId'), 146 deliveryTimeId: orderInfo('deliveryTimeId'),
126 - invoiceText: $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'), 147 + invoiceText: invoiceText,
127 invoiceType: $invoice.find('.invoice-type').val() || orderInfo('invoiceType'), 148 invoiceType: $invoice.find('.invoice-type').val() || orderInfo('invoiceType'),
128 - msg: $('#msg').find('input').val() || orderInfo('msg'), 149 + msg: msg,
129 paymentTypeId: orderInfo('paymentTypeId'), 150 paymentTypeId: orderInfo('paymentTypeId'),
130 paymentType: orderInfo('paymentType'), //支付方式 151 paymentType: orderInfo('paymentType'), //支付方式
131 couponCode: orderInfo('couponCode'), 152 couponCode: orderInfo('couponCode'),
@@ -198,7 +219,7 @@ $invoice.find('[name="invoice-title"]').on('blur', function() { @@ -198,7 +219,7 @@ $invoice.find('[name="invoice-title"]').on('blur', function() {
198 orderInfo('invoiceType', $(this).val()); 219 orderInfo('invoiceType', $(this).val());
199 }); 220 });
200 221
201 -$('#msg').find('input').on('blur', function() { 222 +$('#msg').find('textarea').on('blur', function() {
202 orderInfo('msg', $(this).val()); 223 orderInfo('msg', $(this).val());
203 }); 224 });
204 225
@@ -166,7 +166,8 @@ @@ -166,7 +166,8 @@
166 } 166 }
167 } 167 }
168 168
169 - .block input { 169 + .block {
  170 + input, textarea {
170 box-sizing: border-box; 171 box-sizing: border-box;
171 margin: pxToRem(20px) 0; 172 margin: pxToRem(20px) 0;
172 padding: 0 pxToRem(12px); 173 padding: 0 pxToRem(12px);
@@ -180,6 +181,12 @@ @@ -180,6 +181,12 @@
180 border: 0; 181 border: 0;
181 @include border-radius(4px); 182 @include border-radius(4px);
182 } 183 }
  184 + textarea {
  185 + padding: pxToRem(12px);
  186 + height: auto;
  187 + resize: none;
  188 + }
  189 + }
183 190
184 #invoice { 191 #invoice {
185 border-top: 1px solid #f7f7f7; 192 border-top: 1px solid #f7f7f7;
@@ -50,7 +50,7 @@ @@ -50,7 +50,7 @@
50 </span> 50 </span>
51 51
52 {{#if value}} 52 {{#if value}}
53 - <span class="used coupon-use"> 53 + <span class="used coupon-use" data-value="{{value}}">
54 {{value}} 54 {{value}}
55 <i class="iconfont">&#xe614;</i> 55 <i class="iconfont">&#xe614;</i>
56 </span> 56 </span>
@@ -77,7 +77,7 @@ @@ -77,7 +77,7 @@
77 <span class="title">发票</span> 77 <span class="title">发票</span>
78 <span class="iconfont checkbox {{#if needInvoice}}icon-cb-checked{{else}}icon-checkbox{{/if}}"></span> 78 <span class="iconfont checkbox {{#if needInvoice}}icon-cb-checked{{else}}icon-checkbox{{/if}}"></span>
79 <form id="invoice"> 79 <form id="invoice">
80 - <input type="text" name="invoice-title" value="{{invoiceText}}" placeholder="发票抬头"> 80 + <input type="text" name="invoice-title" value="{{invoiceText}}" maxlength="30" placeholder="发票抬头">
81 <label> 81 <label>
82 发票类型 82 发票类型
83 <select class="invoice-type" name="invoice-type"> 83 <select class="invoice-type" name="invoice-type">
@@ -92,7 +92,7 @@ @@ -92,7 +92,7 @@
92 </ul> 92 </ul>
93 93
94 <form id="msg" action="" method="post"> 94 <form id="msg" action="" method="post">
95 - <input type="text" name="msg" value="{{msg}}" placeholder="留言"> 95 + <textarea name="msg" rows="2" maxlength="40" placeholder="留言">{{msg}}</textarea>
96 </form> 96 </form>
97 </section> 97 </section>
98 98
@@ -103,7 +103,7 @@ class CartModel @@ -103,7 +103,7 @@ class CartModel
103 103
104 /* 普通购物车 */ 104 /* 普通购物车 */
105 $result['commonGoodsCount'] = $ordinaryCount; 105 $result['commonGoodsCount'] = $ordinaryCount;
106 - $result['commonCart'] = self::procCartData($cart['ordinary_cart_data'], $onlyGift, $onlyAdvanceBuy); 106 + $result['commonCart'] = self::procCartData($cart['ordinary_cart_data'], $onlyGift, $onlyAdvanceBuy, false);
107 /* 预售购物车 */ 107 /* 预售购物车 */
108 $result['presellGoodsCount'] = $advanceCount; 108 $result['presellGoodsCount'] = $advanceCount;
109 $result['preSellCart'] = self::procCartData($cart['advance_cart_data'], $onlyGift, $onlyAdvanceBuy); 109 $result['preSellCart'] = self::procCartData($cart['advance_cart_data'], $onlyGift, $onlyAdvanceBuy);
@@ -722,15 +722,16 @@ class CartModel @@ -722,15 +722,16 @@ class CartModel
722 * @param array $data 不同类型购物车数据 722 * @param array $data 不同类型购物车数据
723 * @param bool $onlyGift 只获取赠品的商品数据 723 * @param bool $onlyGift 只获取赠品的商品数据
724 * @param bool $onlyAdvanceBuy 只获取加价购的商品数据 724 * @param bool $onlyAdvanceBuy 只获取加价购的商品数据
  725 + * @param bool $isAdvanceCart 是否是预售购物车,默认是,(和上市期有关)
725 * @return array $result 处理之后的不同类型购物车数据 726 * @return array $result 处理之后的不同类型购物车数据
726 */ 727 */
727 - private static function procCartData($data, $onlyGift = false, $onlyAdvanceBuy = false) 728 + private static function procCartData($data, $onlyGift = false, $onlyAdvanceBuy = false, $isAdvanceCart = true)
728 { 729 {
729 $result = array(); 730 $result = array();
730 731
731 do { 732 do {
732 // 数据为空时返回空的标志 733 // 数据为空时返回空的标志
733 - if (empty($data)) { 734 + if (empty($data['goods_list'])) {
734 break; 735 break;
735 } 736 }
736 737
@@ -746,13 +747,13 @@ class CartModel @@ -746,13 +747,13 @@ class CartModel
746 } 747 }
747 748
748 // 购买的可用商品列表 749 // 购买的可用商品列表
749 - $validGoods = Helpers::formatCartGoods($data['goods_list']); 750 + $validGoods = Helpers::formatCartGoods($data['goods_list'], $isAdvanceCart);
750 if (!empty($validGoods)) { 751 if (!empty($validGoods)) {
751 $result['goods'] = $validGoods; 752 $result['goods'] = $validGoods;
752 } 753 }
753 754
754 // 失效商品列表 755 // 失效商品列表
755 - $notValidGoods = Helpers::formatCartGoods($data['sold_out_goods_list'], false); 756 + $notValidGoods = Helpers::formatCartGoods($data['sold_out_goods_list'], $isAdvanceCart, false);
756 if (!empty($notValidGoods)) { 757 if (!empty($notValidGoods)) {
757 $result['notValidGoods'] = $notValidGoods; 758 $result['notValidGoods'] = $notValidGoods;
758 } 759 }