Blame view

pages/inputCarNumber/inputCarNumber.vue 8.65 KB
4b045f7c   刘淇   江阴初始化项目
1
2
3
4
  <template>
  
  	<view class="so-mask">
  
ff4eb366   chenbiao   add 初始化停车缴费页面 支付订...
5
  		<view class="bg-icon" :class="set">
4b045f7c   刘淇   江阴初始化项目
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  			<image :src="carBg" mode="" class="bac" />
  			<view class="bg-text">
  				<view class="bg-text-top">输 入 车 牌 号</view>
  				<view class="bg-text-bottom">输入完整车牌号,查询停车信息</view>
  			</view>
  		</view>
  
  		<view class="so-plate animation-scale-up">
  			<view class="so-plate-head">
  				<view class="so-plate-type">
  					<radio-group @change="typeChange">
  						<label>
  							<radio value="1" :checked="type===1" />
  							普通车牌
  						</label>
  						<label>
  							<radio value="2" :checked="type===2" />
  							新能源车牌
  						</label>
  					</radio-group>
  				</view>
  			</view>
  			<view class="so-plate-body" @click="plateShowOrHide = true">
ff4eb366   chenbiao   add 初始化停车缴费页面 支付订...
29
30
  				<view class="so-plate-word" :class="{ active: currentInputIndex == 0 }" @tap="inputSwitch"
  					data-index="0">
4b045f7c   刘淇   江阴初始化项目
31
32
  					<text>{{ currentInputValue[0] }}</text>
  				</view>
ff4eb366   chenbiao   add 初始化停车缴费页面 支付订...
33
34
  				<view class="so-plate-word" :class="{ active: currentInputIndex == 1 }" @tap="inputSwitch"
  					data-index="1">
4b045f7c   刘淇   江阴初始化项目
35
36
37
  					<text>{{ currentInputValue[1] }}</text>
  				</view>
  				<view class="so-plate-dot"></view>
ff4eb366   chenbiao   add 初始化停车缴费页面 支付订...
38
39
  				<view class="so-plate-word" :class="{ active: currentInputIndex == 2 }" @tap="inputSwitch"
  					data-index="2">
4b045f7c   刘淇   江阴初始化项目
40
41
  					<text>{{ currentInputValue[2] }}</text>
  				</view>
ff4eb366   chenbiao   add 初始化停车缴费页面 支付订...
42
43
  				<view class="so-plate-word" :class="{ active: currentInputIndex == 3 }" @tap="inputSwitch"
  					data-index="3">
4b045f7c   刘淇   江阴初始化项目
44
45
  					<text>{{ currentInputValue[3] }}</text>
  				</view>
ff4eb366   chenbiao   add 初始化停车缴费页面 支付订...
46
47
  				<view class="so-plate-word" :class="{ active: currentInputIndex == 4 }" @tap="inputSwitch"
  					data-index="4">
4b045f7c   刘淇   江阴初始化项目
48
49
  					<text>{{ currentInputValue[4] }}</text>
  				</view>
ff4eb366   chenbiao   add 初始化停车缴费页面 支付订...
50
51
  				<view class="so-plate-word" :class="{ active: currentInputIndex == 5 }" @tap="inputSwitch"
  					data-index="5">
4b045f7c   刘淇   江阴初始化项目
52
53
  					<text>{{ currentInputValue[5] }}</text>
  				</view>
ff4eb366   chenbiao   add 初始化停车缴费页面 支付订...
54
55
  				<view class="so-plate-word" :class="{ active: currentInputIndex == 6 }" @tap="inputSwitch"
  					data-index="6">
4b045f7c   刘淇   江阴初始化项目
56
57
  					<text>{{ currentInputValue[6] }}</text>
  				</view>
ff4eb366   chenbiao   add 初始化停车缴费页面 支付订...
58
59
  				<view class="so-plate-word" :class="{ active: currentInputIndex == 7 }" @tap="inputSwitch"
  					v-if="type == 2" data-index="7">
4b045f7c   刘淇   江阴初始化项目
60
61
62
63
64
65
66
67
68
  					<text>{{ currentInputValue[7] }}</text>
  				</view>
  			</view>
  
  
  		</view>
  
  		<view style="padding: 0 10px;position: fixed;bottom: 0;left:0">
  			<view class="so-plate-foot" v-show="plateShowOrHide">
ff4eb366   chenbiao   add 初始化停车缴费页面 支付订...
69
  				<view class="so-plate-keyboard" :style="{height:keyboardHeight}">
4b045f7c   刘淇   江阴初始化项目
70
71
  					<view id="keyboard">
  						<block v-if="inputType == 1">
ff4eb366   chenbiao   add 初始化停车缴费页面 支付订...
72
73
  							<view hover-class="hover" class="so-plate-key" v-for="el of provinceText" :key="el"
  								:data-value="el" @tap="chooseKey">{{ el }}</view>
