兑换码 商品列表反选

This commit is contained in:
wangsongsole 2022-06-17 15:44:08 +08:00
parent 37e415a9d9
commit 677191c586
2 changed files with 21 additions and 6 deletions

View File

@ -33,10 +33,23 @@ export default ({ data, onChangeMoney }) => {
newData.recharge_amount = (
Number(stateData.addNew) + Number(stateData.recharge_amount)
).toFixed(2)
sessionStorage.setItem(
'addMoneyData',
JSON.stringify(newData)
let origin = []
if (sessionStorage.getItem('addMoneyData')) {
origin = JSON.parse(sessionStorage.getItem('addMoneyData'))
}
let index = origin.findIndex(
(o) => o.channel_activity_id == newData.channel_activity_id
)
if (index !== -1) {
origin[index] = newData
} else {
origin.push(newData)
}
sessionStorage.setItem('addMoneyData', JSON.stringify(origin))
onChangeMoney(false, Number(stateData.addNew))
}, 1000)
},

View File

@ -315,9 +315,11 @@ export default class exchangedit extends React.Component {
if (sessionStorage.getItem('addMoneyData')) {
const addMoneyData = JSON.parse(sessionStorage.getItem('addMoneyData'))
const tempdata = _.cloneDeep(this.state.tempdata).map((item) => {
if (item.channel_activity_id === addMoneyData.channel_activity_id) {
item.origin.recharge_amount = addMoneyData.recharge_amount
}
addMoneyData.map((item1) => {
if (item.channel_activity_id === item1.channel_activity_id) {
item.origin.recharge_amount = item1.recharge_amount
}
})
return item
})
this.setState({ tempdata })