Blame view

pages/inputCarNumber/inputCarNumber.vue 11.7 KB
4b045f7c   刘淇   江阴初始化项目
1
2
  <template>
  
c0558eba   刘淇   下拉框箭头
3
      <view class="so-mask">
4b045f7c   刘淇   江阴初始化项目
4
  
c0558eba   刘淇   下拉框箭头
5
6
7
8
9
10
11
          <view class="bg-icon" :class="set">
              <image :src="carBg" mode="" class="bac"/>
              <view class="bg-text">
                  <view class="bg-text-top">输 入 车 牌 号</view>
                  <view class="bg-text-bottom">输入完整车牌号,查询停车信息</view>
              </view>
          </view>
4b045f7c   刘淇   江阴初始化项目
12
  
c0558eba   刘淇   下拉框箭头
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
          <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">
                  <view class="so-plate-word" :class="{ active: currentInputIndex == 0 }" @tap="inputSwitch"
                        data-index="0">
                      <text>{{ currentInputValue[0] }}</text>
                  </view>
                  <view class="so-plate-word" :class="{ active: currentInputIndex == 1 }" @tap="inputSwitch"
                        data-index="1">
                      <text>{{ currentInputValue[1] }}</text>
                  </view>
                  <view class="so-plate-dot"></view>
                  <view class="so-plate-word" :class="{ active: currentInputIndex == 2 }" @tap="inputSwitch"
                        data-index="2">
                      <text>{{ currentInputValue[2] }}</text>
                  </view>
                  <view class="so-plate-word" :class="{ active: currentInputIndex == 3 }" @tap="inputSwitch"
                        data-index="3">
                      <text>{{ currentInputValue[3] }}</text>
                  </view>
                  <view class="so-plate-word" :class="{ active: currentInputIndex == 4 }" @tap="inputSwitch"
                        data-index="4">
                      <text>{{ currentInputValue[4] }}</text>
                  </view>
                  <view class="so-plate-word" :class="{ active: currentInputIndex == 5 }" @tap="inputSwitch"
                        data-index="5">
                      <text>{{ currentInputValue[5] }}</text>
                  </view>
                  <view class="so-plate-word" :class="{ active: currentInputIndex == 6 }" @tap="inputSwitch"
                        data-index="6">
                      <text>{{ currentInputValue[6] }}</text>
                  </view>
                  <view class="so-plate-word" :class="{ active: currentInputIndex == 7 }" @tap="inputSwitch"
                        v-if="type == 2" data-index="7">
                      <text>{{ currentInputValue[7] }}</text>
                  </view>
              </view>
4b045f7c   刘淇   江阴初始化项目
63
64
  
  
c0558eba   刘淇   下拉框箭头
65
          </view>
4b045f7c   刘淇   江阴初始化项目
66
  
c0558eba   刘淇   下拉框箭头
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
          <view style="padding: 0 10px;position: fixed;bottom: 0;left:0">
              <view class="so-plate-foot" v-show="plateShowOrHide">
                  <view class="so-plate-keyboard" :style="{height:keyboardHeight}">
                      <view id="keyboard">
                          <block v-if="inputType == 1">
                              <view hover-class="hover" class="so-plate-key" v-for="el of provinceText" :key="el"
                                    :data-value="el" @tap="chooseKey">{{ el }}
                              </view>
                          </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">
                              <view hover-class="hover" class="so-plate-key" v-for="el of numberText" :key="el"
                                    :data-value="el" @tap="chooseKey">{{ el }}
                              </view>
                          </block>
                          <block v-if="inputType >= 2">
                              <view hover-class="hover" class="so-plate-key" v-for="el of wordText" :key="el"
                                    :data-value="el" @tap="chooseKey">{{ el }}
                              </view>
                          </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">
                              <view hover-class="hover" class="so-plate-key" v-for="el of lastWordText" :key="el"
                                    :data-value="el" @tap="chooseKey">{{ el }}
                              </view>
                          </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>
