Quellcode durchsuchen

feat: "空中云汇提现+付款单页面完善"

Ritchie vor 1 Jahr
Ursprung
Commit
a2abaf05ab

+ 2 - 1
src/assets/language/en.json

@@ -637,7 +637,8 @@
     "cancelOrder": "Cancel Order",
     "productName": "Product Name",
     "productsNum": "Products Number",
-    "totalPrice": "Total Price"
+    "totalPrice": "Total Price",
+    "shoppingVoucher": "Shopping Voucher"
   },
   "joinpayMch": {
     "withdrawalAccountNo": "Withdrawal account No",

+ 2 - 1
src/assets/language/zh.json

@@ -638,7 +638,8 @@
     "cancelOrder": "取消订单",
     "productName": "商品名称",
     "productsNum": "商品数量",
-    "totalPrice": "合计金额"
+    "totalPrice": "合计金额",
+    "shoppingVoucher": "购物凭证"
   },
   "joinpayMch": {
     "withdrawalAccountNo": "提现账号",

+ 29 - 14
src/views/Hpp.vue

@@ -8,7 +8,8 @@
 			<div class="checkout">
 				<br>
 				<br>
-				<span style="text-align: center; display: block; font-size: medium; font-weight: bold;"> Sunzee 棉花糖购物凭证
+				<span style="text-align: center; display: block; font-size: medium; font-weight: bold;"> {{
+					$t('airwallex.shoppingVoucher') }}
 				</span>
 				<br>
 				<br>
@@ -18,9 +19,9 @@
 				</span> -->
 				<!-- 订单号  订单状态   订单金额 商品名称  数量 -->
 				<van-cell-group inset>
-					<van-cell :title="$t('airwallex.productName')" :value="productsName" />
-					<van-cell :title="$t('airwallex.productsNum')" :value="productsNum" />
-					<van-cell :title="$t('airwallex.totalPrice')" :value="totalPrice" />
+					<van-cell :title="$t('airwallex.productName')">{{ productsName }}</van-cell>
+					<van-cell :title="$t('airwallex.productsNum')">{{ productsNum }}</van-cell>
+					<van-cell :title="$t('airwallex.totalPrice')">{{ totalPrice }}</van-cell>
 				</van-cell-group>
 
 				<br>
@@ -28,9 +29,10 @@
 				<br>
 				<div class="button-container">
 					<!-- 取消按钮 -->
-					<van-button color="#ee0a24" plain @click="cancelOrder()" round >{{ $t('airwallex.cancelOrder') }}</van-button>
+					<van-button color="#ee0a24" plain @click="cancelOrder()" round>{{ $t('airwallex.cancelOrder')
+					}}</van-button>
 					<!-- 支付按钮 -->
-					<van-button color="linear-gradient(to right, #ff6034, #ee0a24)" @click="redirectHpp()" round >{{
+					<van-button color="linear-gradient(to right, #ff6034, #ee0a24)" @click="redirectHpp()" round>{{
 						$t('airwallex.payForIt') }}</van-button>
 				</div>
 			</div>
@@ -51,7 +53,7 @@
 			</div> -->
 
 			<!-- <van-card num="2" price="2.00" desc="描述信息" title="商品标题" /> -->
-			
+
 		</div>
 	</div>
 </template>
@@ -59,7 +61,8 @@
 <script>
 import { redirectToCheckout, loadAirwallex } from 'airwallex-payment-elements';
 import { useRoute } from "vue-router";
-import { ref } from 'vue';
+// import { useI18n } from "vue-i18n";
+// import { ref } from 'vue';
 import sHeader from "@/components/SimpleHeader";
 
 export default {
@@ -67,15 +70,26 @@ export default {
 	components: { sHeader },
 
 	setup() {
+		// const { t } = useI18n();
+		// 将语言始终设置为英文
+		const curLang = localStorage.getItem('curLang');
+		if (curLang !== 'en') {
+			// 将 urllang 设置为 "en"
+			localStorage.setItem('curLang', 'en');
+		}
+
+
+		const urlParams = new URLSearchParams(window.location.href.split('?')[1]);
+		// console.log("urlParams是>>>" + urlParams.toString());
+		const productsName = urlParams.get('productName');
+		// console.log("productsName的value是:::" + productsName);
+		const productsNum = urlParams.get('productsNum');
+		const totalPrice = urlParams.get('totalPrice');
 
-		const productsName = ref('棉花糖');
-		const productsNum = ref('3');
-		const totalPrice = ref('2.00');
 
 		const mode = 'payment';
 		const route = useRoute();
-		// const router = useRouter();
-		console.log(route.query.intent_id)
+		// console.log("route.query.intent_id>>>>>>>" + route.query.intent_id);
 		const redirectHppForCheckout = () => {
 			redirectToCheckout({
 				env: 'demo',
@@ -254,6 +268,7 @@ export default {
 }
 
 body {
-  background-color: #f8f8f8; /* 设置背景颜色 */
+	background-color: #f8f8f8;
+	/* 设置背景颜色 */
 }
 </style>

+ 5 - 3
src/views/airwallex/beneficiary.vue

@@ -204,13 +204,15 @@ export default {
                 // 请求后端接口 caBeneficiary
                 const respResult = await createBeneficiary(caBeneficiaryReq);
                 const beneficiaryId = respResult.data.beneficiary_id;
-                console.log("收款人id:", beneficiaryId);
-
+                // console.log("收款人id:", beneficiaryId);
+                
                 // if 成功,将 beneficiary_id 缓存下来,跳转到付款单页面
                 if (beneficiaryId) {
                     router.push({
                         path: '/airwallexPayout',
-                        query: { beneficiaryId: beneficiaryId }
+                        query: { 
+                            beneficiaryId: beneficiaryId,
+                        }
                     })
                 }    
 

+ 3 - 6
src/views/airwallex/index.vue

@@ -32,22 +32,19 @@ export default {
     setup() {
         styleUrl("airwallex")
         const router = useRouter();
-        // TODO: 设置默认金额为 100
         const amount = ref(0.00);
 
         const loginUserStr = localStorage.getItem('loginUser');
         const loginUser = JSON.parse(loginUserStr);
         const adminId = loginUser.id;
-
-        console.log("adminId>>>", adminId);
+        // console.log("adminId>>>", adminId);
 
         onMounted(async () => {
             try {
                 // 请求后端接口: 获取钱包信息
                 const resp = await getWallet(adminId);
-                console.log("resp>>>", resp);
-                console.log("resp.data>>>", resp.data);
-                // amount = resp.data.;
+                // console.log("resp.data>>>", resp.data);
+                amount.value = resp.data.accountAmount;
             } catch (error) {
                 console.error(error);
                 // 处理异常情况

+ 37 - 85
src/views/airwallex/payout.vue

@@ -24,6 +24,8 @@ import { getAuthCode } from '@/service/airwallex/index';
 import { onMounted, ref } from 'vue';
 import { styleUrl } from '../../common/js/utils';
 import { useRouter, useRoute } from 'vue-router';
+import { getWallet } from '@/service/airwallex/index';
+
 
 
 export default {
@@ -34,12 +36,24 @@ export default {
         const ready = ref(false);
         let payoutComponent;
 
+        const loginUserStr = localStorage.getItem("loginUser");
+        const loginUser = JSON.parse(loginUserStr);
+        const userId = loginUser.id;
+        // console.log("userId是 >>> " + userId);
+
         onMounted(async () => {
             try {
                 // 获取从 beneficiary 页面获取到的 beneficiaryId
                 // const beneficiaryId = router.currentRoute.value.query.beneficiaryId;
                 const beneficiaryId = route.query.beneficiaryId;
                 console.log("beneficiaryId >>> " + beneficiaryId);
+                
+                // 请求后端接口: 获取钱包信息
+                const resp = await getWallet(userId);
+                const sourceAmount = resp.data.accountAmount;
+                // console.log("sourceAmount >>> " + sourceAmount);
+
+                
 
                 // generate code_verifier
                 const codeVerifier = generateCodeVerifier();
@@ -73,10 +87,33 @@ export default {
                 payoutComponent = await createElement(eleType, {
                     defaultValues: {
                         beneficiary_id: beneficiaryId,
+                        source_amount: sourceAmount,
+                        source_currency: 'USD',
                         // payment_currency: 'USD',
+                    },
+                    customizations: {
+                        fields: {
+                            source_amount: {
+                                disabled: true,
+                            },
+                            source_currency: {
+                                disabled: true,
+                            },
+                            payment_amount: {
+                                disabled: true,
+                            },
+                            // payment_currency: {
+                            //     disabled: true,
+                            // },
+                            // swift_charge_option: {
+                            //     disabled: true, // 禁用swift方式下的选框
+                            //     hidden: true, // 隐藏swift方式下的选框
+                            // },
+                        }
                     }
                 });
 
+
                 payoutComponent.mount('#payout-form-container');
 
                 payoutComponent.on('ready', () => {
@@ -148,91 +185,6 @@ export default {
             }
         }
 
-        // const handleSubmit = async () => {
-        //     if (ready.value) {
-        //         const formResult = await payoutComponent.submit();
-        //         // Handle form results
-        //         console.log('submit 执行结果:', formResult);
-
-        //         const {
-        //             values, additionalInfo
-        //         } = formResult;
-
-        //         const {
-        //             beneficiary_id,
-        //             source_currency,
-        //             payment_method,
-        //             payment_currency,
-        //             // source_amount,
-        //             // fee_paid_by,
-        //             // payment_date,
-        //         } = values;
-
-
-        //         // 校验 values 参数
-        //         if (
-        //             !beneficiary_id ||
-        //             !payment_currency ||
-        //             !payment_method ||
-        //             // !reason ||
-        //             // !reference ||
-        //             !source_currency
-        //         ) {
-        //             throw new Error('缺少必要参数');
-        //         }
-
-        //         // const reason = ref(additionalInfo.reason);
-
-        //         // 
-        //         // setTimeout(() => {
-        //         //     additionalInfo.value = {
-        //         //         reason: {
-        //         //             label: "Audiovisual services",
-        //         //             value: "audio_visual_services"
-        //         //         },
-        //         //         // 其他理由...
-        //         //     }
-        //         // }, 1000)
-
-        //         // const reason = additionalInfo.value.additionalInfo
-        //         // const regference = additionalInfo
-
-        //         // 把这些参数都带去新的页面,然后再去新的页面获取reason 和 sdfsdfs,最后再去请问
-
-        //         // 构建请求数据对象
-        //         // 后端必须的参数 
-        //         // beneficiary_id, 
-        //         // payment_currency, 
-        //         // payment_method, 
-        //         // reason, 
-        //         // reference, 
-        //         // request_id, 
-        //         // source_currency
-        //         const caPaymentReq = {
-        //             beneficiary_id: beneficiary_id,
-        //             payment_currency: payment_currency,
-        //             payment_method: payment_method,
-        //             // reason: reason,
-        //             // reference: reference,
-        //             // request_id: request_id,
-        //             source_currency: source_currency
-        //         }
-
-        //         // 请求后端接口
-        //         const resultsResp = await createPayment(caPaymentReq);
-        //         console.log("resultResp>>>", resultsResp);
-
-        //         // if 成功,将 
-        //         // if (resultsResp.code === "00000") {
-        //         //     router.push({
-        //         //         path: '/caPayment',
-        //         //         query: { beneficiaryId: beneficiaryId }
-        //         //     })
-        //         // }
-
-        //     }
-        // };
-
 
         // 生成 code_verifier
         const dec2hex = (dec) => {