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));