index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <app-view class="g-form bank-wallet-withdraw">
  3. <Form ref="formRef" class="g-form__container" @submit="formSubmit">
  4. <CellGroup inset>
  5. <Field class="form-field" label="提现金额" v-model="formData.Amount" :rules="formRules.Amount">
  6. <template #input>
  7. <input v-model="formData.Amount" placeholder="请填写提现金额" />
  8. <span class="form-field__tips">可出金额:{{ fund.AvailableOutMoney }}</span>
  9. </template>
  10. </Field>
  11. <Field label="开户银行">
  12. <template #input>
  13. {{ sign.bankname }}
  14. </template>
  15. </Field>
  16. <Field label="银行卡号">
  17. <template #input>
  18. {{ sign.bankaccountno }}
  19. </template>
  20. </Field>
  21. <Field label="姓名">
  22. <template #input>
  23. {{ sign.bankaccountname }}
  24. </template>
  25. </Field>
  26. <Field label="支行名称">
  27. <template #input>
  28. {{ sign.branchbankname }}
  29. </template>
  30. </Field>
  31. </CellGroup>
  32. </Form>
  33. <template #footer>
  34. <div class="g-form__footer">
  35. <Button round block type="primary" @click="formRef?.submit()">确定</Button>
  36. </div>
  37. </template>
  38. </app-view>
  39. </template>
  40. <script lang="ts" setup>
  41. import { useDoWithdraw, useAccountFundInfo } from '@/business/bank';
  42. import { Form, Field, CellGroup, FormInstance, Button, FieldRule, Toast } from 'vant'
  43. import { shallowRef } from 'vue'
  44. import { fullloading, dialog } from '@/utils/vant'
  45. import { useNavigation } from '@/hooks/navigation'
  46. const { formData, onSubmit, sign } = useDoWithdraw()
  47. /// 资金账户信息
  48. const { fund } = useAccountFundInfo()
  49. const { router } = useNavigation()
  50. const formRef = shallowRef<FormInstance>()
  51. // 表单验证规则
  52. const formRules: { [key in keyof Proto.t2bBankWithdrawReq]?: FieldRule[] } = {
  53. Amount: [{
  54. required: true,
  55. message: '请输入出金金额',
  56. validator: (val) => {
  57. if (val <= (fund.value.AvailableOutMoney ?? 0.0)) {
  58. return true
  59. }
  60. return '超过可出金额'
  61. }
  62. }]
  63. }
  64. const formSubmit = () => {
  65. fullloading((hideLoading) => {
  66. onSubmit().then(() => {
  67. hideLoading()
  68. dialog('出金提交申请成功,请耐心等待审核。').then(() => {
  69. router.back()
  70. })
  71. }).catch((err) => {
  72. Toast.fail(err)
  73. })
  74. })
  75. }
  76. </script>
  77. <style lang="less">
  78. @import './index.less';
  79. </style>