buynow-select-address.page.js 1.25 KB
/*
 * @Author: Targaryen
 * @Date: 2017-06-23 11:43:18
 * @Last Modified by: Targaryen
 * @Last Modified time: 2017-07-21 11:06:16
 */

require('cart/select-address.page.css');
let $ = require('yoho-jquery'),
    orderInfo = require('cart/buynow/order-info').orderInfo;

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

require('../cart/address/address');
require('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').text(),
        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);
    }
});