|
@@ -7,11 +7,15 @@ |
|
@@ -7,11 +7,15 @@ |
7
|
var $ = require('jquery'),
|
7
|
var $ = require('jquery'),
|
8
|
lazyLoad = require('yoho.lazyload'),
|
8
|
lazyLoad = require('yoho.lazyload'),
|
9
|
Hammer = require('yoho.hammer'),
|
9
|
Hammer = require('yoho.hammer'),
|
|
|
10
|
+ Handlebars = require('yoho.handlebars'),
|
|
|
11
|
+ tip = require('../plugin/tip'),
|
10
|
orderInfo = require('./order-info').orderInfo;
|
12
|
orderInfo = require('./order-info').orderInfo;
|
11
|
|
13
|
|
12
|
var dispatchModeHammer,
|
14
|
var dispatchModeHammer,
|
13
|
dispatchTimeHammer,
|
15
|
dispatchTimeHammer,
|
14
|
- $invoice = $('.invoice');
|
16
|
+ $invoice = $('.invoice'),
|
|
|
17
|
+ $price = $('.price-cal'),
|
|
|
18
|
+ priceTmpl = Handlebars.compile($('#tmpl-price').html());
|
15
|
|
19
|
|
16
|
lazyLoad();
|
20
|
lazyLoad();
|
17
|
|
21
|
|
|
@@ -26,6 +30,38 @@ function dispacthTapEvt(e) { |
|
@@ -26,6 +30,38 @@ function dispacthTapEvt(e) { |
26
|
$cur.addClass('chosed');
|
30
|
$cur.addClass('chosed');
|
27
|
}
|
31
|
}
|
28
|
|
32
|
|
|
|
33
|
+function orderCompute() {
|
|
|
34
|
+ $.ajax({
|
|
|
35
|
+ method: 'POST',
|
|
|
36
|
+ url: '/shoppingCart/orderCompute',
|
|
|
37
|
+ data: {
|
|
|
38
|
+ cartType: orderInfo('cartType'),
|
|
|
39
|
+ deliveryId: orderInfo('deliveryId'),
|
|
|
40
|
+ paymentTypeId: orderInfo('paymentTypeId'),
|
|
|
41
|
+ couponCode: orderInfo('couponCode'),
|
|
|
42
|
+ yohoCoin: orderInfo('yohoCoin')
|
|
|
43
|
+ }
|
|
|
44
|
+ }).then(function(res) {
|
|
|
45
|
+ var priceHtml;
|
|
|
46
|
+
|
|
|
47
|
+ if (!res) {
|
|
|
48
|
+ tip.show('网络出错');
|
|
|
49
|
+ } else {
|
|
|
50
|
+ priceHtml = priceTmpl({
|
|
|
51
|
+ sumPrice: res.order_amount,
|
|
|
52
|
+ salePrice: res.discount_amount,
|
|
|
53
|
+ freight: res.promotion_formula_list[1].promotion_amount,
|
|
|
54
|
+ yohoCoin: res.use_yoho_coin,
|
|
|
55
|
+ price: res.last_order_amount
|
|
|
56
|
+ });
|
|
|
57
|
+
|
|
|
58
|
+ $price.html(priceHtml);
|
|
|
59
|
+ }
|
|
|
60
|
+ }).fail(function() {
|
|
|
61
|
+ tip.show('网络出错');
|
|
|
62
|
+ });
|
|
|
63
|
+}
|
|
|
64
|
+
|
29
|
dispatchModeHammer = new Hammer(document.getElementsByClassName('dispatch-mode')[0]);
|
65
|
dispatchModeHammer = new Hammer(document.getElementsByClassName('dispatch-mode')[0]);
|
30
|
dispatchModeHammer.on('tap', dispacthTapEvt);
|
66
|
dispatchModeHammer.on('tap', dispacthTapEvt);
|
31
|
|
67
|
|
|
@@ -58,6 +94,7 @@ $('.invoice').on('touchend', '.checkbox', function() { |
|
@@ -58,6 +94,7 @@ $('.invoice').on('touchend', '.checkbox', function() { |
58
|
// 界面点击,状态存 cookie
|
94
|
// 界面点击,状态存 cookie
|
59
|
$('.dispatch-mode').on('touchend', 'li', function() {
|
95
|
$('.dispatch-mode').on('touchend', 'li', function() {
|
60
|
orderInfo('deliveryId', $(this).data('id'));
|
96
|
orderInfo('deliveryId', $(this).data('id'));
|
|
|
97
|
+ orderCompute();
|
61
|
});
|
98
|
});
|
62
|
|
99
|
|
63
|
$('.dispatch-time').on('touchend', 'li', function() {
|
100
|
$('.dispatch-time').on('touchend', 'li', function() {
|
|
@@ -69,9 +106,12 @@ $('.coin').on('touchend', function() { |
|
@@ -69,9 +106,12 @@ $('.coin').on('touchend', function() { |
69
|
|
106
|
|
70
|
if ($this.find('.checkbox').hasClass('icon-cb-checked')) {
|
107
|
if ($this.find('.checkbox').hasClass('icon-cb-checked')) {
|
71
|
orderInfo('yohoCoin', $this.data('yoho-coin'));
|
108
|
orderInfo('yohoCoin', $this.data('yoho-coin'));
|
|
|
109
|
+ $this.find('.coin-check em').show();
|
72
|
} else {
|
110
|
} else {
|
73
|
orderInfo('yohoCoin', 0);
|
111
|
orderInfo('yohoCoin', 0);
|
|
|
112
|
+ $this.find('.coin-check em').hide();
|
74
|
}
|
113
|
}
|
|
|
114
|
+ orderCompute();
|
75
|
});
|
115
|
});
|
76
|
|
116
|
|
77
|
$invoice.on('touchend', function() {
|
117
|
$invoice.on('touchend', function() {
|