Fix:2873 【商城小程序】县城详情页,改为一个商品,一个店铺,错开排列,每行固定一个商品,一个店铺
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user