diff --git a/src/pages/Payment/FPS/FPS.js b/src/pages/Payment/FPS/FPS.js index 5caa946..999e32f 100644 --- a/src/pages/Payment/FPS/FPS.js +++ b/src/pages/Payment/FPS/FPS.js @@ -104,6 +104,11 @@ const Index = () => { // setFpsmerchanttimeoutdatetime(convertedDateString) // setPaymentid("C202310268000681") // setPaymentstatuscode("APPR") + localStorage.removeItem("transactionid") + localStorage.removeItem("webtoken") + localStorage.setItem("transactionid", paymentData.transactionid) + localStorage.setItem("webtoken", paymentData.webtoken) + HttpUtils.post({ url: paymentPath+loadPaymentUrl, params:{ diff --git a/src/pages/Payment/index.js b/src/pages/Payment/index.js index 3eee980..40cb8be 100644 --- a/src/pages/Payment/index.js +++ b/src/pages/Payment/index.js @@ -2,13 +2,14 @@ import * as React from "react"; import * as HttpUtils from "utils/HttpUtils"; import * as UrlUtils from "utils/ApiPathConst"; import Loadable from 'components/Loadable'; -const MultiPaymentWindow = Loadable(React.lazy(() => import('./MultiPaymentWindow'))); +// const MultiPaymentWindow = Loadable(React.lazy(() => import('./MultiPaymentWindow'))); const DataGrid = Loadable(React.lazy(() => import('./Details_Public/DataGrid'))); // const FPS = Loadable(React.lazy(() => import('./FPS'))); import { useEffect, useState } from "react"; import { useNavigate, useLocation } from "react-router-dom"; import { paymentPath } from "auth/utils"; import * as FormatUtils from "utils/FormatUtils"; +const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent'))); import { Button, @@ -42,7 +43,7 @@ const Index = () => { //statusWindow - const [open, setOpen] = useState(false); + // const [open, setOpen] = useState(false); const [availableMethods, setAvailableMethods] = useState([]); const [transactionData, setTransactionData] = useState({}); const [fpsStatus, setFPSStatus] = useState({}); @@ -53,6 +54,7 @@ const Index = () => { const [confirmPayment, setConfirmPayment] = useState(false); const [itemList, setItemList] = useState([]); + const [onReady, setOnReady] = useState(false); useEffect(() => { setAppIds(location.state?.appIdList ?? []) @@ -67,26 +69,26 @@ const Index = () => { getAppList(); },[appIds]); - const handleClose = () => { - // handleReset() - setOpen(false); - getTransactionId() - getAvailablePayment() - }; + // const handleClose = () => { + // // handleReset() + // setOpen(false); + // getTransactionId() + // getAvailablePayment() + // }; - const paymentClick = () => { - setTotalAmount(totalAmount); - setSelectedPaymentMethod("") - setConfirmPayment(false) - if (totalAmount > 0) { - getTransactionId() - setOpen(true) - } - }; + // const paymentClick = () => { + // setTotalAmount(totalAmount); + // setSelectedPaymentMethod("") + // setConfirmPayment(false) + // if (totalAmount > 0) { + // getTransactionId() + // // setOpen(true) + // } + // }; useEffect(() => { if (confirmPayment) { - setOpen(false); + // setOpen(false); // let transactionid = ""; // let webtoken = ""; @@ -336,6 +338,12 @@ const Index = () => { }); } + useEffect(() => { + if(availableMethods.length > 0 && Object.keys(transactionData).length > 0){ + setOnReady(true) + } + }, [transactionData,availableMethods]); + const getAppList = () => { HttpUtils.post({ url: UrlUtils.PAYMENT_APP_LIST, @@ -347,7 +355,14 @@ const Index = () => { } }); } + + const selectedPaymentMethodHandle = (method) => () =>{ + setSelectedPaymentMethod(method); + }; + const confirmPaymentHandle = () => () =>{ + setConfirmPayment(true); + }; return ( @@ -382,18 +397,100 @@ const Index = () => { 支付金額: HK$ {FormatUtils.currencyFormat(totalAmount)} - + >選擇付款方式 */} + + + + + + 付款金額: + + + + + {"HK$ "+FormatUtils.currencyFormat(totalAmount)} + + + + {availableMethodData.length > 0? + !onReady ? + : + + + + + 付款方式: + + + + + + + + + + + + + + + + + + + + + + {selectedPaymentMethod !=""? + + + + + 已選擇付款方式: + + + + + {selectedPaymentMethod} + + + + + : null} + + : + + + 付款功能現在不可用。 + + + } + - { setSelectedPaymentMethod={setSelectedPaymentMethod} selectedPaymentMethod={selectedPaymentMethod} setConfirmPayment={setConfirmPayment} - /> + /> */}