en-input.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <view class="wh-box">
  3. <view class="row p-tb30" style="line-height: 30rpx;height: 30rpx;" :class="{'bor-bottom-1':is_border}">
  4. <view class="wh-text size-28">{{label}}<text></text></view>
  5. <view class="row-c flex">
  6. <input class="wh-input sys-size-28 text-color-12 m-l40" placeholder-class="sys-size-28 text-color-999"
  7. :maxlength="maxlength" :type="type" :focus="focus"
  8. :placeholder="is_select ? '请选择' : placeholder?placeholder:`请输入${label}`" :disabled="disabled"
  9. v-model="inputValue" @blur="nameInput" @input="nameInput"></input>
  10. <view class="" style="margin-top: 4rpx;">
  11. <uni-icons type="forward" size="18" color="#D8D8D8" v-if="is_select"></uni-icons>
  12. </view>
  13. </view>
  14. <text class="sys-size-28 m-l20" v-if="rightText">{{rightText}}</text>
  15. <slot></slot>
  16. </view>
  17. <view class="size-24 text-color-E21 p-b20 p-t10" v-if="is_requis">{{name}}为必填</view>
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. name: 'en-input',
  23. props: {
  24. is_select: {
  25. type: Boolean,
  26. default: false
  27. },
  28. is_border: {
  29. type: Boolean,
  30. default: true
  31. },
  32. is_requis: {
  33. type: Boolean,
  34. default: false
  35. },
  36. label: {
  37. type: String,
  38. default: '姓名'
  39. },
  40. rightText: {
  41. type: String,
  42. default: ''
  43. },
  44. type: {
  45. type: String,
  46. default: 'text'
  47. },
  48. placeholder: {
  49. type: String,
  50. default: ''
  51. },
  52. disabled: {
  53. default: false
  54. },
  55. value: {
  56. default: ''
  57. },
  58. maxlength: {
  59. default: 140
  60. },
  61. focus: {
  62. default: false
  63. }
  64. },
  65. data() {
  66. return {
  67. inputValue: '',
  68. showShake: false
  69. };
  70. },
  71. watch: {
  72. 'value': function() {
  73. if (this.inputValue !== this.value) {
  74. console.log(this.inputValue)
  75. this.inputValue = this.value
  76. }
  77. },
  78. 'inputValue': function() {
  79. this.$emit('input', this.inputValue)
  80. }
  81. },
  82. mounted() {
  83. this.inputValue = this.value
  84. },
  85. methods: {
  86. nameInput(e) {
  87. if (this.type === 'nickname') {
  88. this.inputValue = e.detail.value
  89. }
  90. },
  91. onSubmit() {
  92. }
  93. }
  94. }
  95. </script>
  96. <style lang="scss">
  97. .wh-box {
  98. z-index: 1;
  99. .wh-input {
  100. width: 100%;
  101. text-align: right;
  102. direction: rtl;
  103. }
  104. .wh-input-placeholder {
  105. color: #999999;
  106. font-size: 28rpx;
  107. }
  108. }
  109. .wh-text {
  110. width: 110rpx;
  111. text-align: justify;
  112. text-align-last: justify;
  113. vertical-align: top;
  114. height: 0;
  115. padding-top: 2rpx;
  116. }
  117. .wh-text:after {
  118. content: '';
  119. width: 110rpx;
  120. height: 0;
  121. display: inline-block;
  122. overflow: hidden;
  123. }
  124. </style>