Blame view

src/components/inout.vue 6.01 KB
35b48aa6   liuqimichale   init
1
2
  <template>
    <div class="inout-wrap">
05b3e86b   liuqimichale   eslint
3
      <div class="title">无牌车{{ toflag =='0' ? '入场' : '出场' }}结算</div>
145c620a   liuqimichale   传值
4
      <div :class="tipsClass" class="tips-text">{{ tipsText }}</div>
05b3e86b   liuqimichale   eslint
5
      <div class="inout-fix"></div>
145c620a   liuqimichale   传值
6
7
8
9
10
11
12
13
14
15
16
17
18
      <input
        v-show="inputType"
        ref="phoneVal"
        type="text"
        placeholder="请输入手机号"
        maxlength="11"
        onkeyup="this.value=this.value.replace(/[^0-9-]+/,'');">
      <input
        v-show="!inputType"
        ref="carVal"
        type="text"
        placeholder="请输入车牌号"
        maxlength="8">
35b48aa6   liuqimichale   init
19
20
21
22
23
24
25
26
27
28
29
30
31
      <div class="toggle-btn" @click="togglebtn">
        <img src="../assets/toggle-btn.png">
        {{ toggleText }}
      </div>
      <div class="commit-btn" @click="commitsure">确定</div>
    </div>
  </template>
  
  <script>
  import { mapActions } from 'vuex'
  
  export default {
    name: 'InOut',
05b3e86b   liuqimichale   eslint
32
33
34
35
36
37
    props: {
      toflag: {
        type: Number,
        default: 0
      }
    },
35b48aa6   liuqimichale   init
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
    data() {
      return {
        tipsText: '请输入手机号',
        toggleText: '切换车牌',
        inputType: true,
        tipsClass: ''
      }
    },
    methods: {
      ...mapActions([
        'handleShow', 'handleHide', 'handlePayFlag'
      ]),
      togglebtn() {
        this.tipsClass = ''
        this.inputType = !this.inputType
        // this.toggleText=this.toggleText === '切换车牌' ? '切换手机' : '切换车牌'
        if (this.toggleText === '切换车牌') {
          this.toggleText = '切换手机'
          this.tipsText = '请输入车牌号'
        } else {
          this.toggleText = '切换车牌'
          this.tipsText = '请输入手机号'
        }
      },
      commitsure() { // 确定事件
05b3e86b   liuqimichale   eslint
63
        console.log(this.toflag) // 如果为1 就需要去支付
35b48aa6   liuqimichale   init
64
65
66
67
68
69
70
71
72
73
74
75
        if (this.inputType) {
          const phonetext = this.$refs.phoneVal.value.trim()
          const phoneReg = /(^1[3|4|5|7|8]\d{9}$)|(^09\d{8}$)/
          if (phonetext) {
            if (phoneReg.test(phonetext)) {
              // ajax
              this.handleShow()
              // 模拟成功
              setTimeout(() => {
                this.handleHide()
                this.tipsText = '绑定成功'
                this.tipsClass = 'successClass'
05b3e86b   liuqimichale   eslint
76
                if (this.toflag === 1) {
35b48aa6   liuqimichale   init
77
                  this.handlePayFlag()
145c620a   liuqimichale   传值
78
79
80
81
82
                  const passdata = {
                    title: '手机号123',
                    money: '¥1000.00'
                  }
                  this.$emit('commitpass', passdata)
35b48aa6   liuqimichale   init
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
                }
              }, 2000)
            } else {
              this.tipsText = '请输入正确手机号'
              this.tipsClass = 'errorClass'
              return
            }
          } else {
            this.tipsText = '请输入手机号'
            this.tipsClass = ''
            return
          }
        } else {
          const cartext = this.$refs.carVal.value.trim()
          const carReg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳]{1}$/
05b3e86b   liuqimichale   eslint
98
          const carnewreg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([0-9]{5}[DF]$)|([DF][A-HJ-NP-Z0-9][0-9]{4}$))/
35b48aa6   liuqimichale   init
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
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
          if (cartext) {
            if (cartext.length === 7) { // 正常车牌
              if (carReg.test(cartext)) {
                // ajax
                this.handleShow()
                // 模拟成功
                setTimeout(() => {
                  this.handleHide()
                  this.tipsText = '绑定成功'
                  this.tipsClass = 'successClass'
                }, 2000)
              } else {
                this.tipsText = '请输入正确车牌号'
                this.tipsClass = 'errorClass'
                return
              }
            } else if (cartext.length === 8) { // 新能源
              if (carnewreg.test(cartext)) {
                // ajax
                this.handleShow()
                // 模拟成功
                setTimeout(() => {
                  this.handleHide()
                  this.tipsText = '绑定成功'
                  this.tipsClass = 'successClass'
                }, 2000)
              } else {
                this.tipsText = '请输入正确车牌号'
                this.tipsClass = 'errorClass'
                return
              }
            } else {
              this.tipsText = '请输入正确车牌号'
              this.tipsClass = 'errorClass'
              return
            }
          } else {
            this.tipsText = '请输入车牌号'
            this.tipsClass = ''
            return
          }
        }
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
    $corlorwhit: #fff;
    .inout-wrap {
      width: 100%;
      height: 100%;
1bd5e162   liuqimichale   rem
151
      background: url("../assets/inout-bg.png") repeat;
35b48aa6   liuqimichale   init
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
      position: relative;
      text-align: center;
      .title {
        height: 42px;
        line-height: 42px;
        background-color: rgba(255, 255, 255, .9);
        font-size: 17px;
        color: #4A4A4A;
        font-weight: 500;
      }
      .tips-text {
        margin-top: 44px;
        margin-bottom: 10px;
        font-size: 17px;
        color: $corlorwhit;
      }
      .normalClass {
        color: $corlorwhit;
      }
      .successClass {
        color: #0f0;
      }
      .errorClass {
        color: #f00;
      }
145c620a   liuqimichale   传值
177
      input {
35b48aa6   liuqimichale   init
178
179
180
        border: 0;
        outline: 0;
        width: 80%;
8da434bf   liuqimichale   车场进出场支付
181
182
        height: 1.253333rem;
        line-height: 1.253333rem;
35b48aa6   liuqimichale   init
183
        background-color: #fff;
8da434bf   liuqimichale   车场进出场支付
184
        font-size: 0.48rem;
35b48aa6   liuqimichale   init
185
        color: #4A4A4A;
8da434bf   liuqimichale   车场进出场支付
186
187
188
        border-radius: 0.106667rem;
        text-align: center;
        font-weight: 500;
35b48aa6   liuqimichale   init
189
190
191
192
193
194
195
      }
      .toggle-btn {
        height: 17px;
        margin-top: 18px;
        text-align: center;
        cursor: pointer;
        color: $corlorwhit;
1bd5e162   liuqimichale   rem
196
        font-size: 17px;
35b48aa6   liuqimichale   init
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
        img {
          width: 16px;
          height: 16px;
          vertical-align: top;
        }
      }
      .commit-btn {
        width: 80%;
        height: 42px;
        margin: 156px auto 0;
        line-height: 42px;
        border-radius: 21px;
        background: #fff;
        font-size: 18px;
        color: #75CBBE;
        cursor: pointer;
      }
      .inout-fix {
        width: 100%;
        height: 122px;
        position: absolute;
        bottom: 0;
        background: url("../assets/inout-fix.png") no-repeat;
        background-size: 100% 100%;
      }
    }
  </style>