Showing
3 changed files
with
341 additions
and
0 deletions
@@ -37,6 +37,9 @@ require("js/help/entry"); | @@ -37,6 +37,9 @@ require("js/help/entry"); | ||
37 | //订单确认 | 37 | //订单确认 |
38 | require("js/order/ensure"); | 38 | require("js/order/ensure"); |
39 | 39 | ||
40 | +//门票-订单确认 | ||
41 | +require("js/order/ticket-ensure"); | ||
42 | + | ||
40 | //商品支付 | 43 | //商品支付 |
41 | require("js/shopping/pay"); | 44 | require("js/shopping/pay"); |
42 | 45 | ||
@@ -16909,6 +16912,344 @@ $('.to-play input.submit').click(function() { | @@ -16909,6 +16912,344 @@ $('.to-play input.submit').click(function() { | ||
16909 | }); | 16912 | }); |
16910 | 16913 | ||
16911 | }); | 16914 | }); |
16915 | +define("js/order/ticket-ensure", ["jquery","handlebars","source-map"], function(require, exports, module){ | ||
16916 | +/** | ||
16917 | + * @description: 订单保存 | ||
16918 | + * @time: 2015/12/21 | ||
16919 | + */ | ||
16920 | + | ||
16921 | +var $ = require("jquery"); | ||
16922 | + | ||
16923 | +var dialog = require("js/common/dialog"); | ||
16924 | + | ||
16925 | +var accMul = function(arg1, arg2) { | ||
16926 | + var m = 0, | ||
16927 | + s1 = arg1.toString(), | ||
16928 | + s2 = arg2.toString(); | ||
16929 | + | ||
16930 | + try { | ||
16931 | + m += s1.split('.')[1].length; | ||
16932 | + } catch (e) { | ||
16933 | + } | ||
16934 | + try { | ||
16935 | + m += s2.split('.')[1].length; | ||
16936 | + } catch (e) { | ||
16937 | + } | ||
16938 | + return Number(s1.replace('.', '')) * Number(s2.replace('.', '')) / Math.pow(10, m); | ||
16939 | +}; | ||
16940 | + | ||
16941 | +//立即购买-门票 | ||
16942 | +var TicketCat = { | ||
16943 | + el: { | ||
16944 | + $pan: $('.pan'), | ||
16945 | + $biok: $('#bisubmit'), | ||
16946 | + $loading: $('.loading'), | ||
16947 | + $payTotal: $('.play-total'), | ||
16948 | + $toPay: $('.ticket-play em'), | ||
16949 | + $errorTip: $('.errbitip'), | ||
16950 | + $tbody: $('table tbody', '.pay-wapper'), | ||
16951 | + | ||
16952 | + //门票js | ||
16953 | + $showTicketMobile: $('.show-ticket-mobile'), | ||
16954 | + $ticketMobile: $('.ticket-mobile'), | ||
16955 | + $ticketModifyBtn: $('.ticket-modify-btn'), | ||
16956 | + $setTicketMobile: $('.set-ticket-mobile'), | ||
16957 | + $ticketMobileBtn: $('.ticket-mobile-btn'), | ||
16958 | + $ticketMobileInput: $('.ticket-mobile-input'), | ||
16959 | + | ||
16960 | + //变量 | ||
16961 | + phoneReg: /^(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/ | ||
16962 | + }, | ||
16963 | + Data: { | ||
16964 | + buyNumber: 0,//购买总数量 | ||
16965 | + productSku: 0 | ||
16966 | + }, | ||
16967 | + Common: { | ||
16968 | + enterNUM: function(str1, str2) { | ||
16969 | + str1 = str1.replace(/[^\d]/g, ''); | ||
16970 | + if (str1 && str2) { | ||
16971 | + str1 = parseInt(str1); | ||
16972 | + str2 = parseInt(str2); | ||
16973 | + if (str1 > str2) { | ||
16974 | + str1 = str2; | ||
16975 | + } | ||
16976 | + } | ||
16977 | + return str1; | ||
16978 | + }, | ||
16979 | + winShow: function(pan) { | ||
16980 | + pan.find('dt').show(); | ||
16981 | + pan.find('dd').show(); | ||
16982 | + if (pan.attr('class').match(/(-bi-)|(-juan-)/g)) { | ||
16983 | + pan.find('dt').hide(); | ||
16984 | + } | ||
16985 | + }, | ||
16986 | + winHide: function(pan) { | ||
16987 | + pan.find('dt').show(); | ||
16988 | + pan.find('dd').hide(); | ||
16989 | + }, | ||
16990 | + strFixed: function(str) { | ||
16991 | + return parseFloat(str).toFixed(2); | ||
16992 | + } | ||
16993 | + }, | ||
16994 | + init: function() { | ||
16995 | + var _this = this, | ||
16996 | + el = this.el, | ||
16997 | + c = this.Common, | ||
16998 | + productSubtotal = 0; | ||
16999 | + | ||
17000 | + //初始化产品价格(表格中的价格) | ||
17001 | + el.$tbody.find('tr').each(function(index) { | ||
17002 | + var td = $(this).find('td'); | ||
17003 | + var len = el.$tbody.find('tr').length; | ||
17004 | + var subtotal = parseFloat(td.eq(1).html()) * parseInt(td.eq(3).html()); | ||
17005 | + | ||
17006 | + _this.Data.productSku = $(this).data('sku'); | ||
17007 | + _this.Data.buyNumber += parseInt(td.eq(3).html()); | ||
17008 | + td.eq(1).html('¥' + td.eq(1).html()); | ||
17009 | + | ||
17010 | + if (td.hasClass('xforone')) { | ||
17011 | + td.eq(4).find('del').html('¥' + c.strFixed(subtotal)); | ||
17012 | + subtotal = 0; | ||
17013 | + } else { | ||
17014 | + td.eq(4).html('¥' + c.strFixed(subtotal)); | ||
17015 | + } | ||
17016 | + productSubtotal += subtotal; | ||
17017 | + if (!index) { | ||
17018 | + td.last().attr('rowspan', len); | ||
17019 | + } else { | ||
17020 | + td.last().remove(); | ||
17021 | + } | ||
17022 | + if (index === len - 1) { | ||
17023 | + el.$tbody.find('tr').eq(0).find('td').last().html('<strong>¥' + | ||
17024 | + c.strFixed(productSubtotal) + '</strong>'); | ||
17025 | + } | ||
17026 | + }); | ||
17027 | + | ||
17028 | + //修改手机号按钮 | ||
17029 | + el.$ticketModifyBtn.click(function() { | ||
17030 | + el.$showTicketMobile.addClass('hide'); | ||
17031 | + el.$setTicketMobile.removeClass('hide'); | ||
17032 | + }); | ||
17033 | + | ||
17034 | + //保存手机号按钮 | ||
17035 | + el.$ticketMobileBtn.click(function() { | ||
17036 | + var val = el.$ticketMobileInput.val(); | ||
17037 | + | ||
17038 | + if (!el.phoneReg.test(val)) { | ||
17039 | + new dialog.Alert('请输入正确的手机号!').show(); | ||
17040 | + return; | ||
17041 | + } | ||
17042 | + | ||
17043 | + el.$showTicketMobile.removeClass('hide'); | ||
17044 | + el.$setTicketMobile.addClass('hide'); | ||
17045 | + el.$ticketMobile.text(val); | ||
17046 | + | ||
17047 | + window.setCookie('ticketMobileInput', val, { | ||
17048 | + domain: '.yohobuy.com', | ||
17049 | + path: '/' | ||
17050 | + }); | ||
17051 | + }); | ||
17052 | + | ||
17053 | + //手机号,保存cookie中,防止用户刷新 | ||
17054 | + if (el.phoneReg.test(window.cookie('ticketMobileInput'))) { | ||
17055 | + el.$showTicketMobile.removeClass('hide'); | ||
17056 | + el.$setTicketMobile.addClass('hide'); | ||
17057 | + el.$ticketMobile.text(window.cookie('ticketMobileInput')); | ||
17058 | + } | ||
17059 | + | ||
17060 | + // 使用优惠券、使用yoho币点击展开 | ||
17061 | + el.$pan.find('dt').click(function() { | ||
17062 | + var pan = $(this).parent('dl.pan'); | ||
17063 | + | ||
17064 | + if (pan.find('dd').is(':hidden')) { | ||
17065 | + c.winShow(pan); | ||
17066 | + $(this).addClass('active'); | ||
17067 | + } else { | ||
17068 | + c.winHide(pan); | ||
17069 | + $(this).removeClass('active'); | ||
17070 | + } | ||
17071 | + }); | ||
17072 | + | ||
17073 | + //使用有货币确认按钮 | ||
17074 | + el.$biok.click(function() { | ||
17075 | + var pan = $(this).parents('dl.pan'); | ||
17076 | + var selectData = {}; | ||
17077 | + | ||
17078 | + $('#biprice').addClass('is-select'); | ||
17079 | + selectData = _this.getSelectData(); | ||
17080 | + | ||
17081 | + if (!/^\d+$/.test(selectData.yohoCoin + '') || selectData.yohoCoin * 1 === 0) { | ||
17082 | + $('.errbitip').html('请输入一个正整数'); | ||
17083 | + $('#biprice').removeClass('is-select'); | ||
17084 | + } else if (selectData.yohoCoin * 1 > $('.play-pan em').text() * 1) { | ||
17085 | + $('.errbitip').html('您的YOHO币不足'); | ||
17086 | + $('#biprice').removeClass('is-select'); | ||
17087 | + } else { | ||
17088 | + el.$loading.show(); | ||
17089 | + $.ajax({ | ||
17090 | + type: 'POST', | ||
17091 | + url: '/cart/index/setTicket', | ||
17092 | + data: selectData, | ||
17093 | + success: function(data) { | ||
17094 | + el.$loading.hide(); | ||
17095 | + if (data.code === 200) { | ||
17096 | + _this.render(data.data); | ||
17097 | + c.winHide(pan); | ||
17098 | + } else { | ||
17099 | + $('.errbitip').html(data.message); | ||
17100 | + $('#biprice').removeClass('is-select'); | ||
17101 | + } | ||
17102 | + } | ||
17103 | + }); | ||
17104 | + } | ||
17105 | + }); | ||
17106 | + | ||
17107 | + // 修改yoho币 | ||
17108 | + $(document).on('click', '.bi-modify', function() { | ||
17109 | + var $pan = $('.play-bi-pan'); | ||
17110 | + | ||
17111 | + c.winShow($pan); | ||
17112 | + }); | ||
17113 | + | ||
17114 | + //键盘事件,计算有币货抵多少钱 | ||
17115 | + $('#biprice').keyup(function() { | ||
17116 | + var val = $(this).val(); | ||
17117 | + | ||
17118 | + if (!/^\d+$/.test(val + '')) { | ||
17119 | + el.$errorTip.html('请输入一个正整数'); | ||
17120 | + } else if (val * 1 > $(this).data('bi') * 1) { | ||
17121 | + el.$errorTip.html('您的YOHO币不足'); | ||
17122 | + } else { | ||
17123 | + el.$errorTip.html('抵扣' + (val / 100).toFixed(2) + '元'); | ||
17124 | + } | ||
17125 | + }); | ||
17126 | + | ||
17127 | + // 取消yoho 币 | ||
17128 | + $('.cancel-bi').click(function() { | ||
17129 | + var $pan = $('.play-bi-pan'), | ||
17130 | + selectData = {}; | ||
17131 | + | ||
17132 | + $('.errbitip').html(''); | ||
17133 | + el.$loading.show(); | ||
17134 | + selectData = _this.getSelectData(); | ||
17135 | + selectData.yohoCoin = 0; | ||
17136 | + $.ajax({ | ||
17137 | + type: 'POST', | ||
17138 | + url: '/cart/index/setTicket', | ||
17139 | + data: selectData, | ||
17140 | + success: function(data) { | ||
17141 | + el.$loading.hide(); | ||
17142 | + if (data.code === 200) { | ||
17143 | + _this.render(data.data); | ||
17144 | + c.winHide($pan); | ||
17145 | + | ||
17146 | + $('#biprice').val('0'); | ||
17147 | + $('#biprice').removeClass('is-select'); | ||
17148 | + $('.errbitip').html(''); | ||
17149 | + } else { | ||
17150 | + $('.errbitip').html(data.message); | ||
17151 | + } | ||
17152 | + } | ||
17153 | + }); | ||
17154 | + }); | ||
17155 | + | ||
17156 | + // 去支付 | ||
17157 | + $('.ticket-play input.submit').click(function() { | ||
17158 | + var $this = $(this); | ||
17159 | + var selectData = _this.getSelectData(); | ||
17160 | + | ||
17161 | + selectData.mobile = el.$ticketMobile.text(); | ||
17162 | + | ||
17163 | + if (!el.phoneReg.test(selectData.mobile)) { | ||
17164 | + new dialog.Alert('手机号格式不正确!').show(); | ||
17165 | + return; | ||
17166 | + } | ||
17167 | + | ||
17168 | + el.$loading.show(); | ||
17169 | + | ||
17170 | + if (!!$this.attr('disabled')) { | ||
17171 | + return; | ||
17172 | + } | ||
17173 | + | ||
17174 | + $this.attr('disabled', 'disabled'); | ||
17175 | + $.ajax({ | ||
17176 | + type: 'POST', | ||
17177 | + dataType: 'json', | ||
17178 | + url: '/cart/index/ticketOrderSub', | ||
17179 | + data: selectData | ||
17180 | + }).then(function(data) { | ||
17181 | + el.$loading.hide(); | ||
17182 | + | ||
17183 | + if (data.code === 200) { | ||
17184 | + window.location.href = '/shopping/pay?ordercode=' + data.data.order_code; | ||
17185 | + } else { | ||
17186 | + new dialog.Alert(data.message).show(); | ||
17187 | + } | ||
17188 | + }).always(function() { | ||
17189 | + el.$loading.hide(); | ||
17190 | + $this.removeAttr('disabled'); | ||
17191 | + }); | ||
17192 | + }); | ||
17193 | + | ||
17194 | + }, | ||
17195 | + | ||
17196 | + //渲染价格明细 | ||
17197 | + render: function(data) { | ||
17198 | + var e = this.el, | ||
17199 | + i, | ||
17200 | + dArr = data.shopping_cart_data.promotion_formula_list, | ||
17201 | + str = '', | ||
17202 | + isExpress = ''; | ||
17203 | + | ||
17204 | + for (i = 0; i < dArr.length; i++) { | ||
17205 | + | ||
17206 | + if (dArr[i].promotion === 'YOHO币:') { | ||
17207 | + dArr[i].promotion = 'YOHO币<span class="bi-modify">[修改]</span>:'; | ||
17208 | + } | ||
17209 | + | ||
17210 | + if (dArr[i].isExpress) { | ||
17211 | + isExpress = 'total-express-w'; | ||
17212 | + } else { | ||
17213 | + isExpress = ''; | ||
17214 | + } | ||
17215 | + | ||
17216 | + str += '<li class="' + isExpress + '">' + | ||
17217 | + '<label>' + dArr[i].promotion + '</label>' + | ||
17218 | + '<em>' + dArr[i].promotion_amount + '</em>' + | ||
17219 | + '</li>'; | ||
17220 | + } | ||
17221 | + | ||
17222 | + e.$payTotal.html(str); | ||
17223 | + e.$toPay.html((data.shopping_cart_data.last_order_amount).toFixed(2)); | ||
17224 | + | ||
17225 | + //有货币清零状态更新 | ||
17226 | + $('#biprice').val(accMul(100, data.shopping_cart_data.use_yoho_coin)); | ||
17227 | + if (data.use_yoho_coin === 0) { | ||
17228 | + $('.errbitip').text(''); | ||
17229 | + } else { | ||
17230 | + $('.errbitip').text('抵扣' + data.shopping_cart_data.use_yoho_coin.toFixed(2) + '元'); | ||
17231 | + } | ||
17232 | + | ||
17233 | + }, | ||
17234 | + getSelectData: function() { | ||
17235 | + var expressVal = $('.express-list input[name="carriagegroup"]:checked').val(); | ||
17236 | + var biVal = $('#biprice.is-select').val(); | ||
17237 | + var cartType = $('.address-manage').attr('cart-type'); | ||
17238 | + var resultData; | ||
17239 | + | ||
17240 | + resultData = { | ||
17241 | + cartType: cartType, | ||
17242 | + deliveryWay: expressVal, | ||
17243 | + yohoCoin: biVal, | ||
17244 | + productSku: this.Data.productSku, | ||
17245 | + buyNumber: this.Data.buyNumber | ||
17246 | + }; | ||
17247 | + return resultData; | ||
17248 | + } | ||
17249 | +}; | ||
17250 | + | ||
17251 | +TicketCat.init(); | ||
17252 | +}); | ||
16912 | define("js/shopping/pay", ["jquery"], function(require, exports, module){ | 17253 | define("js/shopping/pay", ["jquery"], function(require, exports, module){ |
16913 | /** | 17254 | /** |
16914 | * 支付页面 | 17255 | * 支付页面 |
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
-
Please register or login to post a comment