keyboard-package.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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-if="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-if="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: 1
  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. },
  132. close() {
  133. this.$refs.keyboardPackage.close();
  134. }
  135. }
  136. }
  137. </script>
  138. <style lang="scss" scoped>
  139. .keyboardbox {
  140. background-color: #FFFFFF;
  141. .numkeyboard {
  142. height: 432rpx;
  143. display: flex;
  144. background-color: #ebedf0;
  145. .btn-area {
  146. width: 180rpx;
  147. height: 100%;
  148. display: flex;
  149. flex-direction: column;
  150. .item {
  151. width: 100%;
  152. display: flex;
  153. justify-content: center;
  154. align-items: center;
  155. flex-grow: 1;
  156. }
  157. .del {
  158. background-color: #ebedf0;
  159. color: #333;
  160. &.active {
  161. background-color: #f1f3f5;
  162. }
  163. }
  164. .confirem {
  165. background: linear-gradient(151deg,rgba(255,154,22,1) 0%,rgba(235,109,22,1) 66%,rgba(225,86,22,1) 100%);
  166. color: #FFFFFF;
  167. &.active {
  168. background-color: #0570db;
  169. }
  170. }
  171. }
  172. .num-area {
  173. flex-grow: 1;
  174. display: flex;
  175. flex-wrap: wrap;
  176. .row {
  177. width: 100%;
  178. height: 25%;
  179. display: flex;
  180. margin-top: 1px;
  181. .item {
  182. flex-grow: 1;
  183. height: 100%;
  184. display: flex;
  185. justify-content: center;
  186. align-items: center;
  187. background-color: #FFFFFF;
  188. border-right: 1px solid #ebedf0;
  189. width: 33.33%;
  190. &.active {
  191. background-color: #ebedf0;
  192. }
  193. &.z {
  194. flex-grow: 2;
  195. width: 66.66%;
  196. }
  197. &.disabled {
  198. background: #FFFFFF;
  199. color: #B9B9B9;
  200. }
  201. }
  202. }
  203. }
  204. }
  205. }
  206. .safe-area {
  207. padding-bottom: 0rpx;
  208. padding-bottom: constant(safe-area-inset-bottom);
  209. padding-bottom: env(safe-area-inset-bottom);
  210. }
  211. .platenumber {
  212. background-color: #f5f5f5;
  213. .header {
  214. height: 76rpx;
  215. background-color: #FFFFFF;
  216. display: flex;
  217. justify-content: space-between;
  218. align-items: center;
  219. font-size: 28rpx;
  220. border-top: 1px solid #f5f5f5;
  221. &>view {
  222. padding: 0 45rpx;
  223. color: #00a7ea;
  224. height: 100%;
  225. display: flex;
  226. align-items: center;
  227. &.active {
  228. background-color: #ebedf0;
  229. }
  230. }
  231. }
  232. .main {
  233. height: 435rpx;
  234. .row {
  235. margin: 13rpx 0;
  236. display: flex;
  237. justify-content: center;
  238. align-items: center;
  239. .item {
  240. width: 56rpx;
  241. height: 94rpx;
  242. display: flex;
  243. justify-content: center;
  244. align-items: center;
  245. background-color: #FFFFFF;
  246. border-radius: 6rpx;
  247. margin: 0 7rpx;
  248. font-size: 24rpx;
  249. &.active {
  250. background-color: #ebedf0;
  251. }
  252. &.img {
  253. background-color: #c2cacc;
  254. width: 94rpx;
  255. &.active {
  256. background-color: #ddd;
  257. }
  258. &>image {
  259. width: 49rpx;
  260. height: 48rpx;
  261. }
  262. }
  263. }
  264. }
  265. }
  266. }
  267. </style>