wh-input.vue 2.5 KB

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