|
|
/* eslint-disable vars-on-top */
|
|
|
/**
|
|
|
* 订单确认
|
|
|
* @author: xuqi<qi.xu@yoho.cn>
|
|
|
* @date: 2015/11/12
|
|
|
*/
|
|
|
|
|
|
require('common.js');
|
|
|
|
|
|
var lazyLoad = require('yoho-jquery-lazyload'),
|
|
|
tip = require('plugin/tip'),
|
|
|
loading = require('plugin/loading'),
|
|
|
order = require('./order-info');
|
|
|
order = require('../order-info');
|
|
|
|
|
|
var $invoice = $('.invoice'),
|
|
|
$couponUse = $('.coupon-use.used'),
|
...
|
...
|
@@ -22,9 +25,8 @@ var $invoice = $('.invoice'), |
|
|
isSubmiting,
|
|
|
dispatchInfo,
|
|
|
total,
|
|
|
isTickets = $('#ticketsPage').val(),
|
|
|
productSku = $('#productSku').val(),
|
|
|
buyNumber = $('#buyNumber').val();
|
|
|
activityId = $('#activity-id').val(),
|
|
|
productSku = $('#product-sku').val();
|
|
|
|
|
|
var orderCont = window.cookie('order-info') && JSON.parse(window.cookie('order-info'));
|
|
|
var invoiceCont = {
|
...
|
...
|
@@ -41,7 +43,6 @@ var invoiceCont = { |
|
|
2: '电子'
|
|
|
};
|
|
|
|
|
|
require('../common');
|
|
|
|
|
|
lazyLoad();
|
|
|
|
...
|
...
|
@@ -180,25 +181,15 @@ function orderCompute() { |
|
|
cartType: orderInfo('cartType') || 'ordinary',
|
|
|
deliveryId: orderInfo('deliveryId'),
|
|
|
paymentTypeId: orderInfo('paymentTypeId'),
|
|
|
couponCode: orderInfo('couponCode'),
|
|
|
yohoCoin: yohoCoin,
|
|
|
skuList: isLimitGood() ? orderInfo('skuList') : undefined
|
|
|
};
|
|
|
|
|
|
// 门票
|
|
|
if (isTickets) {
|
|
|
data = {
|
|
|
type: 'tickets',
|
|
|
productSku: productSku,
|
|
|
buyNumber: buyNumber,
|
|
|
yohoCoin: yohoCoin
|
|
|
sku: productSku,
|
|
|
activityId: activityId
|
|
|
};
|
|
|
}
|
|
|
|
|
|
loading.showLoadingMask();
|
|
|
$.ajax({
|
|
|
method: 'POST',
|
|
|
url: '/cart/index/orderCompute',
|
|
|
url: '/cart/seckill/compute',
|
|
|
data: data
|
|
|
}).then(function(res) {
|
|
|
if ($.type(res) !== 'object') {
|
...
|
...
|
@@ -264,22 +255,21 @@ function submitOrder() { |
|
|
isSubmiting = true;
|
|
|
$.ajax({
|
|
|
method: 'POST',
|
|
|
url: '/cart/index/orderSub',
|
|
|
url: '/cart/seckill/submit',
|
|
|
data: {
|
|
|
activityId: activityId,
|
|
|
sku: productSku,
|
|
|
addressId: orderInfo('addressId'),
|
|
|
cartType: orderInfo('cartType') || 'ordinary',
|
|
|
deliveryId: orderInfo('deliveryId'),
|
|
|
deliveryTimeId: orderInfo('deliveryTimeId'),
|
|
|
invoiceText: orderInfo('invoice') ? invoiceText : null,
|
|
|
invoiceType: orderInfo('invoice') ? ($invoice.find('.invoice-type').val() ||
|
|
|
deliveryWay: orderInfo('deliveryId'),
|
|
|
deliveryTime: orderInfo('deliveryTimeId'),
|
|
|
invoiceTitle: orderInfo('invoice') ? invoiceText : null,
|
|
|
invoiceTypeId: orderInfo('invoice') ? ($invoice.find('.invoice-type').val() ||
|
|
|
orderInfo('invoiceType')) : null,
|
|
|
msg: msg,
|
|
|
paymentTypeId: orderInfo('paymentTypeId'),
|
|
|
remark: msg,
|
|
|
paymentId: orderInfo('paymentTypeId'),
|
|
|
paymentType: orderInfo('paymentType'), // 支付方式
|
|
|
couponCode: orderInfo('couponCode'),
|
|
|
yohoCoin: orderInfo('yohoCoin'),
|
|
|
skuList: isLimitGood() ? orderInfo('skuList') : undefined
|
|
|
|
|
|
useYohoCoin: orderInfo('yohoCoin')
|
|
|
}
|
|
|
}).then(function(res) {
|
|
|
var url;
|
...
|
...
|
@@ -314,6 +304,7 @@ if (!orderInfo('addressId')) { |
|
|
orderInfo('addressId', $addressWrap.data('id'));
|
|
|
}
|
|
|
|
|
|
// 配送方式 发生改变
|
|
|
$('.delivery-id').on('touchend', 'li', function() {
|
|
|
orderInfo('deliveryId', $(this).data('id'));
|
|
|
orderCompute();
|
...
|
...
|
@@ -410,10 +401,6 @@ $subBlock.on('touchstart', 'li', function() { |
|
|
|
|
|
|
|
|
$('.bill a').on('touchstart', function() {
|
|
|
if (isTickets) {
|
|
|
ticketsConfirm();
|
|
|
return;
|
|
|
}
|
|
|
orderInfo('paymentTypeId', $('.delivery-id .icon-cb-radio').data('id'));
|
|
|
orderInfo('paymentType', $('.payment-type .icon-cb-radio').data('id'));
|
|
|
|
...
|
...
|
@@ -433,40 +420,6 @@ if (orderInfo('address') && orderInfo('address').is_support === 'N') { |
|
|
orderCompute();
|
|
|
}
|
|
|
|
|
|
// 电子票下单
|
|
|
function ticketsConfirm() {
|
|
|
|
|
|
if (!$ticketsMobile.val()) {
|
|
|
tip.show('手机号必填');
|
|
|
return;
|
|
|
}
|
|
|
var data = {
|
|
|
productSku: productSku,
|
|
|
buyNumber: buyNumber,
|
|
|
mobile: $ticketsMobile.val(),
|
|
|
useYohoCoin: orderInfo('yohoCoin')
|
|
|
};
|
|
|
|
|
|
$.ajax({
|
|
|
url: '/cart/index/submitTicket',
|
|
|
type: 'POST',
|
|
|
dataType: 'json',
|
|
|
data: data,
|
|
|
success: function(ticket) {
|
|
|
// 下单成功调整支付页面
|
|
|
if (ticket.code === 200) {
|
|
|
window.location.href = '/home/orders/pay?order_code=' + ticket.data.order_code;
|
|
|
} else {
|
|
|
tip.show(ticket.message);
|
|
|
}
|
|
|
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络异常~');
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 校验手机号
|
|
|
$ticketsMobile.blur(function function_name(e) {
|
|
|
var reg = /^[0123456789]{1,30}$/;
|
...
|
...
|
|