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