fa-captchaparts.vue 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template>
  2. <view class="" :style="customStyle">
  3. <u-form-item :required ="true" :label-position="labelPosition" prop="captcha" label-width="150" label="验证码">
  4. <view class="u-m-r-15"><u-input v-model="captcha" /></view>
  5. <u-image slot="right" width="250rpx" height="60rpx" :src="img_url" @click="getCaptcha"></u-image>
  6. </u-form-item>
  7. </view>
  8. </template>
  9. <script>
  10. export default {
  11. name: 'fa-captchaparts',
  12. props: {
  13. value: {
  14. type: String,
  15. default: ''
  16. },
  17. ident: {
  18. type: [String, Number],
  19. default: ''
  20. },
  21. labelPosition: {
  22. type: String,
  23. default: 'top'
  24. },
  25. customStyle: {
  26. type: Object,
  27. default() {
  28. return {};
  29. }
  30. }
  31. },
  32. watch: {
  33. captcha(newValue, oldValue) {
  34. this.$emit('input', newValue);
  35. }
  36. },
  37. mounted() {
  38. this.getCaptcha();
  39. },
  40. data() {
  41. return {
  42. captcha: '',
  43. img_url: ''
  44. };
  45. },
  46. methods: {
  47. getCaptcha() {
  48. this.$api.getCaptcha({ ident: this.ident }).then(res => {
  49. if (res.code == 1) {
  50. this.img_url = res.data;
  51. }
  52. });
  53. }
  54. }
  55. };
  56. </script>
  57. <style lang="scss"></style>