4b045f7c   刘淇   江阴初始化项目
108
  
c0558eba   刘淇   下拉框箭头
109
                      </view>
4b045f7c   刘淇   江阴初始化项目
110
  
c0558eba   刘淇   下拉框箭头
111
112
113
114
                  </view>
              </view>
          </view>
      </view>
4b045f7c   刘淇   江阴初始化项目
115
116
  </template>
  <script>
c0558eba   刘淇   下拉框箭头
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
243
244
245
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
282
283
284
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
313
314
315
316
317
318
319
  import carBg from 'static/inputCarNumber_pic/carBg.png'
  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: ['港', '澳', '学', '领', '警'],
        businessId: ''
      };
    },
    props: {
      // plate: {
      //     type: String
      // }
    },
    onLoad() {
      this.type = 1;
      this.currentInputValue = ['苏', 'B', '', '', '', '', ''];
      this.currentInputIndex = 2;
      let indexInfo = uni.getStorageSync("indexInfo");
      this.businessId = indexInfo.businessId;
    },
    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) {
          this.currentInputValue = ['苏', 'B', '', '', '', '', '']
        } else {
          this.currentInputValue = ['苏', 'B', '', '', '', '', '', '']
        }
      },
      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'
        })
        console.log(plate)
        this.getbBillQueryInfo(plate);
      },
      getbBillQueryInfo(plate) {
        let that = this
        let paramsData = {
          carNumber: plate,
          pageNum: '1',
          pageSize: '10',
          businessId: that.businessId,
          parkState: '10',
        }
        // 获取 接口
        that.$myRequest({
          url: that.$common.queryParkingRecordByCarNumbers,
          method: 'POST',
          data: that.$common.requestSign(paramsData)
        }).then(res => {
          console.log(res)
          console.log(res.data.dataList[0])
          if(res.code == '0'){
            let data = res.data.dataList[0]
            // that.parkName = data.parkName;
            // that.parkInTime = data.parkInTime;
            // that.staytime = data.parkDuration;
            // that.due = data.totalFee;
            // that.orderFee = data.unPayFee;
            // that.orderId = data.orderId;
            uni.navigateTo({
              url: '../parkPay/parkPay?optionData=' + JSON.stringify(data)
            })
          }
4b045f7c   刘淇   江阴初始化项目
320
  
c0558eba   刘淇   下拉框箭头
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
        })
      },
      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
      }
      setTimeout(() => { //在动画结束之后才开始获取
        this.$nextTick(() => {
          this.changeKeyboardHeight()
        })
      }, 500);
    }
  };
4b045f7c   刘淇   江阴初始化项目
354
355
  </script>
  <style scoped lang="less">
c0558eba   刘淇   下拉框箭头
356
      @import 'uni-plate-input';
ff4eb366   chenbiao   add 初始化停车缴费页面 支付订...
357
  
c0558eba   刘淇   下拉框箭头
358
359
360
361
362
363
364
      .bg-icon {
          /*padding: 10px 0;*/
          height: 60px;
          /*background: url("../../static/inputCarNumber_pic/carBg.png") no-repeat;*/
          /*background-size: 100% 100%;*/
          color: #FFF;
      }
ff4eb366   chenbiao   add 初始化停车缴费页面 支付订...
365
  
c0558eba   刘淇   下拉框箭头
366
367
368
369
370
      .bac {
          position: absolute;
          width: 100%;
          height: 60px;
      }
ff4eb366   chenbiao   add 初始化停车缴费页面 支付订...
371
  
c0558eba   刘淇   下拉框箭头
372
373
374
375
376
      .bg-text {
          width: 100%;
          position: absolute;
          top: 10px;
          text-align: center;
4b045f7c   刘淇   江阴初始化项目
377
  
c0558eba   刘淇   下拉框箭头
378
      }
4b045f7c   刘淇   江阴初始化项目
379
  </style>