select_ticket.js
2.71 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
/**
* Created by Administrator on 2017/11/15.
*/
var ticket_service = {
minus:function(num1,num2){
var money=num1-num2;
return money.toFixed(2);
},
/**
* 新样式优惠券选择功能
*/
choose:function(){
$("#win2").attr("class","win_none");
var $checkedCoupon = $("input[name='coupon']:checked");
var amount = $checkedCoupon.parents("label").siblings("input").val();
var totalMoney = $("span.total").html();
var finalMoney = ticket_service.minus(totalMoney,amount);
$('.discount').html(amount);
$("#finalMoney").val(finalMoney);
$(".alltotal").find("span").html(finalMoney);
$('.selcoupon .cashcoupon').html("-¥"+amount);
// pangdou_service.reset();
},
/**
* 旧样式优惠券选择功能
*/
old_choose:function(){
$("#win2").attr("class","win_none");
var id = $("input[name='coupon']:checked").val();
var totalMoney = $("#totalMoney").val() ;
var minusMoney = $("#"+id).val() ;
var finalMoney = ticket_service.minus(totalMoney,minusMoney);
$("#mustPayAmount").html("¥"+totalMoney+"商品- ¥"+minusMoney+"优惠");
$("#mustPayFinal").html("需付款:¥"+finalMoney);
$("#finalMoney").val(finalMoney);
$("#ticket").html("下单立减"+minusMoney+"元");
},
init:function(flag){
if(!flag){
alert(1);
ticket_service.choose();
}else{
alert(2);
ticket_service.old_choose();
}
$(".selcoupon").on("click",function(e){
$("#win2").removeClass("win_none");
$("#win2").removeAttr("style");
$("#win2").addClass("win");
$("#win2 .layout_win").animate({bottom:"0rem"},300);
$("body").css({
overflow:"hidden"
});
});
$("#win2 .transparent_bg,#win2 .close").on("click",function(e){
$("#win2 .layout_win").animate({
bottom:"-31rem"
},200);
$("#win2").fadeOut("400",function(){
$(this).attr("class","win_none");
$(this).removeAttr("style");
$(this).children(".layout_win").removeAttr("style");
});
$("body").css({
overflow:"auto",
position: "relative"
});
});
$("#win2 .btn").on("click",function(e){
if(!flag){
ticket_service.choose();
}else{
ticket_service.old_choose();
}
$("body").css({
overflow:"auto",
position: "relative;"
});
});
}
}