index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <template>
  2. <view class="u-demo">
  3. <view class="u-demo-wrap">
  4. <view class="u-demo-title">演示效果</view>
  5. <view class="u-demo-area">
  6. <view class="input-wrap">
  7. <input class="input" disabled type="text" :value="input" placeholder="来自键盘的输入内容" />
  8. <u-button :custom-style="{height: '32px'}" :hairLine="false" class="clear-btn" @tap="input = ''">清空</u-button>
  9. </view>
  10. <u-keyboard :mask="mask" ref="uKeyboard" safe-area-inset-bottom @confirm="confirm"
  11. :random="random" :dotEnable="false" :mode="mode"
  12. :confirmBtn="true" :cancelBtn="true" :tooltip="tooltip" v-model="show"
  13. @change="change" @backspace="backspace"></u-keyboard>
  14. </view>
  15. </view>
  16. <view class="u-config-wrap">
  17. <view class="u-config-title u-border-bottom">
  18. 参数配置
  19. </view>
  20. <view class="u-config-item">
  21. <view class="u-item-title">键盘开关</view>
  22. <u-subsection :current="show == true ? 0 : 1" :list="['开', '关']" @change="statusChange"></u-subsection>
  23. </view>
  24. <view class="u-config-item">
  25. <view class="u-item-title">键盘类型</view>
  26. <u-subsection :list="['数字键盘', '身份证键盘', '车牌号键盘']" @change="modeChange"></u-subsection>
  27. </view>
  28. <view class="u-config-item">
  29. <view class="u-item-title">打乱顺序</view>
  30. <u-subsection :current="1" :list="['是', '否']" @change="randomChange"></u-subsection>
  31. </view>
  32. <view class="u-config-item">
  33. <view class="u-item-title">上方工具条</view>
  34. <u-subsection :list="['显示', '隐藏']" @change="tooltipChange"></u-subsection>
  35. </view>
  36. <view class="u-config-item">
  37. <view class="u-item-title">是否显示遮罩</view>
  38. <u-subsection :list="['显示', '隐藏']" @change="maskChange"></u-subsection>
  39. </view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. export default {
  45. data() {
  46. return {
  47. show: false,
  48. input: '',
  49. mode: 'number',
  50. random: false,
  51. tooltip: true,
  52. mask: true,
  53. }
  54. },
  55. methods: {
  56. statusChange(index) {
  57. this.show = index == 0 ? true : false;
  58. },
  59. modeChange(index) {
  60. if(index == 0) this.mode = 'number';
  61. if(index == 1) this.mode = 'card';
  62. if(index == 2) this.mode = 'car';
  63. this.show = true;
  64. },
  65. randomChange(index) {
  66. this.random = index == 0 ? true : false;
  67. this.show = true;
  68. },
  69. tooltipChange(index) {
  70. this.tooltip = index == 0 ? true : false;
  71. this.show = true;
  72. },
  73. maskChange(index) {
  74. this.show = true;
  75. this.mask = !index;
  76. },
  77. // 点击退格键
  78. backspace() {
  79. if(this.input.length) this.input = this.input.substr(0, this.input.length - 1);
  80. },
  81. // 键盘按键发生变化
  82. change(detail) {
  83. this.input += detail;
  84. },
  85. confirm(e) {
  86. }
  87. }
  88. }
  89. </script>
  90. <style lang="scss" scoped>
  91. .input {
  92. border: 1px solid $u-light-color;
  93. border-radius: 4px;
  94. margin-bottom: 20px;
  95. height: 32px;
  96. font-size: 26rpx;
  97. flex: 1;
  98. box-sizing: border-box;
  99. }
  100. .input-wrap {
  101. display: flex;
  102. }
  103. .clear-btn {
  104. margin-left: 10px;
  105. font-size: 28rpx;
  106. }
  107. </style>