diff --git a/src/components/UseCouponAddEdit/index.jsx b/src/components/UseCouponAddEdit/index.jsx index c5ff9f17..d75dea33 100644 --- a/src/components/UseCouponAddEdit/index.jsx +++ b/src/components/UseCouponAddEdit/index.jsx @@ -864,6 +864,28 @@ const UseCouponAddEdit = forwardRef((props, ref) => { addProductBtnLoading: true, scopePopType: "addProduct", }); + // 第四步:获取商品数据 + let param = { + reseller_id: direct_reseller_ids, + }; + getProductInfoSelect(param).then((res) => { + setState({ addProductBtnLoading: false, addGoldBtnLoading: false }); + handelResponse( + res, + (req, msg) => { + // !!!!!!!!!!!!!! 为了兼容老版本 新增商品设为空!!!老版本使用 productsList 获取商品数据!!!!!!!!!! + sessionStorage.setItem("productsList", JSON.stringify(req.data)); + // !!!!!!!!!!!!!! 为了兼容老版本 新增商品设为空!!!老版本使用 productsList 获取商品数据!!!!!!!!!! + setState({ productData: null }); + setState({ + showScopePop: true, + }); + }, + (err) => { + console.log("err =>", err); + } + ); + }); } else { // 设置立减金时间 sessionStorage.setItem( @@ -877,30 +899,12 @@ const UseCouponAddEdit = forwardRef((props, ref) => { product_title: "新增立减金", addGoldBtnLoading: true, scopePopType: "addKnockGold", + productData: null, + }); + setState({ + showScopePop: true, }); } - // 第四步:获取商品数据 - let param = { - reseller_id: direct_reseller_ids, - }; - getProductInfoSelect(param).then((res) => { - setState({ addProductBtnLoading: false, addGoldBtnLoading: false }); - handelResponse( - res, - (req, msg) => { - // !!!!!!!!!!!!!! 为了兼容老版本 新增商品设为空!!!老版本使用 productsList 获取商品数据!!!!!!!!!! - sessionStorage.setItem("productsList", JSON.stringify(req.data)); - // !!!!!!!!!!!!!! 为了兼容老版本 新增商品设为空!!!老版本使用 productsList 获取商品数据!!!!!!!!!! - setState({ productData: null }); - setState({ - showScopePop: true, - }); - }, - (err) => { - console.log("err =>", err); - } - ); - }); } catch (err) { setState({ addProductBtnLoading: false, addGoldBtnLoading: false }); } @@ -920,33 +924,32 @@ const UseCouponAddEdit = forwardRef((props, ref) => { setState({ tableLoading: true, }); - // 第二步:获取商品数据 - let param = { - reseller_id: direct_reseller_ids, - }; - getProductInfoSelect(param).then((res) => { - setState({ tableLoading: false }); - handelResponse( - res, - (req, msg) => { - // 设置所有的商品数据 - sessionStorage.setItem("productsList", JSON.stringify(req.data)); - /* 区分立减金 */ - if (rowData.type === 2) { - let obj = rowData.only; - setState({ - product_title: "编辑立减金", - productData: obj, - scopePopType: "addKnockGold", - showScopePop: true, - table_index: index, - }); - } else { + // 第三步:区分是新建商品还是立减金 + /* 区分立减金 */ + if (rowData.type === 2) { + let obj = rowData.only; + setState({ + product_title: "编辑立减金", + productData: obj, + scopePopType: "addKnockGold", + showScopePop: true, + table_index: index, + }); + } else { + let param = { + reseller_id: direct_reseller_ids, + }; + getProductInfoSelect(param).then((res) => { + setState({ tableLoading: false }); + handelResponse( + res, + (req, msg) => { + // 设置所有的商品数据 + sessionStorage.setItem("productsList", JSON.stringify(req.data)); // 如果是复制删除 code_batch_id if (state.isState === "1") { delete rowData.code_batch_id; } - console.log("rowData =>", rowData); setState({ product_title: "编辑商品", productData: rowData, @@ -954,13 +957,13 @@ const UseCouponAddEdit = forwardRef((props, ref) => { showScopePop: true, table_index: index, }); + }, + (err) => { + console.log("err =>", err); } - }, - (err) => { - console.log("err =>", err); - } - ); - }); + ); + }); + } } catch (err) { setState({ tableLoading: false }); }