Authored by 陈峰

Merge branch 'hotfix/brand-error-channel' into 'gray'

Hotfix/brand error channel

1、品牌跳转区分男女
2、商品详情页图片加载优化和dom高度预设定

See merge request !28
1 <div id="app" class="product-page" data-pid="{{pid}}" data-goods-id="{{goodsId}}"> 1 <div id="app" class="product-page" data-pid="{{pid}}" data-goods-id="{{goodsId}}">
2 <div id="ssr"> 2 <div id="ssr">
3 {{#product}} 3 {{#product}}
4 - <div class="ssr show-box first-box"> 4 + <div class="ssr show-box first-box carousel">
5 <div class="image-swipe"> 5 <div class="image-swipe">
6 <div class="swipe-wrap"> 6 <div class="swipe-wrap">
7 <div class="ssr-swiper-container"> 7 <div class="ssr-swiper-container">
@@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
15 </div> 15 </div>
16 </div> 16 </div>
17 {{#brandInfo}} 17 {{#brandInfo}}
18 - <div class="show-box zero-top-margin"> 18 + <div class="show-box zero-top-margin action">
19 <div> 19 <div>
20 <ul class="item-action"> 20 <ul class="item-action">
21 <li><a href="/product/shop/{{brand_domain}}"><i class="brand icon"></i><span class="action-text"> 21 <li><a href="/product/shop/{{brand_domain}}"><i class="brand icon"></i><span class="action-text">
@@ -26,8 +26,8 @@ module.exports = () => { @@ -26,8 +26,8 @@ module.exports = () => {
26 const channel = channelMap[req.query.app_channel] || req.query.channel || req.cookies._Channel || 'men'; 26 const channel = channelMap[req.query.app_channel] || req.query.channel || req.cookies._Channel || 'men';
27 27
28 // 设置频道 28 // 设置频道
29 - res.cookie('_Channel', channel);  
30 - res.cookie('_ChannelIndex', indexMap[channel]); 29 + res.cookie('_Channel', channel, {path: '/'});
  30 + res.cookie('_ChannelIndex', indexMap[channel], {path: '/'});
31 31
32 // 用于头部颜色控制 32 // 用于头部颜色控制
33 yoho.pageChannel[channel] = true; 33 yoho.pageChannel[channel] = true;
@@ -99,9 +99,13 @@ const getChannel = function() { @@ -99,9 +99,13 @@ const getChannel = function() {
99 99
100 yoho.ready(function() { 100 yoho.ready(function() {
101 yoho.getChannel({}, function(val) { 101 yoho.getChannel({}, function(val) {
  102 + const opt = {
  103 + path: '/'
  104 + };
  105 +
102 val = val - 1; 106 val = val - 1;
103 - cookie.set('_Channel', channel[val].en);  
104 - cookie.set('_ChannelIndex', val); 107 + cookie.set('_Channel', channel[val].en, opt);
  108 + cookie.set('_ChannelIndex', val, opt);
105 }); 109 });
106 }); 110 });
107 }; 111 };
@@ -12,15 +12,6 @@ yoho.ready(() => { @@ -12,15 +12,6 @@ yoho.ready(() => {
12 el: '#app', 12 el: '#app',
13 components: { 13 components: {
14 app: app 14 app: app
15 - },  
16 - created() {  
17 - setTimeout(() => {  
18 - let ssrs = document.getElementById('ssr');  
19 -  
20 - if (ssrs) {  
21 - ssrs.remove();  
22 - }  
23 - }, 100);  
24 } 15 }
25 }); 16 });
26 }); 17 });
@@ -74,13 +74,16 @@ @@ -74,13 +74,16 @@
74 methods: { 74 methods: {
75 changeChannel(index, id) { 75 changeChannel(index, id) {
76 const objY = {}; 76 const objY = {};
  77 + const opt = {
  78 + path: '/'
  79 + };
77 80
78 objY[this.page + '_' + this.channel[this.current].channel] = window.scrollY; 81 objY[this.page + '_' + this.channel[this.current].channel] = window.scrollY;
79 82
80 this.currentChannel = index; 83 this.currentChannel = index;
81 bus.$emit('channel.change', this.page, this.channel[index].channel, objY); 84 bus.$emit('channel.change', this.page, this.channel[index].channel, objY);
82 - cookie.set('_Channel', this.channel[index].channel);  
83 - cookie.set('_ChannelIndex', index); 85 + cookie.set('_Channel', this.channel[index].channel, opt);
  86 + cookie.set('_ChannelIndex', index, opt);
84 87
85 if(yoho.isApp) { 88 if(yoho.isApp) {
86 yoho.setChannel({ 89 yoho.setChannel({
@@ -93,9 +93,13 @@ @@ -93,9 +93,13 @@
93 }, 93 },
94 methods: { 94 methods: {
95 changeChannel(val) { 95 changeChannel(val) {
  96 + const opt = {
  97 + path: '/'
  98 + };
  99 +
96 this.$emit('cv', val); 100 this.$emit('cv', val);
97 - cookie.set('_Channel', this.channel[val].en);  
98 - cookie.set('_ChannelIndex', val); 101 + cookie.set('_Channel', this.channel[val].en, opt);
  102 + cookie.set('_ChannelIndex', val, opt);
99 }, 103 },
100 bgChange(src) { 104 bgChange(src) {
101 return `background: url(${src})`; 105 return `background: url(${src})`;
@@ -342,12 +342,15 @@ @@ -342,12 +342,15 @@
342 created() { 342 created() {
343 yoho.addNativeMethod('changeChannel', val => { 343 yoho.addNativeMethod('changeChannel', val => {
344 let label; 344 let label;
  345 + const opt = {
  346 + path: '/'
  347 + };
345 348
346 val = val - 1; 349 val = val - 1;
347 label = channelLabel[val]; 350 label = channelLabel[val];
348 this.curChannel = label; 351 this.curChannel = label;
349 - cookie.set('_ChannelIndex', val);  
350 - cookie.set('_Channel', label.toLowerCase()); 352 + cookie.set('_ChannelIndex', val, opt);
  353 + cookie.set('_Channel', label.toLowerCase(), opt);
351 }); 354 });
352 } 355 }
353 }; 356 };
1 <template> 1 <template>
2 - <div class="image-swipe"> 2 + <div class="image-swipe" v-if="allLoaded">
3 <div class="swipe-wrap" @click.prevent="showcase()"> 3 <div class="swipe-wrap" @click.prevent="showcase()">
4 <swiper :options="swiperOption" ref="swiper"> 4 <swiper :options="swiperOption" ref="swiper">
5 <swiper-slide v-for="item in goodsList" :key="item.title"> 5 <swiper-slide v-for="item in goodsList" :key="item.title">
@@ -20,6 +20,7 @@ @@ -20,6 +20,7 @@
20 <script> 20 <script>
21 require('swiper/dist/css/swiper.css'); 21 require('swiper/dist/css/swiper.css');
22 import yoho from 'yoho'; 22 import yoho from 'yoho';
  23 + import util from 'common/util';
23 import vas from 'vue-awesome-swiper'; 24 import vas from 'vue-awesome-swiper';
24 25
25 export default { 26 export default {
@@ -39,7 +40,8 @@ @@ -39,7 +40,8 @@
39 onSlideChangeEnd(swiper) { 40 onSlideChangeEnd(swiper) {
40 vm.setActiveSlide(swiper.realIndex) 41 vm.setActiveSlide(swiper.realIndex)
41 } 42 }
42 - } 43 + },
  44 + allLoaded: false
43 }; 45 };
44 }, 46 },
45 components: { 47 components: {
@@ -69,6 +71,37 @@ @@ -69,6 +71,37 @@
69 } 71 }
70 this.goodsList = temp; 72 this.goodsList = temp;
71 this.slideCount = this.goodsList.length; 73 this.slideCount = this.goodsList.length;
  74 + },
  75 + goodsList(goods) {
  76 + const preloadImg = (list, loaded) => {
  77 + loaded = loaded || [];
  78 +
  79 + // 加载完成
  80 + if(list.length === 0) {
  81 + let $ssr = document.getElementById('ssr');
  82 + $ssr && $ssr.remove();
  83 + this.allLoaded = true;
  84 + return;
  85 + }
  86 +
  87 + let img = new Image();
  88 + img.src = util.getImgUrl(list[0].image_url, '580', '770');
  89 +
  90 + if(img.complete) {
  91 + loaded.push(img);
  92 + list.shift();
  93 + preloadImg(list, loaded);
  94 + }
  95 + else {
  96 + img.onload = function() {
  97 + loaded.push(img);
  98 + list.shift();
  99 + preloadImg(list, loaded);
  100 + };
  101 + }
  102 + };
  103 +
  104 + preloadImg(goods[0].images_list);
72 } 105 }
73 }, 106 },
74 methods: { 107 methods: {
@@ -133,9 +166,21 @@ @@ -133,9 +166,21 @@
133 height: 770px; 166 height: 770px;
134 } 167 }
135 } 168 }
136 -}  
137 169
  170 + .show-box.carousel {
  171 + border-top: none;
  172 + border-bottom: none;
  173 + }
  174 + .show-box.info,
  175 + .show-box.action {
  176 + border-top: none;
  177 + }
138 178
  179 + .show-box.action {
  180 + padding-bottom: 0;
  181 + border-bottom: none;
  182 + }
  183 +}