4b045f7c   刘淇   江阴初始化项目
74
75
76
77
78
79
  						</block>
  						<block v-if="inputType == 1">
  							<text class="so-plate-key fill-block"></text>
  							<text class="so-plate-key fill-block"></text>
  						</block>
  						<block v-if="inputType >= 3">
ff4eb366   chenbiao   add 初始化停车缴费页面 支付订...
80
81
  							<view hover-class="hover" class="so-plate-key" v-for="el of numberText" :key="el"
  								:data-value="el" @tap="chooseKey">{{ el }}</view>
4b045f7c   刘淇   江阴初始化项目
82
83
  						</block>
  						<block v-if="inputType >= 2">
ff4eb366   chenbiao   add 初始化停车缴费页面 支付订...
84
85
  							<view hover-class="hover" class="so-plate-key" v-for="el of wordText" :key="el"
  								:data-value="el" @tap="chooseKey">{{ el }}</view>
4b045f7c   刘淇   江阴初始化项目
86
87
88
89
90
  						</block>
  						<block v-if="inputType == 3">
  							<text v-for="el of fillBlock" :key="el.num" class="so-plate-key fill-block"></text>
  						</block>
  						<block v-if="inputType == 4">
ff4eb366   chenbiao   add 初始化停车缴费页面 支付订...
91
92
  							<view hover-class="hover" class="so-plate-key" v-for="el of lastWordText" :key="el"
  								:data-value="el" @tap="chooseKey">{{ el }}</view>
4b045f7c   刘淇   江阴初始化项目
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
  						</block>
  						<text v-if="inputType == 4" class="so-plate-key fill-block"></text>
  					</view>
  				</view>
  				<view class="so-plate-btn-group">
  					<view>
  						<button class="so-plate-btn so-plate-btn--cancel" @tap="plateShowOrHide = false">取消</button>
  					</view>
  					<view>
  						<button class="so-plate-btn so-plate-btn--delete" @tap="deleteKey">删除</button>
  						<button class="so-plate-btn so-plate-btn--submit" @tap="exportPlate">完成</button>
  
  					</view>
  
  				</view>
  			</view>
  		</view>
  	</view>
  </template>
  <script>
ff4eb366   chenbiao   add 初始化停车缴费页面 支付订...
113
  	import carBg from 'static/inputCarNumber_pic/carBg.png'
4b045f7c   刘淇   江阴初始化项目
114
  
