select-address.page.js 1.21 KB
/**
 * 购物车 地址选择
 * @author: bikai<kai.bi@yoho.cn>
 * @date: 2015/12/14
 */
require('scss/cart/select-address.page.scss');
let $ = require('yoho-jquery'),
    orderInfo = require('./order-info').orderInfo;

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

require('./address/address');
require('js/common');

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

    orderInfo('address_id', 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('address_id') === deleteId) {
        orderInfo('address_id', null);
        orderInfo('address', null);
    }
});