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

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

function init() {
    info = {
        uid: window.getUid(),
        delivery_way: $('.dispatch-mode .chosed').data('id') || 1,
        deliveryTimeId: 1,
        paymentTypeId: 1,
        use_yoho_coin: 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);
};