index.page.js 1.21 KB
var $ = require('yoho-jquery');
const brand_tmp = require('hbs/material/brand.hbs');

$('#filter').on('change', () => {
    if ($('#filter').find('option:selected').attr('value') == 3) {
        $('.date').show();
    }
});

/* 品牌点击*/
$('#brand label').on('click', () => {
    if ($('#brand_container').css('display') == 'none') {
        $('#brand_container').css('display', 'block');
    } else {
        $('#brand_container').hide();
    }
});
$(document).on('click', '#brand_container .nav span', function() {
    $('#brand_container .nav span').removeClass('focus');
    $(this).addClass('focus');
    let yh_channel = $(this).attr('yh_channel');

    getBrandList($(this).attr('_index'), yh_channel);
});

/* 获取品牌数据*/
function getBrandList(_index, yh_channel) {
    $.get('/material/newBrandList?yh_channel=' + yh_channel, data => {
        let list = [];
        list = Object.keys(data.data.all_list).map(item => {
            return { name: item, content: data.data.all_list[item] };
        });
        list['focus' + _index] = true;
        $('#brand_container').html(brand_tmp({ list }));
    });
}
getBrandList(1, 1);

/* 获取品类数据*/
$.get('/material/getCategory', data => {
    console.log(data);
});