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

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

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

    $('#brand_container .nav span').removeClass('focus');
    $(this).addClass('focus');

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

/* 获取品牌数据*/
function getBrandList(_index, yh_channel) {
    $.get('/material/newBrandList?yh_channel=' + yh_channel, function(data) {
        var list = [];

        list = Object.keys(data.data.all_list).map(function(item) {
            return { name: item, content: data.data.all_list[item] };
        });
        list['focus' + _index] = true;
        $('#brand_container').html(brand_tmp({ list: list }));
    });
}
getBrandList(1, 1);

/* 获取品类数据*/
$.get('/material/getCategory', function(data) {
    console.log(data);
});
/* eslint-enable */