keyboard-package.vue 7.1 KB

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