AI营销辅助 普强使用
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 

255 行
4.9 KiB

  1. <template>
  2. <view class="u-keyboard" @touchmove.stop.prevent>
  3. <view class="u-keyboard-grids">
  4. <block>
  5. <view class="u-keyboard-grids-item" v-for="(group, i) in abc ? EngKeyBoardList : areaList" :key="i">
  6. <view :hover-stay-time="100" @tap="carInputClick(i, j)" hover-class="u-carinput-hover" class="u-keyboard-grids-btn"
  7. v-for="(item, j) in group" :key="j">
  8. {{ item }}
  9. </view>
  10. </view>
  11. <view @touchstart="backspaceClick" @touchend="clearTimer" :hover-stay-time="100" class="u-keyboard-back"
  12. hover-class="u-hover-class">
  13. <u-icon :size="38" name="backspace" :bold="true"></u-icon>
  14. </view>
  15. <view :hover-stay-time="100" class="u-keyboard-change" hover-class="u-carinput-hover" @tap="changeCarInputMode">
  16. <text class="zh" :class="[!abc ? 'active' : 'inactive']">中</text>
  17. /
  18. <text class="en" :class="[abc ? 'active' : 'inactive']">英</text>
  19. </view>
  20. </block>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. name: "u-keyboard",
  27. props: {
  28. // 是否打乱键盘按键的顺序
  29. random: {
  30. type: Boolean,
  31. default: false
  32. }
  33. },
  34. data() {
  35. return {
  36. // 车牌输入时,abc=true为输入车牌号码,bac=false为输入省份中文简称
  37. abc: false
  38. };
  39. },
  40. computed: {
  41. areaList() {
  42. let data = [
  43. '京',
  44. '沪',
  45. '粤',
  46. '津',
  47. '冀',
  48. '豫',
  49. '云',
  50. '辽',
  51. '黑',
  52. '湘',
  53. '皖',
  54. '鲁',
  55. '苏',
  56. '浙',
  57. '赣',
  58. '鄂',
  59. '桂',
  60. '甘',
  61. '晋',
  62. '陕',
  63. '蒙',
  64. '吉',
  65. '闽',
  66. '贵',
  67. '渝',
  68. '川',
  69. '青',
  70. '琼',
  71. '宁',
  72. '挂',
  73. '藏',
  74. '港',
  75. '澳',
  76. '新',
  77. '使',
  78. '学'
  79. ];
  80. let tmp = [];
  81. // 打乱顺序
  82. if (this.random) data = this.$u.randomArray(data);
  83. // 切割成二维数组
  84. tmp[0] = data.slice(0, 10);
  85. tmp[1] = data.slice(10, 20);
  86. tmp[2] = data.slice(20, 30);
  87. tmp[3] = data.slice(30, 36);
  88. return tmp;
  89. },
  90. EngKeyBoardList() {
  91. let data = [
  92. 1,
  93. 2,
  94. 3,
  95. 4,
  96. 5,
  97. 6,
  98. 7,
  99. 8,
  100. 9,
  101. 0,
  102. 'Q',
  103. 'W',
  104. 'E',
  105. 'R',
  106. 'T',
  107. 'Y',
  108. 'U',
  109. 'I',
  110. 'O',
  111. 'P',
  112. 'A',
  113. 'S',
  114. 'D',
  115. 'F',
  116. 'G',
  117. 'H',
  118. 'J',
  119. 'K',
  120. 'L',
  121. 'Z',
  122. 'X',
  123. 'C',
  124. 'V',
  125. 'B',
  126. 'N',
  127. 'M'
  128. ];
  129. let tmp = [];
  130. if (this.random) data = this.$u.randomArray(data);
  131. tmp[0] = data.slice(0, 10);
  132. tmp[1] = data.slice(10, 20);
  133. tmp[2] = data.slice(20, 30);
  134. tmp[3] = data.slice(30, 36);
  135. return tmp;
  136. }
  137. },
  138. methods: {
  139. // 点击键盘按钮
  140. carInputClick(i, j) {
  141. let value = '';
  142. // 不同模式,获取不同数组的值
  143. if (this.abc) value = this.EngKeyBoardList[i][j];
  144. else value = this.areaList[i][j];
  145. this.$emit('change', value);
  146. },
  147. // 修改汽车牌键盘的输入模式,中文|英文
  148. changeCarInputMode() {
  149. this.abc = !this.abc;
  150. },
  151. // 点击退格键
  152. backspaceClick() {
  153. this.$emit('backspace');
  154. clearInterval(this.timer); //再次清空定时器,防止重复注册定时器
  155. this.timer = null;
  156. this.timer = setInterval(() => {
  157. this.$emit('backspace');
  158. }, 250);
  159. },
  160. clearTimer() {
  161. clearInterval(this.timer);
  162. this.timer = null;
  163. },
  164. }
  165. };
  166. </script>
  167. <style lang="scss" scoped>
  168. @import "../../libs/css/style.components.scss";
  169. .u-keyboard-grids {
  170. background: rgb(215, 215, 217);
  171. padding: 24rpx 0;
  172. position: relative;
  173. }
  174. .u-keyboard-grids-item {
  175. display: flex;
  176. align-items: center;
  177. justify-content: center;
  178. }
  179. .u-keyboard-grids-btn {
  180. text-decoration: none;
  181. width: 62rpx;
  182. flex: 0 0 64rpx;
  183. height: 80rpx;
  184. display: inline-block;
  185. font-size: 36rpx;
  186. text-align: center;
  187. line-height: 80rpx;
  188. background-color: #fff;
  189. margin: 8rpx 5rpx;
  190. border-radius: 8rpx;
  191. box-shadow: 0 2rpx 0rpx #888992;
  192. font-weight: 500;
  193. }
  194. .u-carinput-hover {
  195. background-color: rgb(185, 188, 195) !important;
  196. }
  197. .u-keyboard-back {
  198. position: absolute;
  199. width: 96rpx;
  200. right: 22rpx;
  201. bottom: 32rpx;
  202. height: 80rpx;
  203. background-color: rgb(185, 188, 195);
  204. display: flex;
  205. align-items: center;
  206. border-radius: 8rpx;
  207. justify-content: center;
  208. box-shadow: 0 2rpx 0rpx #888992;
  209. }
  210. .u-keyboard-change {
  211. font-size: 24rpx;
  212. box-shadow: 0 2rpx 0rpx #888992;
  213. position: absolute;
  214. width: 96rpx;
  215. left: 22rpx;
  216. line-height: 1;
  217. bottom: 32rpx;
  218. height: 80rpx;
  219. background-color: #ffffff;
  220. display: flex;
  221. align-items: center;
  222. border-radius: 8rpx;
  223. justify-content: center;
  224. }
  225. .u-keyboard-change .inactive.zh {
  226. transform: scale(0.85) translateY(-10rpx);
  227. }
  228. .u-keyboard-change .inactive.en {
  229. transform: scale(0.85) translateY(10rpx);
  230. }
  231. .u-keyboard-change .active {
  232. color: rgb(237, 112, 64);
  233. font-size: 30rpx;
  234. }
  235. .u-keyboard-change .zh {
  236. transform: translateY(-10rpx);
  237. }
  238. .u-keyboard-change .en {
  239. transform: translateY(10rpx);
  240. }
  241. </style>