From 69d866e6cebcc99f95f98dc7ddf3feec23f4b38c Mon Sep 17 00:00:00 2001 From: linxi Date: Tue, 24 Dec 2024 11:34:27 +0800 Subject: [PATCH] =?UTF-8?q?Fix=EF=BC=9A2873=20=E3=80=90=E5=95=86=E5=9F=8E?= =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E3=80=91=E5=8E=BF=E5=9F=8E=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5=EF=BC=8C=E6=94=B9=E4=B8=BA=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E5=95=86=E5=93=81=EF=BC=8C=E4=B8=80=E4=B8=AA=E5=BA=97=E9=93=BA?= =?UTF-8?q?=EF=BC=8C=E9=94=99=E5=BC=80=E6=8E=92=E5=88=97=EF=BC=8C=E6=AF=8F?= =?UTF-8?q?=E8=A1=8C=E5=9B=BA=E5=AE=9A=E4=B8=80=E4=B8=AA=E5=95=86=E5=93=81?= =?UTF-8?q?=EF=BC=8C=E4=B8=80=E4=B8=AA=E5=BA=97=E9=93=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg_product/views/famousQianxianShop.vue | 32 ++++++++++++++---------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/pkg_product/views/famousQianxianShop.vue b/pkg_product/views/famousQianxianShop.vue index 7717d12..a643f4a 100644 --- a/pkg_product/views/famousQianxianShop.vue +++ b/pkg_product/views/famousQianxianShop.vue @@ -817,22 +817,28 @@ export default { if (success) { const products = data.products || [] const farmerShops = data.farmerShops || [] - this.leftList = this.sortProductsAndStores(products, farmerShops) - console.log(this.leftList); - // products.map((item, index) => { - // item.isOldBrand = 0 - // item.isLandmarkGoods = 0 - // if (index % 2 === 0) { - // this.leftList.push(item) - // } - // if (index % 2 === 1) { - // item.isFarmer = 1 - // this.rightList.push(item) - // } - // }) + this.leftList = this.newSort(products, farmerShops) } }) }, + newSort(a, b) { + const minLen = Math.min(a.length, b.length) + const megerMap = [] + for (let i = 0; i < minLen; i ++) { + if(i % 2 === 0) { + megerMap.push(a[i], b[i]) + } else { + megerMap.push(b[i], a[i]) + } + } + if(a.length > minLen) { + megerMap.push(...a.slice(minLen)) + } + if(b.length > minLen) { + megerMap.push(...b.slice(minLen)) + } + return megerMap + }, shuffleArray(array) { for (let i = array.length - 1; i > 0; i--) { let j = Math.floor(Math.random() * (i + 1));