Showing
1 changed file
with
0 additions
and
145 deletions
web-static/js/order/save.js
deleted
100644 → 0
1 | -/** | ||
2 | - * @description: 订单保存 | ||
3 | - * @time: 2015/12/21 | ||
4 | - */ | ||
5 | - var $ = require('yoho.jquery'); | ||
6 | - | ||
7 | - | ||
8 | -var Order={ | ||
9 | - Data:{ | ||
10 | - product:0, | ||
11 | - activity:0, | ||
12 | - carriage:0, | ||
13 | - juan:0, | ||
14 | - yohocoin:0 | ||
15 | - }, | ||
16 | - UI:{ | ||
17 | - e:{ | ||
18 | - $pan: $('.pan'), | ||
19 | - $jc: $("#juancode"), | ||
20 | - $bp:$("#biprice"), | ||
21 | - $statistics:$("li",".play-total"), | ||
22 | - $tobi:$("p em",".play-bi-pan .play-pan"), | ||
23 | - $cancel:$(".cancel",".btn-group") | ||
24 | - }, | ||
25 | - init:function(){ | ||
26 | - var e=this.e; | ||
27 | - | ||
28 | - /*初始化价格*/ | ||
29 | - this.render(); | ||
30 | - | ||
31 | - /*点击pan dt 打开dd*/ | ||
32 | - e.$pan.find("dt").click(function () { | ||
33 | - var pan=$(this).parent("dl.pan"); | ||
34 | - if(pan.find("dd").is(":hidden")){ | ||
35 | - pan.find("dd").show(); | ||
36 | - if(pan.attr("class").match(/(-bi-)|(-juan-)/g)){ | ||
37 | - $(this).hide(); | ||
38 | - } | ||
39 | - }else{ | ||
40 | - pan.find("dd").hide(); | ||
41 | - } | ||
42 | - | ||
43 | - }); | ||
44 | - | ||
45 | - /*使用优惠卷支付 下面的文本框*/ | ||
46 | - e.$jc.focus(function(){ | ||
47 | - $(this).prev("label").prev(":radio").attr("checked",true); | ||
48 | - }).change(function(){ | ||
49 | - $(this).prev("label").prev(":radio").val($(this).val()); | ||
50 | - }); | ||
51 | - | ||
52 | - /*使用YOHO币支付*/ | ||
53 | - e.$bp.data("tobi",e.$tobi.html()) | ||
54 | - e.$bp.keyup(function(){ | ||
55 | - var bi=Order.Common.enterNUM($(this).val(),$(this).data("tobi")); | ||
56 | - $(this).val(bi); | ||
57 | - }).change(function(){ | ||
58 | - var bi=Order.Common.enterNUM($(this).val(),$(this).data("tobi")); | ||
59 | - $(this).val(bi); | ||
60 | - }); | ||
61 | - | ||
62 | - /*取消关闭小窗口*/ | ||
63 | - e.$cancel.click(function(){ | ||
64 | - var p=$(this).parents(".pan"); | ||
65 | - p.find("dt").show(); | ||
66 | - p.find("dd").hide(); | ||
67 | - }); | ||
68 | - }, | ||
69 | - render:function(){ | ||
70 | - var e=this.e,d=Order.Data; | ||
71 | - | ||
72 | - e.$statistics.slice(3,5).hide(); | ||
73 | - e.$statistics.slice(2,5).find("em").html("0.00"); | ||
74 | - if(d.carriage){ | ||
75 | - e.$statistics.eq(2).find("em").html(d.carriage); | ||
76 | - } | ||
77 | - if(d.juan){ | ||
78 | - e.$statistics.eq(3).show().find("em").html(d.juan); | ||
79 | - } | ||
80 | - if(d.yohocoin){ | ||
81 | - e.$statistics.eq(4).show().find("em").html(d.yohocoin); | ||
82 | - } | ||
83 | - } | ||
84 | - }, | ||
85 | - Common:{ | ||
86 | - enterNUM:function(str1,str2){ | ||
87 | - str1=str1.replace(/[^\d]/g,''); | ||
88 | - if(str1&&str2){ | ||
89 | - str1=parseInt(str1); | ||
90 | - str2=parseInt(str2); | ||
91 | - if(str1>str2){ | ||
92 | - str1=str2; | ||
93 | - } | ||
94 | - } | ||
95 | - return str1; | ||
96 | - }, | ||
97 | - calucate:function(){ | ||
98 | - var p=Order.Data; | ||
99 | - $.each(Order.Data,function(key,index){ | ||
100 | - p[key]=parseFloat(Order.Data[key]); | ||
101 | - }); | ||
102 | - return p.product-p.activity+p.carriage-p.juan-p.yohocoin; | ||
103 | - } | ||
104 | - }, | ||
105 | - Submit:{ | ||
106 | - e:{ | ||
107 | - $juanok:$("#juansubmit"), | ||
108 | - $juantip:$(".errtip",".play-juan-pan"), | ||
109 | - $biok:$("#juansubmit") | ||
110 | - }, | ||
111 | - init:function(){ | ||
112 | - var e=this.e; | ||
113 | - | ||
114 | - e.$juanok.click(function(){ | ||
115 | - $jgroup=$('input[name="juangroup"]:checked'); | ||
116 | - var pan=$(this).parents(".pan"); | ||
117 | - if($jgroup.val()){ | ||
118 | - var options={ | ||
119 | - url:'/Order/save/priceByCode', | ||
120 | - type:'post', | ||
121 | - data:{code:$jgroup.val()}, | ||
122 | - success:function(data){ | ||
123 | - if(data.code===200){ | ||
124 | - if(data.price){ | ||
125 | - Order.Data.juan=data.price; | ||
126 | - } | ||
127 | - Order.UI.render(); | ||
128 | - pan.hide(); | ||
129 | - } | ||
130 | - e.$juantip.html(data.msg); | ||
131 | - }, | ||
132 | - error:function(){ | ||
133 | - e.$juantip.html(data.msg); | ||
134 | - } | ||
135 | - } | ||
136 | - $.ajax(options); | ||
137 | - } | ||
138 | - }); | ||
139 | - } | ||
140 | - } | ||
141 | -} | ||
142 | - | ||
143 | - | ||
144 | -Order.UI.init(); | ||
145 | -Order.Submit.init(); |
-
Please register or login to post a comment