MyNumberInput.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <view>
  3. <view class="uni-input Numberinput" :class="{'inputdis':Isedit}" @click="maskShow" :id="'input_'+myevent">
  4. <text>{{myvalue}}</text><text class="myfous" v-if="IsShow"></text>
  5. </view>
  6. <view class="mybrankmask" v-if="IsShow">
  7. <view style="padding: 20rpx;">
  8. <view class="MymaskList">
  9. <view class="maskListItem" @click="NumberCk(1)">1</view>
  10. <view class="maskListItem" @click="NumberCk(2)">2</view>
  11. <view class="maskListItem" @click="NumberCk(3)">3</view>
  12. <view class="maskListItem" style="background-color: #FFA500;color: #fff;" @click="Cancelword()">取消
  13. </view>
  14. </view>
  15. <view class="MymaskList">
  16. <view class="maskListItem" @click="NumberCk(4)">4</view>
  17. <view class="maskListItem" @click="NumberCk(5)">5</view>
  18. <view class="maskListItem" @click="NumberCk(6)">6</view>
  19. <view class="maskListItem" style="background-color: #67C23A;color: #fff;" @click="Tuige()">退格</view>
  20. </view>
  21. <view class="MymaskList">
  22. <view class="maskListItem" @click="NumberCk(7)">7</view>
  23. <view class="maskListItem" @click="NumberCk(8)">8</view>
  24. <view class="maskListItem" @click="NumberCk(9)">9</view>
  25. <view class="maskListItem" style="background-color: #F56C6C;color: #fff;" @click="Clear()">清空</view>
  26. </view>
  27. <view class="MymaskList">
  28. <view class="maskListItem" @click="NumberCk(0)">0</view>
  29. <view class="maskListItem" @click="NumberCk('.')">.</view>
  30. <view class="maskListItem" style="background-color: #31BDEC;color: #fff;width: 48%;"
  31. @click="Next()">下一项</view>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. export default {
  39. name: "MyNumberInput",
  40. data() {
  41. return {
  42. inputId: '',
  43. inputShow: false
  44. }
  45. },
  46. props: {
  47. IsShow: {
  48. type: Boolean,
  49. default: false
  50. },
  51. Isedit: {
  52. type: Boolean,
  53. default: false
  54. },
  55. myvalue: {
  56. type: [String, Number],
  57. default: ''
  58. },
  59. myevent: {
  60. type: String,
  61. default: ''
  62. }
  63. },
  64. methods: {
  65. maskShow() {
  66. this.$emit('Mykeywordck');
  67. },
  68. NumberCk(val) {
  69. if (val == '.') {
  70. if (this.myvalue.toString().indexOf('.') >= 0) {
  71. return;
  72. }
  73. }
  74. var txt = this.myvalue == null ? '' : this.myvalue;
  75. var arr = {
  76. even: this.myevent,
  77. value: txt + val.toString()
  78. };
  79. this.$emit('setValue', `${JSON.stringify(arr)}`);
  80. //this.$emit('update:myvalue',txt + val.toString());
  81. },
  82. Tuige() {
  83. if (this.myvalue != null) {
  84. var txt = this.myvalue.toString();
  85. if (txt.length >= 1)
  86. //this.$emit('update:myvalue',txt.substring(0,txt.length-1));
  87. var arr = {
  88. even: this.myevent,
  89. value: txt.substring(0, txt.length - 1)
  90. };
  91. this.$emit('setValue', JSON.stringify(arr));
  92. }
  93. },
  94. //取消按钮
  95. Cancelword() {
  96. this.$emit('Cancelword');
  97. },
  98. //清除按钮
  99. Clear() {
  100. var arr = {
  101. even: this.myevent,
  102. value: null
  103. };
  104. this.$emit('setValue', JSON.stringify(arr));
  105. },
  106. //下一个
  107. Next() {
  108. this.$emit('goNext');
  109. }
  110. }
  111. }
  112. </script>
  113. <style>
  114. .Numberinput {
  115. display: flex;
  116. align-items: center;
  117. /* flex-direction: row-reverse; */
  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>