Commit 7b375380 authored by GuanHua's avatar GuanHua

fix: 解决订单电子合同问题和商品详情购买数量小数时加减问题

parent 3587c772
......@@ -35,17 +35,50 @@ const InputNumber: React.FC<InputNumberPropsType> = (props) => {
const handleReduce = (e) => {
e.stopPropagation()
if (value > minCount) {
onChange(Number(value) - 1, 'click')
onChange(accSub(value, 1), 'click')
}
}
const handleAdd = (e) => {
e.stopPropagation()
if (value < maxCount) {
onChange(Number(value) + 1, 'click')
onChange(accAdd(value, 1), 'click')
}
}
const accAdd = (num1,num2) => {
let r1, r2
try{
r1 = num1.toString().split('.')[1].length;
}catch(e){
r1 = 0;
}
try{
r2 = num2.toString().split(".")[1].length;
}catch(e){
r2 = 0;
}
const m = Math.pow(10, Math.max(r1,r2));
return Math.round(num1 * m + num2 * m)/m;
}
const accSub = (num1, num2) => {
let r1, r2;
try{
r1 = num1.toString().split('.')[1].length;
}catch(e){
r1 = 0;
}
try{
r2 = num2.toString().split(".")[1].length;
}catch(e){
r2 = 0;
}
const m = Math.pow(10,Math.max(r1,r2));
const n = (r1 >= r2) ? r1 : r2;
return (Math.round(num1 * m-num2 * m) / m).toFixed(n);
}
const handleChange = (e) => {
const { value } = e.target;
const reg = /^\d*([.]?\d{0,3})$/
......
......@@ -24,11 +24,11 @@ const Address: React.FC<AddressPropsType> = (props) => {
}, [])
const fetchAddressList = (init = false) => {
let param = {
const param: any = {
current: 1,
pageSize: 50
}
//@ts-ignore
PublicApi.getLogisticsReceiverAddressPage(param).then(res => {
if (res.code === 1000) {
setAddressList(res.data?.data)
......@@ -41,14 +41,14 @@ const Address: React.FC<AddressPropsType> = (props) => {
const initDefaultAddress = async (addressList: GetLogisticsReceiverAddressPageResponseDetail[]) => {
let selectItem
for (let item of addressList) {
for (const item of addressList) {
if (item.isDefault === 1) {
selectItem = item
}
}
if (selectItem) {
setSelectKey(selectItem.id)
let res = await PublicApi.getLogisticsReceiverAddressGet({ id: selectItem.id })
const res = await PublicApi.getLogisticsReceiverAddressGet({ id: selectItem.id })
onChange(Object.assign(selectItem, res.data))
}
}
......@@ -56,13 +56,13 @@ const Address: React.FC<AddressPropsType> = (props) => {
const handleSelect = async (e: any) => {
setSelectKey(e.target.value)
let selectItem
for (let item of addressList) {
for (const item of addressList) {
if (item.id === e.target.value) {
selectItem = item
}
}
if (selectItem) {
let res = await PublicApi.getLogisticsReceiverAddressGet({ id: selectItem.id })
const res = await PublicApi.getLogisticsReceiverAddressGet({ id: selectItem.id })
onChange(Object.assign(selectItem, res.data))
}
}
......@@ -91,11 +91,11 @@ const Address: React.FC<AddressPropsType> = (props) => {
}
const handleSetDefaultAddress = async (addressItem: GetLogisticsReceiverAddressPageResponseDetail) => {
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
//@ts-ignore
let addressDetailRes = await PublicApi.getLogisticsReceiverAddressGet({ id: addressItem.id })
let param: GetLogisticsReceiverAddressGetResponse = addressDetailRes.data
const addressDetailRes = await PublicApi.getLogisticsReceiverAddressGet({ id: addressItem.id })
const param: GetLogisticsReceiverAddressGetResponse = addressDetailRes.data
param.isDefault = 1
//@ts-ignore
PublicApi.postLogisticsReceiverAddressUpdate(param).then(res => {
if (res.code === 1000) {
fetchAddressList()
......
......@@ -26,7 +26,7 @@ const Contract: React.FC<ContractPropsType> = (props) => {
<span>我同意签订:</span>
</Checkbox>
{
contractInfo && <a href={contractInfo?.contractUrl} download target="_blank" className={styles.checkbox_contract_text}>{contractInfo?.contractName}</a>
contractInfo && <a href={contractInfo?.contractUrl} download rel="noreferrer" target="_blank" className={styles.checkbox_contract_text}>{contractInfo?.contractName}</a>
}
</div>
</div>
......
......@@ -33,8 +33,10 @@ const PayWay: React.FC<PayWayProps> = (props) => {
}
useEffect(() => {
fetchCreditInfo()
}, [])
if(expand) {
fetchCreditInfo()
}
}, [expand])
useEffect(() => {
if (payWayList && payWayList.length === 1) {
......@@ -49,9 +51,10 @@ const PayWay: React.FC<PayWayProps> = (props) => {
}
PublicApi.getPayCreditGetCredit(param).then(res => {
message.destroy()
if(res.code === 1000) {
setCreditInfo(res.data)
} else {
message.destroy()
}
})
}
......
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