returns-refund.page.js 1.29 KB
/**
 * 退货申请页
 * @author: yyqing<yanqing.yang@yoho.cn>
 * @date: 2016/7/15
 */
var $ = require('yoho-jquery'),
    lazyload = require('yoho-jquery-lazyload');

var $check = $('.check'),
    $refundType = $('.refund-type'),
    $typeInfo = $refundType.children('dl');

var $applyBtn = $('#apply-btn');

var checked;

require('../plugins/check');

lazyload($('img.lazy'));

function restApplyBtn() {
    if (checked.documents && checked.documents.length) {
        $applyBtn.removeClass('disable');
    } else {
        $applyBtn.addClass('disable');
    }
}

$check.check({
    type: 'checkbox',
    onChange: function() {
        checked = $check.check('getChecked');
        restApplyBtn();
    }
});

$refundType.on('click', '.type-item', function() {
    var $this = $(this),
        index;

    if (!$this.hasClass('cur')) {
        index = $this.index();
        $this.addClass('cur').siblings('.cur').removeClass('cur');
        $typeInfo.addClass('hide');
        $typeInfo.eq(index).removeClass('hide');
    }
});

$applyBtn.click(function() {
    $.ajax({
        type: 'POST',
        url: '/me/return/refund/apply',
        data: {
            id: 11
        },
        success: function(data) {
            if (data.code === 200) {
                console.log(data);
            }
        }
    });
});