Commit c432831d authored by 皮倩雯's avatar 皮倩雯

fix: '产品配置'

parent 01139da3
Pipeline #45151 skipped with stages
......@@ -13,42 +13,42 @@ const ProductConfig = props => {
const [flag, setFlag] = useState(1);
const [list, setList] = useState(new Set());
// 默认展示第一项
useEffect(() => {
setLoading(true);
getProductList()
.then(res => {
const { code } = res;
if (code === 0) {
const {
data: { AllProducts, UserProducts },
} = res;
// setProductList(AllProducts);
setUserProductsList(UserProducts);
setProductObj(AllProducts[0]);
AllProducts.map(i => {
list.add(i.ProductType);
});
let a = [];
list.map(i => {
a.push(i);
});
let aa = [];
a.map((i, j) => {
let ad = [];
AllProducts.map(k => {
if (k.ProductType == i) {
ad.push(k);
}
});
aa.push(ad);
});
setProductList(aa);
}
})
.finally(() => {
setLoading(false);
});
}, []);
// useEffect(() => {
// setLoading(true);
// getProductList()
// .then(res => {
// const { code } = res;
// if (code === 0) {
// const {
// data: { AllProducts, UserProducts },
// } = res;
// // setProductList(AllProducts);
// setUserProductsList(UserProducts);
// setProductObj(AllProducts[0]);
// AllProducts.map(i => {
// list.add(i.ProductType);
// });
// let a = [];
// list.map(i => {
// a.push(i);
// });
// let aa = [];
// a.map((i, j) => {
// let ad = [];
// AllProducts.map(k => {
// if (k.ProductType == i) {
// ad.push(k);
// }
// });
// aa.push(ad);
// });
// setProductList(aa);
// }
// })
// .finally(() => {
// setLoading(false);
// });
// }, []);
useEffect(() => {
setLoading(true);
......@@ -61,9 +61,9 @@ const ProductConfig = props => {
} = res;
// setProductList(AllProducts);
setUserProductsList(UserProducts);
// if (!productObj && data.length > 0) {
// setProductObj(data[0]);
// }
if (!productObj && AllProducts.length > 0) {
setProductObj(AllProducts[0]);
}
// setProductList(data);
AllProducts.map(i => {
list.add(i.ProductType);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment