ensure.page.js
3.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/**
* 订单结算页
* @author: yyq<yanqing.yang@yoho.cn>
* @date: 2016/11/30
*/
var $ = require('yoho-jquery');
var order = {};
var payWay,
deliveryWay;
// 支付方式
payWay = {
$payType: $('.pay-wrap .check-btn'),
init: function() {
var that = this;
this.payType = {};
this.$payType.each(function() {
var $this = $(this),
data = $this.data();
that.payType[data.id] = {
dom: $this,
id: data.id,
type: data.type
};
// 更新订单支付数据
if ($this.hasClass('checked')) {
that.updateOrder(data);
}
});
this.eventBind();
},
eventBind: function() {
var that = this;
this.$payType.click(function() {
var $this = $(this);
if ($this.hasClass('checked')) {
return;
}
that.$payType.removeClass('checked');
$this.addClass('checked');
// 更新订单支付数据
that.updateOrder($this.data());
});
},
updateOrder: function(info) {
if (!info) {
return;
}
if (info.id) {
order.paymentId = info.id;
}
if (info.type) {
order.paymentType = info.type;
}
}
};
deliveryWay = {
$deliveryType: $('.delivery-way-wrap .check-btn'),
$deliveryTime: $('.delivery-time-wrap .check-btn'),
init: function() {
var that = this;
this.deliveryType = {};
this.$deliveryType.each(function() {
var $this = $(this),
data = $this.data();
that.deliveryType[data.id] = {
dom: $this,
id: data.id
};
// 更新订单配送方式数据
if ($this.hasClass('checked')) {
that.updateOrder({way: data.id});
}
});
this.$deliveryTime.each(function() {
var $this = $(this);
// 更新订单送货时间数据
if ($this.hasClass('checked')) {
that.updateOrder({time: $this.data('id')});
}
});
this.eventBind();
},
eventBind: function() {
var that = this;
this.$deliveryType.click(function() {
var $this = $(this);
if ($this.hasClass('checked')) {
return;
}
that.$deliveryType.removeClass('checked');
$this.addClass('checked');
// 更新订单配送方式数据
that.updateOrder({way: $this.data('id')});
});
this.$deliveryTime.click(function() {
var $this = $(this);
if ($this.hasClass('checked')) {
return;
}
that.$deliveryTime.removeClass('checked');
$this.addClass('checked');
// 更新订单送货时间数据
that.updateOrder({time: $this.data('id')});
});
// 仅前端展示,该数据无作用,接口不接受此参数
$('.delivery-time-wrap .radio-btn').click(function() {
var $this = $(this);
if ($this.hasClass('on')) {
return;
}
$this.siblings('.on').removeClass('on');
$this.addClass('on');
});
},
updateOrder: function(info) {
if (!info) {
return;
}
if (info.time) {
order.deliveryTime = info.time;
}
if (info.way) {
order.deliveryWay = info.way;
}
}
};
payWay.init();
deliveryWay.init();