order-info.js 1.17 KB
/*
 * @Author: Targaryen
 * @Date: 2017-06-22 13:51:16
 * @Last Modified by: Targaryen
 */
require('js/common');
let info = window.cookie('buynow_info');

// cookie 参数
let actCkOpthn = {
    path: '/cart/index'
};

function init() {
    info = {
        product_sku: null,
        uid: window.getUid(),
        delivery_way: $('.dispatch-mode .chosed').data('id') || 1,
        delivery_time: 1,
        payment_id: 1,
        use_yoho_coin: 0,
        address_id: null,
        coupon_code: null,
        invoice: null, // 是否选择了发票
        invoices_type: null, // 发票类型: 电子 or 纸质
        invoices_title: null, // 发票抬头
        receiverMobile: null, // 接收人电话
        isModifyTel: false,
        msg: null,
        cartType: 'ordinary'
    };
    window.setCookie('buynow_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_info', JSON.stringify(info), actCkOpthn);
};