caPayment.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <template>
  2. <div class="airwallexPayment">
  3. <s-header :name="$t('airwallex.payout')" :noback="false"></s-header>
  4. <br>
  5. <!-- 卡片展示付款信息 -->
  6. <van-cell-group inset>
  7. <van-cell title="您支付" :value="payment_amount + ' ' + source_currency" />
  8. <van-cell title="付款日期" :value="payment_date" label="送达需要0~3个工作日" />
  9. <!-- <van-cell title="收款方收到" :value="payment_amount + ' ' + payment_currency" /> -->
  10. </van-cell-group>
  11. <br>
  12. <!-- 付款原因 -->
  13. <van-cell-group inset>
  14. <van-field v-model="reason" required is-link readonly label="付款原因" placeholder="选择付款原因"
  15. @click="showPicker = true" />
  16. <van-popup v-model:show="showPicker" round position="bottom">
  17. <van-picker :columns="columns" @cancel="showPicker = false" @confirm="onConfirm" />
  18. </van-popup>
  19. </van-cell-group>
  20. <br>
  21. <!-- 交易附言 -->
  22. <van-form>
  23. <van-cell-group inset>
  24. <van-field v-model="reference" required label="交易附言" placeholder="此信息可能会展示在收款方银行账单上,帮助收款方甄别此付款。"
  25. :rules="[{ required: true, message: '此项为必填项' }]" />
  26. </van-cell-group>
  27. </van-form>
  28. <br>
  29. <!-- 备注(选填) -->
  30. <van-cell-group inset>
  31. <van-field v-model="text" label="备注" placeholder="选填:你可以通过它给审批人或其他用户提供额外信息。" />
  32. </van-cell-group>
  33. <div class="button-container">
  34. <van-button type="primary" class="cancel" @click="handleCancel">取消</van-button>
  35. <van-button type="primary" class="register" @click="handleSubmit">提交付款</van-button>
  36. </div>
  37. </div>
  38. </template>
  39. <script>
  40. import sHeader from "@/components/SimpleHeader";
  41. import { styleUrl } from '../../common/js/utils';
  42. import { useRouter, useRoute } from 'vue-router';
  43. import { ref, onMounted } from 'vue';
  44. import { createPayment } from '@/service/airwallex/index';
  45. export default {
  46. components: { sHeader },
  47. setup() {
  48. const router = useRouter();
  49. const route = useRoute();
  50. let caPaymentReq;
  51. const source_amount = ref();
  52. const source_currency = ref();
  53. const payment_date = ref();
  54. const payment_currency = ref();
  55. const payment_amount = ref();
  56. const payment_method = ref();
  57. const beneficiary_id = ref();
  58. const reference = ref('');
  59. const regerenceError = ref(false);
  60. const loginUserStr = localStorage.getItem('loginUser');
  61. const loginUser = JSON.parse(loginUserStr);
  62. const adminId = loginUser.id;
  63. const columns = [
  64. 'wages_salary',
  65. 'donation_charitable_contribution',
  66. 'personal_remittance',
  67. 'transfer_to_own_account',
  68. 'pension',
  69. 'family_support',
  70. 'living_expenses',
  71. 'education_training',
  72. 'travel',
  73. 'investment_proceeds',
  74. 'investment_capital',
  75. 'loan_credit_repayment',
  76. 'taxes',
  77. 'goods_purchased',
  78. 'business_expenses',
  79. 'medical_services',
  80. 'professional_business_services',
  81. 'technical_services',
  82. 'other_services',
  83. 'construction',
  84. 'freight',
  85. 'real_estate',
  86. 'audio_visual_services'
  87. ];
  88. const reason = ref('');
  89. const showPicker = ref(false);
  90. const onConfirm = (selectedItem) => {
  91. reason.value = selectedItem;
  92. showPicker.value = false;
  93. };
  94. const handleCancel = async () => {
  95. router.push({
  96. path: '/airwallex',
  97. query: {
  98. }
  99. })
  100. }
  101. onMounted(async () => {
  102. try {
  103. // 获取从 payout 页面获取到的参数
  104. // const beneficiaryId = router.currentRoute.value.query.beneficiaryId;
  105. // const payment_currency = router.currentRoute.value.query.payment_currency;
  106. // const payment_method = router.currentRoute.value.query.payment_method;
  107. // const source_currency = router.currentRoute.value.query.source_currency;
  108. // const source_amount = router.currentRoute.value.query.source_amount;
  109. // const fee_paid_by = router.currentRoute.value.query.fee_paid_by;
  110. // const payment_date = router.currentRoute.value.query.payment_date;
  111. beneficiary_id.value = route.query.beneficiary_id;
  112. payment_currency.value = route.query.payment_currency;
  113. payment_method.value = route.query.payment_method;
  114. source_currency.value = route.query.source_currency;
  115. payment_date.value = route.query.payment_date;
  116. // const fee_paid_by = route.query.fee_paid_by;
  117. // 注:这里的 payment_amount 用的是 source_amount
  118. // source_amount.value = route.query.source_amount;
  119. payment_amount.value = route.query.source_amount;
  120. console.log("beneficiary_id >>> " + beneficiary_id.value);
  121. console.log("payment_currency >>> " + payment_currency.value);
  122. console.log("payment_method >>> " + payment_method.value);
  123. console.log("source_currency >>> " + source_currency.value);
  124. console.log("payment_amount >>> " + payment_amount.value);
  125. } catch (error) {
  126. console.error(error);
  127. // 处理异常情况
  128. }
  129. });
  130. const handleSubmit = async () => {
  131. if (caPaymentReq !== null) {
  132. if (reference.value === '') {
  133. regerenceError.value = true;
  134. return;
  135. }
  136. console.log("reference:::", reference.value);
  137. console.log("reason:::", reason.value);
  138. const caPaymentReq = {
  139. beneficiary_id: beneficiary_id.value,
  140. payment_currency: payment_currency.value,
  141. payment_method: payment_method.value,
  142. reason: reason.value,
  143. reference: reference.value,
  144. // request_id: request_id,
  145. source_currency: source_currency.value,
  146. payment_amount: payment_amount.value,
  147. adminId: adminId
  148. }
  149. // 请求后端接口
  150. const resultsResp = await createPayment(caPaymentReq);
  151. console.log("resultResp>>>", resultsResp);
  152. console.log("paymentId>>>", resultsResp.data);
  153. if (resultsResp) {
  154. router.push({
  155. path: '/paymentDetail',
  156. query: {
  157. paymentId: resultsResp.data,
  158. }
  159. })
  160. }
  161. }
  162. }
  163. styleUrl("airwallex");
  164. return {
  165. handleCancel,
  166. handleSubmit,
  167. source_amount,
  168. source_currency,
  169. payment_date,
  170. payment_currency,
  171. payment_amount,
  172. reason,
  173. columns,
  174. onConfirm,
  175. showPicker,
  176. reference
  177. }
  178. }
  179. }
  180. </script>