Blame view

src/views/mySelf/myCars/addCarNum.vue 1.48 KB
5e52ed7c   刘淇   个人中心
1
2
3
4
5
6
7
8
9
10
11
12
13
  <template>
    <div style="padding: 20px 15px;">
      <h3>请输入车牌号码</h3>
      <div class="demo-two-box">
        <vnp-input v-model="value"></vnp-input>
      </div>
  
      <van-button type="info" round block style="margin-top: 40px;" @click="toMyCarsPage">立即添加</van-button>
    </div>
  </template>
  
  <script>
  import VnpInput from "@/components/vant-number-plate/vnp-input";
176eff96   刘淇   添加车牌
14
  import { userCarsInfoEdit } from "@/api/myCars/myCars";
5e52ed7c   刘淇   个人中心
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  export default {
    name: "addCarNum",
    components: {
      "vnp-input": VnpInput
    },
    data() {
      return {
        show: false,
        value: "冀"
      };
    },
    methods: {
      toMyCarsPage() {
        console.log(this.value)
        console.log(this.value.length)
176eff96   刘淇   添加车牌
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
        if(this.value.length>6){
          this.userCarsInfoEdit()
        }else{
          this.$toast('输入正确车牌号')
        }
  
      },
      userCarsInfoEdit(){
        let jsondata = {
          carNumbers: JSON.stringify([{carNumber:this.value}]),
          optType:'00'
        };
        jsondata.sign = this.$utils.signObject(jsondata);
        userCarsInfoEdit(jsondata).then(response => {
          console.log(response);
          if(response.code==0){
            this.$router.push({
                name: "myCars"
              }
            );
          }else if(response.code==-10005){
            this.$toast('最多绑定三辆车')
          }else{
d3808923   刘淇   停车记录
53
            this.$toast(response.message)
5e52ed7c   刘淇   个人中心
54
          }
176eff96   刘淇   添加车牌
55
        });
5e52ed7c   刘淇   个人中心
56
57
58
59
60
61
62
63
64
65
66
      }
    }
  };
  </script>
  
  <style lang="less" scoped>
    h3 {
      text-align: center;
      padding-bottom: 20px;
    }
  </style>