Blame view

public/js/cart/order-info.js 1.04 KB
陈轩 authored
1 2 3 4 5
/**
 * 订单信息读取
 * @author: bikai<kai.bi@yoho.cn>
 * @date: 2015/12/14
 */
郭成尧 authored
6
let info = window.cookie('order-info');
陈轩 authored
7
郭成尧 authored
8
// cookie 参数
陈峰 authored
9
let actCkOpthn = {
郭成尧 authored
10
    path: '/cart/index'
郭成尧 authored
11
};
陈轩 authored
12 13 14 15 16 17 18 19

function init() {
    info = {
        uid: window.getUid(),
        deliveryId: $('.dispatch-mode .chosed').data('id') || 1,
        deliveryTimeId: 1,
        paymentTypeId: 1,
        yohoCoin: 0,
郭成尧 authored
20
        address_id: null,
郭成尧 authored
21
        coupon_code: null,
陈轩 authored
22
        invoice: null,
郭成尧 authored
23 24
        invoices_title: null,
        invoices_type: null,
陈轩 authored
25 26 27 28 29 30
        receiverMobile: null,
        isModifyTel: false,
        invoicesType: null,
        msg: null,
        cartType: 'ordinary'
    };
郭成尧 authored
31
    window.setCookie('order-info', JSON.stringify(info), actCkOpthn);
陈轩 authored
32 33 34 35 36 37 38 39 40 41 42
}

// info 必须是 JSON 字符串
try {
    info = JSON.parse(info);
} catch (e) {
    init();
}

exports.init = init;
exports.orderInfo = function(key, value) {
陈峰 authored
43
    if (typeof value === 'undefined') {
陈轩 authored
44 45 46
        return info[key];
    }
    info[key] = value;
郭成尧 authored
47
    window.setCookie('order-info', JSON.stringify(info), actCkOpthn);
陈轩 authored
48
};