u-car-keyboard.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. "use strict";
  2. const common_vendor = require("../../../../common/vendor.js");
  3. const _sfc_main = {
  4. name: "u-car-keyboard",
  5. mixins: [common_vendor.mpMixin, common_vendor.mixin, common_vendor.props$29],
  6. data() {
  7. return {
  8. // 车牌输入时,abc=true为输入车牌号码,bac=false为输入省份中文简称
  9. abc: false
  10. };
  11. },
  12. computed: {
  13. areaList() {
  14. let data = [
  15. "京",
  16. "沪",
  17. "粤",
  18. "津",
  19. "冀",
  20. "豫",
  21. "云",
  22. "辽",
  23. "黑",
  24. "湘",
  25. "皖",
  26. "鲁",
  27. "苏",
  28. "浙",
  29. "赣",
  30. "鄂",
  31. "桂",
  32. "甘",
  33. "晋",
  34. "陕",
  35. "蒙",
  36. "吉",
  37. "闽",
  38. "贵",
  39. "渝",
  40. "川",
  41. "青",
  42. "琼",
  43. "宁",
  44. "挂",
  45. "藏",
  46. "港",
  47. "澳",
  48. "新",
  49. "使",
  50. "学"
  51. ];
  52. let tmp = [];
  53. if (this.random)
  54. data = common_vendor.randomArray(data);
  55. tmp[0] = data.slice(0, 10);
  56. tmp[1] = data.slice(10, 20);
  57. tmp[2] = data.slice(20, 30);
  58. tmp[3] = data.slice(30, 36);
  59. return tmp;
  60. },
  61. engKeyBoardList() {
  62. let data = [
  63. 1,
  64. 2,
  65. 3,
  66. 4,
  67. 5,
  68. 6,
  69. 7,
  70. 8,
  71. 9,
  72. 0,
  73. "Q",
  74. "W",
  75. "E",
  76. "R",
  77. "T",
  78. "Y",
  79. "U",
  80. "I",
  81. "O",
  82. "P",
  83. "A",
  84. "S",
  85. "D",
  86. "F",
  87. "G",
  88. "H",
  89. "J",
  90. "K",
  91. "L",
  92. "Z",
  93. "X",
  94. "C",
  95. "V",
  96. "B",
  97. "N",
  98. "M"
  99. ];
  100. let tmp = [];
  101. if (this.random)
  102. data = common_vendor.randomArray(data);
  103. tmp[0] = data.slice(0, 10);
  104. tmp[1] = data.slice(10, 20);
  105. tmp[2] = data.slice(20, 30);
  106. tmp[3] = data.slice(30, 36);
  107. return tmp;
  108. }
  109. },
  110. emits: ["change", "backspace"],
  111. methods: {
  112. // 点击键盘按钮
  113. carInputClick(i, j) {
  114. let value = "";
  115. if (this.abc)
  116. value = this.engKeyBoardList[i][j];
  117. else
  118. value = this.areaList[i][j];
  119. if (!this.abc && this.autoChange)
  120. common_vendor.sleep(200).then(() => this.abc = true);
  121. this.$emit("change", value);
  122. },
  123. // 修改汽车牌键盘的输入模式,中文|英文
  124. changeCarInputMode() {
  125. this.abc = !this.abc;
  126. },
  127. // 点击退格键
  128. backspaceClick() {
  129. this.$emit("backspace");
  130. clearInterval(this.timer);
  131. this.timer = null;
  132. this.timer = setInterval(() => {
  133. this.$emit("backspace");
  134. }, 250);
  135. },
  136. clearTimer() {
  137. clearInterval(this.timer);
  138. this.timer = null;
  139. }
  140. }
  141. };
  142. if (!Array) {
  143. const _easycom_u_icon2 = common_vendor.resolveComponent("u-icon");
  144. _easycom_u_icon2();
  145. }
  146. const _easycom_u_icon = () => "../u-icon/u-icon.js";
  147. if (!Math) {
  148. _easycom_u_icon();
  149. }
  150. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  151. return {
  152. a: common_vendor.f($data.abc ? $options.engKeyBoardList : $options.areaList, (group, i, i0) => {
  153. return common_vendor.e({
  154. a: i === 3
  155. }, i === 3 ? {
  156. b: common_vendor.n(!$data.abc && "u-keyboard__button__inner-wrapper__left__lang--active"),
  157. c: common_vendor.n($data.abc && "u-keyboard__button__inner-wrapper__left__lang--active"),
  158. d: common_vendor.o((...args) => $options.changeCarInputMode && $options.changeCarInputMode(...args), i)
  159. } : {}, {
  160. e: common_vendor.f(group, (item, j, i1) => {
  161. return {
  162. a: common_vendor.t(item),
  163. b: common_vendor.o(($event) => $options.carInputClick(i, j), j),
  164. c: j
  165. };
  166. }),
  167. f: i === 3
  168. }, i === 3 ? {
  169. g: "1eba9919-0-" + i0,
  170. h: common_vendor.p({
  171. size: "28",
  172. name: "backspace",
  173. color: "#303133"
  174. }),
  175. i: common_vendor.o((...args) => $options.backspaceClick && $options.backspaceClick(...args), i),
  176. j: common_vendor.o((...args) => $options.clearTimer && $options.clearTimer(...args), i)
  177. } : {}, {
  178. k: i,
  179. l: i,
  180. m: common_vendor.n(i + 1 === 4 && "u-keyboard__button--center")
  181. });
  182. }),
  183. b: common_vendor.o((...args) => _ctx.noop && _ctx.noop(...args))
  184. };
  185. }
  186. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-1eba9919"], ["__file", "C:/Users/Administrator/Desktop/srcaaa/node_modules/uview-plus/components/u-car-keyboard/u-car-keyboard.vue"]]);
  187. wx.createComponent(Component);