select-address.js 1.11 KB
/**
 * 购物车 地址选择
 * @author: bikai<kai.bi@yoho.cn>
 * @date: 2015/12/14
 */

var $ = require('jquery'),
    orderInfo = require('./order-info').orderInfo;

var $confim = $('.confim-mask'),
    deleteId;

require('../common');

$('.address-item').on('click', function() {
    var $this = $(this);
    var addressId = decodeURIComponent($this.data('address-id'));
    var address = {
        address_id: addressId,
        consignee: $this.find('.name').text(),
        mobile: $this.find('.tel').text(),
        address_info: $this.find('.address-info').text(),
        is_support: $this.data('is-support')
    };

    orderInfo('addressId', addressId);
    orderInfo('address', address);
    window.location.href = $this.data('href') + (orderInfo('limitUrlSufix') || '');

}).on('click', '.edit', function() {
    window.location.href = $(this).data('href');
    return false;
}).on('click', '.del', function() {
    deleteId = $(this).data('id');
});

$confim.on('click', '.confim', function() {
    if (orderInfo('addressId') === deleteId) {
        orderInfo('addressId', null);
        orderInfo('address', null);
    }
});