Authored by 郭成尧

order-info-cookie

... ... @@ -2,7 +2,7 @@
* @Author: Targaryen
* @Date: 2017-06-21 10:30:21
* @Last Modified by: Targaryen
* @Last Modified time: 2017-06-22 11:36:42
* @Last Modified time: 2017-06-22 13:50:36
*/
require('buynow/order-ensure.page.css');
const $ = require('yoho-jquery');
... ... @@ -11,7 +11,7 @@ const cookie = require('yoho-cookie');
let tip = require('plugin/tip'),
loading = require('plugin/loading'),
order = require('../cart/order-info'),
order = require('./order-info'),
richTip = require('plugin/rich-tip');
let $invoice = $('.invoice'),
... ... @@ -131,7 +131,7 @@ $invoice.on('touchend', '.checkbox', function() {
});
function updateDeliverId(id) {
function updateDeliverWay(deliver_way) {
let $moreJit = $('.more-jit a').get(0),
url;
... ... @@ -142,18 +142,18 @@ function updateDeliverId(id) {
}
if (url.indexOf('deliveryId') < 0) {
$moreJit.href = url + '&deliveryId=' + id;
$moreJit.href = url + '&deliveryId=' + deliver_way;
} else {
$moreJit.href = url.replace(/deliveryId=(\d)/, 'deliveryId=' + id);
$moreJit.href = url.replace(/deliveryId=(\d)/, 'deliveryId=' + deliver_way);
}
}
function orderCompute() {
let yohoCoin = orderInfo('yohoCoin'),
deliverId = orderInfo('deliveryId'),
deliver_way = orderInfo('delivery_way'),
data = {
cart_type: orderInfo('cartType') || 'ordinary',
delivery_way: orderInfo('deliveryId'),
delivery_way: orderInfo('delivery_way'),
payment_type: orderInfo('paymentType'),
coupon_code: orderInfo('couponCode'),
use_yoho_coin: yohoCoin,
... ... @@ -194,7 +194,7 @@ function orderCompute() {
$('.total').html(total);
}
updateDeliverId(deliverId);
updateDeliverWay(deliver_way);
}
}).fail(function() {
window.location.reload();
... ... @@ -223,7 +223,7 @@ function submitOrder() {
method: 'POST',
url: '/cart/index/new/orderSub',
data: {
addressId: orderInfo('addressId'),
delivery_way: orderInfo('delivery_way'),
cartType: orderInfo('cartType') || 'ordinary',
deliveryId: orderInfo('deliveryId'),
deliveryTimeId: orderInfo('deliveryTimeId'),
... ...
/*
* @Author: Targaryen
* @Date: 2017-06-22 13:51:16
* @Last Modified by: Targaryen
* @Last Modified time: 2017-06-22 13:51:16
*/
require('common');
let info = window.cookie('buynow-order-info');
// cookie 参数
let actCkOpthn = {
path: '/cart'
};
function init() {
info = {
uid: window.getUid(),
delivery_way: $('.dispatch-mode .chosed').data('id') || 1,
deliveryTimeId: 1,
paymentTypeId: 1,
yohoCoin: 0,
addressId: null,
couponCode: null,
couponName: null,
invoice: null,
invoiceText: null,
invoiceType: null,
invoiceTitle: null,
receiverMobile: null,
isModifyTel: false,
invoicesType: null,
msg: null,
cartType: 'ordinary'
};
window.setCookie('buynow-order-info', JSON.stringify(info), actCkOpthn);
}
// info 必须是 JSON 字符串
try {
info = JSON.parse(info);
} catch (e) {
init();
}
exports.init = init;
exports.orderInfo = function(key, value) {
if (typeof value === 'undefined') {
return info[key];
}
info[key] = value;
window.setCookie('buynow-order-info', JSON.stringify(info), actCkOpthn);
};
... ...