Commit 659c3740 authored by GuanHua's avatar GuanHua

feat:积分支付获取当前用户积分接口对接

parent 5b0367f8
...@@ -4,8 +4,8 @@ import PasswordInput from '../passwordInput' ...@@ -4,8 +4,8 @@ import PasswordInput from '../passwordInput'
import { LAYOUT_TYPE } from '@/constants' import { LAYOUT_TYPE } from '@/constants'
import { history } from 'umi' import { history } from 'umi'
import { GetOrderOrderPayDetailsResponse } from '@/services/OrderApi' import { GetOrderOrderPayDetailsResponse } from '@/services/OrderApi'
import { GetMemberSecurityGetResponse } from '@/services/MemberApi' import { GetMemberSecurityGetResponse, GetMemberBusinessLrcRightPointGetResponse } from '@/services/MemberApi'
import { Button, message } from 'antd' import { Button, message, Spin } from 'antd'
import { numFormat } from '@/utils/numberFomat' import { numFormat } from '@/utils/numberFomat'
import { PublicApi } from '@/services/api' import { PublicApi } from '@/services/api'
import { linkToUrl } from '../../utils' import { linkToUrl } from '../../utils'
...@@ -21,27 +21,49 @@ interface PointPayWayPropsType { ...@@ -21,27 +21,49 @@ interface PointPayWayPropsType {
} }
const PointPayWay: React.FC<PointPayWayPropsType> = (props) => { const PointPayWay: React.FC<PointPayWayPropsType> = (props) => {
const { payInfo, orderId, orderInfo, layoutType, shopUrlParam } = props const { payInfo, orderId, orderInfo, layoutType, onChange, shopUrlParam } = props
const [securityInfo, setSecurityInfo] = useState<GetMemberSecurityGetResponse>() const [securityInfo, setSecurityInfo] = useState<GetMemberSecurityGetResponse>()
const [payPassword, setPayPassword] = useState<string>('') const [payPassword, setPayPassword] = useState<string>('')
const [type, setType] = useState<string>('normal') // normal: 普通;member:会员 const [pointInfo, setPointInfo] = useState<GetMemberBusinessLrcRightPointGetResponse>()
const [confirmLoading, setConfirmLoading] = useState<boolean>(false) const [confirmLoading, setConfirmLoading] = useState<boolean>(false)
const [payDisabled, setPayDisabled] = useState<boolean>(false) const [payDisabled, setPayDisabled] = useState<boolean>(false)
const [pageLoading, setPageLoading] = useState<boolean>(true)
const [relType, setRelType] = useState<number>(0) // 0: 平台;1:会员
const handlePasswordChange = (value: string) => { const handlePasswordChange = (value: string) => {
setPayPassword(value) setPayPassword(value)
} }
const handleChangeType = (type: string) => { const handleChangeType = (type: number) => {
setType(type) setRelType(type)
} }
useEffect(() => { useEffect(() => {
if (orderInfo) { if (orderInfo) {
fetchPointInfo()
fetchSecurity() fetchSecurity()
} }
}, [orderInfo]) }, [orderInfo])
const fetchPointInfo = () => {
let param = {
memberId: orderInfo.supplyMembersId,
roleId: orderInfo.supplyMembersRoleId
}
//@ts-ignore
PublicApi.getMemberBusinessLrcRightPointGet(param).then(res => {
if (res.code === 1000) {
setPointInfo(res.data)
setPageLoading(false)
} else {
setPageLoading(false)
onChange(true, res.message)
}
}).catch(() => {
})
}
const fetchSecurity = () => { const fetchSecurity = () => {
PublicApi.getMemberSecurityGet().then(res => { PublicApi.getMemberSecurityGet().then(res => {
...@@ -52,6 +74,10 @@ const PointPayWay: React.FC<PointPayWayPropsType> = (props) => { ...@@ -52,6 +74,10 @@ const PointPayWay: React.FC<PointPayWayPropsType> = (props) => {
} }
const pay = () => { const pay = () => {
if (!checkPoint()) {
message.error("积分不足")
return
}
if (!payPassword || payPassword.length < 6) { if (!payPassword || payPassword.length < 6) {
message.error("请输入支付密码") message.error("请输入支付密码")
return return
...@@ -80,8 +106,24 @@ const PointPayWay: React.FC<PointPayWayPropsType> = (props) => { ...@@ -80,8 +106,24 @@ const PointPayWay: React.FC<PointPayWayPropsType> = (props) => {
} }
const checkPoint = () => {
if(relType === 0) {
if (Number(pointInfo?.platformScore) >= Number(payInfo?.payPrice)) {
return true
} else {
return false
}
} else {
if (Number(pointInfo?.memberScore) >= Number(payInfo?.payPrice)) {
return true
} else {
return false
}
}
}
return ( return (
<> <Spin spinning={pageLoading}>
<div className={styles.common_title}> <div className={styles.common_title}>
<span>积分支付</span> <span>积分支付</span>
<div className={styles.common_title_amount}> <div className={styles.common_title_amount}>
...@@ -92,21 +134,21 @@ const PointPayWay: React.FC<PointPayWayPropsType> = (props) => { ...@@ -92,21 +134,21 @@ const PointPayWay: React.FC<PointPayWayPropsType> = (props) => {
</div> </div>
<div className={styles.pay_point}> <div className={styles.pay_point}>
<div className={styles.pay_point_way_list}> <div className={styles.pay_point_way_list}>
<div className={cx(styles.pay_point_way_list_item, type === 'normal' ? styles.active : '')} onClick={() => handleChangeType('normal')}> <div className={cx(styles.pay_point_way_list_item, relType === 0 ? styles.active : '')} onClick={() => handleChangeType(0)}>
<div className={styles.pay_point_way_list_item_title}>平台通用积分</div> <div className={styles.pay_point_way_list_item_title}>平台通用积分</div>
<div className={styles.pay_point_way_list_item_content}> <div className={styles.pay_point_way_list_item_content}>
<div className={styles.pay_point_way_list_item_point}> <div className={styles.pay_point_way_list_item_point}>
<label>30,000</label> <label>{numFormat(pointInfo?.platformScore)}</label>
<span></span> <span></span>
</div> </div>
<p>可用积分</p> <p>可用积分</p>
</div> </div>
</div> </div>
<div className={cx(styles.pay_point_way_list_item, type === 'member' ? styles.active : '')} onClick={() => handleChangeType('member')}> <div className={cx(styles.pay_point_way_list_item, relType === 1 ? styles.active : '')} onClick={() => handleChangeType(1)}>
<div className={cx(styles.pay_point_way_list_item_title, styles.member)}>会员专有积分</div> <div className={cx(styles.pay_point_way_list_item_title, styles.member)}>会员专有积分</div>
<div className={styles.pay_point_way_list_item_content}> <div className={styles.pay_point_way_list_item_content}>
<div className={styles.pay_point_way_list_item_point}> <div className={styles.pay_point_way_list_item_point}>
<label>40,000</label> <label>{numFormat(pointInfo?.memberScore)}</label>
<span></span> <span></span>
</div> </div>
<p>可用积分</p> <p>可用积分</p>
...@@ -128,7 +170,7 @@ const PointPayWay: React.FC<PointPayWayPropsType> = (props) => { ...@@ -128,7 +170,7 @@ const PointPayWay: React.FC<PointPayWayPropsType> = (props) => {
</div> </div>
) )
} }
</> </Spin>
) )
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment