<template>
  <view class="container">
    <!-- 车辆信息区域 -->
    <view class="car-info-container" v-for="(item, index) in carList" :key="index">
      <view class="license-plate">
        <view class="plate-type-box">
          <text class="plate-type">{{ item.car_number_color }}</text>
        </view>
        <text class="plate-number">{{ item.car_number }}</text>
      </view>
    </view>

    <!-- 添加车辆按钮 -->
    <button class="add-car-btn" @click="addCar">添加车辆</button>
  </view>
</template>

<script>
import {
  isPhone,
  picUrl,
  request,
  upload,
  NavgateTo
} from '../../../utils';
import { apiArr } from '@/api/park.js'

export default {
  data() {
    return {
      carList: []
    }
  },
  methods: {
    getCarList() {
      const params = {
        user_id: uni.getStorageSync('userId')
      }
      request(apiArr.carList, "POST", params).then((res) => {
        this.carList = res.car_list;
      })
    },
    addCar() {
      // 跳转到添加车辆页面
      uni.navigateTo({
        url: '/packages/park/addCar/index'
      })
    }
  },
  onShow() {
    this.getCarList();
  }
}
</script>

<style>
@import url('./index.css');
</style>