MyNumberInput.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <view>
  3. <view class="uni-input Numberinput" :class="{'inputdis':Isedit}" @click="maskShow" :id="'input_'+myevent">
  4. <text>{{myvalue}}</text>
  5. <text class="myfous" v-if="IsShow"></text>
  6. </view>
  7. <view class="mybrankmask" v-if="IsShow">
  8. <view style="padding: 20rpx;">
  9. <view class="MymaskList">
  10. <view class="maskListItem" @click="NumberCk(1)">1</view>
  11. <view class="maskListItem" @click="NumberCk(2)">2</view>
  12. <view class="maskListItem" @click="NumberCk(3)">3</view>
  13. <view class="maskListItem" style="background-color: #FFA500;color: #fff;" @click="Cancelword()">取消
  14. </view>
  15. </view>
  16. <view class="MymaskList">
  17. <view class="maskListItem" @click="NumberCk(4)">4</view>
  18. <view class="maskListItem" @click="NumberCk(5)">5</view>
  19. <view class="maskListItem" @click="NumberCk(6)">6</view>
  20. <view class="maskListItem" style="background-color: #67C23A;color: #fff;" @click="Tuige()">退格</view>
  21. </view>
  22. <view class="MymaskList">
  23. <view class="maskListItem" @click="NumberCk(7)">7</view>
  24. <view class="maskListItem" @click="NumberCk(8)">8</view>
  25. <view class="maskListItem" @click="NumberCk(9)">9</view>
  26. <view class="maskListItem" style="background-color: #F56C6C;color: #fff;" @click="Clear()">清空</view>
  27. </view>
  28. <view class="MymaskList">
  29. <view class="maskListItem" @click="NumberCk(0)">0</view>
  30. <view class="maskListItem" @click="NumberCk('.')">.</view>
  31. <view class="maskListItem" style="background-color: #31BDEC;color: #fff;width: 48%;"
  32. @click="Next()">下一项</view>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. export default {
  40. name: "MyNumberInput",
  41. data() {
  42. return {
  43. inputId: '',
  44. inputShow: false
  45. }
  46. },
  47. props: {
  48. IsShow: {
  49. type: Boolean,
  50. default: false
  51. },
  52. Isedit: {
  53. type: Boolean,
  54. default: false
  55. },
  56. myvalue: {
  57. type: [String, Number],
  58. default: ''
  59. },
  60. myevent: {
  61. type: String,
  62. default: ''
  63. }
  64. },
  65. methods: {
  66. maskShow() {
  67. this.$emit('Mykeywordck');
  68. },
  69. NumberCk(val) {
  70. if (val == '.') {
  71. if (this.myvalue.toString().indexOf('.') >= 0) {
  72. return;
  73. }
  74. }
  75. var txt = this.myvalue == null ? '' : this.myvalue;
  76. var arr = {
  77. even: this.myevent,
  78. value: txt + val.toString()
  79. };
  80. this.$emit('setValue', `${JSON.stringify(arr)}`);
  81. //this.$emit('update:myvalue',txt + val.toString());
  82. },
  83. Tuige() {
  84. if (this.myvalue != null) {
  85. var txt = this.myvalue.toString();
  86. if (txt.length >= 1)
  87. //this.$emit('update:myvalue',txt.substring(0,txt.length-1));
  88. var arr = {
  89. even: this.myevent,
  90. value: txt.substring(0, txt.length - 1)
  91. };
  92. this.$emit('setValue', JSON.stringify(arr));
  93. }
  94. },
  95. //取消按钮
  96. Cancelword() {
  97. this.$emit('Cancelword');
  98. },
  99. //清除按钮
  100. Clear() {
  101. var arr = {
  102. even: this.myevent,
  103. value: null
  104. };
  105. this.$emit('setValue', JSON.stringify(arr));
  106. },
  107. //下一个
  108. Next() {
  109. this.$emit('goNext');
  110. }
  111. }
  112. }
  113. </script>
  114. <style>
  115. .Numberinput {
  116. display: flex;
  117. align-items: center;
  118. }
  119. .myfous {
  120. width: 1rpx;
  121. height: 41rpx;
  122. background-color: #000;
  123. display: block;
  124. animation: mytreat 1.5s linear infinite;
  125. }
  126. .mybrankmask {
  127. width: 100%;
  128. height: 470rpx;
  129. background-color: #EBEEF5;
  130. position: fixed;
  131. z-index: 999;
  132. left: 0;
  133. bottom: 0;
  134. }
  135. .mybrankmask .MymaskList {
  136. display: flex;
  137. width: 100%;
  138. justify-content: space-around;
  139. margin-bottom: 20rpx;
  140. }
  141. .mybrankmask .MymaskList .maskListItem {
  142. width: 23%;
  143. height: 90rpx;
  144. background-color: #fff;
  145. text-align: center;
  146. line-height: 90rpx;
  147. border-radius: 10rpx;
  148. }
  149. //自定义光标模拟Input焦点
  150. @keyframes mytreat {
  151. /*开始画面*/
  152. 0% {
  153. background-color: #000;
  154. }
  155. 50% {
  156. background: none;
  157. }
  158. 100% {
  159. background-color: #000;
  160. }
  161. }
  162. </style>