|
|
|
@ -109,8 +109,12 @@ |
|
|
|
|
if (status == 200) { |
|
|
|
|
if (data.list.length > 0) { |
|
|
|
|
data.list.forEach((item_1, index_1) => { |
|
|
|
|
let name = this.findElementsById(this.categoryList, item_1.category.split(",").map( |
|
|
|
|
item => Number(item))) |
|
|
|
|
if (typeof item_1.category == 'string') { |
|
|
|
|
item_1.category = item_1.category.split(",").map(item => Number(item)) |
|
|
|
|
} else { |
|
|
|
|
item_1.category = [item_1.category] |
|
|
|
|
} |
|
|
|
|
let name = this.findElementsById(this.categoryList,item_1.category) |
|
|
|
|
item_1.category_name = name.join(',') + (name.length > 0 ? '等' : ''); |
|
|
|
|
item_1.price_list.forEach((item_2, index_2) => { |
|
|
|
|
item_2.startProfit = Number((Number(item_2.min) * (Number(item_2 |
|
|
|
@ -284,6 +288,28 @@ |
|
|
|
|
} |
|
|
|
|
item.price_list.pop() |
|
|
|
|
}, |
|
|
|
|
// 对比数组中取不同的 |
|
|
|
|
mergeArrays(arr1, arr2) { |
|
|
|
|
// 创建一个空数组存放结果 |
|
|
|
|
let mergedArr = []; |
|
|
|
|
// 遍历第一个数组 |
|
|
|
|
for (let i = 0; i < arr1.length; i++) { |
|
|
|
|
if (!arr2.includes(arr1[i])) { |
|
|
|
|
// 如果第二个数组没有包含当前元素,则将其添加到结果数组中 |
|
|
|
|
mergedArr.push(arr1[i]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 再次遍历第二个数组 |
|
|
|
|
for (let j = 0; j < arr2.length; j++) { |
|
|
|
|
if (!arr1.includes(arr2[j]) && !mergedArr.includes(arr2[j])) { |
|
|
|
|
// 如果第一个数组也没有包含该元素且结果数组中还未包含该元素,则将其添加到结果数组中 |
|
|
|
|
mergedArr.push(arr2[j]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return mergedArr; |
|
|
|
|
}, |
|
|
|
|
// 选择分类 |
|
|
|
|
onCategory(categoryId, index) { |
|
|
|
|
let newId = [] |
|
|
|
@ -291,12 +317,19 @@ |
|
|
|
|
this.activeIndex = []; |
|
|
|
|
this.list.forEach((item, index) => { |
|
|
|
|
if (item.category) { |
|
|
|
|
newId = newId.concat((item.category.split(",").map(item => Number(item)))) |
|
|
|
|
newId = newId.concat(item.category) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
let list = Array.from(new Set(newId)); |
|
|
|
|
let list = Array.from(new Set(newId)); //所有以选中的 |
|
|
|
|
// 找到除了当前分类的id集合 |
|
|
|
|
let currentList = []; |
|
|
|
|
if (this.list[index].category) { |
|
|
|
|
currentList = this.list[index].category |
|
|
|
|
} |
|
|
|
|
if (currentList.length > 0 && list.length > 0) { |
|
|
|
|
uni.setStorageSync('beyondList', this.mergeArrays(list, currentList)) |
|
|
|
|
} |
|
|
|
|
this.activeIndex = list |
|
|
|
|
uni.setStorageSync('list', list) |
|
|
|
|
this.$refs.category.afterSale = true; |
|
|
|
|
}, |
|
|
|
|
findElementsById(arr, ids) { |
|
|
|
@ -316,14 +349,9 @@ |
|
|
|
|
// 获取分类 |
|
|
|
|
getChoseCategory(res) { |
|
|
|
|
let nameList = []; |
|
|
|
|
let list = []; |
|
|
|
|
if (this.list[this.categoryIndex].category) { |
|
|
|
|
list = this.list[this.categoryIndex].category.split(",").map(item => Number(item)) |
|
|
|
|
} |
|
|
|
|
let newList = list.concat(res.category_id); |
|
|
|
|
nameList = this.findElementsById(this.categoryList, newList); |
|
|
|
|
nameList = this.findElementsById(this.categoryList, res.category_id); |
|
|
|
|
this.list[this.categoryIndex].category_name = nameList.join(',') + (nameList.length > 0 ? '等' : ''); |
|
|
|
|
this.list[this.categoryIndex].category = newList.join(',') |
|
|
|
|
this.list[this.categoryIndex].category = res.category_id.join(',') |
|
|
|
|
this.$refs.category.afterSale = false; |
|
|
|
|
}, |
|
|
|
|
// 新增分类 |
|
|
|
|