zhengjinyi 2 лет назад
Родитель
Сommit
4a248a9424
1 измененных файлов с 20 добавлено и 13 удалено
  1. 20 13
      src/main/resources/static/js/supplier-center/shop/goods.js

+ 20 - 13
src/main/resources/static/js/supplier-center/shop/goods.js

@@ -73,19 +73,8 @@ var myGoods = new Vue({
                     let page = data.productPage;
                     _this.featuredNum = data.featuredNum;
                     _this.isForbid = data.listingFee === 1
-                    _this.productsList = page.results.map(function(el){
-                        el.isAddFeatured = false;
-                        el.isDelFeatured = false;
-                        if(_this.featuredNum<4){
-                            if(el.validFlag === 2 && el.featuredFlag === 0 ){
-                                el.isAddFeatured = true;
-                            }
-                            if (el.validFlag === 2 && el.featuredFlag === 1) {
-                                el.isDelFeatured = true;
-                            }
-                        }
-                        return el
-                    })
+                    _this.productsList = _this.handleResults(page.results,_this.featuredNum)
+                    console.log('productsList',_this.productsList)
                     _this.total = page.totalRecord;
                     _this.listLoading = false
                 }else{
@@ -94,6 +83,24 @@ var myGoods = new Vue({
                 }
             })
         },
+        //处理
+        handleResults(list,featuredNum){
+            return list.map(function(el){
+                el.isAddFeatured = false;
+                el.isDelFeatured = false;
+                if(featuredNum<4){
+                    if(el.validFlag === 2 && el.featuredFlag === 0 ){
+                        el.isAddFeatured = true;
+                    }
+                }
+                if(featuredNum>0){
+                    if (el.validFlag === 2 && el.featuredFlag === 1) {
+                        el.isDelFeatured = true;
+                    }
+                }
+                return el
+            })
+        },
         handleCommodityType(event){//选择商品属性
             console.log('event',event)
             console.log('event',this.listQuery.commodityType)