Commit 52b64dee68b9cb93036c4dcb4c413018af1badda

Authored by 王强
1 parent b7efbf80

购好物首页,隐藏页面再显示刷新添加时间间隔控制,默认5分钟~

src/pages/optimization2/optimization2.vue
@@ -474,7 +474,9 @@ @@ -474,7 +474,9 @@
474 page: 1, 474 page: 1,
475 list: [] 475 list: []
476 }, 476 },
477 - hotSalesActivityCode: 'ds_ghw_ad' // 页面渠道码 477 + hotSalesActivityCode: 'ds_ghw_ad', // 页面渠道码
  478 + refreshInterval: 5, // 刷新时间间隔
  479 + refreshPoint: 0 // 页面从隐藏到显示的刷新时间点,时间戳格式
478 } 480 }
479 }, 481 },
480 computed: { 482 computed: {
@@ -555,6 +557,13 @@ @@ -555,6 +557,13 @@
555 // 优选页面接口 557 // 优选页面接口
556 this.index(); 558 this.index();
557 559
  560 + // 设置刷新时间点
  561 + if (!this.refreshPoint && this.refreshInterval > 0) {
  562 +
  563 + // 设置刷新时间点
  564 + this.setRefreshPoint(this.refreshInterval);
  565 + }
  566 +
558 // 商品列表 567 // 商品列表
559 // this.shopGoodsList(); 568 // this.shopGoodsList();
560 569
@@ -598,6 +607,16 @@ @@ -598,6 +607,16 @@
598 methods: { 607 methods: {
599 608
600 /** 609 /**
  610 + * 设置刷新时间点
  611 + * @param {Number} minute [刷新间隔时间,单位分钟]
  612 + */
  613 + setRefreshPoint(minute) {
  614 +
  615 + // 设置刷新时间点
  616 + this.refreshPoint = new Date().getTime() + (parseFloat(minute) * 60 * 1000);
  617 + },
  618 +
  619 + /**
601 * 加载更多 620 * 加载更多
602 */ 621 */
603 loadMore() { 622 loadMore() {
@@ -1495,7 +1514,10 @@ @@ -1495,7 +1514,10 @@
1495 document.addEventListener('visibilitychange', () => { 1514 document.addEventListener('visibilitychange', () => {
1496 1515
1497 // 页面显示出来了 1516 // 页面显示出来了
1498 - if (document.hidden === false && this.$route.name == 'optimization2') { 1517 + if (document.hidden === false && this.$route.name == 'optimization2' && ((this.refreshPoint && new Date().getTime() > this.refreshPoint) || !this.refreshPoint)) {
  1518 +
  1519 + // 设置刷新时间点
  1520 + this.setRefreshPoint(this.refreshInterval);
1499 1521
1500 // 优选页面接口 1522 // 优选页面接口
1501 this.index(); 1523 this.index();