|
|
var $ = require('yoho-jquery');
|
|
|
var _ = require('lodash');
|
|
|
var brandTmp = require('hbs/material/brand.hbs');
|
|
|
var tableTmp = require('hbs/material/tbl.hbs');
|
|
|
var $mask = $('.mask');
|
|
|
var $brand = $('#brand_container');
|
|
|
var query = {
|
|
|
page: 1,
|
|
|
maxSortId: 0,
|
|
|
middleSortId: 0,
|
|
|
smallSortId: 0
|
|
|
maxSortId: '',
|
|
|
middleSortId: '',
|
|
|
smallSortId: ''
|
|
|
};
|
|
|
var brandList = {
|
|
|
list1: [],
|
...
|
...
|
@@ -16,6 +15,7 @@ var brandList = { |
|
|
list3: [],
|
|
|
list4: []
|
|
|
};
|
|
|
var option0 = '<option value="">--请选择--</option>';
|
|
|
|
|
|
function brandItemEventBind() {
|
|
|
$('#brand_container .item').off().on('click', function() {
|
...
|
...
|
@@ -45,7 +45,7 @@ function getBrandList(_index, yhChannel) { |
|
|
}
|
|
|
|
|
|
function getCategoryOpt(opts) {
|
|
|
var html = '';
|
|
|
var html = option0;
|
|
|
|
|
|
$.each(opts, function(k, c) {
|
|
|
html += '<option value="' + c.sort_id + '">' + c.sort_name + '</option>';
|
...
|
...
|
@@ -54,6 +54,18 @@ function getCategoryOpt(opts) { |
|
|
return html;
|
|
|
}
|
|
|
|
|
|
function findSub(data, id) {
|
|
|
var sub = [];
|
|
|
|
|
|
$.each(data, function(k, c) {
|
|
|
if (c.sort_id === id) {
|
|
|
sub = c.sub;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
return sub;
|
|
|
}
|
|
|
|
|
|
getBrandList(1, 1);
|
|
|
|
|
|
/* 获取品类数据*/
|
...
|
...
|
@@ -72,21 +84,34 @@ $.get('/3party/material/getCategory', function(res) { |
|
|
|
|
|
$category1.on('change', function() {
|
|
|
var id = $(this).val();
|
|
|
var html = option0;
|
|
|
|
|
|
sub = _.find(categoryData, {sort_id: id}).sub;
|
|
|
$category2.html(getCategoryOpt(sub)).show();
|
|
|
$category3.html('').hide();
|
|
|
query.maxSortId = '';
|
|
|
query.middleSortId = '';
|
|
|
query.smallSortId = '';
|
|
|
|
|
|
if ($(this).find('option:selected').index() !== 0) {
|
|
|
sub = findSub(categoryData, id);
|
|
|
html = getCategoryOpt(sub);
|
|
|
query.maxSortId = id;
|
|
|
query.middleSortId = $category2.find('option').eq(0).attr('value');
|
|
|
}
|
|
|
|
|
|
$category2.html(html);
|
|
|
$category3.html(option0);
|
|
|
});
|
|
|
|
|
|
$category2.on('change', function() {
|
|
|
var id = $(this).val();
|
|
|
var third = _.find(sub, {sort_id: id}).sub;
|
|
|
var third = [];
|
|
|
|
|
|
$category3.html(getCategoryOpt(third)).show();
|
|
|
query.smallSortId = '';
|
|
|
query.middleSortId = '';
|
|
|
|
|
|
if ($(this).find('option:selected').index() !== 0) {
|
|
|
third = findSub(sub, id);
|
|
|
$category3.html(getCategoryOpt(third));
|
|
|
query.middleSortId = id;
|
|
|
query.smallSortId = $category3.find('option').eq(0).attr('value');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$category3.on('change', function() {
|
...
|
...
|
|