Преглед на файлове

Add Enable 2C2P payment switch

vbea преди 3 години
родител
ревизия
113619eeaa

+ 3 - 1
Strides-APP/app/pages/payment/PaymentMethod.js

@@ -12,6 +12,8 @@ import { PageList } from '../Router';
 import { PAYTYPE } from '../wallet/Payment';
 import { WalletTitle } from '../wallet/Topup';
 
+const ENABLE_2C2P = true;
+
 export default class PaymentMethod extends Component {
   constructor(props) {
     super(props);
@@ -235,7 +237,7 @@ export default class PaymentMethod extends Component {
         <Button
           text="Confirm"
           style={$margin(16)}
-          onClick={() => this.onConfirm()}
+          onClick={() => ENABLE_2C2P ? this.onConfirmV2() : this.onConfirm()}
         />
       </View>
     );

+ 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: 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
+   }
+ })

+ 1 - 1
Strides-Admin/src/layout/components/Sidebar/index.vue

@@ -95,4 +95,4 @@ export default {
     }
   }
 }
-</script>
+</script>

+ 11 - 2
Strides-Admin/src/styles/sidebar.scss

@@ -124,7 +124,7 @@
 
   .hideSidebar {
     .sidebar-container {
-      width: 54px !important;
+      width: 56px !important;
       padding: 0px 0px;
     }
 
@@ -154,7 +154,7 @@
 
       & > .el-submenu__title {
         padding: 0 !important;
-
+        
         .svg-icon {
           margin-left: 20px;
         }
@@ -167,6 +167,15 @@
           display: none;
         }
       }
+      &.is-active .el-submenu__title::before {
+        left: 6px;
+        right: 6px;
+        bottom: 6px;
+        height: 3px;
+        content: " ";
+        position: absolute;
+        background-color: $subMenuHover;
+      }
     }
 
     .el-menu--collapse {