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] + }) + ) } //渲染范围列表数据以及数据转换