Преглед изворни кода

change: 分类页同步au的排序逻辑.

peter пре 3 недеља
родитељ
комит
a1d58883c5
1 измењених фајлова са 25 додато и 22 уклоњено
  1. 25 22
      mixins/category.js

+ 25 - 22
mixins/category.js

@@ -21,8 +21,8 @@ export default {
       return this.productsList.filter(item => {
         let moqFlag = true
 
-        // moq 过滤. 要筛出1到最大输入quantities范围的
-        if (!item.moq || item.moq > this.quantity) {
+        // moq 过滤. 要筛出1到最大输入quantities范围的. 直接进入页面忽视这个值, 只有手动更改moq才会触发enableQuantity验证.
+        if (this.enableQuantity && (!item.moq || item.moq > this.quantity)) {
           moqFlag = false
         }
 
@@ -359,7 +359,7 @@ export default {
       cate: [],
       order_name: '',
       order_type: '',
-      quantityMin: 1,
+      enableQuantity: false,
       quantity: 1000,
       priceMin: 1000,
       priceMax: 0.01,
@@ -409,6 +409,14 @@ export default {
         ''
       const config = {
         hitsPerPage: 1000,
+        restrictSearchableAttributes: [
+          'name',
+          'keywords',
+          'colour',
+          'moq',
+          'collection',
+          'filter',
+        ],
         // attributesToRetrieve: ['cat_name'], // 限定只返回某个属性
       }
       if (
@@ -538,7 +546,7 @@ export default {
                   (typeof item.collection_detail === 'string'
                     ? JSON.parse(item.collection_detail)
                     : item.collection_detail) || [],
-                product_name: item.alias_name || item.name || '',
+                product_name: item.name || '',
                 info: {
                   image: colorImg || item.img || '',
                   id: item.id,
@@ -561,16 +569,6 @@ export default {
                   ? parseInt(item.rank)
                   : Math.floor(Math.random() * 10000),
               }
-              // if (item.price_max) {
-              //   console.log(item.product_code)
-              // } else {
-              //   console.log(item.product_code, ' null max')
-              // }
-              // if (item.price_min) {
-              //   console.log(item.product_code)
-              // } else {
-              //   console.log(item.product_code, ' null min')
-              // }
               const min = Number(item.price_min)
               const max = Number(item.price_max)
               if (min < this.priceMin && min !== 0) {
@@ -638,15 +636,19 @@ export default {
         this.colourList = colorList
         // this.decorationList = []
         // this.complianceList = []
-        if (this.$route.fullPath.includes('searchResult')) {
-          temp.sort((a, b) => {
-            if (a.hasBestSeller !== b.hasBestSeller) {
-              return b.hasBestSeller - a.hasBestSeller
-            }
-          })
-        } else {
-          temp.sort(sortFunc)
+
+        if (!this.$route.fullPath.includes('searchResult')) {
+          if (
+            this.$route.query.feature &&
+            Number(this.$route.query.feature) === 54
+          ) {
+            temp.sort((a, b) => b.create_time - a.create_time)
+          } else {
+            temp.sort(sortFunc)
+          }
         }
+
+
         this.productsList = temp
         this.loaded = true
         this.listLoading = false
@@ -772,6 +774,7 @@ export default {
     handleChangeQuantity(value) {
       if (value) {
         this.quantity = value
+        this.enableQuantity = true
         // this.$router.replace({
         //   path: this.$route.path,
         //   query: {