东莞皮具网站建设,展示页网站怎么做排名,网络系统设计,手工做皮具国外的网站背景介绍
通过uni-app框架实现商城小程序商品详情页的视频与图片轮播功能#xff0c;以提升用户体验和增加商品吸引力。通过展示商品视频和图片#xff0c;用户可以更全面地了解商品细节#xff0c;从而提高购买决策的便利性和满意度。这种功能适用于各类商品#xff0c;如…背景介绍
通过uni-app框架实现商城小程序商品详情页的视频与图片轮播功能以提升用户体验和增加商品吸引力。通过展示商品视频和图片用户可以更全面地了解商品细节从而提高购买决策的便利性和满意度。这种功能适用于各类商品如服装、家具、电子产品等。通过本文的步骤您将学会如何在商城小程序中利用uni-app框架实现商品详情页的视频与图片轮播功能。
代码组件
新建文件productConSwiper.vue
templateview classproduct-bgswiper :indicator-dotsindicatorDots indicator-active-color#E93323 :autoplayautoplay:circularcircular :intervalinterval :durationduration changechangeswiper-item v-ifvideolineview classitemview v-if!controls stylewidth:100%;height:100% video idmyVideo :srcvideoline objectFitcover controls stylewidth:100%;height:100% show-center-play-btn show-mute-btntrue auto-pause-if-navigate :custom-cachefalse:enable-progress-gesturefalse :posterimgUrls[0] pausevideoPause/video/viewview classposter v-ifcontrolsimage classimage :srcimgUrls[0]/image/viewview classstop v-ifcontrols tapbindPauseimage classimage src../../static/images/stop.png/image/view/view/swiper-itemblock v-for(item,index) in imgUrls :keyindexswiper-itemimage :srcitem classslide-image //swiper-item/block/swiper/view
/templatescriptexport default {props: {imgUrls: {type: Array,default: function() {return [];}},videoline: {type: String,value: }},data() {return {indicatorDots: true,circular: true,autoplay: true,interval: 3000,duration: 500,currents: 1,controls: true,isPlay: true,videoContext: null};},mounted() {if (this.videoline) {this.imgUrls.shift()this.videoContext uni.createVideoContext(myVideo, this); // 创建videoContext}},methods: {videoPause(e) {},bindPause: function() { if (this.videoContext) {this.videoContext.play(); // 调用play方法this.$set(this, controls, false);this.autoplay false;}},change: function(e) {this.$set(this, currents, e.detail.current 1);}}}
/scriptstyle scoped langscss.product-bg {width: 100%;height: 750rpx;position: relative;}.product-bg swiper {width: 100%;height: 100%;position: relative;}.product-bg .slide-image {width: 100%;height: 100%;}.product-bg .pages {position: absolute;background-color: #fff;height: 34rpx;padding: 0 10rpx;border-radius: 3rpx;right: 30rpx;bottom: 30rpx;line-height: 34rpx;font-size: 24rpx;color: #050505;}#myVideo {width: 100%;height: 100%}.product-bg .item {position: relative;width: 100%;height: 100%;}.product-bg .item .poster {position: absolute;top: 0;left: 0;height: 750rpx;width: 100%;z-index: 9;}.product-bg .item .poster .image {width: 100%;height: 100%;}.product-bg .item .stop {position: absolute;top: 50%;left: 50%;width: 136rpx;height: 136rpx;margin-top: -68rpx;margin-left: -68rpx;z-index: 9;}.product-bg .item .stop .image {width: 100%;height: 100%;}
/style组件使用
import productConSwiper from /components/productConSwiper;
components: {productConSwiper,
},sliderImage是一个图片地址数组
productInfo.video是视频的地址
productConSwiper :imgUrlssliderImage :videolineproductInfo.video
/productConSwiper