Authored by 郭成尧

buynow-ok

... ... @@ -2,7 +2,7 @@
* @Author: Targaryen
* @Date: 2017-06-21 10:15:38
* @Last Modified by: Targaryen
* @Last Modified time: 2017-06-23 11:48:11
* @Last Modified time: 2017-06-23 14:53:12
*/
const _ = require('lodash');
const co = require('bluebird').coroutine;
... ... @@ -33,7 +33,7 @@ class BuyNowController {
let orderInfo;
try {
orderInfo = JSON.parse(req.cookies['buynow-order-info']);
orderInfo = JSON.parse(req.cookies.buynow_info);
} catch (e) {
logger.info(`orderEnsure: get buynow-order-info from cookie error:${JSON.stringify(e)}`);
orderInfo = {};
... ... @@ -192,7 +192,7 @@ class BuyNowController {
let orderInfo;
try {
orderInfo = JSON.parse(req.cookies['order-info']);
orderInfo = JSON.parse(req.cookies.buynow_info);
} catch (e) {
orderInfo = {};
}
... ...
... ... @@ -758,7 +758,7 @@ let _detailDataPkgAsync = (origin, uid, vipLevel, ua) => {
return resolve(dest);
}
});
} else if (origin.showBuyNow) { // 显示立即购买和加入购物车两个按钮
} else if (origin.buy_now === 1) { // 显示立即购买和加入购物车两个按钮
Object.assign(dest.cartInfo, cartInfo, {
price: dest.goodsPrice.previousPrice ? dest.goodsPrice.previousPrice : '',
salePrice: dest.goodsPrice.currentPrice ? dest.goodsPrice.currentPrice : '',
... ...
... ... @@ -2,7 +2,7 @@
* @Author: Targaryen
* @Date: 2017-06-21 10:30:21
* @Last Modified by: Targaryen
* @Last Modified time: 2017-06-23 11:23:09
* @Last Modified time: 2017-06-23 15:28:40
*/
require('buynow/order-ensure.page.css');
const $ = require('yoho-jquery');
... ... @@ -145,25 +145,22 @@ $('.checkbox').on('touchstart', function(e) {
}
});
$invoice.on('touchend', '.checkbox', function() {
$invoice.on('touchend', '.checkbox', function(e) {
let $this = $(this);
orderInfo('invoice', $this.hasClass('icon-cb-radio'));
if ($this.hasClass('icon-cb-radio')) {
$invoice.addClass('focus');
orderInfo('invoices_title', '');
orderInfo('invoices_type_id', '7');
orderInfo('receiverMobile', $('.user-mobile').val());
orderInfo('invoicesType', '2');
orderInfo('invoiceTitle', '个人');
}
if ($this.hasClass('icon-radio')) {
$invoice.removeClass('focus');
orderInfo('invoices_title', null);
orderInfo('invoices_type_id', null);
orderInfo('invoices_type', null);
orderInfo('receiverMobile', null);
orderInfo('invoicesType', null);
orderInfo('invoiceTitle', null);
orderInfo('buyerTaxNumber', null);
}
e.preventDefault();
e.stopPropagation();
});
... ... @@ -241,8 +238,7 @@ function orderCompute() {
}
function submitOrder() {
let invoiceText = $invoice.find('[name="invoice-title"]').val() || orderInfo('invoices_title'),
msg = $('#msg').find('input').val() || orderInfo('msg');
let msg = $('#msg').find('input').val() || orderInfo('msg');
if (isSubmiting) {
return false;
... ... @@ -256,26 +252,34 @@ function submitOrder() {
}
loading.showLoadingMask();
isSubmiting = true;
let postData = {
product_sku: qs.product_sku,
address_id: orderInfo('address_id'),
delivery_way: orderInfo('delivery_way'),
delivery_time: orderInfo('delivery_time'),
msg: msg,
is_print_price: orderInfo('is_print_price'),
payment_id: orderInfo('payment_id'),
payment_type: orderInfo('payment_type'), // 支付方式
coupon_code: orderInfo('coupon_code'),
use_yoho_coin: orderInfo('use_yoho_coin')
};
if (orderInfo('invoice')) {
Object.assign(postData, {
invoice: orderInfo('invoice'),
invoices_title: orderInfo('invoices_title'), // 发票抬头
invoices_type: orderInfo('invoices_type'), // 发票类型 1 纸质 2 电子
receiverMobile: orderInfo('receiverMobile'), // 接收人电话
buyerTaxNumber: orderInfo('buyerTaxNumber') // 购买方纳税人识别号,需要开具
});
}
$.ajax({
method: 'POST',
url: '/cart/index/buynow/ordersub',
data: {
product_sku: qs.product_sku,
address_id: orderInfo('address_id'),
delivery_way: orderInfo('delivery_way'),
delivery_time: orderInfo('delivery_time'),
invoice: orderInfo('invoice') || null,
invoices_title: orderInfo('invoice') ? invoiceText : null,
invoices_type_id: orderInfo('invoice') ? ($invoice.find('.invoice-type').val() ||
orderInfo('invoices_type_id')) : null,
receiverMobile: orderInfo('receiverMobile') || null,
msg: msg,
is_print_price: orderInfo('is_print_price'),
payment_id: orderInfo('payment_id'),
payment_type: orderInfo('payment_type'), // 支付方式
coupon_code: orderInfo('coupon_code'),
use_yoho_coin: orderInfo('use_yoho_coin')
}
data: postData
}).then(function(res) {
let url;
... ... @@ -314,7 +318,7 @@ function submitOrder() {
}, []]);
}
cookie.remove(['order-info', 'activity-info']);
cookie.remove(['buynow_info']);
window.location.href = url;
} else if (res.code === 409) {
richTip.show(res.message, res.buttons);
... ... @@ -390,14 +394,6 @@ $('.coin').on('touchend', function(e) {
orderCompute();
});
$invoice.on('touchend', '.checkbox', function(e) {
let $this = $(this);
orderInfo('invoice', $this.hasClass('icon-cb-radio'));
e.preventDefault();
e.stopPropagation();
});
/**
* 是否打印价格
*/
... ...
... ... @@ -2,10 +2,10 @@
* @Author: Targaryen
* @Date: 2017-06-22 13:51:16
* @Last Modified by: Targaryen
* @Last Modified time: 2017-06-23 11:15:44
* @Last Modified time: 2017-06-23 14:51:56
*/
require('common');
let info = window.cookie('buynow-order-info');
let info = window.cookie('buynow_info');
// cookie 参数
let actCkOpthn = {
... ... @@ -30,7 +30,7 @@ function init() {
msg: null,
cartType: 'ordinary'
};
window.setCookie('buynow-order-info', JSON.stringify(info), actCkOpthn);
window.setCookie('buynow_info', JSON.stringify(info), actCkOpthn);
}
// info 必须是 JSON 字符串
... ... @@ -47,5 +47,5 @@ exports.orderInfo = function(key, value) {
return info[key];
}
info[key] = value;
window.setCookie('buynow-order-info', JSON.stringify(info), actCkOpthn);
window.setCookie('buynow_info', JSON.stringify(info), actCkOpthn);
};
... ...
/*
* @Author: Targaryen
* @Date: 2017-06-23 11:43:34
* @Last Modified by: Targaryen
* @Last Modified time: 2017-06-23 11:43:34
* @Last Modified by: Targaryen
* @Last Modified time: 2017-06-23 15:15:21
*/
require('cart/select-invoice.page.css');
... ... @@ -122,10 +122,10 @@ function confirmAction() {
rightBtnText: '确定'
}
}, function() {
orderInfo('invoices_type', eInvoiceType); // 发票类型,目前只有电子发票
orderInfo('invoice_title', (title === '单位' ? company : '')); // 发票抬头,个人不传
orderInfo('invoices_type', eInvoiceType);
orderInfo('invoices_title', title === '单位' ? company : '');
orderInfo('receiverMobile', tel);
orderInfo('buyerTaxNumber', buyerTaxNumber);
orderInfo('buyerTaxNumber', title === '单位' ? buyerTaxNumber : '');
if (isModifyTel && $copyTel !== tel) {
orderInfo('isModifyTel', true);
... ...
... ... @@ -108,28 +108,24 @@ $('.checkbox').on('touchstart', function(e) {
}
});
$invoice.on('touchend', '.checkbox', function() {
$invoice.on('touchend', '.checkbox', function(e) {
let $this = $(this);
orderInfo('invoice', $this.hasClass('icon-cb-radio'));
if ($this.hasClass('icon-cb-radio')) {
$invoice.addClass('focus');
orderInfo('invoiceText', '');
orderInfo('invoiceType', '7');
orderInfo('receiverMobile', $('.user-mobile').val());
orderInfo('invoicesType', '2');
orderInfo('invoiceTitle', '个人');
}
if ($this.hasClass('icon-radio')) {
$invoice.removeClass('focus');
orderInfo('invoiceText', null);
orderInfo('invoiceType', null);
orderInfo('invoices_title', null);
orderInfo('invoices_type', null);
orderInfo('receiverMobile', null);
orderInfo('invoicesType', null);
orderInfo('invoiceTitle', null);
orderInfo('buyerTaxNumber', null);
}
e.preventDefault();
e.stopPropagation();
});
function updateDeliverId(id) {
let $moreJit = $('.more-jit a').get(0),
url;
... ... @@ -373,14 +369,6 @@ $('.coin').on('touchend', function(e) {
orderCompute();
});
$invoice.on('touchend', '.checkbox', function(e) {
let $this = $(this);
orderInfo('invoice', $this.hasClass('icon-cb-radio'));
e.preventDefault();
e.stopPropagation();
});
/**
* 是否打印价格
*/
... ...
... ... @@ -179,7 +179,7 @@ setTimeout(() => {
return;
}
if (result.buyNow) { // 立即购买
console.log('/cart/index/buynow'); // TODO
location.href = '/cart/index/buynow/orderensure?product_sku=' + result.sku.skuId;
return;
}
detailFuns.addToCart(result.sku.skuId, productSkn, result.buyNum);
... ...