vbea 3 лет назад
Родитель
Сommit
c90624918d

+ 6 - 1
Strides-APP/app/pages/wallet/Payment.js

@@ -11,7 +11,12 @@ import utils from '../../utils/utils';
 import { LowCreditDialog } from '../charge/InfoDialog';
 import { PageList } from '../Router';
 
-const Payment = ({topup, balance, payType="Credit Wallet", onMethodChange, isWallet = true, refreshId = 0}) => {
+const Payment = ({
+    topup, balance,
+    payType="Pay Per Use (SGQR)", isWallet = false,
+    //payType="Credit Wallet", isWallet = true,
+    onMethodChange, refreshId = 0
+  }) => {
   const [visible, showDialog] = useState(false)
   /*useEffect(() => {
     if (balance == undefined) {

+ 0 - 253
Strides-APP/app/pages/wallet/TopUpV2.js

@@ -1,253 +0,0 @@
-/**
- * 2C2P钱包充值页面
- * @邠心vbe on 2022/12/27
- */
- import React, { Component } from 'react';
- import { View, Text, ScrollView, StyleSheet, Switch } from 'react-native';
- import apiWallet from '../../api/apiWallet';
- import Button from '../../components/Button';
- import Dialog from '../../components/Dialog';
- import { PageList } from '../Router';
- import { Balance } from './Payment';
- 
- export default class TopupV2 extends Component {
-   constructor(props) {
-     super(props);
-     this.state = {
-       isAuto: false,
-       topupList: [],
-       selectIndex: 0,
-       payType: {},
-       balance: 0,
-     };
-   }
- 
-   componentDidMount() {
-     this.props.navigation.addListener('focus', () => {
-       getUserInfo(info => {
-         this.setState({
-           balance: info.credit
-         })
-       })
-     });
-     this.getTopupList();
-   }
- 
-   getTopupList() {
-     Dialog.showProgressDialog();
-     apiWallet.getTopUpAmountList().then(res => {
-       Dialog.dismissLoading();
-       if (res.data.length > 0) {
-         this.setState({
-           topupList: res.data
-         });
-       }
-     }).catch(err => {
-       Dialog.dismissLoading();
-     })
-   }
- 
-   topup2() {
-     const params = {
-       payAmount: this.state.topupList[this.state.selectIndex]?.key,
-     }
-     apiWallet.doPaymentV2(params).then(res => {
-       Dialog.dismissLoading();
-       if (res.data.webPaymentUrl) {
-         startPage(PageList.paymentWeb, { amount: params.payAmount, url: res.data.webPaymentUrl, type: 'Topup' });
-       } else {
-         toastShort('Error 0')
-       }
-     }).catch(err => {
-       Dialog.dismissLoading();
-       toastShort(err);
-     });
-   }
- 
-   topup() {
-     const params = {
-       payAmount: this.state.topupList[this.state.selectIndex]?.key,
-       fomoPayType: this.state.payType.fomoPayType
-     }
-     console.log('params',params);
-     if (params.payAmount) {
-       if (params.fomoPayType == 'PAYNOW') {
-         //PAYNOW支付
-         Dialog.showProgressDialog();
-         apiWallet.doPayment(params).then(res => {
-           Dialog.dismissLoading();
-           if (res.data.fomoId && res.data.qrCodeInBase64) {
-             startPage(PageList.paynow, { amount: params.payAmount, base64: res.data.qrCodeInBase64 });
-           } else {
-             toastShort('Error 0')
-           }
-         }).catch(err => {
-           Dialog.dismissLoading();
-           toastShort(err);
-         });
-       } else {
-         //信用卡支付
-         startPage(PageList.formCard, { amount: params.payAmount, payType: params.fomoPayType });
-       }
-     } else {
-       toastShort('Error 1')
-     }
-   }
- 
-   render() {
-     return (
-       <ScrollView style={styles.container}>
-         <View style={styles.headerView}>
-           <Balance balance={this.state.balance}/>
-         </View>
-         <View style={styles.contentView}>
-           <View style={styles.topupView}>
-             <WalletTitle>Top Up</WalletTitle>
-             <Text style={styles.subTitle}>Choose Top Up Value: </Text>
-             <View style={styles.topupItems}>
-               { this.state.topupList.map((item, index) => {
-                   return (
-                     <Text
-                       key={index}
-                       style={[
-                         styles.topupItem,
-                         index > 0 && styles.right,
-                         index == this.state.selectIndex && styles.selected]}
-                       onPress={() => {
-                         this.setState({
-                           selectIndex: index
-                         })
-                       }}
-                     >{currency}{item.key}</Text>
-                   );
-                 })
-               }
-             </View>
-           </View>
-           {/* <View style={styles.topupView}>
-             <WalletTitle>Payment</WalletTitle>
-             <Text style={styles.subTitle}>Pay with: </Text>
-             <PaythodList
-               onChange={type => {
-                 this.setState({
-                   payType: type
-                 });
-               }}/>
-           </View> */}
-           {/* <View style={ui.flexc}>
-             <Text
-               style={styles.autoView}
-               onPress={() => {
-                 this.setState({
-                   isAuto: !this.state.isAuto
-                 });
-               }}>Automatically top up S$20 when wallet balance is below S$5</Text>
-             <Switch
-               value={this.state.isAuto}
-               trackColor={isIOS ? { false: "#B2B2B2", true: colorAccent } : null}
-               onValueChange={v => {
-                 this.setState({
-                   isAuto: v
-                 });
-               }}/>
-           </View> */}
-         </View>
-         <View style={styles.buttonView}>
-           <Button
-             text='Top Up'
-             elevation={1.5}
-             onClick={() => {
-               //startPage(PageList.paycard)
-               this.topup2();
-             }}/>
-         </View>
-       </ScrollView>
-     );
-   }
- }
- 
- export const WalletTitle = ({children}) => {
-   return (
-     <View style={styles.topupTitle}>
-       <Text style={styles.titleLeft}></Text>
-       <Text style={styles.titleText}>{children}</Text>
-     </View>
-   );
- }
- 
- const styles = StyleSheet.create({
-   container: {
-     flex: 1,
-     backgroundColor: '#F5F5F5'
-   },
-   headerView: {
-     paddingBottom: 76,
-     backgroundColor: colorAccent
-   },
-   contentView: {
-     padding: 16,
-     marginTop: -88
-   },
-   topupView: {
-     padding: 16,
-     borderRadius: 10,
-     marginBottom: 16,
-     backgroundColor: 'white'
-   },
-   topupTitle: {
-     alignItems: 'center',
-     flexDirection: 'row'
-   },
-   titleLeft: {
-     width: 4,
-     height: 15,
-     borderRadius: 16,
-     backgroundColor: colorAccent
-   },
-   titleText: {
-     color: '#333',
-     fontSize: 16,
-     paddingLeft: 10
-   },
-   subTitle: {
-     color: '#333',
-     fontSize: 14,
-     marginTop: 16,
-     marginBottom: 16
-   },
-   topupItems: {
-     paddingBottom: 16,
-     alignItems: 'center',
-     flexDirection: 'row'
-   },
-   topupItem: {
-     flex: 1,
-     height: 60,
-     lineHeight: 60,
-     color: '#666',
-     fontSize: 24,
-     borderWidth: 1,
-     borderRadius: 4,
-     borderColor: '#999',
-     textAlign: 'center'
-   },
-   right: {
-     marginLeft: 20
-   },
-   selected: {
-     color: '#333',
-     borderColor: '#333',
-     backgroundColor: colorAccent
-   },
-   autoView: {
-     flex: 1,
-     color: '#333',
-     fontSize: 14,
-     paddingRight: 32
-   },
-   buttonView: {
-     padding: 16,
-     marginTop: 0,
-     marginBottom: 16
-   }
- })

+ 253 - 0
Strides-APP/app/pages/wallet/TopupV2.js

@@ -0,0 +1,253 @@
+/**
+ * 2C2P钱包充值页面
+ * @邠心vbe on 2022/12/27
+ */
+import React, { Component } from 'react';
+import { View, Text, ScrollView, StyleSheet, Switch } from 'react-native';
+import apiWallet from '../../api/apiWallet';
+import Button from '../../components/Button';
+import Dialog from '../../components/Dialog';
+import { PageList } from '../Router';
+import { Balance } from './Payment';
+
+export default class TopupV2 extends Component {
+  constructor(props) {
+    super(props);
+    this.state = {
+      isAuto: false,
+      topupList: [],
+      selectIndex: 0,
+      payType: {},
+      balance: 0,
+    };
+  }
+
+  componentDidMount() {
+    this.props.navigation.addListener('focus', () => {
+      getUserInfo(info => {
+        this.setState({
+          balance: info.credit
+        })
+      })
+    });
+    this.getTopupList();
+  }
+
+  getTopupList() {
+    Dialog.showProgressDialog();
+    apiWallet.getTopUpAmountList().then(res => {
+      Dialog.dismissLoading();
+      if (res.data.length > 0) {
+        this.setState({
+          topupList: res.data
+        });
+      }
+    }).catch(err => {
+      Dialog.dismissLoading();
+    })
+  }
+
+  topup2() {
+    const params = {
+      payAmount: this.state.topupList[this.state.selectIndex]?.key,
+    }
+    apiWallet.doPaymentV2(params).then(res => {
+      Dialog.dismissLoading();
+      if (res.data.webPaymentUrl) {
+        startPage(PageList.paymentWeb, { amount: params.payAmount, url: res.data.webPaymentUrl, type: 'Topup' });
+      } else {
+        toastShort('Error 0')
+      }
+    }).catch(err => {
+      Dialog.dismissLoading();
+      toastShort(err);
+    });
+  }
+
+  topup() {
+    const params = {
+      payAmount: this.state.topupList[this.state.selectIndex]?.key,
+      fomoPayType: this.state.payType.fomoPayType
+    }
+    console.log('params',params);
+    if (params.payAmount) {
+      if (params.fomoPayType == 'PAYNOW') {
+        //PAYNOW支付
+        Dialog.showProgressDialog();
+        apiWallet.doPayment(params).then(res => {
+          Dialog.dismissLoading();
+          if (res.data.fomoId && res.data.qrCodeInBase64) {
+            startPage(PageList.paynow, { amount: params.payAmount, base64: res.data.qrCodeInBase64 });
+          } else {
+            toastShort('Error 0')
+          }
+        }).catch(err => {
+          Dialog.dismissLoading();
+          toastShort(err);
+        });
+      } else {
+        //信用卡支付
+        startPage(PageList.formCard, { amount: params.payAmount, payType: params.fomoPayType });
+      }
+    } else {
+      toastShort('Error 1')
+    }
+  }
+
+  render() {
+    return (
+      <ScrollView style={styles.container}>
+        <View style={styles.headerView}>
+          <Balance balance={this.state.balance}/>
+        </View>
+        <View style={styles.contentView}>
+          <View style={styles.topupView}>
+            <WalletTitle>Top Up</WalletTitle>
+            <Text style={styles.subTitle}>Choose Top Up Value: </Text>
+            <View style={styles.topupItems}>
+              { this.state.topupList.map((item, index) => {
+                  return (
+                    <Text
+                      key={index}
+                      style={[
+                        styles.topupItem,
+                        index > 0 && styles.right,
+                        index == this.state.selectIndex && styles.selected]}
+                      onPress={() => {
+                        this.setState({
+                          selectIndex: index
+                        })
+                      }}
+                    >{currency}{item.key}</Text>
+                  );
+                })
+              }
+            </View>
+          </View>
+          {/* <View style={styles.topupView}>
+            <WalletTitle>Payment</WalletTitle>
+            <Text style={styles.subTitle}>Pay with: </Text>
+            <PaythodList
+              onChange={type => {
+                this.setState({
+                  payType: type
+                });
+              }}/>
+          </View> */}
+          {/* <View style={ui.flexc}>
+            <Text
+              style={styles.autoView}
+              onPress={() => {
+                this.setState({
+                  isAuto: !this.state.isAuto
+                });
+              }}>Automatically top up S$20 when wallet balance is below S$5</Text>
+            <Switch
+              value={this.state.isAuto}
+              trackColor={isIOS ? { false: "#B2B2B2", true: colorAccent } : null}
+              onValueChange={v => {
+                this.setState({
+                  isAuto: v
+                });
+              }}/>
+          </View> */}
+        </View>
+        <View style={styles.buttonView}>
+          <Button
+            text='Top Up'
+            elevation={1.5}
+            onClick={() => {
+              //startPage(PageList.paycard)
+              this.topup2();
+            }}/>
+        </View>
+      </ScrollView>
+    );
+  }
+}
+
+export const WalletTitle = ({children}) => {
+  return (
+    <View style={styles.topupTitle}>
+      <Text style={styles.titleLeft}></Text>
+      <Text style={styles.titleText}>{children}</Text>
+    </View>
+  );
+}
+
+const styles = StyleSheet.create({
+  container: {
+    flex: 1,
+    backgroundColor: '#F5F5F5'
+  },
+  headerView: {
+    paddingBottom: 76,
+    //backgroundColor: colorAccent
+  },
+  contentView: {
+    padding: 16,
+    marginTop: -88
+  },
+  topupView: {
+    padding: 16,
+    borderRadius: 10,
+    marginBottom: 16,
+    backgroundColor: 'white'
+  },
+  topupTitle: {
+    alignItems: 'center',
+    flexDirection: 'row'
+  },
+  titleLeft: {
+    width: 4,
+    height: 15,
+    borderRadius: 16,
+    backgroundColor: colorPrimary
+  },
+  titleText: {
+    color: '#333',
+    fontSize: 16,
+    paddingLeft: 10
+  },
+  subTitle: {
+    color: '#333',
+    fontSize: 14,
+    marginTop: 16,
+    marginBottom: 16
+  },
+  topupItems: {
+    paddingBottom: 16,
+    alignItems: 'center',
+    flexDirection: 'row'
+  },
+  topupItem: {
+    flex: 1,
+    height: 60,
+    lineHeight: 60,
+    color: '#666',
+    fontSize: 24,
+    borderWidth: 1,
+    borderRadius: 4,
+    borderColor: '#999',
+    textAlign: 'center'
+  },
+  right: {
+    marginLeft: 20
+  },
+  selected: {
+    color: '#fff',
+    borderColor: '#333',
+    backgroundColor: colorPrimary
+  },
+  autoView: {
+    flex: 1,
+    color: '#333',
+    fontSize: 14,
+    paddingRight: 32
+  },
+  buttonView: {
+    padding: 16,
+    marginTop: 0,
+    marginBottom: 16
+  }
+})