ff4eb366   chenbiao   add 初始化停车缴费页面 支付订...
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
  	export default {
  		name: 'uni-plate-input',
  		data() {
  			return {
  				plateShowOrHide: false,
  				type: 1, //车牌类型
  				currentInputIndex: 2, //当前编辑的输入框
  				currentInputValue: ['苏', 'B', '', '', '', '', ''],
  				fillBlock: [{
  					num: 11
  				}, {
  					num: 12
  				}, {
  					num: 13
  				}, {
  					num: 14
  				}, {
  					num: 15
  				}, {
  					num: 16
  				}], //避免:key报错
  				keyboardHeightInit: false,
  				keyboardHeight: 'auto',
  				carBg: '',
  				provinceText: [
  					'粤',
  					'京',
  					'冀',
  					'沪',
  					'津',
  					'晋',
  					'蒙',
  					'辽',
  					'吉',
  					'黑',
  					'苏',
  					'浙',
  					'皖',
  					'闽',
  					'赣',
  					'鲁',
  					'豫',
  					'鄂',
  					'湘',
  					'桂',
  					'琼',
  					'渝',
  					'川',
  					'贵',
  					'云',
  					'藏',
  					'陕',
  					'甘',
  					'青',
  					'宁',
  					'新'
  				],
  				numberText: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'],
  				wordText: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U',
  					'V', 'W', 'X', 'Y', 'Z'
  				],
  				lastWordText: ['港', '澳', '学', '领', '警']
  			};
  		},
  		props: {
  			// plate: {
  			//     type: String
  			// }
  		},
  		onLoad() {
  			this.type = 1;
  			this.currentInputValue = ['苏', 'B', '', '', '', '', ''];
  			this.currentInputIndex = 2;
  		},
  		onShow() {
  			this.carBg = carBg
  		},
  		computed: {
  			//输入框类型
  			inputType() {
  				switch (this.currentInputIndex) {
  					case 0:
  						return 1;
  						break;
  					case 1:
  						return 2;
  						break;
  					case 2:
  						return 3;
  						break;
  					case 3:
  						return 3;
  						break;
  					case 4:
  						return 3;
  						break;
  					case 5:
  						return 3;
  						break;
  					case 6:
  						return this.type == 2 ? 3 : 4;
  						break;
  					case 7:
  						return 4;
  						break;
  					default:
  						return 1;
  						break;
  				}
  			}
  		},
  		watch: {
  			// currentInputIndex:function(n,o){
  			//     if(!this.keyboardHeightInit) return
  			//     this.$nextTick(()=>{
  			//         this.changeKeyboardHeight()
  			//     })
  			// }
  		},
  		methods: {
  			//车牌类型切换
  			typeChange(e) {
  				const {
  					value
  				} = e.detail;
  				this.type = parseInt(value)
  				this.currentInputIndex = 0
  				if (value == 1) {
b36ea78a   chenbiao   add 修复bug
243
  					this.currentInputValue = ['苏', 'B', '', '', '', '', '']
ff4eb366   chenbiao   add 初始化停车缴费页面 支付订...
244
  				} else {
b36ea78a   chenbiao   add 修复bug
245
  					this.currentInputValue = ['苏', 'B','', '', '', '', '', '']
ff4eb366   chenbiao   add 初始化停车缴费页面 支付订...
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
  				}
  			},
  			inputSwitch(e) {
  				const {
  					index
  				} = e.currentTarget.dataset;
  				this.currentInputIndex = parseInt(index);
  			},
  			chooseKey(e) {
  				const {
  					value
  				} = e.currentTarget.dataset;
  				this.$set(this.currentInputValue, this.currentInputIndex, value);
  				if (this.type == 1 && this.currentInputIndex < 6) {
  					this.currentInputIndex++
  				}
  				if (this.type == 2 && this.currentInputIndex < 7) {
  					this.currentInputIndex++
  				}
  			},
  			deleteKey() {
  				this.$set(this.currentInputValue, this.currentInputIndex, '')
  				if (this.currentInputIndex != 0) this.currentInputIndex--
  			},
  			exportPlate() {
  				const plate = this.currentInputValue.join('')
  				let err = false
  				if (this.type === 1 && plate.length != 7) {
  					err = true
  				} else if (this.type === 2 && plate.length != 8) {
  					err = true
  				}
  				if (err) return uni.showToast({
  					title: '请输入完整的车牌号码',
  					icon: 'error'
  				})
4b045f7c   刘淇   江阴初始化项目
282
  
ff4eb366   chenbiao   add 初始化停车缴费页面 支付订...
283
  				console.log(plate)
4b045f7c   刘淇   江阴初始化项目
284
  
ff4eb366   chenbiao   add 初始化停车缴费页面 支付订...
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
  				uni.navigateTo({
  					url: '../parkPay/parkPay?carNumber=' + plate
  				})
  			},
  			changeKeyboardHeight() {
  				const that = this
  				const query = uni.createSelectorQuery().in(this);
  				query.select('#keyboard').boundingClientRect();
  				query.exec(function(res) {
  					if (res && res[0]) {
  						that.keyboardHeight = res[0].height + uni.upx2px(30) + 'px'
  						that.keyboardHeightInit = true
  					}
  				});
  			}
  		},
  		mounted() {
  			console.log(this.plate);
  			const plateKey = this.plate.split('')
  			if (plateKey.length === 7) {
  				this.type = 1
  			} else if (plateKey.length === 8) {
  				this.type = 2
  			}
  			if (plateKey.length === 7 || plateKey.length === 8) {
  				this.currentInputValue = plateKey
  				this.currentInputIndex = plateKey.length - 1
  			}
4b045f7c   刘淇   江阴初始化项目
313
  
ff4eb366   chenbiao   add 初始化停车缴费页面 支付订...
314
315
316
317
318
319
320
  			setTimeout(() => { //在动画结束之后才开始获取
  				this.$nextTick(() => {
  					this.changeKeyboardHeight()
  				})
  			}, 500);
  		}
  	};
4b045f7c   刘淇   江阴初始化项目
321
322
323
  </script>
  <style scoped lang="less">
  	@import 'uni-plate-input';
ff4eb366   chenbiao   add 初始化停车缴费页面 支付订...
324
325
  
  	.bg-icon {
4b045f7c   刘淇   江阴初始化项目
326
327
328
329
330
331
  		/*padding: 10px 0;*/
  		height: 60px;
  		/*background: url("../../static/inputCarNumber_pic/carBg.png") no-repeat;*/
  		/*background-size: 100% 100%;*/
  		color: #FFF;
  	}
ff4eb366   chenbiao   add 初始化停车缴费页面 支付订...
332
333
  
  	.bac {
4b045f7c   刘淇   江阴初始化项目
334
335
336
337
  		position: absolute;
  		width: 100%;
  		height: 60px;
  	}
ff4eb366   chenbiao   add 初始化停车缴费页面 支付订...
338
339
  
  	.bg-text {
4b045f7c   刘淇   江阴初始化项目
340
341
  		width: 100%;
  		position: absolute;
ff4eb366   chenbiao   add 初始化停车缴费页面 支付订...
342
  		top: 10px;
4b045f7c   刘淇   江阴初始化项目
343
344
345
346
  		text-align: center;
  
  	}
  </style>