修复 商品列表数据 丢失问题以及优化代码

This commit is contained in:
wangsongsole 2022-08-17 18:04:52 +08:00
parent e8d9b6312e
commit ff02de0c98
2 changed files with 33 additions and 29 deletions

View File

@ -30,7 +30,6 @@ import {
uploadImg,
getReseller,
getAccessVerification,
keyApproval,
getProductInfoSelect
} from '../../../assets/api.js'
import Productform from '../product/add'
@ -152,12 +151,13 @@ export default class acclist extends React.Component {
this.setState({ pagetitle: '复制key' })
getReseller(req.reseller_id).then((res) => {
handelResponse(res, (req, msg) => {
this.setState({ reseller: req })
this.setState({
direct_reseller_id: req.direct_reseller_id
email_list: req.contact_email,
phone_list: req.contact_phone,
direct_reseller_id: req.direct_reseller_id,
reseller: req
})
this.setState({ phone_list: req.contact_phone })
this.setState({ email_list: req.contact_email })
this.getProductFunction(req.direct_reseller_id)
})
})
@ -259,13 +259,13 @@ export default class acclist extends React.Component {
getReseller(id).then((res) => {
handelResponse(res, (req, msg) => {
this.setState({ reseller: req })
this.setState({ phone_list: req.contact_phone })
this.setState({ email_list: req.contact_email })
this.setState({
direct_reseller_id: req.direct_reseller_id
reseller: req,
direct_reseller_id: req.direct_reseller_id,
email_list: req.contact_email,
phone_list: req.contact_phone
})
this.getProductFunction(req.direct_reseller_id)
})
})
@ -287,6 +287,16 @@ export default class acclist extends React.Component {
this.setState({ paytype: e.target.value })
}
/* 获取商品列表 */
getProductFunction(id) {
if (sessionStorage.getItem('productsList')) return
getProductInfoSelect({ reseller_id: id }).then((res) => {
if (res.code === 200) {
sessionStorage.setItem('productsList', JSON.stringify(res.data.data))
}
})
}
async submit() {
let valide = false
if (this.refs.form1.validator()) {
@ -421,16 +431,10 @@ export default class acclist extends React.Component {
} else {
this.setState({ product_title: '新增立减金', newGoldLoading: true })
}
let param = {
reseller_id: direct_reseller_ids
}
try {
getProductInfoSelect(param).then((res) => {
if (res.code === 200) {
sessionStorage.setItem('productsList', JSON.stringify(res.data.data))
this.setState({ productData: null })
this.setState({ drawerVisible2: true })
}
if (type === 'addProduct') {
this.setState({
newGoodsBtnLoading: false
@ -440,7 +444,6 @@ export default class acclist extends React.Component {
newGoldLoading: false
})
}
})
} catch (err) {
if (type === 'addProduct') {
this.setState({

View File

@ -132,6 +132,7 @@ export default class acclist extends React.Component {
direct_reseller_id: req.direct_reseller_id
})
if (sessionStorage.getItem('productsList')) return
/* 请求商品数据 */
getProductInfoSelect({
reseller_id: req.direct_reseller_id