Explorar o código

add 2C2P switch

vbea %!s(int64=3) %!d(string=hai) anos
pai
achega
d8d6e04514

+ 2 - 2
Strides-APP/android/app/version.properties

@@ -1,2 +1,2 @@
-#Wed Jan 11 14:18:08 CST 2023
-VERSION_CODE=69
+#Fri Jan 13 10:58:43 CST 2023
+VERSION_CODE=71

+ 1 - 1
Strides-APP/app.json

@@ -4,5 +4,5 @@
   "versionCode": 80,
   "versionName": "V0.4.0 Beta",
   "product": false,
-  "debug": false
+  "debug": true
 }

+ 6 - 2
Strides-APP/app/pages/Router.js

@@ -23,8 +23,8 @@ import Rating from './charge/Rating';
 import Wallet from './wallet/Wallet';
 import EditProfile from './my/EditProfile';
 import Referral from './my/Referral';
-//import Topup from './wallet/Topup'; //not 2C2P
-import Topup from './wallet/TopupV2'; //2C2P payment
+import Topup from './wallet/Topup'; //not 2C2P
+import TopupV2 from './wallet/TopupV2'; //2C2P payment
 import AddCard from './wallet/AddCard';
 import FormCard from './payment/FormCard';
 import AddVehicle from './my/AddVehicle';
@@ -119,6 +119,10 @@ export var PageList = {
     title: 'Top Up',
     component: Topup
   },
+  'topupV2': {
+    title: 'Top Up',
+    component: TopupV2
+  },
   'addCard': {
     title: 'Add Cards',
     component: AddCard

+ 3 - 3
Strides-APP/app/pages/charge/Charge.js

@@ -9,7 +9,7 @@ import Button from '../../components/Button';
 import Dialog from '../../components/Dialog';
 import { PageList } from '../Router';
 import { BatteryView, ChargeStyle, circleSize, EnterStationDialog, TypeImage } from './Charging';
-import Payment, { PAYTYPE } from '../wallet/Payment';
+import Payment, { PaymentDefault, PAYTYPE } from '../wallet/Payment';
 import { QRResult } from './QRScan';
 import { ErrorDialog } from './InfoDialog';
 import utils from '../../utils/utils';
@@ -39,8 +39,8 @@ export default class Charge extends Component {
       curerntPerUser: undefined,
       //currentPayment: PAYTYPE.CREDIT_WALLET,
       //currentPaytype: "Credit Wallet",
-      currentPayment: PAYTYPE.PAY_PER_USE,
-      currentPaytype: "Pay Per Use (SGQR)"
+      currentPayment: PaymentDefault.DEFAULT.payType,
+      currentPaytype: PaymentDefault.DEFAULT.payName
     };
     this.changeMethod = false;
     this.canAutoRefresh = false;

+ 2 - 3
Strides-APP/app/pages/home/Drawer.js

@@ -15,6 +15,7 @@ import { getStorageJsonSync, setStorage, setStorageJson } from '../../utils/stor
 import Button from '../../components/Button';
 import { AutoLogin, RegisterToken } from '../sign/Login';
 import apiCharge from '../../api/apiCharge';
+import { toTopupPage } from '../wallet/Payment';
 
 const Drawer = createDrawerNavigator();
 
@@ -358,9 +359,7 @@ const DrawerContent = ({isLogin, userInfo, onLogout, navigation}) => {
             <Pressable
               style={styles.balanceView}
               android_ripple={ripple}
-              onPress={() => {
-                startPage(PageList.topup);
-              }}>
+              onPress={() => toTopupPage()}>
               <Image
                 style={styles.icon}
                 source={require('../../images/icon/draw-wallet.png')}/>

+ 1 - 1
Strides-APP/app/pages/home/maps/Test.js

@@ -113,7 +113,7 @@ export default class Test extends Component {
         />
         <Button
           text="Test Page"
-          onClick={() => startPage(PageList.home)}
+          onClick={() => startPage(PageList.paymentMethod)}
         />
       </View>
     );

+ 20 - 6
Strides-APP/app/pages/payment/PaymentMethod.js

@@ -9,18 +9,28 @@ import Button from '../../components/Button';
 import Dialog from '../../components/Dialog';
 import ChargeItemSelect from '../../icons/ChargeItemSelect';
 import { PageList } from '../Router';
-import { PAYTYPE } from '../wallet/Payment';
+import { PaymentDefault, PAYTYPE } from '../wallet/Payment';
 import { WalletTitle } from '../wallet/Topup';
 
-const ENABLE_2C2P = true;
-
 export default class PaymentMethod extends Component {
   constructor(props) {
     super(props);
     this.state = {
       cIndex: 0,
       selectIndex: 0,
-      paymentOptions: [{
+      paymentOptions: [],
+      paymentOptionsWallet: [{
+        title: "Credit Wallet",
+        desc: '',
+        value: PAYTYPE.CREDIT_WALLET,
+        icon: require('../../images/icon/draw-wallet.png')
+      }, {
+        title: "Pay Per Use",
+        desc: '(SGQR)',
+        value: PAYTYPE.PAY_PER_USE,
+        icon: require('../../images/wallet/ic_payperuse.png')
+      }],
+      paymentOptionsUse: [{
         title: "Pay Per Use",
         desc: '(SGQR)',
         value: PAYTYPE.PAY_PER_USE,
@@ -44,9 +54,13 @@ export default class PaymentMethod extends Component {
       connectorInfo: {}
     };
     this.rate = 0
+    this.ENABLE_2C2P = PaymentDefault.DEFAULT.payType == PAYTYPE.PAY_PER_USE;
   }
 
   componentDidMount() {
+    this.setState({
+      paymentOptions: this.ENABLE_2C2P ? this.state.paymentOptionsUse : this.state.paymentOptionsWallet
+    });
     const params = this.props.route.params;
     const info = params.info ?? {};
     console.log('----params----', params);
@@ -201,7 +215,7 @@ export default class PaymentMethod extends Component {
             })
           }
           </View>
-          { this.state.cIndex == 0 &&
+          { (this.state.cIndex == (this.ENABLE_2C2P ? 0 : 1)) &&
             <View style={[styles.optionView, ui.flex1]}>
               <WalletTitle>Pay Per Use</WalletTitle>
               <Text style={styles.subTitle}>Choose Amount:</Text>
@@ -237,7 +251,7 @@ export default class PaymentMethod extends Component {
         <Button
           text="Confirm"
           style={$margin(16)}
-          onClick={() => ENABLE_2C2P ? this.onConfirmV2() : this.onConfirm()}
+          onClick={() => this.ENABLE_2C2P ? this.onConfirmV2() : this.onConfirm()}
         />
       </View>
     );

+ 42 - 14
Strides-APP/app/pages/wallet/Payment.js

@@ -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,

+ 2 - 4
Strides-APP/app/pages/wallet/Wallet.js

@@ -4,7 +4,7 @@
  */
 import React, { Component } from 'react';
 import { View, Text, StyleSheet, ScrollView, RefreshControl } from 'react-native';
-import Payment from './Payment';
+import Payment, { toTopupPage } from './Payment';
 import { PageList } from '../Router';
 import History from './History';
 import Overview from './Overview';
@@ -66,9 +66,7 @@ export default class Wallet extends Component {
         <View style={styles.balanceView}>
           <Payment 
             balance={this.state.balance}
-            topup={() => {
-              startPage(PageList.topup);
-            }}/>
+            topup={() => toTopupPage()}/>
         </View>
         <View style={styles.tabView}>
           <Button