diff --git a/pages/home/index.vue b/pages/home/index.vue index 00f76e4..1a0bdc4 100644 --- a/pages/home/index.vue +++ b/pages/home/index.vue @@ -200,7 +200,7 @@ - + @@ -476,6 +476,8 @@ export default { keywordIndex: 0, shareData: {}, currentIndex: 0, + newZoneSwiperKey: 0, + newZoneResumeTimer: null, // 轮播组件实例 swiperInstances: { productSwiper: true, @@ -542,17 +544,33 @@ export default { }, // 页面显示时恢复轮播 pageToShowHandle() { - // 恢复所有轮播组件的自动播放 + // 恢复所有轮播组件的自动播放,甄选好礼轮播先停后启,避免 iOS 熄屏恢复后卡顿 + if (this.newZoneResumeTimer) { + clearTimeout(this.newZoneResumeTimer) + this.newZoneResumeTimer = null + } this.swiperInstances = { productSwiper: true, homestay: true, banner: true, festival: true, - newZone: true, + newZone: false, } + this.currentIndex = 0 + this.newZoneSwiperKey += 1 + this.$nextTick(() => { + this.newZoneResumeTimer = setTimeout(() => { + this.swiperInstances.newZone = true + this.newZoneResumeTimer = null + }, 120) + }) }, // 页面隐藏时暂停轮播 pageToHideHandle() { + if (this.newZoneResumeTimer) { + clearTimeout(this.newZoneResumeTimer) + this.newZoneResumeTimer = null + } this.swiperInstances = { productSwiper: false, homestay: false, @@ -565,6 +583,12 @@ export default { bindSwiperInstance(e, key) { // this.swiperInstances[key] = e.detail }, + resetNewZoneCurrentIndex() { + const products = (this.newZone && this.newZone.indexProducts) || [] + if (!products.length || this.currentIndex >= products.length) { + this.currentIndex = 0 + } + }, changeRecommendKeyword(e) { this.keywordIndex = e }, @@ -1458,6 +1482,7 @@ export default { _this.$set(_this, 'contentHomestay', data.contentHomestayV2 || []) _this.$set(_this, 'contentFestival', data.contentFestivalV2 || []) _this.$set(_this, 'newZone', data.newGoods || []) + _this.resetNewZoneCurrentIndex() _this.$set(_this, 'hasExperienceCoupon', data.hasExperienceCoupon || 0) _this.$set(_this, 'hasUnusedExperienceCoupon', data.hasUnusedExperienceCoupon || 0) _this.$set(_this, 'experienceCouponImage', data.experienceCouponImage || '') @@ -1508,6 +1533,7 @@ export default { this.$set(this, 'contentHomestay', data.contentHomestayV2 || []) this.$set(this, 'contentFestival', data.contentFestivalV2 || []) this.$set(this, 'newZone', data.newGoods || []) + this.resetNewZoneCurrentIndex() this.$set(this, 'hasExperienceCoupon', data.hasExperienceCoupon || 0) this.$set(this, 'hasUnusedExperienceCoupon', data.hasUnusedExperienceCoupon || 0) this.$set(this, 'experienceCouponImage', data.experienceCouponImage || '')