From 659f5f225efd61e5221099445f7d5adbac26ffe4 Mon Sep 17 00:00:00 2001 From: wangsongsole Date: Mon, 20 Jun 2022 10:35:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=85=91=E6=8D=A2=E7=A0=81=E6=89=B9=E6=AC=A1=E7=9A=84=E7=94=9F?= =?UTF-8?q?=E6=95=88=E6=97=B6=E9=97=B4=EF=BC=8C=E5=A6=82=E6=9E=9C=E7=AB=8B?= =?UTF-8?q?=E5=87=8F=E9=87=91=E7=9A=84=E6=9C=89=E6=95=88=E6=9C=9F=E5=A4=A7?= =?UTF-8?q?=E4=BA=8E=E4=BA=86=E4=BF=AE=E6=94=B9=E5=90=8E=E7=9A=84=E6=97=B6?= =?UTF-8?q?=E9=97=B4=EF=BC=8C=E7=AB=8B=E5=87=8F=E9=87=91=E7=9A=84=E7=94=9F?= =?UTF-8?q?=E6=95=88=E6=97=B6=E9=97=B4=E4=B9=9F=E8=A6=81=E8=B7=9F=E7=9D=80?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/exchangecode/edit/edit.js | 32 ++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/pages/exchangecode/edit/edit.js b/src/pages/exchangecode/edit/edit.js index 7e4ac19e..2c15eb55 100644 --- a/src/pages/exchangecode/edit/edit.js +++ b/src/pages/exchangecode/edit/edit.js @@ -534,7 +534,16 @@ export default class exchangedit extends React.Component { const addProductCopy = { legal: [], reduce: [] } addProduct.map((item) => { if (item.type === 2) { - if (item.origin) addProductCopy.reduce.push(item.origin) + if (item.origin) { + const is = this.compareDate( + this.state.codeInfo.date_time[1], + item.origin.time_limit.effect_time.end_time + ) + if (!is) + item.origin.time_limit.effect_time.end_time = + this.state.codeInfo.date_time[1] + addProductCopy.reduce.push(item.origin) + } } else { addProductCopy.legal.push(item) } @@ -544,6 +553,13 @@ export default class exchangedit extends React.Component { const updateProductCopy = { legal: [], reduce: [] } updateProduct.map((item) => { if (item.type === 2) { + const is = this.compareDate( + this.state.codeInfo.date_time[1], + item.time_limit.effect_time.end_time + ) + if (!is) + item.time_limit.effect_time.end_time = + this.state.codeInfo.date_time[1] updateProductCopy.reduce.push(item) } else { updateProductCopy.legal.push(item) @@ -569,6 +585,12 @@ export default class exchangedit extends React.Component { return { data, addProduct, updateProduct } } + + //比较时间 + compareDate(d1, d2) { + return new Date(d1.replace(/-/g, '/')) > new Date(d2.replace(/-/g, '/')) + } + submitCodeData() { if (!this.state.reseller) { Notify.error('该兑换码对应分销商不存在') @@ -747,6 +769,14 @@ export default class exchangedit extends React.Component { let model2 = this.state.codeInfo model2.date_time = e this.setState({ codeInfo: model2 }) + + sessionStorage.setItem( + 'knockGold_effectDate', + JSON.stringify({ + begin_time: model2.date_time[0], + end_time: model2.date_time[1] + }) + ) } //渲染范围列表数据以及数据转换