Showing
10 changed files
with
790 additions
and
575 deletions
1 | 'use strict'; | 1 | 'use strict'; |
2 | 2 | ||
3 | -const index = (req, res ,next) => { | 3 | +const headerModel = require('../../../doraemon/models/header'); // 头部model |
4 | +const indexModel = require('../models/ticketsConfirm'); | ||
5 | + | ||
6 | +const ticketsConfirm = (req, res) => { | ||
4 | let headerData = headerModel.setNav({ | 7 | let headerData = headerModel.setNav({ |
5 | navTitle: '确认订单' | 8 | navTitle: '确认订单' |
6 | }); | 9 | }); |
@@ -8,15 +11,56 @@ const index = (req, res ,next) => { | @@ -8,15 +11,56 @@ const index = (req, res ,next) => { | ||
8 | let responseData = { | 11 | let responseData = { |
9 | pageHeader: headerData, | 12 | pageHeader: headerData, |
10 | module: 'cart', | 13 | module: 'cart', |
11 | - page: 'index-editor', | 14 | + page: 'tickets-confirm', |
12 | title: '确认订单', | 15 | title: '确认订单', |
13 | - pageFooter: true, | ||
14 | - localCss: true | 16 | + |
17 | + // pageFooter: true, | ||
18 | + localCss: true, | ||
19 | + navBtn: false | ||
20 | + }; | ||
21 | + | ||
22 | + let params = { | ||
23 | + uid: req.user.uid, | ||
24 | + productSku: req.body.productSku, | ||
25 | + buyNumber: req.body.buyNumber, | ||
26 | + useYohoCoin: 0, | ||
27 | + yohoCoinMode: true | ||
15 | }; | 28 | }; |
16 | 29 | ||
17 | - res.render('ticketsConfirm', responseData); | ||
18 | -} | 30 | + indexModel.ticketsConfirm(params).then(result => { |
31 | + res.render('ticketsConfirm', Object.assign(responseData, result)); | ||
32 | + }); | ||
33 | +}; | ||
34 | + | ||
35 | +const submitTicket = (req, res) => { | ||
36 | + let params = { | ||
37 | + uid: req.user.uid, | ||
38 | + productSku: req.body.productSku, | ||
39 | + buyNumber: req.body.buyNumber, | ||
40 | + mobile: req.body.mobile, | ||
41 | + useYohoCoin: req.body.useYohoCoin | ||
42 | + }; | ||
43 | + | ||
44 | + indexModel.submitTicket(params).then(result => { | ||
45 | + res.json(result); | ||
46 | + }); | ||
47 | +}; | ||
48 | + | ||
49 | +const checkTickets = (req, res) => { | ||
50 | + let params = { | ||
51 | + uid: req.user.uid, | ||
52 | + productSku: req.body.productSku, | ||
53 | + buyNumber: req.body.buyNumber, | ||
54 | + useYohoCoin: 0 | ||
55 | + }; | ||
56 | + | ||
57 | + indexModel.checkTickets(params).then(result => { | ||
58 | + res.json(result); | ||
59 | + }); | ||
60 | +}; | ||
19 | 61 | ||
20 | module.exports = { | 62 | module.exports = { |
21 | - index | ||
22 | -}; | ||
63 | + ticketsConfirm, | ||
64 | + submitTicket, | ||
65 | + checkTickets | ||
66 | +}; |
apps/cart/models/ticketsConfirm.js
0 → 100644
1 | +'use strict'; | ||
2 | + | ||
3 | +const api = global.yoho.API; | ||
4 | +const helpers = global.yoho.helpers; | ||
5 | + | ||
6 | +// 展览票(单日票)skn | ||
7 | +const SINGLE_TICKETS_SKN = 51335912; | ||
8 | + | ||
9 | +const checkTickets = (param) => { | ||
10 | + return api.get('', { | ||
11 | + method: 'app.shopping.ticket', | ||
12 | + uid: param.uid, | ||
13 | + product_sku: param.productSku, | ||
14 | + buy_number: param.buyNumber, | ||
15 | + use_yoho_coin: param.useYohoCoin, | ||
16 | + yoho_coin_mode: param.yohoCoinMode ? param.yohoCoinMode : 0 | ||
17 | + }, { | ||
18 | + code: 200 | ||
19 | + }).then((result) => { | ||
20 | + return result; | ||
21 | + }); | ||
22 | +}; | ||
23 | + | ||
24 | +const yohoCoinCompute = ($orderCompute) => { | ||
25 | + let $yohoCoinData = { | ||
26 | + totalYohoCoinNum: 0, | ||
27 | + yohoCoin: 0, | ||
28 | + useYohoCoin: 0, | ||
29 | + yohoCoinClick: 0, | ||
30 | + yohoCoinMsg: '', | ||
31 | + yoho_coin_pay_rule: [] | ||
32 | + }; | ||
33 | + | ||
34 | + if (!$orderCompute || !$orderCompute.yoho_coin_pay_rule) { | ||
35 | + return $yohoCoinData; | ||
36 | + } | ||
37 | + | ||
38 | + $yohoCoinData = { | ||
39 | + totalYohoCoinNum: $orderCompute.total_yoho_coin_num ? $orderCompute.total_yoho_coin_num : 0, | ||
40 | + yohoCoin: $orderCompute.yoho_coin ? $orderCompute.yoho_coin : 0, | ||
41 | + useYohoCoin: $orderCompute.use_yoho_coin ? $orderCompute.use_yoho_coin : 0, | ||
42 | + yohoCoinClick: 0, | ||
43 | + yohoCoinMsg: '', | ||
44 | + yoho_coin_pay_rule: $orderCompute.yoho_coin_pay_rule | ||
45 | + }; | ||
46 | + | ||
47 | + if ($yohoCoinData.totalYohoCoinNum < 100) { | ||
48 | + $yohoCoinData.yohoCoinMsg = '共' + $yohoCoinData.totalYohoCoinNum + | ||
49 | + '有货币,满' + $orderCompute.yoho_coin_pay_rule.num_limit + '可用'; | ||
50 | + } else if ($yohoCoinData.useYohoCoin > 0 || $yohoCoinData.yohoCoin > 0) { | ||
51 | + $yohoCoinData.yohoCoinMsg = '可抵¥' + | ||
52 | + $yohoCoinData.useYohoCoin > 0 ? $yohoCoinData.useYohoCoin : $yohoCoinData.yohoCoin; | ||
53 | + $yohoCoinData.yohoCoinClick = 1; | ||
54 | + } else { | ||
55 | + $yohoCoinData.yohoCoinMsg = '不满足有货币使用条件'; | ||
56 | + } | ||
57 | + | ||
58 | + return $yohoCoinData; | ||
59 | +}; | ||
60 | + | ||
61 | +const ticketsConfirm = (param) => { | ||
62 | + return api.all([ | ||
63 | + checkTickets(param) | ||
64 | + ]).then((result) => { | ||
65 | + let resu = { | ||
66 | + goods: [], | ||
67 | + productSku: param.productSku, | ||
68 | + buyNumber: param.buyNumber, | ||
69 | + orderEnsurePage: true | ||
70 | + }; | ||
71 | + | ||
72 | + if (result && result[0] && result[0].data) { | ||
73 | + let bulid = []; | ||
74 | + | ||
75 | + result[0].data.goods_list.forEach((val) => { | ||
76 | + bulid.push({ | ||
77 | + tickets: true, | ||
78 | + id: val.product_sku, | ||
79 | + thumb: helpers.image(val.goods_images, 120, 160), | ||
80 | + name: val.product_name, | ||
81 | + color: val.color_name, | ||
82 | + size: val.product_skn == SINGLE_TICKETS_SKN ? '' : val.size_name, | ||
83 | + count: val.buy_number, | ||
84 | + price: parseInt(val.last_price).toFixed(2) | ||
85 | + }); | ||
86 | + resu.goods = bulid; | ||
87 | + }); | ||
88 | + resu.cartPayData = result[0].data.shopping_cart_data.promotion_formula_list; | ||
89 | + resu.price = parseInt(result[0].data.shopping_cart_data.last_order_amount).toFixed(2); | ||
90 | + resu.yohoCoinCompute = yohoCoinCompute(result[0].data.shopping_cart_data); | ||
91 | + } | ||
92 | + return resu; | ||
93 | + }); | ||
94 | +}; | ||
95 | + | ||
96 | + | ||
97 | +// 门票下单 | ||
98 | +const submitTicket = (param) => { | ||
99 | + return api.get('', { | ||
100 | + method: 'app.shopping.submitTicket', | ||
101 | + uid: param.uid, | ||
102 | + product_sku: param.productSku, | ||
103 | + buy_number: param.buyNumber, | ||
104 | + mobile: param.mobile, | ||
105 | + use_yoho_coin: 0, | ||
106 | + qhy_union: '' | ||
107 | + }, { | ||
108 | + code: 200 | ||
109 | + }).then((result) => { | ||
110 | + return result; | ||
111 | + }); | ||
112 | +}; | ||
113 | + | ||
114 | +module.exports = { | ||
115 | + ticketsConfirm, | ||
116 | + submitTicket, | ||
117 | + checkTickets | ||
118 | +}; |
@@ -64,6 +64,12 @@ router.post('/index/new/giftinfo', indexController.giftinfo); // 获取购物车 | @@ -64,6 +64,12 @@ router.post('/index/new/giftinfo', indexController.giftinfo); // 获取购物车 | ||
64 | router.get('/home/orders/paynew', authMW, payController.payCenter); | 64 | router.get('/home/orders/paynew', authMW, payController.payCenter); |
65 | 65 | ||
66 | // 门票确认 | 66 | // 门票确认 |
67 | -router.get('/index/ticketsConfirm', authMW, ticketsConfirmController.index); | 67 | +router.post('/index/ticketsConfirm', authMW, ticketsConfirmController.ticketsConfirm); |
68 | + | ||
69 | +// 门票下单 | ||
70 | +router.post('/index/submitTicket', ticketsConfirmController.submitTicket); | ||
71 | + | ||
72 | +// 添加门票 | ||
73 | +router.post('/index/checkTickets', ticketsConfirmController.checkTickets); | ||
68 | 74 | ||
69 | module.exports = router; | 75 | module.exports = router; |
@@ -25,7 +25,7 @@ | @@ -25,7 +25,7 @@ | ||
25 | 25 | ||
26 | <section class="block goods-bottom"> | 26 | <section class="block goods-bottom"> |
27 | {{#each goods}} | 27 | {{#each goods}} |
28 | - {{> me/order/good}} | 28 | + {{> tickets/good}} |
29 | {{/each}} | 29 | {{/each}} |
30 | </section> | 30 | </section> |
31 | 31 | ||
@@ -35,7 +35,7 @@ | @@ -35,7 +35,7 @@ | ||
35 | <li class="coin" data-yoho-coin="{{yohoCoinCompute.yohoCoin}}" data-yoho-coin-click={{yohoCoinCompute.yohoCoinClick}}> | 35 | <li class="coin" data-yoho-coin="{{yohoCoinCompute.yohoCoin}}" data-yoho-coin-click={{yohoCoinCompute.yohoCoinClick}}> |
36 | <span class="title">有货币</span> | 36 | <span class="title">有货币</span> |
37 | <span class="desc msg">{{yohoCoinCompute.yohoCoinMsg}}</span> | 37 | <span class="desc msg">{{yohoCoinCompute.yohoCoinMsg}}</span> |
38 | - <span class="yoho-coin-help"></span> | 38 | + <span class="yoho-coin-help">?</span> |
39 | {{#if yohoCoinCompute.useYohoCoin}} | 39 | {{#if yohoCoinCompute.useYohoCoin}} |
40 | <span class="coin-check"> | 40 | <span class="coin-check"> |
41 | <i class="iconfont checkbox icon-cb-radio"></i> | 41 | <i class="iconfont checkbox icon-cb-radio"></i> |
apps/cart/views/partial/tickets/good.hbs
0 → 100644
1 | +<div class="order-good" data-id="{{id}}" data-skn="{{skn}}"> | ||
2 | + <div class="thumb-wrap"> | ||
3 | + {{#if link}} | ||
4 | + <a href="{{link}}"><img class="thumb lazy" data-original="{{thumb}}"></a> | ||
5 | + {{else}} | ||
6 | + <img class="thumb lazy" data-original="{{thumb}}"> | ||
7 | + {{/if}} | ||
8 | + <p class="tag{{#if gift}} gift-tag{{/if}}{{#if advanceBuy}} advance-buy-tag{{/if}}"></p> | ||
9 | + </div> | ||
10 | + <div class="deps"> | ||
11 | + <p class="name row">{{name}}</p> | ||
12 | + <p class="row"> | ||
13 | + {{#if color}} | ||
14 | + <span class="color"> | ||
15 | + {{#if tickets}}日期{{else}}颜色{{/if}}:{{color}} | ||
16 | + </span> | ||
17 | + {{/if}} | ||
18 | + | ||
19 | + {{#if size}} | ||
20 | + <span class="size"> | ||
21 | + {{#if tickets}}区域{{else}}尺码{{/if}}:{{size}} | ||
22 | + </span> | ||
23 | + {{/if}} | ||
24 | + | ||
25 | + </p> | ||
26 | + | ||
27 | + {{#if isLimitSkn}} | ||
28 | + <p class="limit">不支持7天无理由退换货</p> | ||
29 | + {{/if}} | ||
30 | + <p class="row price-wrap"> | ||
31 | + <span class="price"> | ||
32 | + ¥{{price}} | ||
33 | + </span> | ||
34 | + <span class="count"> | ||
35 | + ×{{count}} | ||
36 | + </span> | ||
37 | + {{#if appearDate}} | ||
38 | + <span class="appear-date">上市期:{{appearDate}}</span> | ||
39 | + {{/if}} | ||
40 | + </p> | ||
41 | + </div> | ||
42 | +</div> |
public/img/cart/help.png
0 → 100644

1.56 KB
public/js/cart/order-ensure.js
0 → 100644
1 | +/** | ||
2 | + * 订单确认 | ||
3 | + * @author: xuqi<qi.xu@yoho.cn> | ||
4 | + * @date: 2015/11/12 | ||
5 | + */ | ||
6 | + | ||
7 | +var $ = require('yoho-jquery'), | ||
8 | + lazyLoad = require('yoho-jquery-lazyload'), | ||
9 | + cookie = require('yoho-cookie'); | ||
10 | + | ||
11 | +var tip = require('../plugin/tip'), | ||
12 | + loading = require('../plugin/loading'), | ||
13 | + order = require('./order-info'), | ||
14 | + richTip = require('../plugin/rich-tip'); | ||
15 | + | ||
16 | +var $invoice = $('.invoice'), | ||
17 | + $couponUse = $('.coupon-use.used'), | ||
18 | + $addressWrap = $('.address-wrap'), | ||
19 | + $coinCheck = $('.coin-check'), | ||
20 | + $coinLi = $('li.coin'), | ||
21 | + $subBlock = $('.sub-block'), | ||
22 | + $ticketsMobile = $('#mobile'), | ||
23 | + payType, | ||
24 | + queryString = $.queryString(), | ||
25 | + orderInfo = order.orderInfo, | ||
26 | + isSubmiting, | ||
27 | + dispatchInfo, | ||
28 | + total, | ||
29 | + isTickets = $('#ticketsPage').val(), | ||
30 | + productSku = $('#productSku').val(), | ||
31 | + buyNumber = $('#buyNumber').val(), | ||
32 | + headerTop = $('#yoho-header').outerHeight(), | ||
33 | + isYohoCoinClick = $coinLi.data('yoho-coin-click') * 1, // 判断有货币是否可以单击 | ||
34 | + addressTop = $('.address-wrap').outerHeight(); | ||
35 | + | ||
36 | +var orderCont = cookie.get('order-info') && JSON.parse(cookie.get('order-info')); | ||
37 | +var invoiceCont = { | ||
38 | + 7: '服装', | ||
39 | + 1: '图书', | ||
40 | + 9: '配件', | ||
41 | + 11: '日用品', | ||
42 | + 3: '办公用品', | ||
43 | + 6: '体育用品', | ||
44 | + 10: '数码产品' | ||
45 | + }, | ||
46 | + invoicesType = { | ||
47 | + 1: '纸质', | ||
48 | + 2: '电子' | ||
49 | + }; | ||
50 | + | ||
51 | +require('../common'); | ||
52 | + | ||
53 | +lazyLoad(); | ||
54 | + | ||
55 | +// 初始化发票信息 | ||
56 | +function invoiceInit() { | ||
57 | + if (orderCont.invoiceType) { | ||
58 | + $('.invoice-type').text(invoiceCont[orderCont.invoiceType] + '(' + invoicesType[orderCont.invoicesType] + ')'); | ||
59 | + } else { | ||
60 | + $('.invoice-type').text('服装(电子)'); | ||
61 | + } | ||
62 | +} | ||
63 | + | ||
64 | +function getQueryParam() { | ||
65 | + var queryArray = location.search.substr(1).split('&'), | ||
66 | + i, | ||
67 | + subArr = [], | ||
68 | + obj = {}; | ||
69 | + | ||
70 | + for (i = 0; i < queryArray.length; i++) { | ||
71 | + subArr = queryArray[i].split('='); | ||
72 | + obj[subArr[0]] = subArr[1]; | ||
73 | + subArr = []; | ||
74 | + } | ||
75 | + | ||
76 | + return obj; | ||
77 | +} | ||
78 | + | ||
79 | +function isLimitGood() { | ||
80 | + return getQueryParam().limitproductcode; | ||
81 | +} | ||
82 | + | ||
83 | + | ||
84 | +if (window.getUid() !== orderInfo('uid')) { | ||
85 | + order.init(); | ||
86 | + window.location.reload(); | ||
87 | +} | ||
88 | + | ||
89 | +if ($couponUse.data('name') !== orderInfo('couponName')) { | ||
90 | + orderInfo('couponCode', null); | ||
91 | + orderInfo('couponName', null); | ||
92 | +} | ||
93 | + | ||
94 | +// 来自购物车的链接默认不使用优惠券 | ||
95 | +if (document.referrer && document.referrer.indexOf('/cart/index/index') !== -1) { | ||
96 | + orderInfo('couponCode', null); | ||
97 | + orderInfo('couponName', null); | ||
98 | +} | ||
99 | + | ||
100 | +isLimitGood() && (function() { | ||
101 | + var a = []; | ||
102 | + | ||
103 | + var data = getQueryParam(); | ||
104 | + | ||
105 | + data.type = 'limitcode'; | ||
106 | + | ||
107 | + a.push(data); | ||
108 | + orderInfo('skuList', JSON.stringify(a)); | ||
109 | + orderInfo('limitUrlSufix', location.search); | ||
110 | +}()); | ||
111 | + | ||
112 | +if (queryString.cartType || queryString.carttype || !orderInfo('cartType')) { | ||
113 | + orderInfo('cartType', queryString.cartType || queryString.carttype || 'ordinary'); | ||
114 | +} | ||
115 | + | ||
116 | +// function dispacthTapEvt(e) { | ||
117 | +// var $cur = $(e.target).closest('li'); | ||
118 | + | ||
119 | +// if ($cur.length === 0 || $cur.hasClass('chosed')) { | ||
120 | +// return; | ||
121 | +// } | ||
122 | + | ||
123 | +// $cur.siblings('li.chosed').removeClass('chosed'); | ||
124 | +// $cur.addClass('chosed'); | ||
125 | +// } | ||
126 | + | ||
127 | +$('.checkbox').on('touchstart', function(e) { | ||
128 | + var $this = $(this); | ||
129 | + | ||
130 | + if ($(e.target).closest('.coin-check').length && !isYohoCoinClick) { | ||
131 | + return true; | ||
132 | + } | ||
133 | + | ||
134 | + if ($this.hasClass('icon-cb-radio')) { | ||
135 | + $this.removeClass('icon-cb-radio').addClass('icon-radio'); | ||
136 | + return; | ||
137 | + } | ||
138 | + | ||
139 | + if ($this.hasClass('icon-radio')) { | ||
140 | + $this.removeClass('icon-radio').addClass('icon-cb-radio'); | ||
141 | + } | ||
142 | +}); | ||
143 | + | ||
144 | +$invoice.on('touchend', '.checkbox', function() { | ||
145 | + var $this = $(this); | ||
146 | + | ||
147 | + if ($this.hasClass('icon-cb-radio')) { | ||
148 | + $invoice.addClass('focus'); | ||
149 | + orderInfo('invoiceText', ''); | ||
150 | + orderInfo('invoiceType', '7'); | ||
151 | + orderInfo('receiverMobile', $('.user-mobile').val()); | ||
152 | + orderInfo('invoicesType', '2'); | ||
153 | + orderInfo('invoiceTitle', '个人'); | ||
154 | + } | ||
155 | + if ($this.hasClass('icon-radio')) { | ||
156 | + $invoice.removeClass('focus'); | ||
157 | + orderInfo('invoiceText', null); | ||
158 | + orderInfo('invoiceType', null); | ||
159 | + orderInfo('receiverMobile', null); | ||
160 | + orderInfo('invoicesType', null); | ||
161 | + orderInfo('invoiceTitle', null); | ||
162 | + } | ||
163 | + | ||
164 | + orderCont = cookie.get('order-info') && JSON.parse(cookie.get('order-info')); | ||
165 | + invoiceInit(); | ||
166 | +}); | ||
167 | + | ||
168 | + | ||
169 | +function updateDeliverId(id) { | ||
170 | + var $moreJit = $('.more-jit a').get(0), | ||
171 | + url; | ||
172 | + | ||
173 | + if ($moreJit) { | ||
174 | + url = $moreJit.href; | ||
175 | + } else { | ||
176 | + return; | ||
177 | + } | ||
178 | + | ||
179 | + if (url.indexOf('deliveryId') < 0) { | ||
180 | + $moreJit.href = url + '&deliveryId=' + id; | ||
181 | + } else { | ||
182 | + $moreJit.href = url.replace(/deliveryId=(\d)/, 'deliveryId=' + id); | ||
183 | + } | ||
184 | +} | ||
185 | + | ||
186 | +function orderCompute() { | ||
187 | + var yohoCoin = orderInfo('yohoCoin'), | ||
188 | + deliverId = orderInfo('deliveryId'), | ||
189 | + data = { | ||
190 | + cartType: orderInfo('cartType') || 'ordinary', | ||
191 | + deliveryId: orderInfo('deliveryId'), | ||
192 | + paymentType: orderInfo('paymentType'), | ||
193 | + couponCode: orderInfo('couponCode'), | ||
194 | + yohoCoin: yohoCoin, | ||
195 | + skuList: isLimitGood() ? orderInfo('skuList') : undefined | ||
196 | + }; | ||
197 | + | ||
198 | + // 门票 | ||
199 | + if (isTickets) { | ||
200 | + data = { | ||
201 | + type: 'tickets', | ||
202 | + productSku: productSku, | ||
203 | + buyNumber: buyNumber, | ||
204 | + yohoCoin: yohoCoin | ||
205 | + }; | ||
206 | + } | ||
207 | + | ||
208 | + loading.showLoadingMask(); | ||
209 | + $.ajax({ | ||
210 | + method: 'POST', | ||
211 | + url: '/cart/index/new/orderCompute', | ||
212 | + data: data | ||
213 | + }).then(function(res) { | ||
214 | + if ($.type(res) !== 'object') { | ||
215 | + window.location.reload(); | ||
216 | + } else { | ||
217 | + if (typeof res.last_order_amount !== undefined) { | ||
218 | + res.last_order_amount = (+res.last_order_amount).toFixed(2); | ||
219 | + } | ||
220 | + | ||
221 | + if (res.use_yoho_coin) { | ||
222 | + $coinCheck.find('em').html('- ¥ ' + res.use_yoho_coin); | ||
223 | + $coinCheck.find('em').show(); | ||
224 | + } | ||
225 | + $coinLi.find('.msg').html(res.yohoCoinCompute.yohoCoinMsg); | ||
226 | + isYohoCoinClick = res.yohoCoinCompute.yohoCoinClick * 1; | ||
227 | + $('.coin').data('yoho-coin', res.yohoCoinCompute.yohoCoin); | ||
228 | + | ||
229 | + total = ''; | ||
230 | + if (res.promotion_formula_list) { | ||
231 | + $.each(res.promotion_formula_list, function(index, value) { | ||
232 | + total += '<li>' + | ||
233 | + '<p>' + value.promotion + '</p>' + | ||
234 | + '<span>' + value.promotion_amount + '</span>' + | ||
235 | + '</li>'; | ||
236 | + }); | ||
237 | + $('.price-cost span').html('¥' + res.last_order_amount); | ||
238 | + $('.bill span').html('¥' + res.last_order_amount); | ||
239 | + $('.total').html(total); | ||
240 | + } | ||
241 | + | ||
242 | + updateDeliverId(deliverId); | ||
243 | + } | ||
244 | + }).fail(function() { | ||
245 | + window.location.reload(); | ||
246 | + }).always(function() { | ||
247 | + loading.hideLoadingMask(); | ||
248 | + }); | ||
249 | +} | ||
250 | + | ||
251 | +function submitOrder() { | ||
252 | + var invoiceText = $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'), | ||
253 | + msg = $('#msg').find('input').val() || orderInfo('msg'); | ||
254 | + | ||
255 | + if (isSubmiting) { | ||
256 | + return false; | ||
257 | + } | ||
258 | + | ||
259 | + // if (orderInfo('invoice')) { | ||
260 | + // if (!invoiceText) { | ||
261 | + // tip.show('请输入发票抬头'); | ||
262 | + // return; | ||
263 | + // } | ||
264 | + // if (invoiceText.length > 30) { | ||
265 | + // tip.show('发票抬头不得超过30个汉字'); | ||
266 | + // return; | ||
267 | + // } | ||
268 | + // } | ||
269 | + | ||
270 | + if (msg) { | ||
271 | + if (msg.length > 40) { | ||
272 | + tip.show('留言不得超过40个汉字'); | ||
273 | + return; | ||
274 | + } | ||
275 | + } | ||
276 | + loading.showLoadingMask(); | ||
277 | + isSubmiting = true; | ||
278 | + $.ajax({ | ||
279 | + method: 'POST', | ||
280 | + url: '/cart/index/new/orderSub', | ||
281 | + data: { | ||
282 | + addressId: orderInfo('addressId'), | ||
283 | + cartType: orderInfo('cartType') || 'ordinary', | ||
284 | + deliveryId: orderInfo('deliveryId'), | ||
285 | + deliveryTimeId: orderInfo('deliveryTimeId'), | ||
286 | + invoiceText: orderInfo('invoice') ? invoiceText : null, | ||
287 | + invoiceType: orderInfo('invoice') ? ($invoice.find('.invoice-type').val() || | ||
288 | + orderInfo('invoiceType')) : null, | ||
289 | + msg: msg, | ||
290 | + paymentTypeId: orderInfo('paymentTypeId'), | ||
291 | + paymentType: orderInfo('paymentType'), // 支付方式 | ||
292 | + couponCode: orderInfo('couponCode'), | ||
293 | + yohoCoin: orderInfo('yohoCoin'), | ||
294 | + skuList: isLimitGood() ? orderInfo('skuList') : undefined | ||
295 | + } | ||
296 | + }).then(function(res) { | ||
297 | + var url; | ||
298 | + | ||
299 | + if (!res) { | ||
300 | + tip.show('系统繁忙,请稍后再试!'); | ||
301 | + return; | ||
302 | + } | ||
303 | + | ||
304 | + if (res.code === 200) { | ||
305 | + if (payType === 2) { | ||
306 | + | ||
307 | + // 货到付款的进入订单页面 | ||
308 | + url = '/home/orderDetail?order_code=' + res.data.order_code; | ||
309 | + } else { | ||
310 | + url = '/home/orders/paynew?order_code=' + res.data.order_code; | ||
311 | + } | ||
312 | + | ||
313 | + /* tar add 161116 */ | ||
314 | + if (window._yas && window._yas.sendCustomInfo) { | ||
315 | + window._yas.sendCustomInfo({ | ||
316 | + op: 'YB_SC_TOPAY_CLICK', | ||
317 | + param: JSON.stringify({ | ||
318 | + C_ID: window._ChannelVary[cookie.get('_Channel')], | ||
319 | + ORDER_CODE: res.data.order_code + '', | ||
320 | + PRD_NUM: $('#goods-num').val(), | ||
321 | + ORDER_AMOUNT: res.data.order_amount | ||
322 | + }) | ||
323 | + }, true); | ||
324 | + } | ||
325 | + | ||
326 | + /* tar add 190222 */ | ||
327 | + if (window._fxcmd) { | ||
328 | + window._fxcmd.push(['trackOrder', { | ||
329 | + oid: res.data.order_code, | ||
330 | + otp: res.data.order_amount, | ||
331 | + u_info: cookie.get('_UID'), | ||
332 | + u_type: cookie.get('_isNewUser') ? 1 : 0 | ||
333 | + }, []]); | ||
334 | + } | ||
335 | + | ||
336 | + cookie.remove(['order-info', 'activity-info']); | ||
337 | + window.location.href = url; | ||
338 | + } else if (res.code === 409) { | ||
339 | + richTip.show(res.message, res.buttons); | ||
340 | + } else if (res.message) { | ||
341 | + tip.show(res.message); | ||
342 | + } | ||
343 | + }).fail(function() { | ||
344 | + tip.show('系统繁忙,请稍后再试!'); | ||
345 | + }).always(function() { | ||
346 | + isSubmiting = false; | ||
347 | + loading.hideLoadingMask(); | ||
348 | + }); | ||
349 | +} | ||
350 | + | ||
351 | +// 界面点击,状态存 cookie | ||
352 | +if (!orderInfo('addressId')) { | ||
353 | + orderInfo('addressId', $addressWrap.data('id')); | ||
354 | +} | ||
355 | + | ||
356 | +$('.delivery-id').on('touchend', 'li', function() { | ||
357 | + orderInfo('deliveryId', $(this).data('id')); | ||
358 | + | ||
359 | + // 实付金额发生变化,使用有货币为0 | ||
360 | + orderInfo('yohoCoin', 0); | ||
361 | + $('.coin').find('.checkbox').removeClass('icon-cb-radio').addClass('icon-radio'); | ||
362 | + | ||
363 | + orderCompute(); | ||
364 | +}); | ||
365 | + | ||
366 | +$('.payment-type').on('touchend', 'li', function() { | ||
367 | + var $paymentType = $('.icon-cb-radio', this); | ||
368 | + | ||
369 | + orderInfo('paymentTypeId', $paymentType.data('id')); // 支付方式id | ||
370 | + orderInfo('paymentType', $paymentType.data('payment-type')); // 支付方式 | ||
371 | +}); | ||
372 | + | ||
373 | +$('.dispatch-time').on('touchend', 'li', function() { | ||
374 | + orderInfo('deliveryTimeId', $(this).data('id')); | ||
375 | +}); | ||
376 | + | ||
377 | +$('.yoho-coin-help-dialog-bg, .yoho-coin-footer').on('touchend', function(e) { | ||
378 | + e.preventDefault(); | ||
379 | + $('.yoho-coin-help-dialog-bg').addClass('hide'); | ||
380 | + $('.yoho-coin-help-dialog').addClass('hide'); | ||
381 | +}); | ||
382 | + | ||
383 | +$('.coin').on('touchend', function(e) { | ||
384 | + var $this = $(this); | ||
385 | + | ||
386 | + if ($(e.target).closest('.yoho-coin-help').length) { | ||
387 | + $('.yoho-coin-help-dialog-bg').removeClass('hide'); | ||
388 | + $('.yoho-coin-help-dialog').removeClass('hide'); | ||
389 | + return true; | ||
390 | + } | ||
391 | + | ||
392 | + if ($(e.target).closest('.coin-check').length <= 0) { | ||
393 | + return false; | ||
394 | + } | ||
395 | + | ||
396 | + if (!isYohoCoinClick) { | ||
397 | + return true; | ||
398 | + } | ||
399 | + | ||
400 | + if ($this.find('.checkbox').hasClass('icon-cb-radio')) { | ||
401 | + orderInfo('yohoCoin', $this.data('yoho-coin')); | ||
402 | + $this.find('.can-use').hide(); | ||
403 | + } else { | ||
404 | + orderInfo('yohoCoin', 0); | ||
405 | + $this.find('.coin-check em').hide(); | ||
406 | + $this.find('.can-use').show(); | ||
407 | + $this.find('.used').hide(); | ||
408 | + } | ||
409 | + orderCompute(); | ||
410 | +}); | ||
411 | + | ||
412 | +$invoice.on('touchend', '.checkbox', function(e) { | ||
413 | + var $this = $(this); | ||
414 | + | ||
415 | + orderInfo('invoice', $this.hasClass('icon-cb-radio')); | ||
416 | + e.preventDefault(); | ||
417 | + e.stopPropagation(); | ||
418 | +}); | ||
419 | + | ||
420 | +$invoice.find('[name="invoice-title"]').on('blur', function() { | ||
421 | + orderInfo('invoiceText', $(this).val()); | ||
422 | +}).end().find('.invoice-type').on('change', function() { | ||
423 | + orderInfo('invoiceType', $(this).val()); | ||
424 | +}); | ||
425 | + | ||
426 | +$('#msg').find('textarea').on('blur', function() { | ||
427 | + orderInfo('msg', $(this).val()); | ||
428 | +}); | ||
429 | + | ||
430 | +$('form').on('submit', function() { | ||
431 | + return false; | ||
432 | +}); | ||
433 | + | ||
434 | +// xwg 2016/3/21 13:22 | ||
435 | +$('.dispatch').on('touchend', 'h3', function() { | ||
436 | + if ($(this).siblings('ul').is(':hidden')) { | ||
437 | + $('.dispatch h3').removeClass('border-none'); | ||
438 | + $(this).addClass('border-none'); | ||
439 | + $('.down').removeClass('hide'); | ||
440 | + $('.up').addClass('hide'); | ||
441 | + $('.up', this).removeClass('hide'); | ||
442 | + $('.down', this).addClass('hide'); | ||
443 | + $('.dispatch ul').hide(); | ||
444 | + $(this).siblings('ul').show(); | ||
445 | + } else { | ||
446 | + $(this).removeClass('border-none'); | ||
447 | + $('.down', this).removeClass('hide'); | ||
448 | + $('.up', this).addClass('hide'); | ||
449 | + $(this).siblings('ul').hide(); | ||
450 | + } | ||
451 | +}); | ||
452 | + | ||
453 | +$subBlock.on('touchstart', 'li', function() { | ||
454 | + // 送货时间提示语li,不响应事件 | ||
455 | + if ($(this).hasClass('dispatch-time-info')) { | ||
456 | + return true; | ||
457 | + } | ||
458 | + | ||
459 | + $.each($(this).parents('ul').find('i'), function() { | ||
460 | + $(this).parents('ul').find('i').removeClass('icon-cb-radio').addClass('icon-radio'); | ||
461 | + }); | ||
462 | + let self = $(this); | ||
463 | + | ||
464 | + setTimeout(function() { | ||
465 | + self.parents('ul').hide(); | ||
466 | + }, 300); | ||
467 | + | ||
468 | + $('.down').removeClass('hide'); | ||
469 | + $('.up').addClass('hide'); | ||
470 | + $('.dispatch h3').removeClass('border-none'); | ||
471 | + dispatchInfo = $(this).find('span').html(); | ||
472 | + $(this).parents('.sub-block').find('h3 span').html(dispatchInfo); | ||
473 | + if ($(this).find('i').hasClass('icon-cb-radio')) { | ||
474 | + $(this).find('i').addClass('icon-radio'); | ||
475 | + } else if ($(this).find('i').hasClass('icon-radio')) { | ||
476 | + $(this).find('i').addClass('icon-cb-radio'); | ||
477 | + } | ||
478 | +}); | ||
479 | + | ||
480 | + | ||
481 | +$('.bill a').on('touchstart', function() { | ||
482 | + var $paymentType; | ||
483 | + | ||
484 | + if (isTickets) { | ||
485 | + ticketsConfirm(); // eslint-disable-line | ||
486 | + return; | ||
487 | + } | ||
488 | + | ||
489 | + $paymentType = $('.payment-type .icon-cb-radio'); | ||
490 | + orderInfo('paymentTypeId', $paymentType.data('id')); // 支付方式id | ||
491 | + orderInfo('paymentType', $paymentType.data('payment-type')); // 支付方式 | ||
492 | + | ||
493 | + payType = $paymentType.data('payment-type'); | ||
494 | + submitOrder(); | ||
495 | +}); | ||
496 | + | ||
497 | +function phoneHidden(phone) { | ||
498 | + phone = phone || ''; | ||
499 | + return phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2'); | ||
500 | +} | ||
501 | + | ||
502 | +$('.info-phone').html(phoneHidden($('.info-phone').html())); | ||
503 | + | ||
504 | +if (orderInfo('address') && orderInfo('address').is_support === 'N') { | ||
505 | + orderInfo('deliveryId', $('.delivery-id .icon-cb-radio').data('id')); | ||
506 | + orderCompute(); | ||
507 | +} | ||
508 | + | ||
509 | +// 电子票下单 | ||
510 | +function ticketsConfirm() { | ||
511 | + var data = { | ||
512 | + productSku: productSku, | ||
513 | + buyNumber: buyNumber, | ||
514 | + mobile: $ticketsMobile.val(), | ||
515 | + useYohoCoin: orderInfo('yohoCoin') | ||
516 | + }; | ||
517 | + | ||
518 | + if (!$ticketsMobile.val()) { | ||
519 | + tip.show('手机号必填'); | ||
520 | + return; | ||
521 | + } | ||
522 | + | ||
523 | + $.ajax({ | ||
524 | + url: '/cart/index/submitTicket', | ||
525 | + type: 'POST', | ||
526 | + dataType: 'json', | ||
527 | + data: data, | ||
528 | + success: function(ticket) { | ||
529 | + | ||
530 | + // 下单成功调整支付页面 | ||
531 | + if (ticket.code === 200) { | ||
532 | + window.location.href = '/home/orders/paynew?order_code=' + ticket.data.order_code; | ||
533 | + } else { | ||
534 | + tip.show(ticket.message); | ||
535 | + } | ||
536 | + | ||
537 | + }, | ||
538 | + error: function() { | ||
539 | + tip.show('网络异常~'); | ||
540 | + } | ||
541 | + }); | ||
542 | +} | ||
543 | + | ||
544 | +// 校验手机号 | ||
545 | +$ticketsMobile.blur(function() { | ||
546 | + var reg = /^[0123456789]{1,30}$/; | ||
547 | + var mobile = $ticketsMobile.val(); | ||
548 | + | ||
549 | + if (!reg.test(mobile)) { | ||
550 | + tip.show('手机号码不正确!'); | ||
551 | + } | ||
552 | +}); | ||
553 | + | ||
554 | +// 初始化发票信息内容 | ||
555 | +invoiceInit(); | ||
556 | + | ||
557 | +$(window).scroll(function() { | ||
558 | + | ||
559 | + if ($(this).scrollTop() >= (headerTop + addressTop)) { | ||
560 | + $('.address-bottom').show(); | ||
561 | + } else { | ||
562 | + $('.address-bottom').hide(); | ||
563 | + } | ||
564 | +}); |
1 | -/** | ||
2 | - * 订单确认 | ||
3 | - * @author: xuqi<qi.xu@yoho.cn> | ||
4 | - * @date: 2015/11/12 | ||
5 | - */ | ||
6 | - | ||
7 | -var $ = require('yoho-jquery'), | ||
8 | - lazyLoad = require('yoho-jquery-lazyload'), | ||
9 | - cookie = require('yoho-cookie'); | ||
10 | - | ||
11 | -var tip = require('../plugin/tip'), | ||
12 | - loading = require('../plugin/loading'), | ||
13 | - order = require('./order-info'), | ||
14 | - richTip = require('../plugin/rich-tip'); | ||
15 | - | ||
16 | -var $invoice = $('.invoice'), | ||
17 | - $couponUse = $('.coupon-use.used'), | ||
18 | - $addressWrap = $('.address-wrap'), | ||
19 | - $coinCheck = $('.coin-check'), | ||
20 | - $coinLi = $('li.coin'), | ||
21 | - $subBlock = $('.sub-block'), | ||
22 | - $ticketsMobile = $('#mobile'), | ||
23 | - payType, | ||
24 | - queryString = $.queryString(), | ||
25 | - orderInfo = order.orderInfo, | ||
26 | - isSubmiting, | ||
27 | - dispatchInfo, | ||
28 | - total, | ||
29 | - isTickets = $('#ticketsPage').val(), | ||
30 | - productSku = $('#productSku').val(), | ||
31 | - buyNumber = $('#buyNumber').val(), | ||
32 | - headerTop = $('#yoho-header').outerHeight(), | ||
33 | - isYohoCoinClick = $coinLi.data('yoho-coin-click') * 1, // 判断有货币是否可以单击 | ||
34 | - addressTop = $('.address-wrap').outerHeight(); | ||
35 | - | ||
36 | -var orderCont = cookie.get('order-info') && JSON.parse(cookie.get('order-info')); | ||
37 | -var invoiceCont = { | ||
38 | - 7: '服装', | ||
39 | - 1: '图书', | ||
40 | - 9: '配件', | ||
41 | - 11: '日用品', | ||
42 | - 3: '办公用品', | ||
43 | - 6: '体育用品', | ||
44 | - 10: '数码产品' | ||
45 | - }, | ||
46 | - invoicesType = { | ||
47 | - 1: '纸质', | ||
48 | - 2: '电子' | ||
49 | - }; | ||
50 | - | ||
51 | -require('../common'); | ||
52 | - | ||
53 | -lazyLoad(); | ||
54 | - | ||
55 | -// 初始化发票信息 | ||
56 | -function invoiceInit() { | ||
57 | - if (orderCont.invoiceType) { | ||
58 | - $('.invoice-type').text(invoiceCont[orderCont.invoiceType] + '(' + invoicesType[orderCont.invoicesType] + ')'); | ||
59 | - } else { | ||
60 | - $('.invoice-type').text('服装(电子)'); | ||
61 | - } | ||
62 | -} | ||
63 | - | ||
64 | -function getQueryParam() { | ||
65 | - var queryArray = location.search.substr(1).split('&'), | ||
66 | - i, | ||
67 | - subArr = [], | ||
68 | - obj = {}; | ||
69 | - | ||
70 | - for (i = 0; i < queryArray.length; i++) { | ||
71 | - subArr = queryArray[i].split('='); | ||
72 | - obj[subArr[0]] = subArr[1]; | ||
73 | - subArr = []; | ||
74 | - } | ||
75 | - | ||
76 | - return obj; | ||
77 | -} | ||
78 | - | ||
79 | -function isLimitGood() { | ||
80 | - return getQueryParam().limitproductcode; | ||
81 | -} | ||
82 | - | ||
83 | - | ||
84 | -if (window.getUid() !== orderInfo('uid')) { | ||
85 | - order.init(); | ||
86 | - window.location.reload(); | ||
87 | -} | ||
88 | - | ||
89 | -if ($couponUse.data('name') !== orderInfo('couponName')) { | ||
90 | - orderInfo('couponCode', null); | ||
91 | - orderInfo('couponName', null); | ||
92 | -} | ||
93 | - | ||
94 | -// 来自购物车的链接默认不使用优惠券 | ||
95 | -if (document.referrer && document.referrer.indexOf('/cart/index/index') !== -1) { | ||
96 | - orderInfo('couponCode', null); | ||
97 | - orderInfo('couponName', null); | ||
98 | -} | ||
99 | - | ||
100 | -isLimitGood() && (function() { | ||
101 | - var a = []; | ||
102 | - | ||
103 | - var data = getQueryParam(); | ||
104 | - | ||
105 | - data.type = 'limitcode'; | ||
106 | - | ||
107 | - a.push(data); | ||
108 | - orderInfo('skuList', JSON.stringify(a)); | ||
109 | - orderInfo('limitUrlSufix', location.search); | ||
110 | -}()); | ||
111 | - | ||
112 | -if (queryString.cartType || queryString.carttype || !orderInfo('cartType')) { | ||
113 | - orderInfo('cartType', queryString.cartType || queryString.carttype || 'ordinary'); | ||
114 | -} | ||
115 | - | ||
116 | -// function dispacthTapEvt(e) { | ||
117 | -// var $cur = $(e.target).closest('li'); | ||
118 | - | ||
119 | -// if ($cur.length === 0 || $cur.hasClass('chosed')) { | ||
120 | -// return; | ||
121 | -// } | ||
122 | - | ||
123 | -// $cur.siblings('li.chosed').removeClass('chosed'); | ||
124 | -// $cur.addClass('chosed'); | ||
125 | -// } | ||
126 | - | ||
127 | -$('.checkbox').on('touchstart', function(e) { | ||
128 | - var $this = $(this); | ||
129 | - | ||
130 | - if ($(e.target).closest('.coin-check').length && !isYohoCoinClick) { | ||
131 | - return true; | ||
132 | - } | ||
133 | - | ||
134 | - if ($this.hasClass('icon-cb-radio')) { | ||
135 | - $this.removeClass('icon-cb-radio').addClass('icon-radio'); | ||
136 | - return; | ||
137 | - } | ||
138 | - | ||
139 | - if ($this.hasClass('icon-radio')) { | ||
140 | - $this.removeClass('icon-radio').addClass('icon-cb-radio'); | ||
141 | - } | ||
142 | -}); | ||
143 | - | ||
144 | -$invoice.on('touchend', '.checkbox', function() { | ||
145 | - var $this = $(this); | ||
146 | - | ||
147 | - if ($this.hasClass('icon-cb-radio')) { | ||
148 | - $invoice.addClass('focus'); | ||
149 | - orderInfo('invoiceText', ''); | ||
150 | - orderInfo('invoiceType', '7'); | ||
151 | - orderInfo('receiverMobile', $('.user-mobile').val()); | ||
152 | - orderInfo('invoicesType', '2'); | ||
153 | - orderInfo('invoiceTitle', '个人'); | ||
154 | - } | ||
155 | - if ($this.hasClass('icon-radio')) { | ||
156 | - $invoice.removeClass('focus'); | ||
157 | - orderInfo('invoiceText', null); | ||
158 | - orderInfo('invoiceType', null); | ||
159 | - orderInfo('receiverMobile', null); | ||
160 | - orderInfo('invoicesType', null); | ||
161 | - orderInfo('invoiceTitle', null); | ||
162 | - } | ||
163 | - | ||
164 | - orderCont = cookie.get('order-info') && JSON.parse(cookie.get('order-info')); | ||
165 | - invoiceInit(); | ||
166 | -}); | ||
167 | - | ||
168 | - | ||
169 | -function updateDeliverId(id) { | ||
170 | - var $moreJit = $('.more-jit a').get(0), | ||
171 | - url; | ||
172 | - | ||
173 | - if ($moreJit) { | ||
174 | - url = $moreJit.href; | ||
175 | - } else { | ||
176 | - return; | ||
177 | - } | ||
178 | - | ||
179 | - if (url.indexOf('deliveryId') < 0) { | ||
180 | - $moreJit.href = url + '&deliveryId=' + id; | ||
181 | - } else { | ||
182 | - $moreJit.href = url.replace(/deliveryId=(\d)/, 'deliveryId=' + id); | ||
183 | - } | ||
184 | -} | ||
185 | - | ||
186 | -function orderCompute() { | ||
187 | - var yohoCoin = orderInfo('yohoCoin'), | ||
188 | - deliverId = orderInfo('deliveryId'), | ||
189 | - data = { | ||
190 | - cartType: orderInfo('cartType') || 'ordinary', | ||
191 | - deliveryId: orderInfo('deliveryId'), | ||
192 | - paymentType: orderInfo('paymentType'), | ||
193 | - couponCode: orderInfo('couponCode'), | ||
194 | - yohoCoin: yohoCoin, | ||
195 | - skuList: isLimitGood() ? orderInfo('skuList') : undefined | ||
196 | - }; | ||
197 | - | ||
198 | - // 门票 | ||
199 | - if (isTickets) { | ||
200 | - data = { | ||
201 | - type: 'tickets', | ||
202 | - productSku: productSku, | ||
203 | - buyNumber: buyNumber, | ||
204 | - yohoCoin: yohoCoin | ||
205 | - }; | ||
206 | - } | ||
207 | - | ||
208 | - loading.showLoadingMask(); | ||
209 | - $.ajax({ | ||
210 | - method: 'POST', | ||
211 | - url: '/cart/index/new/orderCompute', | ||
212 | - data: data | ||
213 | - }).then(function(res) { | ||
214 | - if ($.type(res) !== 'object') { | ||
215 | - window.location.reload(); | ||
216 | - } else { | ||
217 | - if (typeof res.last_order_amount !== undefined) { | ||
218 | - res.last_order_amount = (+res.last_order_amount).toFixed(2); | ||
219 | - } | ||
220 | - | ||
221 | - if (res.use_yoho_coin) { | ||
222 | - $coinCheck.find('em').html('- ¥ ' + res.use_yoho_coin); | ||
223 | - $coinCheck.find('em').show(); | ||
224 | - } | ||
225 | - $coinLi.find('.msg').html(res.yohoCoinCompute.yohoCoinMsg); | ||
226 | - isYohoCoinClick = res.yohoCoinCompute.yohoCoinClick * 1; | ||
227 | - $('.coin').data('yoho-coin', res.yohoCoinCompute.yohoCoin); | ||
228 | - | ||
229 | - total = ''; | ||
230 | - if (res.promotion_formula_list) { | ||
231 | - $.each(res.promotion_formula_list, function(index, value) { | ||
232 | - total += '<li>' + | ||
233 | - '<p>' + value.promotion + '</p>' + | ||
234 | - '<span>' + value.promotion_amount + '</span>' + | ||
235 | - '</li>'; | ||
236 | - }); | ||
237 | - $('.price-cost span').html('¥' + res.last_order_amount); | ||
238 | - $('.bill span').html('¥' + res.last_order_amount); | ||
239 | - $('.total').html(total); | ||
240 | - } | ||
241 | - | ||
242 | - updateDeliverId(deliverId); | ||
243 | - } | ||
244 | - }).fail(function() { | ||
245 | - window.location.reload(); | ||
246 | - }).always(function() { | ||
247 | - loading.hideLoadingMask(); | ||
248 | - }); | ||
249 | -} | ||
250 | - | ||
251 | -function submitOrder() { | ||
252 | - var invoiceText = $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'), | ||
253 | - msg = $('#msg').find('input').val() || orderInfo('msg'); | ||
254 | - | ||
255 | - if (isSubmiting) { | ||
256 | - return false; | ||
257 | - } | ||
258 | - | ||
259 | - // if (orderInfo('invoice')) { | ||
260 | - // if (!invoiceText) { | ||
261 | - // tip.show('请输入发票抬头'); | ||
262 | - // return; | ||
263 | - // } | ||
264 | - // if (invoiceText.length > 30) { | ||
265 | - // tip.show('发票抬头不得超过30个汉字'); | ||
266 | - // return; | ||
267 | - // } | ||
268 | - // } | ||
269 | - | ||
270 | - if (msg) { | ||
271 | - if (msg.length > 40) { | ||
272 | - tip.show('留言不得超过40个汉字'); | ||
273 | - return; | ||
274 | - } | ||
275 | - } | ||
276 | - loading.showLoadingMask(); | ||
277 | - isSubmiting = true; | ||
278 | - $.ajax({ | ||
279 | - method: 'POST', | ||
280 | - url: '/cart/index/new/orderSub', | ||
281 | - data: { | ||
282 | - addressId: orderInfo('addressId'), | ||
283 | - cartType: orderInfo('cartType') || 'ordinary', | ||
284 | - deliveryId: orderInfo('deliveryId'), | ||
285 | - deliveryTimeId: orderInfo('deliveryTimeId'), | ||
286 | - invoiceText: orderInfo('invoice') ? invoiceText : null, | ||
287 | - invoiceType: orderInfo('invoice') ? ($invoice.find('.invoice-type').val() || | ||
288 | - orderInfo('invoiceType')) : null, | ||
289 | - msg: msg, | ||
290 | - paymentTypeId: orderInfo('paymentTypeId'), | ||
291 | - paymentType: orderInfo('paymentType'), // 支付方式 | ||
292 | - couponCode: orderInfo('couponCode'), | ||
293 | - yohoCoin: orderInfo('yohoCoin'), | ||
294 | - skuList: isLimitGood() ? orderInfo('skuList') : undefined | ||
295 | - } | ||
296 | - }).then(function(res) { | ||
297 | - var url; | ||
298 | - | ||
299 | - if (!res) { | ||
300 | - tip.show('系统繁忙,请稍后再试!'); | ||
301 | - return; | ||
302 | - } | ||
303 | - | ||
304 | - if (res.code === 200) { | ||
305 | - if (payType === 2) { | ||
306 | - | ||
307 | - // 货到付款的进入订单页面 | ||
308 | - url = '/home/orderDetail?order_code=' + res.data.order_code; | ||
309 | - } else { | ||
310 | - url = '/home/orders/paynew?order_code=' + res.data.order_code; | ||
311 | - } | ||
312 | - | ||
313 | - /* tar add 161116 */ | ||
314 | - if (window._yas && window._yas.sendCustomInfo) { | ||
315 | - window._yas.sendCustomInfo({ | ||
316 | - op: 'YB_SC_TOPAY_CLICK', | ||
317 | - param: JSON.stringify({ | ||
318 | - C_ID: window._ChannelVary[cookie.get('_Channel')], | ||
319 | - ORDER_CODE: res.data.order_code + '', | ||
320 | - PRD_NUM: $('#goods-num').val(), | ||
321 | - ORDER_AMOUNT: res.data.order_amount | ||
322 | - }) | ||
323 | - }, true); | ||
324 | - } | ||
325 | - | ||
326 | - /* tar add 190222 */ | ||
327 | - if (window._fxcmd) { | ||
328 | - window._fxcmd.push(['trackOrder', { | ||
329 | - oid: res.data.order_code, | ||
330 | - otp: res.data.order_amount, | ||
331 | - u_info: cookie.get('_UID'), | ||
332 | - u_type: cookie.get('_isNewUser') ? 1 : 0 | ||
333 | - }, []]); | ||
334 | - } | ||
335 | - | ||
336 | - cookie.remove(['order-info', 'activity-info']); | ||
337 | - window.location.href = url; | ||
338 | - } else if (res.code === 409) { | ||
339 | - richTip.show(res.message, res.buttons); | ||
340 | - } else if (res.message) { | ||
341 | - tip.show(res.message); | ||
342 | - } | ||
343 | - }).fail(function() { | ||
344 | - tip.show('系统繁忙,请稍后再试!'); | ||
345 | - }).always(function() { | ||
346 | - isSubmiting = false; | ||
347 | - loading.hideLoadingMask(); | ||
348 | - }); | ||
349 | -} | ||
350 | - | ||
351 | -// 界面点击,状态存 cookie | ||
352 | -if (!orderInfo('addressId')) { | ||
353 | - orderInfo('addressId', $addressWrap.data('id')); | ||
354 | -} | ||
355 | - | ||
356 | -$('.delivery-id').on('touchend', 'li', function() { | ||
357 | - orderInfo('deliveryId', $(this).data('id')); | ||
358 | - | ||
359 | - // 实付金额发生变化,使用有货币为0 | ||
360 | - orderInfo('yohoCoin', 0); | ||
361 | - $('.coin').find('.checkbox').removeClass('icon-cb-radio').addClass('icon-radio'); | ||
362 | - | ||
363 | - orderCompute(); | ||
364 | -}); | ||
365 | - | ||
366 | -$('.payment-type').on('touchend', 'li', function() { | ||
367 | - var $paymentType = $('.icon-cb-radio', this); | ||
368 | - | ||
369 | - orderInfo('paymentTypeId', $paymentType.data('id')); // 支付方式id | ||
370 | - orderInfo('paymentType', $paymentType.data('payment-type')); // 支付方式 | ||
371 | -}); | ||
372 | - | ||
373 | -$('.dispatch-time').on('touchend', 'li', function() { | ||
374 | - orderInfo('deliveryTimeId', $(this).data('id')); | ||
375 | -}); | ||
376 | - | ||
377 | -$('.yoho-coin-help-dialog-bg, .yoho-coin-footer').on('touchend', function(e) { | ||
378 | - e.preventDefault(); | ||
379 | - $('.yoho-coin-help-dialog-bg').addClass('hide'); | ||
380 | - $('.yoho-coin-help-dialog').addClass('hide'); | ||
381 | -}); | ||
382 | - | ||
383 | -$('.coin').on('touchend', function(e) { | ||
384 | - var $this = $(this); | ||
385 | - | ||
386 | - if ($(e.target).closest('.yoho-coin-help').length) { | ||
387 | - $('.yoho-coin-help-dialog-bg').removeClass('hide'); | ||
388 | - $('.yoho-coin-help-dialog').removeClass('hide'); | ||
389 | - return true; | ||
390 | - } | ||
391 | - | ||
392 | - if ($(e.target).closest('.coin-check').length <= 0) { | ||
393 | - return false; | ||
394 | - } | ||
395 | - | ||
396 | - if (!isYohoCoinClick) { | ||
397 | - return true; | ||
398 | - } | ||
399 | - | ||
400 | - if ($this.find('.checkbox').hasClass('icon-cb-radio')) { | ||
401 | - orderInfo('yohoCoin', $this.data('yoho-coin')); | ||
402 | - $this.find('.can-use').hide(); | ||
403 | - } else { | ||
404 | - orderInfo('yohoCoin', 0); | ||
405 | - $this.find('.coin-check em').hide(); | ||
406 | - $this.find('.can-use').show(); | ||
407 | - $this.find('.used').hide(); | ||
408 | - } | ||
409 | - orderCompute(); | ||
410 | -}); | ||
411 | - | ||
412 | -$invoice.on('touchend', '.checkbox', function(e) { | ||
413 | - var $this = $(this); | ||
414 | - | ||
415 | - orderInfo('invoice', $this.hasClass('icon-cb-radio')); | ||
416 | - e.preventDefault(); | ||
417 | - e.stopPropagation(); | ||
418 | -}); | ||
419 | - | ||
420 | -$invoice.find('[name="invoice-title"]').on('blur', function() { | ||
421 | - orderInfo('invoiceText', $(this).val()); | ||
422 | -}).end().find('.invoice-type').on('change', function() { | ||
423 | - orderInfo('invoiceType', $(this).val()); | ||
424 | -}); | ||
425 | - | ||
426 | -$('#msg').find('textarea').on('blur', function() { | ||
427 | - orderInfo('msg', $(this).val()); | ||
428 | -}); | ||
429 | - | ||
430 | -$('form').on('submit', function() { | ||
431 | - return false; | ||
432 | -}); | ||
433 | - | ||
434 | -// xwg 2016/3/21 13:22 | ||
435 | -$('.dispatch').on('touchend', 'h3', function() { | ||
436 | - if ($(this).siblings('ul').is(':hidden')) { | ||
437 | - $('.dispatch h3').removeClass('border-none'); | ||
438 | - $(this).addClass('border-none'); | ||
439 | - $('.down').removeClass('hide'); | ||
440 | - $('.up').addClass('hide'); | ||
441 | - $('.up', this).removeClass('hide'); | ||
442 | - $('.down', this).addClass('hide'); | ||
443 | - $('.dispatch ul').hide(); | ||
444 | - $(this).siblings('ul').show(); | ||
445 | - } else { | ||
446 | - $(this).removeClass('border-none'); | ||
447 | - $('.down', this).removeClass('hide'); | ||
448 | - $('.up', this).addClass('hide'); | ||
449 | - $(this).siblings('ul').hide(); | ||
450 | - } | ||
451 | -}); | ||
452 | - | ||
453 | -$subBlock.on('touchstart', 'li', function() { | ||
454 | - // 送货时间提示语li,不响应事件 | ||
455 | - if ($(this).hasClass('dispatch-time-info')) { | ||
456 | - return true; | ||
457 | - } | ||
458 | - | ||
459 | - $.each($(this).parents('ul').find('i'), function() { | ||
460 | - $(this).parents('ul').find('i').removeClass('icon-cb-radio').addClass('icon-radio'); | ||
461 | - }); | ||
462 | - let self = $(this); | ||
463 | - | ||
464 | - setTimeout(function() { | ||
465 | - self.parents('ul').hide(); | ||
466 | - }, 300); | ||
467 | - | ||
468 | - $('.down').removeClass('hide'); | ||
469 | - $('.up').addClass('hide'); | ||
470 | - $('.dispatch h3').removeClass('border-none'); | ||
471 | - dispatchInfo = $(this).find('span').html(); | ||
472 | - $(this).parents('.sub-block').find('h3 span').html(dispatchInfo); | ||
473 | - if ($(this).find('i').hasClass('icon-cb-radio')) { | ||
474 | - $(this).find('i').addClass('icon-radio'); | ||
475 | - } else if ($(this).find('i').hasClass('icon-radio')) { | ||
476 | - $(this).find('i').addClass('icon-cb-radio'); | ||
477 | - } | ||
478 | -}); | ||
479 | - | ||
480 | - | ||
481 | -$('.bill a').on('touchstart', function() { | ||
482 | - var $paymentType; | ||
483 | - | ||
484 | - if (isTickets) { | ||
485 | - ticketsConfirm(); // eslint-disable-line | ||
486 | - return; | ||
487 | - } | ||
488 | - | ||
489 | - $paymentType = $('.payment-type .icon-cb-radio'); | ||
490 | - orderInfo('paymentTypeId', $paymentType.data('id')); // 支付方式id | ||
491 | - orderInfo('paymentType', $paymentType.data('payment-type')); // 支付方式 | ||
492 | - | ||
493 | - payType = $paymentType.data('payment-type'); | ||
494 | - submitOrder(); | ||
495 | -}); | ||
496 | - | ||
497 | -function phoneHidden(phone) { | ||
498 | - phone = phone || ''; | ||
499 | - return phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2'); | ||
500 | -} | ||
501 | - | ||
502 | -$('.info-phone').html(phoneHidden($('.info-phone').html())); | ||
503 | - | ||
504 | -if (orderInfo('address') && orderInfo('address').is_support === 'N') { | ||
505 | - orderInfo('deliveryId', $('.delivery-id .icon-cb-radio').data('id')); | ||
506 | - orderCompute(); | ||
507 | -} | ||
508 | - | ||
509 | -// 电子票下单 | ||
510 | -function ticketsConfirm() { | ||
511 | - var data = { | ||
512 | - productSku: productSku, | ||
513 | - buyNumber: buyNumber, | ||
514 | - mobile: $ticketsMobile.val(), | ||
515 | - useYohoCoin: orderInfo('yohoCoin') | ||
516 | - }; | ||
517 | - | ||
518 | - if (!$ticketsMobile.val()) { | ||
519 | - tip.show('手机号必填'); | ||
520 | - return; | ||
521 | - } | ||
522 | - | ||
523 | - $.ajax({ | ||
524 | - url: '/cart/index/submitTicket', | ||
525 | - type: 'POST', | ||
526 | - dataType: 'json', | ||
527 | - data: data, | ||
528 | - success: function(ticket) { | ||
529 | - | ||
530 | - // 下单成功调整支付页面 | ||
531 | - if (ticket.code === 200) { | ||
532 | - window.location.href = '/home/orders/paynew?order_code=' + ticket.data.order_code; | ||
533 | - } else { | ||
534 | - tip.show(ticket.message); | ||
535 | - } | ||
536 | - | ||
537 | - }, | ||
538 | - error: function() { | ||
539 | - tip.show('网络异常~'); | ||
540 | - } | ||
541 | - }); | ||
542 | -} | ||
543 | - | ||
544 | -// 校验手机号 | ||
545 | -$ticketsMobile.blur(function() { | ||
546 | - var reg = /^[0123456789]{1,30}$/; | ||
547 | - var mobile = $ticketsMobile.val(); | ||
548 | - | ||
549 | - if (!reg.test(mobile)) { | ||
550 | - tip.show('手机号码不正确!'); | ||
551 | - } | ||
552 | -}); | ||
553 | - | ||
554 | -// 初始化发票信息内容 | ||
555 | -invoiceInit(); | ||
556 | - | ||
557 | -$(window).scroll(function() { | ||
558 | - | ||
559 | - if ($(this).scrollTop() >= (headerTop + addressTop)) { | ||
560 | - $('.address-bottom').show(); | ||
561 | - } else { | ||
562 | - $('.address-bottom').hide(); | ||
563 | - } | ||
564 | -}); | 1 | +require('./order-ensure'); |
public/js/cart/tickets-confirm.page.js
0 → 100644
public/scss/cart/tickets-confirm.page.css
0 → 100644
-
Please register or login to post a comment