sunlupeng 2 سال پیش
والد
کامیت
50c7aa2064
3فایلهای تغییر یافته به همراه13 افزوده شده و 10 حذف شده
  1. 5 4
      src/views/HomeView/Index.vue
  2. 3 2
      src/views/HomeView/PointsMall.vue
  3. 5 4
      src/views/NoticeCenter.vue

+ 5 - 4
src/views/HomeView/Index.vue

@@ -47,7 +47,8 @@
 </template>
 <script scoped>
 import { msgList } from "@/api/allApi";
-import SiderInfo from '@/components/SiderInfo.vue'
+import SiderInfo from '@/components/SiderInfo.vue';
+import { debounce } from '@/utils/index';
 export default{
   components: {
     SiderInfo
@@ -109,7 +110,7 @@ export default{
         var scrollHeight = document.documentElement.scrollHeight||document.body.scrollHeight;
         //滚动条到底部的条件
         console.log("距顶部---"+scrollTop+"可视区高度---"+windowHeight+"滚动条总高度---"+scrollHeight);
-        if(scrollHeight - (scrollTop+windowHeight) < 10){
+        if(scrollHeight - (scrollTop+windowHeight) < 1){
             if(this.page > this.pages){
                 return
             }else{
@@ -120,12 +121,12 @@ export default{
   },
  
   mounted () {
-    window.addEventListener('scroll', this.handleScroll)
+    window.addEventListener('scroll', debounce(this.handleScroll,500));
   },
 
   destroyed () {
     // 离开该页面需要移除这个监听的事件,不然会报错
-    window.removeEventListener('scroll', this.handleScroll)
+    window.removeEventListener('scroll', this.handleScroll);
   }
 }
 </script>

+ 3 - 2
src/views/HomeView/PointsMall.vue

@@ -145,6 +145,7 @@
 <script>
 import { integralList, festivalList, notice, welfareType, integralTypes } from "@/api/allApi";
 import { getTab } from '@/utils/auth'
+import { debounce } from '@/utils/index'
 export default {
     data() {
         return {
@@ -362,7 +363,7 @@ export default {
             var scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight;
             //滚动条到底部的条件
             console.log("距顶部---" + scrollTop + "可视区高度---" + windowHeight + "滚动条总高度---" + scrollHeight);
-            if (scrollHeight - (scrollTop + windowHeight) < 10) {
+            if (scrollHeight - (scrollTop + windowHeight) < 1) {
                 if (this.page > this.pages) {
                     return
                 } else {
@@ -372,7 +373,7 @@ export default {
         },
     },
     mounted() {
-        window.addEventListener('scroll', this.handleScroll)
+        window.addEventListener('scroll', debounce(this.handleScroll,500));
     },
     destroyed() {
         console.log('lalalal')

+ 5 - 4
src/views/NoticeCenter.vue

@@ -43,7 +43,8 @@
 </template>
 <script>
 import { msgList } from "@/api/allApi";
-import SiderInfo from '@/components/SiderInfo.vue'
+import SiderInfo from '@/components/SiderInfo.vue';
+import { debounce } from '@/utils/index';
 export default{
   components: {
     SiderInfo
@@ -97,7 +98,7 @@ export default{
         var scrollHeight = document.documentElement.scrollHeight||document.body.scrollHeight;
         //滚动条到底部的条件
         console.log("距顶部---"+scrollTop+"可视区高度---"+windowHeight+"滚动条总高度---"+scrollHeight);
-        if(scrollHeight - (scrollTop+windowHeight) < 10){
+        if(scrollHeight - (scrollTop+windowHeight) < 1){
             if(this.page > this.pages){
                 return
             }else{
@@ -108,13 +109,13 @@ export default{
   },
  
   mounted () {
-    window.addEventListener('scroll', this.handleScroll)
+    window.addEventListener('scroll', debounce(this.handleScroll,500));
   },
 
   destroyed () {
     console.log('lalalal')
     // 离开该页面需要移除这个监听的事件,不然会报错
-    window.removeEventListener('scroll', this.handleScroll)
+    window.removeEventListener('scroll', this.handleScroll);
   }
 }
 </script>