diff --git a/pagesInn/inn/innHome.vue b/pagesInn/inn/innHome.vue index 9010c98..b6dace8 100644 --- a/pagesInn/inn/innHome.vue +++ b/pagesInn/inn/innHome.vue @@ -484,7 +484,8 @@ export default { isLoadGoodListoSuccess: false, isLoadInfoListSuccess: false, pageKeyId: '', - shareImg: '' + shareImg: '', + videoPlayers: [] } }, // 必须在页面加 onPageScroll(e){} ,才能滑动显示背景 diff --git a/pkg_product/views/famousQianxianVillageShop.vue b/pkg_product/views/famousQianxianVillageShop.vue index f56a084..56a11ad 100644 --- a/pkg_product/views/famousQianxianVillageShop.vue +++ b/pkg_product/views/famousQianxianVillageShop.vue @@ -33,6 +33,7 @@ object-fit="contain" play-btn-position="center" class="video" + id="coverVideo" /> @@ -175,6 +176,8 @@ controls play-btn-position="center" class="video-item" + :id='"video-item" + index' + @play="handleVideo(item, index)" /> @@ -239,7 +242,8 @@ export default { // 资讯 infoArray: [], isLoadInfoListSuccess: false, - pageKeyId: '' + pageKeyId: '', + videoPlayers: [] } }, onPageScroll(e) { @@ -252,6 +256,27 @@ export default { this.getInfoReq() }, methods: { + handleVideo(item, index) { + if(item.type === 2) { + const coverCtx = uni.createVideoContext('coverVideo', this) + coverCtx.pause() + const playerId = 'video-item' + index + if(this.videoPlayers.includes(playerId)) { + this.videoPlayers.forEach(player => { + if(player === playerId) return + const playerCtx = uni.createVideoContext(player, this) + playerCtx.pause() + }) + } { + this.videoPlayers.push(playerId) + this.videoPlayers.forEach(player => { + if(player === playerId) return + const playerCtx = uni.createVideoContext(player, this) + playerCtx.pause() + }) + } + } + }, getShopDetailReq() { const _this = this getCountyFamousVillageDetail(_this.id).then((res) => {