diff --git a/src/pages/plan/add/add.js b/src/pages/plan/add/add.js index d9e060dc..7118287e 100644 --- a/src/pages/plan/add/add.js +++ b/src/pages/plan/add/add.js @@ -64,7 +64,6 @@ export default class add extends React.Component { whiteStyle: false, keyStyle: 1, direct_reseller_id: 0, - keyType: 1, // 1兑换码 2优惠券 }; } @@ -275,7 +274,9 @@ export default class add extends React.Component { // 获取落地页 getStep3Theme() { - this.refs.step3.getThemeData(); + if (this.state.card_visible) { + this.refs.step3.getThemeData(); + } } send(e) { @@ -410,8 +411,6 @@ export default class add extends React.Component { this.onStyleChange(e); }} getStep3Theme={() => this.getStep3Theme()} - changeKeyType={(e) => this.setState({ keyType: e })} - keyType={this.state.keyType} keyStyle={this.state.keyStyle} isload={this.state.isload} curstep={this.state.curstep} diff --git a/src/pages/plan/add/edit.js b/src/pages/plan/add/edit.js index 9d52ca8f..10581c8e 100644 --- a/src/pages/plan/add/edit.js +++ b/src/pages/plan/add/edit.js @@ -216,7 +216,9 @@ export default class add extends React.Component { // 获取落地页 getStep3Theme() { - this.refs.step3.getThemeData(); + if (this.state.card_visible) { + this.refs.step3.getThemeData(); + } } /* 转译 */ @@ -224,9 +226,6 @@ export default class add extends React.Component { // 需要转译的类型 let type = Number(req.keys[0].bind_object[0]); sessionStorage.setItem("keyType", type); - this.setState({ - keyType: Number(type), - }); if (type === 2) { // 优惠券的转译-弹窗已做了优化 return req.keys; @@ -679,13 +678,8 @@ export default class add extends React.Component { this.onStyleChange(e); }} is_Edit={true} - changeKeyType={(e) => { - sessionStorage.setItem("keyType", e); - this.setState({ keyType: e }); - }} getStep3Theme={() => this.getStep3Theme()} curstep={this.state.curstep} - keyType={this.state.keyType} whiteStyle={this.state.whiteStyle} keyStyle={this.state.keyStyle} isload={this.state.isload} diff --git a/src/pages/plan/add/plan-copy.js b/src/pages/plan/add/plan-copy.js index 8a4324e5..0ddb2ca0 100644 --- a/src/pages/plan/add/plan-copy.js +++ b/src/pages/plan/add/plan-copy.js @@ -94,7 +94,6 @@ export default class add extends React.Component { }); } componentDidMount(e) { - sessionStorage.setItem("white", 3); sessionStorage.setItem("plan_id", ""); let plan_id_copy = sessionStorage.getItem("plan_id_copy"); this.setState({ plan_id_detail: plan_id_copy }); @@ -159,9 +158,7 @@ export default class add extends React.Component { tranFormData(req) { // 需要转译的类型 let type = Number(req.keys[0].bind_object[0]); - this.setState({ - keyType: Number(type), - }); + sessionStorage.setItem("keyType", type); if (type === 2) { // 优惠券的转译-弹窗已做了优化 return req.keys; @@ -214,7 +211,9 @@ export default class add extends React.Component { // 获取落地页 getStep3Theme() { - this.refs.step3.getThemeData(); + if (this.state.card_visible) { + this.refs.step3.getThemeData(); + } } onConfirm(e) { @@ -520,11 +519,6 @@ export default class add extends React.Component { this.onStyleChange(e); }} keyStyle={this.state.keyStyle} - changeKeyType={(e) => { - sessionStorage.setItem("keyType", e); - this.setState({ keyType: e }); - }} - keyType={this.state.keyType} getStep3Theme={() => this.getStep3Theme()} curstep={this.state.curstep} isCopy={true} diff --git a/src/pages/plan/add/step2.js b/src/pages/plan/add/step2.js index 2213a700..b3f1f6f0 100644 --- a/src/pages/plan/add/step2.js +++ b/src/pages/plan/add/step2.js @@ -210,6 +210,9 @@ export default class acclist extends React.Component { width: "auto", }, ], + keyType: sessionStorage.getItem("keyType") + ? Number(sessionStorage.getItem("keyType")) + : 1, }; } @@ -230,7 +233,7 @@ export default class acclist extends React.Component { submit() { let valide = false; // 兑换码 - if (this.props.keyType === 1) { + if (this.state.keyType === 1) { if (this.refs.form1.validator()) { /* 处理数据 区分立减金和商品 开始 2022-05-30 13:40*/ const dataCopy = this.refs.tempdata.getSelectData(); @@ -257,7 +260,7 @@ export default class acclist extends React.Component { data.batch_name = this.state.model.batch_name; data.style = this.state.model.style; data.quantity = this.state.model.quantity; - data.bind_object = [this.props.keyType]; + data.bind_object = [this.state.keyType]; data.allow_repetition = this.state.model.allow_repetition; data.allow_loss = this.state.model.allow_loss; data.merge_stock = this.state.model.merge_stock; @@ -274,7 +277,7 @@ export default class acclist extends React.Component { data.batch_name = this.state.model.batch_name; data.style = this.state.model.style; data.quantity = this.state.model.quantity; - data.bind_object = [this.props.keyType]; + data.bind_object = [this.state.keyType]; data.allow_repetition = this.state.model.allow_repetition; data.allow_loss = this.state.model.allow_loss; data.merge_stock = this.state.model.merge_stock; @@ -292,9 +295,12 @@ export default class acclist extends React.Component { } onCheckChange = ({ target }) => { - this.props.changeKeyType(target.value); sessionStorage.setItem("keyType", target.value); - if (this.props.getStep3Theme && this.props.curstep === 3) { + this.setState({ + keyType: target.value, + }); + // 获取落地页 select + if (this.props.getStep3Theme) { this.props.getStep3Theme(); } }; @@ -308,17 +314,19 @@ export default class acclist extends React.Component { model2.style = e.target.value; model2.quantity = 0; this.setState({ model: model2 }); + if (e.target.value == 6) { sessionStorage.setItem("white", 1); - console.log("this.props.curstep =>", this.props.curstep); - if (this.props.getStep3Theme && this.props.curstep === 3) { - this.props.getStep3Theme(); - } this.setState({ white_visible: true }); } else { sessionStorage.setItem("white", 3); this.setState({ white_visible: false }); } + + // 获取落地页 select + if (this.props.getStep3Theme) { + this.props.getStep3Theme(); + } } onRepetitionChange(e) { @@ -555,7 +563,7 @@ export default class acclist extends React.Component { codeSubmit() { // 优惠券数据 - if (this.props.keyType === 2) { + if (this.state.keyType === 2) { let coupon_validator = this.refs.addEditCouponEl.submit(); if (coupon_validator) { let param = this.refs.addEditCouponEl.getModel(); @@ -654,7 +662,7 @@ export default class acclist extends React.Component { let text = e.target.value; text = text.replace(/[^\d]/g, ""); - if (this.props.keyType === 1) { + if (this.state.keyType === 1) { this.state.distdata[index].restrict = text; this.setState({ distdata: this.state.distdata }); } else { @@ -735,7 +743,10 @@ export default class acclist extends React.Component { this.setState({ mobile_excel: data.mobile_excel }); this.setState({ mobile_repeat: data.mobile_repeat }); if (model.style == 6) { + sessionStorage.setItem("white", 1); this.setState({ white_visible: true }); + } else { + sessionStorage.setItem("white", 3); } this.setState({ model: model }); @@ -765,7 +776,10 @@ export default class acclist extends React.Component { this.setState({ mobile_excel: data.mobile_excel }); this.setState({ mobile_repeat: data.mobile_repeat }); if (model.style == 6) { + sessionStorage.setItem("white", 1); this.setState({ white_visible: true }); + } else { + sessionStorage.setItem("white", 3); } this.setState({ model: model }); @@ -873,7 +887,7 @@ export default class acclist extends React.Component { rowItemClick(row, rowIndex) { // 兑换码 - if (this.props.keyType === 1) { + if (this.state.keyType === 1) { let codeInfo = { //数据模型不可少 code_name: row.title, @@ -1346,7 +1360,7 @@ export default class acclist extends React.Component { ) : null} { this.onCheckChange(e); }} @@ -1361,7 +1375,7 @@ export default class acclist extends React.Component { - {this.props.keyType === 1 ? ( + {this.state.keyType === 1 ? ( { this.checkIndex(0); @@ -1386,12 +1400,12 @@ export default class acclist extends React.Component { isShowPageBar={false} spliteColor={"#fff"} tableData={ - this.props.keyType === 1 + this.state.keyType === 1 ? this.state.distdata : this.state.couponData } Column={ - this.props.keyType === 1 + this.state.keyType === 1 ? this.state.Column : this.state.Column_coupon } @@ -1418,7 +1432,7 @@ export default class acclist extends React.Component { ); } // 优惠券范围 - if (com === "product" && this.props.keyType === 2) { + if (com === "product" && this.state.keyType === 2) { return coupon_range(rowData.product); } if (com == "edit") { @@ -1497,7 +1511,7 @@ export default class acclist extends React.Component { }} maskClosable={false} > - {this.props.keyType === 1 ? ( + {this.state.keyType === 1 ? ( - {this.props.keyType === 1 ? ( + {this.state.keyType === 1 ? ( <> ", white); + console.log("keyType =>", keyType); // 2 优惠券 if (keyType == 2) { - // 并且是 白名单 if (white == 1) { + // 并且是 白名单 params.page = 8; } else { params.page = 4; @@ -62,10 +62,10 @@ export default class acclist extends React.Component { } else { // 兑换码 if (white == 1) { - params.page = 3; - } else { // 并且是 白名单 params.page = 1; + } else { + params.page = 3; } } getThemeChoice(params).then((res) => {