商品详情轮播图及评价图点击预览功能
This commit is contained in:
parent
3918c52643
commit
4f1d542908
|
|
@ -19,7 +19,7 @@
|
||||||
</view>
|
</view>
|
||||||
<view class="grid flex-sub padding-lr col-3 grid-square" v-if="reviewer.picList">
|
<view class="grid flex-sub padding-lr col-3 grid-square" v-if="reviewer.picList">
|
||||||
<view class="bg-img" :style="'background-image:url(' + item.url + ');'"
|
<view class="bg-img" :style="'background-image:url(' + item.url + ');'"
|
||||||
v-for="(item, index) in reviewer.picList" :key="index" v-if="index < 3">
|
v-for="(item, index) in reviewer.picList" :key="index" v-if="index < 3" :data-url="item.url" :data-imgs="reviewer.picList" @click="viewImage($event)">
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -41,8 +41,19 @@
|
||||||
isCard: true
|
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
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
</uni-transition>
|
</uni-transition>
|
||||||
<!-- 轮播图,视频 -->
|
<!-- 轮播图,视频 -->
|
||||||
<swiper class="screen-swiper" @change="changeSwiper">
|
<swiper class="screen-swiper" @change="changeSwiper">
|
||||||
<swiper-item v-for="(item,index) in swiperList" :key="item.id" @click="pauseVideo($event, item)">
|
<swiper-item v-for="(item,index) in swiperList" :key="item.id" @click="clickSwiper($event, item)">
|
||||||
<image :src="item.url" mode="aspectFill" v-if="item.type=='image'"></image>
|
<image :src="item.url" mode="aspectFill" v-if="item.type=='image'"></image>
|
||||||
<video v-if="item.type=='video'" id="productVideo" :src="item.url" :controls="true" :autoplay="false"
|
<video v-if="item.type=='video'" id="productVideo" :src="item.url" :controls="true" :autoplay="false"
|
||||||
:show-center-play-btn="true" :show-fullscreen-btn="false"></video>
|
:show-center-play-btn="true" :show-fullscreen-btn="false"></video>
|
||||||
|
|
@ -177,7 +177,8 @@
|
||||||
ifShowPageMeta: false,
|
ifShowPageMeta: false,
|
||||||
orderNow: false,
|
orderNow: false,
|
||||||
totalPickCount: 0,
|
totalPickCount: 0,
|
||||||
ifHasCsMsg: true
|
ifHasCsMsg: true,
|
||||||
|
swiperPicUrls: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
|
|
@ -203,7 +204,12 @@
|
||||||
this.curProductSpecs = this.specsList[0];
|
this.curProductSpecs = this.specsList[0];
|
||||||
this.reviewers = productDetail.reviewers;
|
this.reviewers = productDetail.reviewers;
|
||||||
this.productDetailImgUrl = productDetail.productDetailImgUrl;
|
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() {
|
bindEvent() {
|
||||||
uni.$on('product-detail_add2Cart', this.add2Cart);
|
uni.$on('product-detail_add2Cart', this.add2Cart);
|
||||||
|
|
@ -216,11 +222,21 @@
|
||||||
},
|
},
|
||||||
showAllSpecs() {
|
showAllSpecs() {
|
||||||
this.isShowAllSpecs = !this.isShowAllSpecs;
|
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) {
|
pauseVideo(e) {
|
||||||
if (item.type !== 'video') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (this.productVideoPlaying) {
|
if (this.productVideoPlaying) {
|
||||||
this.productVideoContext.pause();
|
this.productVideoContext.pause();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue