|
|
@@ -2,29 +2,54 @@
|
|
|
* 支付组件
|
|
|
* @邠心vbe on 2021/04/23
|
|
|
*/
|
|
|
-import React, { useState } from 'react';
|
|
|
-import { useEffect } from 'react';
|
|
|
+import React, { useEffect, useState } from 'react';
|
|
|
import { View, Text, StyleSheet, Image } from 'react-native';
|
|
|
import Button from '../../components/Button';
|
|
|
-import TextRadius from '../../components/TextRadius';
|
|
|
import utils from '../../utils/utils';
|
|
|
import { LowCreditDialog } from '../charge/InfoDialog';
|
|
|
import { PageList } from '../Router';
|
|
|
|
|
|
+/**
|
|
|
+ * DEFAULT
|
|
|
+ * 控制是否启用2C2P
|
|
|
+ */
|
|
|
+export const PaymentDefault = {
|
|
|
+ DEFAULT: {
|
|
|
+ payType: "CreditWallet",
|
|
|
+ payName: "Credit Wallet",
|
|
|
+ isWallet: true,
|
|
|
+ isPayPerUse: false
|
|
|
+ },
|
|
|
+ DEFAULT2: {
|
|
|
+ payType: "PayPerUse",
|
|
|
+ payName: "Pay Per Use (SGQR)",
|
|
|
+ isWallet: false,
|
|
|
+ isPayPerUse: true
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+export const PAYTYPE = {
|
|
|
+ CREDIT_WALLET: "CreditWallet", // 钱包余额支付
|
|
|
+ PAY_PER_USE: "PayPerUse" // 按次支付
|
|
|
+}
|
|
|
+
|
|
|
const Payment = ({
|
|
|
topup, balance,
|
|
|
- payType="Pay Per Use (SGQR)", isWallet = false, isPayPerUse=true,
|
|
|
- //payType="Credit Wallet", isWallet = true,
|
|
|
- onMethodChange, refreshId = 0
|
|
|
+ payType = PaymentDefault.DEFAULT.payName,
|
|
|
+ isWallet = PaymentDefault.DEFAULT.isWallet,
|
|
|
+ isPayPerUse = PaymentDefault.DEFAULT.isPayPerUse,
|
|
|
+ canShowLowCreditDialog = false,
|
|
|
+ onMethodChange,
|
|
|
+ refreshId = 0
|
|
|
}) => {
|
|
|
const [visible, showDialog] = useState(false)
|
|
|
- /*useEffect(() => {
|
|
|
- if (balance == undefined) {
|
|
|
+ useEffect(() => {
|
|
|
+ if (balance == undefined && canShowLowCreditDialog) {
|
|
|
if (userInfo.credit <= 5 && refreshId > 0) {
|
|
|
showDialog(true)
|
|
|
}
|
|
|
}
|
|
|
- }, [refreshId])*/
|
|
|
+ }, [refreshId]);
|
|
|
return (
|
|
|
<View style={styles.paymentView}>
|
|
|
<Image
|
|
|
@@ -98,16 +123,19 @@ export const Balance = ({balance}) => {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
-export const PAYTYPE = {
|
|
|
- CREDIT_WALLET: "CreditWallet", // 钱包余额支付
|
|
|
- PAY_PER_USE: "PayPerUse" // 按次支付
|
|
|
-}
|
|
|
-
|
|
|
const getBalance = (balance) => {
|
|
|
console.log('getBalance', balance, userInfo);
|
|
|
return balance ? balance.toFixed(2) : '0.0'
|
|
|
}
|
|
|
|
|
|
+export const toTopupPage = () => {
|
|
|
+ if (PaymentDefault.DEFAULT.payType == PAYTYPE.CREDIT_WALLET) {
|
|
|
+ startPage(PageList.topup);
|
|
|
+ } else {
|
|
|
+ startPage(PageList.topupV2);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
const styles = StyleSheet.create({
|
|
|
paymentView: {
|
|
|
borderRadius: 8,
|