bundle.page.js 1.29 KB
/**
 * Created by targaryen on 2016/11/28.
 */
var $ = require('yoho-jquery'),
    tip = require('../plugin/tip');

require('../common');

var chosePanelRender = require('../common/chose-panel'),
    chosePanel = require('./bundle/chose-pannel');

var $selectBtn = $('.select-btn'),
    $buyNowBtn = $('#bundle-buy-now');

/**
 * 选择商品颜色等
 */
$selectBtn.on('click', function() {
    var self = $(this);

    $.post('/product/detail/info', {
        id: self.data('id'),
        productSkn: self.data('skn')
    }, function(data) {
        chosePanelRender(data);
        chosePanel.init(self.data('skn'));
        chosePanel.show();
    });
});

/**
 * 立即购买
 */
$buyNowBtn.on('click', function() {
    var bundleGoods = [],
        bundleId = $('#activityId').val();

    $('span[id^="gskn"]').each(function() {
        if (!$(this).data('sku')) {
            tip.show('请为套餐商品选择属性');
            return;
        }

        bundleGoods.push({
            type: 'bundle',
            sku: $(this).data('sku'),
            buy_number: 1
        });
    });

    window.setCookie('bundle-info', JSON.stringify({
        bundleGoods: bundleGoods,
        bundleId: bundleId
    }));

    window.location.href = '/cart/index/orderEnsure?cartType=ordinary&bundleId=' +
        bundleId;
});