From d46288b5916ff7ff9e0a1a862496648cfa88b89f Mon Sep 17 00:00:00 2001 From: Gucheng Wang Date: Mon, 12 Dec 2022 00:42:45 +0800 Subject: [PATCH] Add renderQrCodeModal() --- web/src/ProductBuyPage.js | 49 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/web/src/ProductBuyPage.js b/web/src/ProductBuyPage.js index 58cfe161..3a453c01 100644 --- a/web/src/ProductBuyPage.js +++ b/web/src/ProductBuyPage.js @@ -13,7 +13,8 @@ // limitations under the License. import React from "react"; -import {Button, Descriptions, Spin} from "antd"; +import {Button, Descriptions, Modal, Spin} from "antd"; +import {CheckCircleTwoTone} from "@ant-design/icons"; import i18next from "i18next"; import * as ProductBackend from "./backend/ProductBackend"; import * as Setting from "./Setting"; @@ -26,6 +27,7 @@ class ProductBuyPage extends React.Component { productName: props.match?.params.productName, product: null, isPlacingOrder: false, + qrCodeModalProvider: null, }; } @@ -75,6 +77,13 @@ class ProductBuyPage extends React.Component { } buyProduct(product, provider) { + if (provider.clientId.startsWith("http")) { + this.setState({ + qrCodeModalProvider: provider, + }); + return; + } + this.setState({ isPlacingOrder: true, }); @@ -97,6 +106,41 @@ class ProductBuyPage extends React.Component { }); } + renderQrCodeModal() { + return ( + + + {" " + i18next.t("product:Please scan the QR code to pay")} + + } + open={this.state.qrCodeModalProvider !== null} + onOk={() => { + Setting.goToLink(this.state.product.returnUrl); + }} + onCancel={() => { + this.setState({ + qrCodeModalProvider: null, + }); + }} + okText={i18next.t("product:I have completed the payment")} + cancelText={i18next.t("general:Cancel")}> +

+ { + i18next.t("product:Please provide your username in the remark") + } + :   + { + Setting.getTag("default", this.props.account.name) + } +
+
+ {this.state.qrCodeModalProvider?.name} +

+
+ ); + } + getPayButton(provider) { let text = provider.type; if (provider.type === "Alipay") { @@ -185,6 +229,9 @@ class ProductBuyPage extends React.Component { + { + this.renderQrCodeModal() + } ); }