|
@@ -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) => {
|