Authored by 张文文

商品详情页尺码显示多张图 review by lea.guo

@@ -62,11 +62,9 @@ export default { @@ -62,11 +62,9 @@ export default {
62 activated() { 62 activated() {
63 let params = {...this.$route.query}; 63 let params = {...this.$route.query};
64 64
65 - // if (this.yoho.direction === 'forword') {  
66 Object.assign(this.$data, this.$options.data()); 65 Object.assign(this.$data, this.$options.data());
67 !params.order && (params.order = 'sale_desc'); 66 !params.order && (params.order = 'sale_desc');
68 this.fetchData(params); 67 this.fetchData(params);
69 - // }  
70 }, 68 },
71 69
72 computed: { 70 computed: {
1 <template> 1 <template>
2 <!--尺码图片展示--> 2 <!--尺码图片展示-->
3 - <div v-if="sizeImage.imageUrl" class="size-img-container" :data-bid="brandId" :data-pid="productId">  
4 - <img v-lazy="sizeImage.imageUrl" :style="{width: sizeImage.imageWidth, height: sizeImage.imageHeight}"> 3 + <div v-if="sizeImageList.length">
  4 + <div v-for="item in sizeImageList" :key="item.imageUrl" class="size-img-container" :data-bid="brandId" :data-pid="productId">
  5 + <img v-lazy="item.imageUrl" :style="{width: item.imageWidth, height: item.imageHeight}">
  6 + </div>
5 </div> 7 </div>
6 </template> 8 </template>
7 9
@@ -28,29 +30,28 @@ export default { @@ -28,29 +30,28 @@ export default {
28 }, 30 },
29 data() { 31 data() {
30 return { 32 return {
31 - sizeImage: {  
32 - imageUrl: '',  
33 - imageWidth: '100%',  
34 - imageHeight: 'auto'  
35 - } 33 + sizeImageList: []
36 }; 34 };
37 }, 35 },
38 activated() { 36 activated() {
39 - this.getProductSizeImage({brand_id: this.brandId, product_id: this.productId}).then(result => {  
40 - if (result.code === 200 && result.data && result.data.imageUrl) {  
41 - let url = result.data.imageUrl.split('?')[0]; 37 + this.getProductSizeImages({brand_id: this.brandId, product_id: this.productId}).then(result => {
  38 + if (result.code === 200 && result.data) {
  39 +
  40 + let listArr = [];
42 41
43 - // let imageWidth = result.data.imageWidth || 750; 42 + result.data.forEach(function(item) {
44 43
45 - this.sizeImage.imageUrl = url + '?imageView2/2/w/750/q/60'; 44 + let url = item.imageUrl.split('?')[0];
  45 +
  46 + listArr.push({imageUrl: url + '?imageView2/2/w/750/q/60', imageWidth: '100%', imageHeight: 'auto'});
  47 + });
46 48
47 - // this.sizeImage.imageWidth = imageWidth ? (imageWidth / 40) + 'rem' : '100%';  
48 - // this.sizeImage.imageHeight = imageHeight ? (imageHeight / 40) + 'rem' : 'auto'; 49 + this.sizeImageList = listArr;
49 } 50 }
50 }); 51 });
51 }, 52 },
52 methods: { 53 methods: {
53 - ...mapActions(['getProductSizeImage']) 54 + ...mapActions(['getProductSizeImages'])
54 } 55 }
55 }; 56 };
56 </script> 57 </script>
@@ -264,8 +264,8 @@ export default { @@ -264,8 +264,8 @@ export default {
264 }, 264 },
265 265
266 // 获取详情页尺码图片 266 // 获取详情页尺码图片
267 - async getProductSizeImage({state}, {product_id, brand_id}) {  
268 - let result = await this.$api.get('/api/ufo/product/sizeImage', { 267 + async getProductSizeImages({state}, {product_id, brand_id}) {
  268 + let result = await this.$api.get('/api/ufo/product/sizeImages', {
269 product_id, 269 product_id,
270 brand_id 270 brand_id
271 }); 271 });
@@ -184,10 +184,10 @@ module.exports = { @@ -184,10 +184,10 @@ module.exports = {
184 }, 184 },
185 185
186 // 获取详情页的尺码图片 186 // 获取详情页的尺码图片
187 - '/api/ufo/product/sizeImage': { 187 + '/api/ufo/product/sizeImages': {
188 ufo: true, 188 ufo: true,
189 auth: false, 189 auth: false,
190 - api: 'ufo.product.sizeImage', 190 + api: 'ufo.product.sizeImages',
191 params: { 191 params: {
192 product_id: {type: Number}, 192 product_id: {type: Number},
193 brand_id: {type: Number} 193 brand_id: {type: Number}