order-ensure.js
1.61 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
// import qs from 'yoho-qs';
class OrderEnsure {
constructor(order) { // 参数为使用哪个 cookie
this.order = order;
this.orderInfo = order.orderInfo;
this.selector = {
invoice: $('.invoice'),
invoiceType: $('.invoice-type'),
userMobile: $('.user-mobile')
};
this.init();
this.bindEvents();
}
init() {
if (window.getUid() !== this.orderInfo('uid')) {
this.order.init();
window.location.reload();
}
}
bindEvents() {
this.selector.invoice.on('click', '.checkbox', this.needInvoice.bind(this));
}
/**
* 是否需要开发票
*/
needInvoice(event) {
let $this = $(event.currentTarget);
this.orderInfo('invoice', $this.hasClass('icon-cb-radio'));
if ($this.hasClass('icon-cb-radio')) {
this.selector.invoice.addClass('focus');
this.selector.invoiceType.html('电子发票(个人)<i class="iconfont"></i>');
this.orderInfo('receiverMobile', this.selector.userMobile.val());
this.orderInfo('invoices_type', 2);
}
if ($this.hasClass('icon-radio')) {
this.selector.invoice.removeClass('focus');
this.selector.invoiceType.html('');
this.orderInfo('invoices_title', null);
this.orderInfo('invoices_type', null);
this.orderInfo('receiverMobile', null);
this.orderInfo('buyerTaxNumber', null);
}
event.preventDefault();
event.stopPropagation();
}
}
module.exports = OrderEnsure;