keyboard.uvue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <cl-page>
  3. <view class="p-3">
  4. <demo-item :label="t('数字键盘')">
  5. <view class="mb-3 overflow-visible">
  6. <cl-input type="number" v-model="content"></cl-input>
  7. </view>
  8. <cl-button @tap="openKeyboardNumber">{{ t("打开键盘") }}</cl-button>
  9. <cl-list
  10. border
  11. :pt="{
  12. className: 'mt-3'
  13. }"
  14. >
  15. <cl-list-item :label="t('是否显示输入值')">
  16. <cl-switch v-model="isShowValue"></cl-switch>
  17. </cl-list-item>
  18. <cl-list-item :label="t('输入即绑定')">
  19. <cl-switch v-model="isInputImmediate"></cl-switch>
  20. </cl-list-item>
  21. <cl-list-item :label="t('身份证键盘')">
  22. <cl-switch v-model="isIdcard"></cl-switch>
  23. </cl-list-item>
  24. </cl-list>
  25. </demo-item>
  26. <demo-item :label="t('密码键盘')">
  27. <cl-button @tap="openKeyboardPassword">{{ t("打开键盘") }}</cl-button>
  28. <cl-list
  29. border
  30. :pt="{
  31. className: 'mt-3'
  32. }"
  33. >
  34. <cl-list-item :label="t('是否加密')">
  35. <cl-switch v-model="isEncrypt"></cl-switch>
  36. </cl-list-item>
  37. </cl-list>
  38. </demo-item>
  39. <demo-item :label="t('车牌号键盘')">
  40. <view class="flex mb-3 justify-center flex-row overflow-visible">
  41. <cl-input-otp
  42. input-type="text"
  43. :length="8"
  44. :pt="{
  45. className: 'w-full',
  46. list: {
  47. className: 'justify-between'
  48. },
  49. item: {
  50. className: '!h-9 !w-9'
  51. },
  52. cursor: {
  53. className: '!h-3'
  54. }
  55. }"
  56. v-model="carNumber"
  57. ></cl-input-otp>
  58. </view>
  59. <cl-button @tap="openKeyboardCar">{{ t("打开键盘") }}</cl-button>
  60. </demo-item>
  61. </view>
  62. <cl-keyboard-number
  63. v-model="content"
  64. ref="keyboardNumberRef"
  65. :show-value="isShowValue"
  66. :input-immediate="isInputImmediate"
  67. :type="isIdcard ? 'idcard' : 'number'"
  68. ></cl-keyboard-number>
  69. <cl-keyboard-car v-model="carNumber" ref="keyboardCarRef"></cl-keyboard-car>
  70. <cl-keyboard-password ref="keyboardPasswordRef" :encrypt="isEncrypt"></cl-keyboard-password>
  71. </cl-page>
  72. </template>
  73. <script lang="ts" setup>
  74. import { ref } from "vue";
  75. import DemoItem from "../components/item.uvue";
  76. import { t } from "@/locale";
  77. const keyboardNumberRef = ref<ClKeyboardNumberComponentPublicInstance | null>(null);
  78. const isShowValue = ref(true);
  79. const isInputImmediate = ref(false);
  80. const isIdcard = ref(false);
  81. const content = ref("");
  82. function openKeyboardNumber() {
  83. keyboardNumberRef.value!.open();
  84. }
  85. const keyboardPasswordRef = ref<ClKeyboardPasswordComponentPublicInstance | null>(null);
  86. const isEncrypt = ref(false);
  87. function openKeyboardPassword() {
  88. keyboardPasswordRef.value!.open();
  89. }
  90. const keyboardCarRef = ref<ClKeyboardCarComponentPublicInstance | null>(null);
  91. const carNumber = ref("");
  92. function openKeyboardCar() {
  93. keyboardCarRef.value!.open();
  94. }
  95. </script>