gui-car-number.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <gui-popup
  3. ref="guipopupforcarnumber"
  4. width="750rpx"
  5. position="bottom"
  6. @close="close"
  7. :canCloseByShade="true">
  8. <view
  9. @tap.stop.prevent="stopfun"
  10. class="gui-bg-white">
  11. <view
  12. class="gui-flex gui-rows gui-space-between gui-align-items-center"
  13. style="padding:20rpx;">
  14. <!-- 类型 -->
  15. <view style="width:320rpx;">
  16. <gui-segmented-control
  17. :items="['普通车牌','新能源牌']"
  18. :current="carType"
  19. @change="changeType"></gui-segmented-control>
  20. </view>
  21. <text class="gui-car-number-submit gui-block-text gui-color-blue"
  22. @tap="confirm">确定</text>
  23. </view>
  24. <!-- 车牌展示 -->
  25. <view
  26. class="gui-flex gui-rows gui-nowrap gui-justify-content-center"
  27. style="padding-top:20rpx; padding-bottom:20rpx;">
  28. <text class="gui-car-number-item gui-block-text"
  29. :class="[
  30. idx == inputIndex ? 'gui-bg-blue' : '',
  31. idx == inputIndex ? 'gui-a-shade' : ''
  32. ]"
  33. v-for="(item, idx) in carNumberArray" :key="idx"
  34. @tap="numberTap(idx)">{{item}}</text>
  35. </view>
  36. <!-- 错误信息 -->
  37. <view
  38. v-if="errorshow"
  39. style="padding:20rpx; margin-bottom:10rpx;">
  40. <text class="gui-text gui-block-text gui-color-red gui-text-center">请输入完整车牌号码</text>
  41. </view>
  42. <view class="gui-bg-gray"
  43. style="padding:15rpx;">
  44. <!-- 省份前缀键盘 -->
  45. <view class="gui-flex gui-rows gui-wrap"
  46. v-if="inputIndex == 0">
  47. <view class="gui-car-number-key"
  48. hover-class="gui-bg-blue"
  49. :hover-stay-time="50"
  50. v-for="(item, idx) in provinces"
  51. :key="idx"
  52. @tap="provinceTap(item)">
  53. <text class="gui-car-number-key-txt gui-block-text">{{item}}</text>
  54. </view>
  55. </view>
  56. <!-- 号码键盘 -->
  57. <view class="gui-flex gui-rows gui-wrap gui-space-between"
  58. v-else>
  59. <view class="gui-car-number-key"
  60. hover-class="gui-kd-tap"
  61. :hover-stay-time="50"
  62. v-for="(item, idx) in keyWords"
  63. :key="idx"
  64. @tap="keyTap(item)">
  65. <text class="gui-car-number-key-txt gui-block-text">{{item}}</text>
  66. </view>
  67. <view class="gui-car-number-key"
  68. hover-class="gui-kd-tap"
  69. @tap="deleteNumber">
  70. <text class="gui-car-number-key-txt gui-block-text gui-icons">&#xe623;</text>
  71. </view>
  72. </view>
  73. </view>
  74. <gui-iphone-bottom></gui-iphone-bottom>
  75. </view>
  76. </gui-popup>
  77. </template>
  78. <script>
  79. export default{
  80. name : "gui-car-number",
  81. props : {},
  82. data() {
  83. return {
  84. carNumber : '',
  85. carNumberArray : [],
  86. carType : 0,
  87. inputIndex : 0,
  88. provinces : ['京','津','沪','渝','冀','豫','云',
  89. '辽','黑','湘','皖','鲁','新','苏',
  90. '浙','赣','鄂','桂','甘','晋','蒙',
  91. '陕','吉','闽','贵','粤','青','藏',
  92. '川','宁','琼','使','领','新'
  93. ],
  94. keyWords : ['1','2','3','4','5','6','7','8','9','0',
  95. 'A','B','C','D','E','F','G','H',
  96. 'J','K','L','M','N','P','Q','R',
  97. 'S','T','U','V','W','X','Y','Z',
  98. '港','澳','学','领','警'],
  99. errorshow : false
  100. }
  101. },
  102. mounted:function(){
  103. this.showNumber();
  104. },
  105. methods:{
  106. showError : function () {
  107. this.errorshow = true;
  108. setTimeout(()=>{this.errorshow = false},2000)
  109. },
  110. confirm : function () {
  111. let carNumberLength = this.carType == 0 ? 7 : 8;
  112. if(this.carNumber.length < carNumberLength){
  113. this.showError();
  114. return ;
  115. }
  116. this.$emit('confirm', this.carNumber);
  117. this.$refs.guipopupforcarnumber.close();
  118. },
  119. numberTap : function (idx) {
  120. this.inputIndex = idx
  121. },
  122. provinceTap : function(key){
  123. this.carNumberArray[0] = key;
  124. this.carNumber = this.carNumberArray.join('');
  125. this.showNumber();
  126. },
  127. keyTap : function(key){
  128. let carNumberLength = this.carType == 0 ? 7 : 8;
  129. if(this.inputIndex >= carNumberLength){return ;}
  130. this.carNumberArray[this.inputIndex] = key;
  131. this.carNumber = this.carNumberArray.join('');
  132. this.showNumber();
  133. },
  134. showNumber : function(){
  135. let carNumberArray = this.carNumber.split('');
  136. let carNumberLength = this.carType == 0 ? 7 : 8;
  137. let carNumberArrLength = carNumberArray.length;
  138. this.carNumberArray = [];
  139. var inputIndex = 0;
  140. for(let i = 0; i < carNumberLength; i++){
  141. if(carNumberArrLength > i){
  142. this.carNumberArray[i] = carNumberArray[i];
  143. inputIndex++;
  144. }else{
  145. this.carNumberArray[i] = '';
  146. }
  147. }
  148. this.carNumber = this.carNumberArray.join('');
  149. this.inputIndex = inputIndex;
  150. },
  151. changeType : function(e){
  152. this.carType = e;
  153. this.showNumber();
  154. },
  155. setType : function(carType){
  156. this.carType = carType;
  157. this.showNumber();
  158. },
  159. setVal : function(carNumber){
  160. this.carNumber = carNumber;
  161. this.showNumber();
  162. },
  163. deleteNumber : function(){
  164. if(this.inputIndex < 0){return ;}
  165. this.carNumberArray.splice((this.inputIndex -1), 1, '');
  166. this.carNumber = this.carNumberArray.join('');
  167. this.showNumber();
  168. },
  169. open : function(){
  170. this.$refs.guipopupforcarnumber.open();
  171. this.$emit('open');
  172. },
  173. stopfun : function(e){
  174. e.stopPropagation();
  175. return ;
  176. },
  177. close : function(){
  178. this.$emit('close');
  179. }
  180. }
  181. }
  182. </script>
  183. <style scoped>
  184. .gui-car-number-item{width:70rpx; height:70rpx; font-size:30rpx; line-height:70rpx; text-align:center; border:1px solid #CECECE; border-radius:6rpx; margin-right:15rpx; font-weight:700;}
  185. .gui-car-number-key{width:76rpx; height:76rpx; border:1px solid #CECECE; border-radius:6rpx; margin:5rpx;}
  186. .gui-car-number-key-txt{font-size:30rpx; line-height:76rpx; text-align:center;}
  187. .gui-car-number-submit{width:100rpx; line-height:60rpx; text-align:center; font-size:30rpx;}
  188. .gui-bg-blue{color:#FFFFFF; border-color: #008AFF;}
  189. /* #ifndef APP-NVUE */
  190. @keyframes gui-a-shade{0%{opacity:1;} 25%{opacity:0.6;} 50%{opacity:0.6;} 75%{opacity:1;} 100%{opacity:1;}}
  191. .gui-a-shade{animation:gui-a-shade 1.5s ease infinite;}
  192. .gui-kd-tap{color:#FFFFFF; background-color:#008AFF; border-color:#008AFF;}
  193. /* #endif */
  194. /* #ifdef APP-NVUE */
  195. .gui-kd-tap{color:#FFFFFF; background-color:#CECECE; border-color:#CECECE;}
  196. /* #endif */
  197. </style>