You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

186 lines
9.2 KiB

4 years ago
  1. <template>
  2. <view class="number-keyboard-component numberkeyboard">
  3. <view class="keys">
  4. <view
  5. class="key button"
  6. v-for="num in config.loop"
  7. :key="num.key"
  8. @tap="number(num.number)"
  9. hover-class="hover-dark"
  10. :hover-stay-time="50"
  11. >{{num.number}}</view>
  12. <view class="key button" @tap="del" style="background: #e2e7eb;"></view>
  13. <view class="key button" @tap="number(0)">0</view>
  14. <view class="key button" @tap="del" style="background: #e2e7eb;">
  15. <image style="width: 50rpx;height: 50rpx;" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAQU0lEQVR4Xu2dCch1VRWGHysztUENSmwwipRmshzSBs1G0+YJG4iS0hKjiMwyLbXBolAqi8oCs0EiFFHUJjXTnDLExILKgWgiS8shUzNe/nPz8+uee/be59zh7PUu+Pl+uHvfe9a793P3uWevvdZG2KyAFWhVYCNrYwWsQLsCBsSzwwrMUMCAeHpYAQPiOWAFyhTwClKmm3sFUcCABBlou1mmgAEp0829gihgQIIMtN0sU8CAlOnmXkEUMCBBBtpulilgQMp0c68gChiQIANtN8sUMCBlurlXEAUMSJCBtptlChiQMt3cK4gCBiTIQNvNMgUMSJlu7hVEAQMSZKDtZpkCBqRMN/cKooABCTLQdrNMAQNSppt7BVHAgAQZaLtZpoABKdPNvYIoYECCDLTdLFPAgJTp5l5BFDAgQQbabpYpYEDKdHOvIAoYkCADbTfLFDAgZbq5VxAFDEiQgbabZQoYkDLd3CuIAgYkyEDbzTIFDEiZbu4VRIHIgDwW2AF4FLBpkPEeu5vXAZcBVwK3L8KZiIAIiG8DuyxCYH/GXBS4DTgHOAP4MXDFXD4FiAbI9sAFwFbzEtTvuxQFrgFOBI4H9P/BLBIg2wCXAPprq1OBO4HvAB8DrhrCxSiAbAFcCGgFsdWvwB3AccBhwI193I0AyP2Ac4Gd+gjlvqNU4I/AG4CzS6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dLFFhpQOSQVhA92twiwTvvtieI5CZZC
  16. </view>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. /**
  22. * 数字键盘
  23. * @event onChange 输入值改变时触发
  24. */
  25. export default {
  26. name: 'number-keyboard',
  27. data() {
  28. return {
  29. val: '',
  30. config: {
  31. loop: [
  32. {number: 1,key: 'number-1'},
  33. {number: 2,key: 'number-2'},
  34. {number: 3,key: 'number-3'},
  35. {number: 4,key: 'number-4'},
  36. {number: 5,key: 'number-5'},
  37. {number: 6,key: 'number-6'},
  38. {number: 7,key: 'number-7'},
  39. {number: 8,key: 'number-8'},
  40. {number: 9,key: 'number-9'}
  41. ]
  42. },
  43. };
  44. },
  45. props: {
  46. length: {
  47. type: Number,
  48. default: 6
  49. }
  50. },
  51. methods: {
  52. del() {
  53. if(this.val.length > 0){
  54. this.val = this.val.slice(0, this.val.length - 1);
  55. this.$emit('onChange', this.val)
  56. }
  57. },
  58. number(number) {
  59. if(this.val.length < this.length){
  60. this.val = this.val + number;
  61. this.$emit('onChange', this.val)
  62. }
  63. }
  64. }
  65. };
  66. </script>
  67. <style scoped="scoped" lang="scss">
  68. .number-keyboard-component {
  69. width: 100%;
  70. border-top: 1px solid #f1f4f4;
  71. .title {
  72. display: flex;
  73. justify-content: center;
  74. align-items: center;
  75. height: 60rpx;
  76. background: #f0f0f0;
  77. }
  78. .keys {
  79. display: flex;
  80. flex-direction: row;
  81. flex-wrap: wrap;
  82. .key {
  83. width: 250rpx;
  84. height: 110rpx;
  85. display: flex;
  86. justify-content: center;
  87. align-items: center;
  88. border-right: 1px solid #f1f4f4;
  89. box-sizing: border-box;
  90. font-size: 36rpx;
  91. font-weight: 700;
  92. color: #333;
  93. }
  94. .key:nth-child(n + 4) {
  95. border-top: 1px solid #f1f4f4;
  96. box-sizing: border-box;
  97. }
  98. }
  99. .container {
  100. width: 100%;
  101. .count-text {
  102. justify-content: center;
  103. align-items: center;
  104. display: flex;
  105. font-size: 18px;
  106. }
  107. }
  108. .numberkeyboard-popup {
  109. width: 100%;
  110. z-index: 10;
  111. .count-text {
  112. position: fixed;
  113. top: -100px;
  114. font-size: 28px;
  115. color: #ffffff;
  116. width: 100%;
  117. text-align: center;
  118. font-weight: 500;
  119. span {
  120. padding: 0 40px;
  121. border-radius: 30px;
  122. background: -webkit-linear-gradient(left top, #999999, #777777);
  123. }
  124. }
  125. .desc-text {
  126. position: fixed;
  127. top: -40px;
  128. font-size: 12px;
  129. color: #ffffff;
  130. width: 100%;
  131. text-align: center;
  132. font-weight: 100;
  133. }
  134. .number {
  135. height: 70px;
  136. line-height: 70px;
  137. font-size: 25px;
  138. font-weight: 400;
  139. color: #666666;
  140. border-right: 1px solid #999999;
  141. box-sizing: border-box;
  142. }
  143. .number:nth-child(n + 4) {
  144. border-top: 1px solid #999999;
  145. box-sizing: border-box;
  146. }
  147. .number:active {
  148. background: #04be02;
  149. color: #ffffff;
  150. border: 0px solid #000000;
  151. box-shadow: 0 0 2px 2px #09bb07;
  152. box-sizing: border-box;
  153. }
  154. .del {
  155. height: 140px;
  156. vertical-align: middle;
  157. line-height: 140px;
  158. border-bottom: 0.1px solid #999999;
  159. box-sizing: border-box;
  160. }
  161. .confirm {
  162. font-size: 15px;
  163. height: 140px;
  164. line-height: 140px;
  165. color: #ffffff;
  166. }
  167. }
  168. }
  169. </style>