<template>
  <view class="cheku">
    <view class="hezi">
        <view class="garage" v-for="(i,j) in list" :key="j">
      <mygarageList
        :carid="i.car_id"
        :isdefault="i.ismr"
        :picurl="i.brandlogo"
        :carname="i.car_name"
        :cardesc="i.kuanxing "
        @mr="mr"
        @del="del"
      ></mygarageList>
    </view>
    </view>
  
    <!-- <view class="garage">
             <mygarageList isdefault=false picurl="../../static/img/garagecaricon.png" carname="江淮安驰-小公主" cardesc="2019款2.9T 手自一体 "></mygarageList>
    </view>-->

    <view class="anniu" @click="xzcx">
      <mygarageBtn></mygarageBtn>
    </view>
  </view>
</template>
<script>
import mygarageList from "../../components/mygarage/mygarage-list";
import mygarageBtn from "../../components/mygarage/mygarage-btn";
import requestP from "../../static/js/request.js";
export default {
  components: {
    mygarageList,
    mygarageBtn
  },
  data() {
    return {
      list: []
    };
  },
  onLoad() {
    requestP
      .requestP({
        url: "user_car/get_car_list"
      })
      .then(res => {
        console.log(res);
        this.list = res.data.data;
      });
  },
  methods: {
    xzcx() {
      uni.navigateTo({
        url: "/pages/ceshi/ceshi"
      });
    },
    mr(e) {
      requestP
        .requestP({
          url: "user_car/update_car_moren",
          data: {
            car_id: e
          }
        })
        .then(res => {
          console.log(res);
          uni.showToast({
            title: "设置成功",
            icon: "none"
          });
          requestP
            .requestP({
              url: "user_car/get_car_list"
            })
            .then(res => {
              console.log(res);
              this.list = res.data.data;
            });
        });
    },
    del(e) {
      requestP
        .requestP({
          url: "user_car/del_car",
          data: {
            car_id: e
          }
        })
        .then(res => {
          uni.showToast({
            title: "删除成功",
            icon: "none"
          });
          requestP
            .requestP({
              url: "user_car/get_car_list"
            })
            .then(res => {
              console.log(res);
              this.list = res.data.data;
            });
        });
    }
  }
};
</script>
<style lang="scss">
.hezi{
 padding-bottom:100upx;
}
Page {
  background-color: #f0eeef;
}
.garage {
  padding-bottom: 19upx;
}
.anniu {
  height: 107upx;
  position: fixed;
  bottom: 0;
}
</style>