Authored by hf

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

... ... @@ -561,9 +561,10 @@ class Helpers
*
* @param array $cartGoods 购物车商品列表
* @param boolean $isValid 是否是可用商品(非失效商品),默认是
* @param bool $isAdvanceCart 是否是预售购物车(和上市期有关)
* @return array 处理之后的购物车商品数据
*/
public static function formatCartGoods($cartGoods, $isValid = true)
public static function formatCartGoods($cartGoods, $isAdvanceCart, $isValid = true)
{
$arr = array();
... ... @@ -592,7 +593,7 @@ class Helpers
$oneGoods['isAdvanceBuy'] = true;
}
// 上市期
if (!empty($value['expect_arrival_time'])) {
if ($isAdvanceCart && !empty($value['expect_arrival_time'])) {
$oneGoods['appearDate'] = $value['expect_arrival_time'];
}
// 商品链接
... ... @@ -628,7 +629,6 @@ class Helpers
$oneGoods['id'] = $single['product_skn'];
$oneGoods['name'] = $single['product_name'];
$oneGoods['thumb'] = !empty($single['goods_images']) ? Images::getImageUrl($single['goods_images'], 120, 160) : '';
$oneGoods['appearDate'] = '12月'; // 目前app接口没有返回该数据
$oneGoods['price'] = self::transPrice($single['last_price']);
$oneGoods['marketPrice'] = self::transPrice($single['market_price']);
$oneGoods['count'] = $single['storage_number'];
... ...
... ... @@ -16,6 +16,7 @@ var dispatchModeHammer,
dispatchTimeHammer,
$invoice = $('.invoice'),
$price = $('.price-cal'),
$couponUse = $('.coupon-use.used'),
payType,
priceTmpl = Handlebars.compile($('#tmpl-price').html()),
queryString = $.queryString(),
... ... @@ -27,6 +28,11 @@ if (window.getUid() !== orderInfo('uid')) {
order.init();
}
if ($couponUse.data('value') !== orderInfo('couponValue')) {
orderInfo('couponCode', null);
orderInfo('couponValue', null);
}
function dispacthTapEvt(e) {
var $cur = $(e.target).closest('li');
... ... @@ -110,10 +116,25 @@ function orderCompute() {
}
function submitOrder() {
if (orderInfo('invoice') && !orderInfo('invoiceText')) {
var invoiceText = $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'),
msg = $('#msg').find('input').val() || orderInfo('msg');
if (orderInfo('invoice')) {
if (!invoiceText) {
tip.show('请输入发票抬头');
return;
}
if (invoiceText.length > 30) {
tip.show('发票抬头不得超过30个汉字');
return;
}
}
if (msg) {
if (msg.length > 40) {
tip.show('留言不得超过40个汉字');
return;
}
}
loading.showLoadingMask();
$.ajax({
method: 'POST',
... ... @@ -123,9 +144,9 @@ function submitOrder() {
cartType: queryString.cartType || queryString.carttype || 'ordinary',
deliveryId: orderInfo('deliveryId'),
deliveryTimeId: orderInfo('deliveryTimeId'),
invoiceText: $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'),
invoiceText: invoiceText,
invoiceType: $invoice.find('.invoice-type').val() || orderInfo('invoiceType'),
msg: $('#msg').find('input').val() || orderInfo('msg'),
msg: msg,
paymentTypeId: orderInfo('paymentTypeId'),
paymentType: orderInfo('paymentType'), //支付方式
couponCode: orderInfo('couponCode'),
... ... @@ -198,7 +219,7 @@ $invoice.find('[name="invoice-title"]').on('blur', function() {
orderInfo('invoiceType', $(this).val());
});
$('#msg').find('input').on('blur', function() {
$('#msg').find('textarea').on('blur', function() {
orderInfo('msg', $(this).val());
});
... ...
... ... @@ -166,7 +166,8 @@
}
}
.block input {
.block {
input, textarea {
box-sizing: border-box;
margin: pxToRem(20px) 0;
padding: 0 pxToRem(12px);
... ... @@ -180,6 +181,12 @@
border: 0;
@include border-radius(4px);
}
textarea {
padding: pxToRem(12px);
height: auto;
resize: none;
}
}
#invoice {
border-top: 1px solid #f7f7f7;
... ...
... ... @@ -50,7 +50,7 @@
</span>
{{#if value}}
<span class="used coupon-use">
<span class="used coupon-use" data-value="{{value}}">
{{value}}
<i class="iconfont">&#xe614;</i>
</span>
... ... @@ -77,7 +77,7 @@
<span class="title">发票</span>
<span class="iconfont checkbox {{#if needInvoice}}icon-cb-checked{{else}}icon-checkbox{{/if}}"></span>
<form id="invoice">
<input type="text" name="invoice-title" value="{{invoiceText}}" placeholder="发票抬头">
<input type="text" name="invoice-title" value="{{invoiceText}}" maxlength="30" placeholder="发票抬头">
<label>
发票类型
<select class="invoice-type" name="invoice-type">
... ... @@ -92,7 +92,7 @@
</ul>
<form id="msg" action="" method="post">
<input type="text" name="msg" value="{{msg}}" placeholder="留言">
<textarea name="msg" rows="2" maxlength="40" placeholder="留言">{{msg}}</textarea>
</form>
</section>
... ...
... ... @@ -103,7 +103,7 @@ class CartModel
/* 普通购物车 */
$result['commonGoodsCount'] = $ordinaryCount;
$result['commonCart'] = self::procCartData($cart['ordinary_cart_data'], $onlyGift, $onlyAdvanceBuy);
$result['commonCart'] = self::procCartData($cart['ordinary_cart_data'], $onlyGift, $onlyAdvanceBuy, false);
/* 预售购物车 */
$result['presellGoodsCount'] = $advanceCount;
$result['preSellCart'] = self::procCartData($cart['advance_cart_data'], $onlyGift, $onlyAdvanceBuy);
... ... @@ -722,15 +722,16 @@ class CartModel
* @param array $data 不同类型购物车数据
* @param bool $onlyGift 只获取赠品的商品数据
* @param bool $onlyAdvanceBuy 只获取加价购的商品数据
* @param bool $isAdvanceCart 是否是预售购物车,默认是,(和上市期有关)
* @return array $result 处理之后的不同类型购物车数据
*/
private static function procCartData($data, $onlyGift = false, $onlyAdvanceBuy = false)
private static function procCartData($data, $onlyGift = false, $onlyAdvanceBuy = false, $isAdvanceCart = true)
{
$result = array();
do {
// 数据为空时返回空的标志
if (empty($data)) {
if (empty($data['goods_list'])) {
break;
}
... ... @@ -746,13 +747,13 @@ class CartModel
}
// 购买的可用商品列表
$validGoods = Helpers::formatCartGoods($data['goods_list']);
$validGoods = Helpers::formatCartGoods($data['goods_list'], $isAdvanceCart);
if (!empty($validGoods)) {
$result['goods'] = $validGoods;
}
// 失效商品列表
$notValidGoods = Helpers::formatCartGoods($data['sold_out_goods_list'], false);
$notValidGoods = Helpers::formatCartGoods($data['sold_out_goods_list'], $isAdvanceCart, false);
if (!empty($notValidGoods)) {
$result['notValidGoods'] = $notValidGoods;
}
... ...