7-Port USB3.0 HUB
$(function () {
var attributes = JSON.parse('""');
var pictures = JSON.parse('[{"id":148006,"product_id":8532,"image_url":["\/uploads\/uk\/product\/CL7U-U3\/CL7U-U3-800-1.jpg","\/uploads\/uk\/product\/CL7U-U3\/CL7U-U3-800-SIZE.jpg"],"image_sort":0,"image_desc":"","image_color":[]}]');
//多属性选择及绑定事件
$(".hd .attr_item").click(function(){
$(this).siblings().removeClass('on');
$(this).toggleClass('on');
var attrVal = $(this).data('feed');
if($(this).hasClass("on")){
$(this).parents(".hd").find(".selectedAttr").text(attrVal);
}
else{
$(this).parents(".hd").find(".selectedAttr").html('');
}
//验证是否所有属性全部选中
var skuCount = $('.attr_type').length;
var activeCount = $('.hd .on').length;
var productAttr = skuAttrType();
if(activeCount == skuCount)
{
//勾选属性事件: 重新加载属性图片
pictures.forEach(function(image, key) {
//选中的属性
var imageColor = image.image_color;
//判断属性是否全部匹配
var attrFlag = true;
attributes.forEach(function(attrName, kat) {
//console.log(imageColor[kat][attrName] + '=====+++++====' + productAttr[kat][attrName]);
if(imageColor[kat][attrName] == productAttr[kat][attrName]){
}else{
attrFlag = false;
return;
}
})
if(attrFlag){
var smaImagesHtml = '';
var bigImagesHtml = '';
var firstImage = '';
var imageUrl = image.image_url;
imageUrl.forEach(function(atrVal,atrKey) {
if(atrKey == 0) {
$("#midimg").attr('src', atrVal);
}
bigImagesHtml += '