graceNumberKeyboard.vue 3.2 KB

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