<template>
<div>
<Myheader></Myheader>
   <div class="rc-top"></div>
   <div class="online bold"></div>
    <div class="usercontshow rc-max-width--xl">
 <div class="usercontend" v-for="(item, index) in list" :key="index">
  <div class="usercontshow usermain" >
    <div class="rc-cat" >
        <div class="rc-center">
      <div class=" rc-title">
        <em>
          {{ item.name }}
        </em>
        <span>
          {{ item.tel }}
        </span>
      </div>
      <div class="rc-address">
        <span>
          {{ item.address }}
        </span>
      </div>
      <div class="rc-footer">
        <div class="rc-foot">
           <img :src="item.isDefault?require('../../assets/image/userred.png'):require('../../assets/image/userselect.png')" @click="changeadddress(item,index)"/>
          <span>设置为默认收货地址</span>

        </div>
        <div class="rc-right">
          <span @click="onEdit(item, index)">编辑</span>
          <span @click="userdelete(item, index)">删除</span>
        </div>
      </div>
    </div>
      
 
    </div>
      
  </div>
   <div class="online bold rc-md-down"></div>
  <!-- <div class="usercontend useradd">
      <img src="../../assets/image/userselect.png" alt="">
      <span>添加收货地址</span>
  </div> -->
  
 </div>
 
    <div class="usercontshow useredit">

      <img src="../../assets/image/userselect.png" alt="">
      <span>添加收货地址</span>
    </div>
     <div class="rc-button">
      <div class="rc-footbutton" @click="onAdd()">
        <span>新增收货地址</span>
      </div>
    </div>

  </div>
    <MyFooter></MyFooter>
</div>
</template>

<script>

import Myheader from '~/components/header.vue' 
import MyFooter from '~/components/rc-footer.vue'
export default {
  data() {
    return {
      chosenAddressId: "1",
      checked: true,
      userid: null,
      usermessage:null,
      list: [
        {
          id: 1,
          name: "张三",
          tel: "13000000000",
          address: "浙江省杭州市西湖区文三路 138 号",
          isDefault: true,

        },
        {
          id: 2,
          name: "李四",
          tel: "1310000000",
          isDefault: false,
          address: "浙江省杭州市拱墅区莫干山路 50 号",
        },
           {
          id: 3,
          name: "李四",
          tel: "1310000000",
          isDefault: false,
          address: "浙江省杭州市拱墅区莫干山路 50 号",
        },
      ],
    };
  },
  methods: { 
    changeadddress(item,index){
      console.log(item)
    },
    onEdit(item, index) {
      // let userid = item.id;
      console.log(item);
      this.$router.push({
        path: "/useraddress/editaddress",
        query: {
          id: item,
        },
      });
    },
       onAdd(item, index) {
      // let userid = item.id;
      // console.log(item);
      this.$router.push({
        path: "/useraddress/addaddress",
        // query: {
        //   id: userid,
        // },
      });
    },



    //删除地址
    // async userdelete(item) {
    //   console.log(item.memberId);
    //   let data = await editdelete(this.userid, item.id);
    //  this.editaddress(this.usermessage);
    //   console.log(data);
    // },

    //查询人的所有地址
    // async editaddress(user) {
    //  user.data.id=844350
    //     let data = await selectaddress(user.data.id);
    //     this.list=data.data;
    //     console.log(this.list);
    //   console.log(data);
    // },
  },
  components: {
   Myheader,
   MyFooter
  },

  mounted() {
    //地址的查询
    // this.usermessage = JSON.parse(localStorage.getItem("userInfo"));
    //    this.editaddress(this.usermessage);
    // this.userid = this.usermessage.data.id;
  },
};
</script>

<style lang="less" scoped >
@import url("../../assets/css/global.less");
@import url("../../assets/css/openaddress.less");
</style>
