//获取分类列表
getCategoryList() {
wx.showLoading({
title: '玩命加载中',
})
let categoryUrl = "/category/all";
let productUrl = "/product/all";
let categoryDate = app.$get(categoryUrl);
let productDate = app.$get(productUrl);
Promise.all([categoryDate, productDate]).then(res => {
console.log(res)
wx.hideLoading()
let list = res[0].list;
list.splice(8,1)
console.log(list)
let detail = res[1].list;
let arr = list.map(item => {
let children = [];
detail.forEach(i => {
if (item.categoryId === i.categoryId) {
children.push(i);
}
});
return {
...item,
children
};
});
console.log(arr)
this.setData({
items:arr
})
}).catch(err => {
console.log(err)
})
},
Promise.all请求和分类的map方法
最新推荐文章于 2024-06-14 06:52:58 发布