Authored by 邱骏

修改店铺图片高度适应

... ... @@ -881,12 +881,53 @@ function activityPlan() {
}
}
function changeShopAndProductHeightSingle(parent, className) {
let img = $(parent).find('.' + className);
if (img[0] && !img.hasClass('completed')) {
// console.log(img[0].src, /(\.jpg|\.png)/.test(img[0].src));
if (/(\.jpg|\.png)/.test(img[0].src)) {
let image = new Image();
image.src = img[0].src;
image.onload = function() {
img.removeClass(className);
img.addClass('completed');
let height = $(parent).find('.product-wrapper .feature-product-info').height();
$(parent).find('.shop-wrapper .feature-shop-info').height(height);
};
} else {
setTimeout(changeShopAndProductHeightSingle, 300, parent, className);
}
}
}
// 改变店铺+商品组中店铺的高度
function changeShopAndProductHeight() {
$('.shop-product-container').each(function() {
let height = $(this).find('.product-wrapper .feature-product-info').height();
let img = $(this).find('.product-detail-img').eq(0);
let that = this;
if (img[0] && !img.hasClass('completed')) {
// console.log(img[0].src, /(\.jpg|\.png)/.test(img[0].src));
if (/(\.jpg|\.png)/.test(img[0].src)) {
let image = new Image();
image.src = img[0].src;
image.onload = function() {
img.addClass('completed');
let height = $(that).find('.product-wrapper .feature-product-info').height();
$(this).find('.shop-wrapper .feature-shop-info').height(height);
$(that).find('.shop-wrapper .feature-shop-info').height(height);
};
} else {
let className = 'no-completed-' + Math.random().toString(16).substr(2, 8);
img.addClass(className);
setTimeout(changeShopAndProductHeightSingle, 300, that, className);
}
}
});
}
... ... @@ -954,7 +995,7 @@ $(function() {
// 定时计划
activityPlan();
setTimeout(changeShopAndProductHeight, 400);
changeShopAndProductHeight();
// 小程序相关处理
if (!window.WeixinJSBridge || !window.WeixinJSBridge.invoke) {
... ...