StdFormCardContent.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <a-card :bordered="false" class="form-card">
  3. <a-form :form="form" @submit="handleSubmit">
  4. <div class="logo">
  5. <img :src="logo"/>
  6. </div>
  7. <p class="title">
  8. {{ options.title }}
  9. </p>
  10. <a-form-item
  11. v-for="item in options.items"
  12. :key="item.label"
  13. :help="errors[item.decorator[0]] ? errors[item.decorator[0]] : null"
  14. :label="item.label"
  15. :validate-status="errors[item.decorator[0]] ? 'error' :'success'"
  16. >
  17. <a-input
  18. v-decorator="item.decorator"
  19. :autocomplate="item.autocomplate ? 'on' : 'off'"
  20. :placeholder="item.placeholder"
  21. :type="item.type"
  22. >
  23. <a-icon slot="prefix" :type="item.icon" style="color: rgba(0,0,0,.25)"/>
  24. </a-input>
  25. </a-form-item>
  26. <div class="action">
  27. <div class="center">
  28. <a-button
  29. :loading="loading"
  30. class="std-border-radius"
  31. html-type="submit"
  32. type="primary"
  33. >
  34. {{ options.button_text }}
  35. </a-button>
  36. </div>
  37. <div class="small-link center">
  38. <slot name="small-link"/>
  39. </div>
  40. </div>
  41. </a-form>
  42. </a-card>
  43. </template>
  44. <script>
  45. //import {VueReCaptcha} from 'vue-recaptcha-v3'
  46. //import Vue from 'vue'
  47. /*Vue.use(VueReCaptcha, {
  48. siteKey: process.env.VUE_APP_RECAPTCHA_SITEKEY,
  49. loaderOptions: {
  50. useRecaptchaNet: true
  51. }
  52. })*/
  53. export default {
  54. name: 'StdFormCardContent',
  55. props: {
  56. options: Object,
  57. errors: {
  58. type: Object,
  59. default() {
  60. return {}
  61. }
  62. },
  63. },
  64. data() {
  65. return {
  66. logo: require('@/assets/img/logo.png'),
  67. loading: false,
  68. form: null
  69. }
  70. },
  71. mounted() {
  72. this.form = this.$form.createForm(this)
  73. },
  74. methods: {
  75. async handleSubmit(e) {
  76. e.preventDefault()
  77. this.form.validateFields((err, values) => {
  78. if (!err) {
  79. this.loading = true
  80. //this.$recaptchaLoaded().then(() => {
  81. //this.$recaptcha('std_form').then(token => {
  82. //values.token = token
  83. this.$emit('onSubmit', values)
  84. //})
  85. // })
  86. this.loading = false
  87. }
  88. })
  89. }
  90. }
  91. }
  92. </script>
  93. <style lang="less">
  94. .form-card {
  95. .ant-form-item {
  96. input {
  97. border-radius: 20px;
  98. }
  99. }
  100. }
  101. </style>
  102. <style lang="less" scoped>
  103. .form-card {
  104. box-shadow: 0 0 30px rgba(200, 200, 200, 0.25);
  105. .ant-form {
  106. max-width: 250px;
  107. margin: 0 auto;
  108. .title {
  109. text-align: center;
  110. font-size: 17px;
  111. margin: 10px 0;
  112. }
  113. }
  114. .logo {
  115. display: grid;
  116. padding: 10px;
  117. img {
  118. height: 80px;
  119. margin: 0 auto;
  120. }
  121. }
  122. .action {
  123. .small-link {
  124. font-size: 13px;
  125. padding: 15px 0 0 0;
  126. }
  127. }
  128. }
  129. </style>