新增加款接口

This commit is contained in:
wangsongsole 2022-06-01 13:36:42 +08:00
commit 5a78d55033
2 changed files with 24 additions and 4 deletions

View File

@ -7,8 +7,8 @@ if (process.env.NODE_ENV == 'test' || process.env.NODE_ENV == 'development') {
// 测试环境
baseurl = 'http://192.168.6.75'
window.baseurl = 'http://192.168.6.75'
// baseurl = 'http://192.168.6.148:8056'
// window.baseurl = 'http://192.168.6.148:8056'
// baseurl = 'http://192.168.6.116:8056'
// window.baseurl = 'http://192.168.6.116:8056'
}
if (process.env.NODE_ENV == 'production') {
// 生成环境
@ -870,4 +870,9 @@ export const getVoucherWarningAccount = () => {
return req('get', baseurl + '/auth/admin/voucherWarningAccount')
}
// 加款
export const addFund = (data, id) => {
return req('post', baseurl + `/codes/voucher/fund/${id}`, data)
}
export { req }

View File

@ -5,7 +5,7 @@ import Form from '../../../components/form/main'
import FormItem from '../../../components/form-item/main'
import rules from './rules'
import { Button, Notify } from 'zent'
import { addFund, handelResponse } from '../../../assets/api'
export default ({ data, onChangeMoney }) => {
const [stateData, setStateData] = useState({ addNew: '' })
const ref = useRef()
@ -19,7 +19,22 @@ export default ({ data, onChangeMoney }) => {
Number(stateData?.recharge_amount) + Number(stateData.addNew) <
Number(stateData?.all_budget)
) {
onChangeMoney(false, Number(stateData.addNew))
addFund({ recharge_amount: stateData.addNew }, data.goods_id).then(
(res) => {
handelResponse(
res,
(req, msg) => {
Notify.error('加款成功')
setTimeout(() => {
onChangeMoney(false, Number(stateData.addNew))
}, 1000)
},
(err) => {
Notify.error(err)
}
)
}
)
} else {
Notify.error('加款失败')
}