sunlupeng vor 2 Jahren
Ursprung
Commit
d39b56dacf
1 geänderte Dateien mit 20 neuen und 24 gelöschten Zeilen
  1. 20 24
      src/views/HomeView/PointsMall.vue

+ 20 - 24
src/views/HomeView/PointsMall.vue

@@ -205,19 +205,20 @@ export default {
         };
     },
     created() {
+        window.addEventListener('scroll', this.handleScroll, true)
         const Tab = getTab();
         if(Tab == 'gift'){
             this.activeName = 'giftNotice';
         };
         this.getIntegralTypes();
         this.getWelfareList();
-        this.getList(this.activeName);
+        this.getFirstList();
         this.getNotice(this.activeName);
     },
     methods: {
         handleFilter(){
             this.page = 1;
-            this.getList('goodsNotice');
+            this.getFirstList();
         },
         // 保存滚动值,这是兼容的写法
         handleScroll () {
@@ -229,7 +230,7 @@ export default {
                 if(this.page > this.pages){
                     return
                 }else{
-                    this.getList(this.activeName);
+                    this.getFirstList();
                 }
             }
         },
@@ -240,7 +241,7 @@ export default {
             item.checked = true;
             this.orderByClause = item.orderByClause;
             this.page = 1;
-            this.getList('goodsNotice');
+            this.getFirstList();
         },
         getIntegralTypes() {
             integralTypes({ dictType: 'mall_sku_attribute' }).then(response => {
@@ -281,7 +282,7 @@ export default {
                     this.curChosed = dataList[0].welfareId;
                     festivalList({ welfareId: this.curChosed }).then(response => {
                         console.log(response.data.data);
-                        this.goodsList = response.data.data
+                        this.giftList = response.data.data
                     })
                 }
             })
@@ -293,7 +294,7 @@ export default {
             item.checked = true;
             this.deliveryType = item.type;
             this.page = 1;
-            this.getList('goodsNotice');
+            this.getFirstList();
         },
         choseProductAttributeType(item) {
             this.options.forEach((element) => {
@@ -302,7 +303,7 @@ export default {
             item.checked = true;
             this.productAttribute = item.dictValue;
             this.page = 1;
-            this.getList('goodsNotice');
+            this.getFirstList();
         },
         choseType(item) {
             this.choseList.forEach((element) => {
@@ -310,19 +311,16 @@ export default {
             });
             item.checked = true;
             this.curChosed = item.welfareId;
-            this.getList('giftNotice');
+            this.getSecondList();
         },
         getNotice(val) {
             notice({ noticeType: val }).then(response => {
                 console.log(response.data.data);
                 this.noticeContent = response.data.data.content
-            }).catch(() => {
-                this.goodsList = []
             })
         },
-        getList(val) {
-            if (val == 'goodsNotice') {
-                let params = {
+        getFirstList(){
+            let params = {
                     limit:8,
                     page:this.page,
                     name: this.goodsName,
@@ -344,20 +342,21 @@ export default {
                     }
                     ++this.page  
                 })
-            } else {
-                
-                festivalList({ welfareId: this.curChosed }).then(response => {
+        },
+        getSecondList(){
+            festivalList({ welfareId: this.curChosed }).then(response => {
                     console.log(response.data.data);
                     this.giftList = response.data.data;
-                   
                 })
-            }
         },
-
         handleClick(tab, event) {
             this.page = 1;
             console.log(tab.name, event);
-            this.getList(tab.name);
+            if(tab.name=='goodsNotice'){
+                this.getFirstList();
+            }else{
+                this.getSecondList();
+            }
             this.getNotice(tab.name);
         },
         handleClickExchange(id) {
@@ -370,14 +369,11 @@ export default {
             });
         },
     },
-    mounted () {
-        window.addEventListener('scroll', this.handleScroll)
-    },
 
     destroyed () {
         console.log('lalalal')
         // 离开该页面需要移除这个监听的事件,不然会报错
-        window.removeEventListener('scroll', this.handleScroll)
+        window.removeEventListener('scroll', this.handleScroll, true)
     }
 };
 </script>