diff --git a/components/goods-card/comments-card.vue b/components/goods-card/comments-card.vue index 9c683c1..8354bd1 100644 --- a/components/goods-card/comments-card.vue +++ b/components/goods-card/comments-card.vue @@ -19,7 +19,7 @@ + v-for="(item, index) in reviewer.picList" :key="index" v-if="index < 3" :data-url="item.url" :data-imgs="reviewer.picList" @click="viewImage($event)"> @@ -41,8 +41,19 @@ isCard: true } }, - methods: { - + methods: { + viewImage(e) { + let imgList = e.currentTarget.dataset.imgs; + let curUrl = e.currentTarget.dataset.url; + let picList = []; + for(let i = 0; i < imgList.length; i++) { + picList.push(imgList[i].url); + } + uni.previewImage({ + urls: picList, + current: curUrl + }); + } } } diff --git a/pages/product/product-detail.vue b/pages/product/product-detail.vue index beb8ae2..c92c0cd 100644 --- a/pages/product/product-detail.vue +++ b/pages/product/product-detail.vue @@ -17,7 +17,7 @@ - + @@ -177,7 +177,8 @@ ifShowPageMeta: false, orderNow: false, totalPickCount: 0, - ifHasCsMsg: true + ifHasCsMsg: true, + swiperPicUrls: [] } }, onLoad() { @@ -203,7 +204,12 @@ this.curProductSpecs = this.specsList[0]; this.reviewers = productDetail.reviewers; this.productDetailImgUrl = productDetail.productDetailImgUrl; - this.shopInfo = productDetail.shopInfo; + this.shopInfo = productDetail.shopInfo; + for (let i = 0; i < this.swiperList.length; i++) { + if (this.swiperList[i].type === 'image') { + this.swiperPicUrls.push(this.swiperList[i].url); + } + } }, bindEvent() { uni.$on('product-detail_add2Cart', this.add2Cart); @@ -216,11 +222,21 @@ }, showAllSpecs() { this.isShowAllSpecs = !this.isShowAllSpecs; + }, + clickSwiper(e, item) { + if (item.type === 'image') { + this.viewImage(item.url); + } else if (item.type === 'video') { + this.pauseVideo(e); + } + }, + viewImage(url) { + uni.previewImage({ + urls: this.swiperPicUrls, + current: url + }); }, - pauseVideo(e, item) { - if (item.type !== 'video') { - return; - } + pauseVideo(e) { if (this.productVideoPlaying) { this.productVideoContext.pause(); } else {