keyboard-package.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <template>
  2. <uni-popup :custom="true" type="bottom" ref="keyboardPackage">
  3. <view class="keyboardbox">
  4. <view class="numkeyboard" v-if="type==='number'">
  5. <view class="num-area">
  6. <view class="row" v-for="(item,index) in numKeybordList" :key="index">
  7. <view :class="['item',ite===0?'z':'',(disableDot && ite==='.')?'disabled':'']"
  8. v-for="(ite,idx) in item"
  9. hover-class="active" :hover-start-time="0" :hover-stay-time="5" :key="idx"
  10. @tap="input(ite)">{{ite}}
  11. </view>
  12. </view>
  13. </view>
  14. <view class="btn-area">
  15. <view :class="['item','del']" hover-class="active" :hover-start-time="0" :hover-stay-time="5"
  16. @tap="deleteVal">
  17. 删除
  18. </view>
  19. <view class="confirem item" hover-class="active" :hover-start-time="0" :hover-stay-time="5"
  20. @tap="confirm">
  21. 完成
  22. </view>
  23. </view>
  24. </view>
  25. <view class="numkeyboard" v-if="type==='idCard'">
  26. <view class="num-area">
  27. <view class="row" v-for="(item,index) in idCardList" :key="index">
  28. <view :class="['item',ite===0?'z':'',(disableDot && ite==='.')?'disabled':'']"
  29. v-for="(ite,idx) in item"
  30. hover-class="active" :hover-start-time="0" :hover-stay-time="5" :key="idx"
  31. @tap="input(ite)">{{ite}}
  32. </view>
  33. </view>
  34. </view>
  35. <view class="btn-area">
  36. <view :class="['item','del']" hover-class="active" :hover-start-time="0" :hover-stay-time="5"
  37. @tap="deleteVal">
  38. 删除
  39. </view>
  40. <view class="confirem item" hover-class="active" :hover-start-time="0" :hover-stay-time="5"
  41. @tap="confirm">
  42. 完成
  43. </view>
  44. </view>
  45. </view>
  46. <view class="platenumber" v-if="type==='plateNumber'">
  47. <view class="header">
  48. <view @tap="active=active===1?2:1" hover-class="active" :hover-start-time="0" :hover-stay-time="5">
  49. {{active===1?'地区':'车牌号'}}
  50. </view>
  51. <view hover-class="active" :hover-start-time="0" :hover-stay-time="5" @tap="confirm">完成</view>
  52. </view>
  53. <view class="main">
  54. <view class="normal" v-show="active===1">
  55. <view class="row" v-for="(item,index) in EngKeyBoardList" :key="index">
  56. <view class="item" v-for="(ite,idx) in item" :key="idx" hover-class="active"
  57. :hover-start-time="0" :hover-stay-time="5" @tap="input(ite)">
  58. {{ite}}
  59. </view>
  60. <view class="item img" v-if="index===EngKeyBoardList.length-1" hover-class="active"
  61. :hover-start-time="0" :hover-stay-time="5" @tap="deleteVal">
  62. <image src="/static/delete.png" mode=""></image>
  63. </view>
  64. </view>
  65. </view>
  66. <view class="area" v-show="active===2">
  67. <view class="row" v-for="(item,index) in areaList" :key="index">
  68. <view class="item" v-for="(ite,idx) in item" :key="idx" hover-class="active"
  69. :hover-start-time="0" :hover-stay-time="5" @tap="input(ite)">
  70. {{ite}}
  71. </view>
  72. <view class="item img" v-if="index===EngKeyBoardList.length-1" hover-class="active"
  73. :hover-start-time="0" :hover-stay-time="5" @tap="deleteVal">
  74. <image src="/static/delete.png" mode=""></image>
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. </view>
  80. </view>
  81. <view class="safe-area" v-if="safeAreaInsetBottom"></view>
  82. </uni-popup>
  83. </template>
  84. <script>
  85. import uniPopup from "@/components/uni-popup/uni-popup.vue"
  86. export default {
  87. components: {
  88. uniPopup
  89. },
  90. props: {
  91. type: {
  92. type: String,
  93. default: 'number'
  94. },
  95. safeAreaInsetBottom: { //是否设置安全区
  96. type: Boolean,
  97. default: false
  98. },
  99. disableDot: { //数字键盘是否禁止点击.仅type为number生效
  100. type: Boolean,
  101. default: false
  102. }
  103. },
  104. data() {
  105. return {
  106. numKeybordList: [
  107. [1, 2, 3],
  108. [4, 5, 6],
  109. [7, 8, 9],
  110. [0, '.']
  111. ],
  112. idCardList: [
  113. [1, 2, 3],
  114. [4, 5, 6],
  115. [7, 8, 9],
  116. [0, 'X']
  117. ],
  118. areaList: [
  119. ['京', '沪', '粤', '津', '冀', '豫', '云', '辽', '黑', '湘'],
  120. ['皖', '鲁', '苏', '浙', '赣', '鄂', '桂', '甘', '晋', '陕'],
  121. ['蒙', '吉', '闽', '贵', '渝', '川', '青', '琼', '宁'],
  122. ['藏', '新', '使', '港', '澳', '学']
  123. ],
  124. EngKeyBoardList: [
  125. [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],
  126. ['Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P'],
  127. ['A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L'],
  128. ['Z', 'X', 'C', 'V', 'B', 'N', 'M']
  129. ],
  130. active: 2
  131. };
  132. },
  133. methods: {
  134. open() {
  135. this.$refs.keyboardPackage.open();
  136. },
  137. confirm() {
  138. this.close();
  139. this.$emit('onConfirm');
  140. },
  141. deleteVal() {
  142. this.$emit('onDelete');
  143. },
  144. input(val) {
  145. if (val === '.' && this.disableDot) return;
  146. this.$emit('onInput', val);
  147. if (this.active === 2) {
  148. this.active = 1;
  149. }
  150. },
  151. close() {
  152. this.$refs.keyboardPackage.close();
  153. }
  154. }
  155. }
  156. </script>
  157. <style lang="scss" scoped>
  158. .keyboardbox {
  159. background-color: #FFFFFF;
  160. .numkeyboard {
  161. height: 432 rpx;
  162. display: flex;
  163. background-color: #ebedf0;
  164. .btn-area {
  165. width: 180 rpx;
  166. height: 100%;
  167. display: flex;
  168. flex-direction: column;
  169. .item {
  170. width: 100%;
  171. display: flex;
  172. justify-content: center;
  173. align-items: center;
  174. flex-grow: 1;
  175. }
  176. .del {
  177. background-color: #ebedf0;
  178. color: #333;
  179. &.active {
  180. background-color: #f1f3f5;
  181. }
  182. }
  183. .confirem {
  184. background-color: $base-color;
  185. color: #FFFFFF;
  186. &.active {
  187. background-color: #0570db;
  188. }
  189. }
  190. }
  191. .num-area {
  192. flex-grow: 1;
  193. display: flex;
  194. flex-wrap: wrap;
  195. .row {
  196. width: 100%;
  197. height: 25%;
  198. display: flex;
  199. margin-top: 1px;
  200. .item {
  201. flex-grow: 1;
  202. height: 100%;
  203. display: flex;
  204. justify-content: center;
  205. align-items: center;
  206. background-color: #FFFFFF;
  207. border-right: 1px solid #ebedf0;
  208. width: 33.33%;
  209. &.active {
  210. background-color: #ebedf0;
  211. }
  212. &.z {
  213. flex-grow: 2;
  214. width: 66.66%;
  215. }
  216. &.disabled {
  217. background: #FFFFFF;
  218. color: #B9B9B9;
  219. }
  220. }
  221. }
  222. }
  223. }
  224. }
  225. .safe-area {
  226. padding-bottom: 0 rpx;
  227. padding-bottom: constant(safe-area-inset-bottom);
  228. padding-bottom: env(safe-area-inset-bottom);
  229. }
  230. .platenumber {
  231. background-color: #f5f5f5;
  232. .header {
  233. height: 76 rpx;
  234. background-color: #FFFFFF;
  235. display: flex;
  236. justify-content: space-between;
  237. align-items: center;
  238. font-size: 28 rpx;
  239. border-top: 1px solid #f5f5f5;
  240. & > view {
  241. padding: 0 45 rpx;
  242. color: $base-color;
  243. height: 100%;
  244. display: flex;
  245. align-items: center;
  246. &.active {
  247. background-color: #ebedf0;
  248. }
  249. }
  250. }
  251. .main {
  252. height: 435 rpx;
  253. .row {
  254. margin: 13 rpx 0;
  255. display: flex;
  256. justify-content: center;
  257. align-items: center;
  258. .item {
  259. width: 56 rpx;
  260. height: 94 rpx;
  261. display: flex;
  262. justify-content: center;
  263. align-items: center;
  264. background-color: #FFFFFF;
  265. border-radius: 6 rpx;
  266. margin: 0 7 rpx;
  267. font-size: 24 rpx;
  268. &.active {
  269. background-color: #ebedf0;
  270. }
  271. &.img {
  272. background-color: #c2cacc;
  273. width: 94 rpx;
  274. &.active {
  275. background-color: #ddd;
  276. }
  277. & > image {
  278. width: 49 rpx;
  279. height: 48 rpx;
  280. }
  281. }
  282. }
  283. }
  284. }
  285. }
  286. </style>