graceNumberKeyboard.vue 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <view>
  3. <view class="grace-mask" @tap.stop="masktap" @touchmove.stop.prevent="" v-if="show"></view>
  4. <view class="grace-keyboard" v-if="show">
  5. <view class="grace-keyboard-res" v-if="showInputRes"
  6. :style="{color:resultColor, fontSize:resultSize}">{{resVal}}</view>
  7. <view class="grace-keyboard-body">
  8. <view class="grace-keyboard-left">
  9. <view class="grace-keyboard-keys"
  10. v-for="(item, index) in [1,2,3,4,5,6,7,8,9]" :key="index"
  11. :data-keynumber="item" hover-class="keydown" hover-stay-time="100"
  12. @tap.stop="inputNow">{{item}}</view>
  13. <view class="grace-keyboard-keys"
  14. :style="{width:isPoint ? '259rpx':'538rpx'}" hover-class="keydown" hover-stay-time="100"
  15. data-keynumber="0" @tap.stop="inputNow">0</view>
  16. <view v-if="isPoint" class="grace-keyboard-keys"
  17. style="width:259rpx;" hover-class="keydown" hover-stay-time="100"
  18. data-keynumber="." @tap.stop="inputNow">.</view>
  19. </view>
  20. <view class="grace-keyboard-right">
  21. <view class="grace-keyboard-keys grace-keyboard-delete grace-icons"
  22. hover-class="keydown" hover-stay-time="100" @tap.stop="deleteNow"></view>
  23. <view class="grace-keyboard-keys grace-keyboard-done" @tap.stop="done"
  24. :style="{background:confirmBtnColor}">{{doneBtnName}}</view>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. export default {
  32. props: {
  33. show : { type : Boolean, default : false },
  34. doneBtnName : { type : String, default : "完成" },
  35. isPoint : { type : Boolean, default : true },
  36. showInputRes : {type : Boolean, default : true},
  37. value : {type:String, default:''},
  38. confirmBtnColor:{type:String, default:'#3688FF'},
  39. resultColor : {type:String, default:'#323232'},
  40. resultSize : {type:String, default:'32rpx'},
  41. closeByShade : {type:Boolean, default:true}
  42. },
  43. data() {
  44. return {
  45. resVal: ''
  46. }
  47. },
  48. created:function(){
  49. this.resVal = this.value+'';
  50. },
  51. methods: {
  52. inputNow : function (e){
  53. var k = e.currentTarget.dataset.keynumber;
  54. this.resVal += k+'';
  55. this.$emit('keyboardInput', k);
  56. },
  57. deleteNow : function (e){
  58. this.resVal = this.resVal.substring(0, this.resVal.length - 1);
  59. this.$emit('keyboardDelete');
  60. },
  61. done : function(e){
  62. this.$emit('keyboardDone');
  63. },
  64. setVal : function (val) {
  65. this.resVal = val;
  66. },
  67. masktap : function(){
  68. if(!this.closeByShade){return ;}
  69. this.done();
  70. }
  71. }
  72. }
  73. </script>
  74. <style scoped>
  75. .grace-mask{background:rgba(255, 255, 255, 0); position:fixed; width:100%; height:100%; left:0; top:0; z-index:1;}
  76. .grace-keyboard{background:#F4F5F6; position:fixed; width:100%; height:auto; left:0; bottom:0; z-index:3;}
  77. .grace-keyboard-body{display:flex; flex-direction:row; justify-content:space-between; padding:10px 0;}
  78. .grace-keyboard-left{width:560rpx; display:flex; flex-direction:row; flex-wrap:wrap; justify-content:space-between;}
  79. .grace-keyboard-right{width:188rpx; display:flex; flex-direction:column; justify-content:space-between;}
  80. .grace-keyboard-keys{width:166rpx; height:100rpx; margin:10rpx; background:#FFFFFF; text-align:center; line-height:100rpx; border-radius:8rpx; font-weight:700; font-size:50rpx;}
  81. .grace-keyboard-done{height:340rpx !important; line-height:340rpx !important; font-size:36rpx !important; font-weight:400 !important; color:#FFFFFF !important;}
  82. .grace-keyboard-delete{font-family:"grace-iconfont";}
  83. .grace-keyboard-delete:before{content:"\e623";}
  84. .keydown{background:#3688FF !important; color:#FFFFFF !important;}
  85. .grace-keyboard-res{line-height:60rpx; text-align:center; font-size:32rpx; font-weight:bold; padding-top:20rpx;}
  86. </style>