addCarNum.vue 1.48 KB
<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";
import { userCarsInfoEdit } from "@/api/myCars/myCars";
export default {
  name: "addCarNum",
  components: {
    "vnp-input": VnpInput
  },
  data() {
    return {
      show: false,
      value: "冀"
    };
  },
  methods: {
    toMyCarsPage() {
      console.log(this.value)
      console.log(this.value.length)
      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{
          this.$toast('添加车牌失败')
        }
      });
    }
  }
};
</script>

<style lang="less" scoped>
  h3 {
    text-align: center;
    padding-bottom: 20px;
  }
</style>