Authored by 毕凯

订单确认增加价格价格计算

... ... @@ -7,11 +7,15 @@
var $ = require('jquery'),
lazyLoad = require('yoho.lazyload'),
Hammer = require('yoho.hammer'),
Handlebars = require('yoho.handlebars'),
tip = require('../plugin/tip'),
orderInfo = require('./order-info').orderInfo;
var dispatchModeHammer,
dispatchTimeHammer,
$invoice = $('.invoice');
$invoice = $('.invoice'),
$price = $('.price-cal'),
priceTmpl = Handlebars.compile($('#tmpl-price').html());
lazyLoad();
... ... @@ -26,6 +30,38 @@ function dispacthTapEvt(e) {
$cur.addClass('chosed');
}
function orderCompute() {
$.ajax({
method: 'POST',
url: '/shoppingCart/orderCompute',
data: {
cartType: orderInfo('cartType'),
deliveryId: orderInfo('deliveryId'),
paymentTypeId: orderInfo('paymentTypeId'),
couponCode: orderInfo('couponCode'),
yohoCoin: orderInfo('yohoCoin')
}
}).then(function(res) {
var priceHtml;
if (!res) {
tip.show('网络出错');
} else {
priceHtml = priceTmpl({
sumPrice: res.order_amount,
salePrice: res.discount_amount,
freight: res.promotion_formula_list[1].promotion_amount,
yohoCoin: res.use_yoho_coin,
price: res.last_order_amount
});
$price.html(priceHtml);
}
}).fail(function() {
tip.show('网络出错');
});
}
dispatchModeHammer = new Hammer(document.getElementsByClassName('dispatch-mode')[0]);
dispatchModeHammer.on('tap', dispacthTapEvt);
... ... @@ -58,6 +94,7 @@ $('.invoice').on('touchend', '.checkbox', function() {
// 界面点击,状态存 cookie
$('.dispatch-mode').on('touchend', 'li', function() {
orderInfo('deliveryId', $(this).data('id'));
orderCompute();
});
$('.dispatch-time').on('touchend', 'li', function() {
... ... @@ -69,9 +106,12 @@ $('.coin').on('touchend', function() {
if ($this.find('.checkbox').hasClass('icon-cb-checked')) {
orderInfo('yohoCoin', $this.data('yoho-coin'));
$this.find('.coin-check em').show();
} else {
orderInfo('yohoCoin', 0);
$this.find('.coin-check em').hide();
}
orderCompute();
});
$invoice.on('touchend', function() {
... ...
... ... @@ -102,23 +102,23 @@
</form>
</section>
<section class="block">
<section class="price-cal block">
<ul class="total">
<li>
<span>总价</span>
&nbsp;&nbsp;¥ {{sumPrice}}
&nbsp;&nbsp;¥{{sumPrice}}
</li>
<li>
<span>活动价</span>
- ¥ {{salePrice}}
- ¥{{salePrice}}
</li>
<li>
<span>运费</span>
+ ¥ {{freight}}
+ ¥{{freight}}
</li>
<li>
<span>YOHO币</span>
- ¥ {{yohoCoin}}
- ¥{{yohoCoin}}
</li>
<li class="cost">
应付金额: <em>¥{{price}}</em>
... ... @@ -142,4 +142,27 @@
</ul>
{{/ orderEnsure}}
</div>
<script id="tmpl-price" type="text/tmpl">
<ul class="total">
<li>
<span>总价</span>
&nbsp;&nbsp;¥\{{sumPrice}}
</li>
<li>
<span>活动价</span>
- ¥\{{salePrice}}
</li>
<li>
<span>运费</span>
+ \{{freight}}
</li>
<li>
<span>YOHO币</span>
- ¥\{{yohoCoin}}
</li>
<li class="cost">
应付金额: <em>¥\{{price}}</em>
</li>
</ul>
</script>
{{> layout/footer}}
... ...
... ... @@ -169,10 +169,10 @@ class ShoppingCartController extends AbstractAction
if ($this->isAjax()) {
$cartType = $this->post('cartType', 'ordinary');
$deliveryWay = $this->post('deliveryWay', 1);
$paymentType = $this->post('paymentType', 1);
$couponCode = $this->post('paymentType', null);
$yohoCoin = $this->post('paymentType', null);
$deliveryWay = $this->post('deliveryId', 1);
$paymentType = $this->post('paymentTypeId', 1);
$couponCode = $this->post('couponCode', null);
$yohoCoin = $this->post('yohoCoin', null);
$uid = $this->getUid(true);
$result = CartModel::orderCompute($uid, $cartType, $deliveryWay, $paymentType, $couponCode, $yohoCoin);
}
... ...