139 184
140 .image-swipe { 185 .image-swipe {
141 position: relative; 186 position: relative;
@@ -422,7 +422,6 @@ @@ -422,7 +422,6 @@
422 return result.data; 422 return result.data;
423 }).then((data)=> { 423 }).then((data)=> {
424 if (data) { 424 if (data) {
425 - console.log(data)  
426 // 读取商品详情 425 // 读取商品详情
427 $.get(`/product/product/intro_${pid}.json`, {skn: data.product_skn}).then(intro => { 426 $.get(`/product/product/intro_${pid}.json`, {skn: data.product_skn}).then(intro => {
428 this.intro = intro; 427 this.intro = intro;
@@ -520,6 +519,7 @@ @@ -520,6 +519,7 @@
520 } 519 }
521 520
522 .show-box.carousel { 521 .show-box.carousel {
  522 + border-top: none;
523 border-bottom: none; 523 border-bottom: none;
524 } 524 }
525 .show-box.info, 525 .show-box.info,
@@ -530,6 +530,14 @@ @@ -530,6 +530,14 @@
530 .show-box.action { 530 .show-box.action {
531 padding-bottom: 0; 531 padding-bottom: 0;
532 border-bottom: none; 532 border-bottom: none;
  533 +
  534 + .item-action {
  535 + height: 103px;
  536 + }
  537 +
  538 + .item-price {
  539 + min-height: 80px;
  540 + }
533 } 541 }
534 542
535 .service { 543 .service {