//这里是监听数组变化,可以不监听
watch: { allProduceArr(newVal, oldVal) {
// console.log('新数组', newVal)
this.sortArr(newVal)
},
// 将列表分成左右两列
async sortArr(arr) {
var array = arr
array.map((item, index) => { //这里面处理我们需要处理的数据,不需要处理的话就可以省略
item.DiscountPrice = item.DiscountPrice ? this.helper.toFixed(item.DiscountPrice) : 0
// item.Discount = item.Discount * 10
item.NetPath = item.ImageUrl ? item.ImageUrl : ''
item.GoodsCode = item.GoodsCode
item.MembershipPrice = item.MembershipPrice ? this.helper.toFixed(item.MembershipPrice) : 0
item.MarketPrice = item.MarketPrice ? this.helper.toFixed(item.MarketPrice) : 0
item.WeightShort = item.WeightShort ? item.WeightShort : ''
})
this.goodList = array
//将array进行处理,他的index索引余2===0的就放到一个新数组中leftArr
this.leftArr = array.filter((_item, index) => index % 2 === 0)
//将array进行处理,他的index索引余2 !===0的就放到一个新数组中rightArr
this.rightArr = array.filter((_item, index) => index % 2 !== 0)
// console.log('商品列表组件数据', this.leftArr, this.rightArr)
},