Blame view

public/js/cart/order-info.js 1.36 KB
陈轩 authored
1 2 3 4 5 6 7 8
/**
 * 订单信息读取
 * @author: bikai<kai.bi@yoho.cn>
 * @date: 2015/12/14
 */
require('../common');
var info = window.cookie('order-info');
郭成尧 authored
9 10 11 12
// cookie 参数
var actCkOpthn = {
    expires: 'Session',
    path: '/cart/index',
13
    domain: 'm.yohobuy.com'
郭成尧 authored
14
};
陈轩 authored
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35

function init() {
    info = {
        uid: window.getUid(),
        deliveryId: $('.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'
    };
郭成尧 authored
36
    window.setCookie('order-info', JSON.stringify(info), actCkOpthn);
陈轩 authored
37 38 39 40 41 42 43
}

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

    // 2015/12/31 hf: fixes bug to 购物车页面调用该JS, 会导致有有货币,值却没有传给服务端. 因此需要再设置一下
lijing authored
44
    // info['yohoCoin'] = $('.coin').data('yoho-coin') || 0;
陈轩 authored
45 46 47 48 49 50 51 52 53 54 55
} catch (e) {
    init();
}

exports.init = init;

exports.orderInfo = function(key, value) {
    if (value === undefined) {
        return info[key];
    }
    info[key] = value;
郭成尧 authored
56
    window.setCookie('order-info', JSON.stringify(info), actCkOpthn);
陈轩 authored
57
};