$.fn.initCheckImg = function (imgdata, oldimg, width, height) {
var imgInfo = null;
if(imgdata && imgdata.length > 0) {
$.extend(imgdata[0]);
var imgstr = '';
if (oldimg) {
imgdata.map(function (item, index) {
if (item.Id == oldimg.Id) {
imgInfo = {
Id: item.Id,
Class: item.IconClass
};
$.ImgInfo = imgInfo;
imgstr += '
';
} else {
imgstr += '
';
}
});
} else {
imgdata.map(function (item, index) {
if (index === 0) {
imgInfo = {
Id: item.Id,
Class: item.IconClass
};
$.ImgInfo = imgInfo;
imgstr += '
';
} else {
imgstr += '
';
}
});
}
imgstr = '' + imgstr + '
';
$(this).html(imgstr);
$(this).find('.imgbox').click(function() {
$(this).addClass('true').siblings().removeClass('true');
imgInfo = {
Id: $(this).attr("id"),
Class: $(this).find('i').attr('class')
};
$.extend({
ImgInfo: imgInfo
});
});
} else {
console.log('数组参数错误');
}
}