Authored by 陈峰

Merge branch 'feature/new-shop-product-floor' into 'release/6.8.6'

修复楼层背景错位



See merge request !1697
@@ -352,6 +352,14 @@ class featureModel extends global.yoho.BaseModel { @@ -352,6 +352,14 @@ class featureModel extends global.yoho.BaseModel {
352 352
353 } 353 }
354 354
  355 + // 对背景图做特殊处理
  356 + if (f.component && f.component[0] && f.component[0].type === 'productGroup') {
  357 + if (f.param.bgimg) { // 对背景图做特殊处理
  358 + f.param._bgimgFill = f.param.bgimg;
  359 + f.param.bgimg = '';
  360 + }
  361 + }
  362 +
355 // 新增店铺组 363 // 新增店铺组
356 if (componentType === 'shopGroup') { 364 if (componentType === 'shopGroup') {
357 shopGroups.push(self._getShopGroup(f.component[0])); 365 shopGroups.push(self._getShopGroup(f.component[0]));
@@ -376,6 +384,11 @@ class featureModel extends global.yoho.BaseModel { @@ -376,6 +384,11 @@ class featureModel extends global.yoho.BaseModel {
376 } else if (shop.defaultSkn) { 384 } else if (shop.defaultSkn) {
377 componentArr.push(shop); 385 componentArr.push(shop);
378 } 386 }
  387 +
  388 + if (f.param.bgimg) { // 对背景图做特殊处理
  389 + f.param._bgimgFill = f.param.bgimg;
  390 + f.param.bgimg = '';
  391 + }
379 } 392 }
380 393
381 if (_.get(f, 'type') === 'bottombar') { 394 if (_.get(f, 'type') === 'bottombar') {
@@ -881,12 +881,53 @@ function activityPlan() { @@ -881,12 +881,53 @@ function activityPlan() {
881 } 881 }
882 } 882 }
883 883
  884 +function changeShopAndProductHeightSingle(parent, className) {
  885 + let img = $(parent).find('.' + className);
  886 +
  887 + if (img[0] && !img.hasClass('completed')) {
  888 + // console.log(img[0].src, /(\.jpg|\.png)/.test(img[0].src));
  889 + if (/(\.jpg|\.png)/.test(img[0].src)) {
  890 + let image = new Image();
  891 +
  892 + image.src = img[0].src;
  893 + image.onload = function() {
  894 + img.removeClass(className);
  895 + img.addClass('completed');
  896 + let height = $(parent).find('.product-wrapper .feature-product-info').height();
  897 +
  898 + $(parent).find('.shop-wrapper .feature-shop-info').height(height);
  899 + };
  900 + } else {
  901 + setTimeout(changeShopAndProductHeightSingle, 300, parent, className);
  902 + }
  903 + }
  904 +}
  905 +
884 // 改变店铺+商品组中店铺的高度 906 // 改变店铺+商品组中店铺的高度
885 function changeShopAndProductHeight() { 907 function changeShopAndProductHeight() {
886 $('.shop-product-container').each(function() { 908 $('.shop-product-container').each(function() {
887 - let height = $(this).find('.product-wrapper .feature-product-info').height(); 909 + let img = $(this).find('.product-detail-img').eq(0);
  910 + let that = this;
  911 +
  912 + if (img[0] && !img.hasClass('completed')) {
  913 + // console.log(img[0].src, /(\.jpg|\.png)/.test(img[0].src));
  914 + if (/(\.jpg|\.png)/.test(img[0].src)) {
  915 + let image = new Image();
  916 +
  917 + image.src = img[0].src;
  918 + image.onload = function() {
  919 + img.addClass('completed');
  920 + let height = $(that).find('.product-wrapper .feature-product-info').height();
888 921
889 - $(this).find('.shop-wrapper .feature-shop-info').height(height); 922 + $(that).find('.shop-wrapper .feature-shop-info').height(height);
  923 + };
  924 + } else {
  925 + let className = 'no-completed-' + Math.random().toString(16).substr(2, 8);
  926 +
  927 + img.addClass(className);
  928 + setTimeout(changeShopAndProductHeightSingle, 300, that, className);
  929 + }
  930 + }
890 }); 931 });
891 } 932 }
892 933
@@ -954,7 +995,7 @@ $(function() { @@ -954,7 +995,7 @@ $(function() {
954 // 定时计划 995 // 定时计划
955 activityPlan(); 996 activityPlan();
956 997
957 - setTimeout(changeShopAndProductHeight, 300); 998 + changeShopAndProductHeight();
958 999
959 // 小程序相关处理 1000 // 小程序相关处理
960 if (!window.WeixinJSBridge || !window.WeixinJSBridge.invoke) { 1001 if (!window.WeixinJSBridge || !window.WeixinJSBridge.invoke) {