<template>
  <van-address-edit
  :area-list="areaList"
  show-postal
  show-set-default
  show-search-result
  :search-result="searchResult"
    :address-info="AddressInfo"
  :area-columns-placeholder="['请选择', '请选择', '请选择']"
  @save="onSave"
  @change-detail="onChangeDetail"
>
<!-- <div class="main">
  <span>我的</span>

</div> -->
       
</van-address-edit>
</template>

<script>
import { Toast } from 'vant';
import { areaList } from '@vant/area-data';
import { editupdate } from "../../ajax/getData";
export default {
  data(){
      return{
         areaList,
      searchResult: [],
      AddressInfo:{//收货人信息初始值
                    name:'',//姓名
                    tel:'',//电话
                    province:'',//省份
                    city:'',//城市
                    country:'',//区县
                    address:'',
                    areaCode:'',//地址code：ID
                    addressDetail:'',//详细地址
                    isDefault:false,//是否选择默认
                },

      }
  },
  methods:{

      valf(){
       setTimeout(()=>{
            let s=this.$route.query.id;
       console.log(s);
                 this.AddressInfo.name= s.recipient,
                  this.AddressInfo.tel=s.recipientPhone,
                  this.AddressInfo.province=s.name
                    this.AddressInfo.city=s.name
                    this.AddressInfo.addressDetail=s.detailAddress
                    this.AddressInfo.isDefault=s.isDefault,
                  this.AddressInfo.country='江西省'
                 this.AddressInfo.address='江西省'

       },100)
      },
  async onSave(content) {
       let data = await editupdate(this.tel);
       console.log(data);
     console.log(content);
    //   Toast('save');
      console.log(content.areaCode.substring(0,2)+'0000');//城市编码
       console.log(content.areaCode.substring(0,4)+'00'); //市区id
       console.log(content.areaCode) //区域编码

    },
     onDelete() {
      Toast('delete');
    },
    onChangeDetail(val){

        console.log(this.searchResult);
        console.log(val);
    }
  },
  mounted(){
       this.valf();
       this.searchResult = [
          {
            name: '黄龙万科中心',
            address: '杭州市西湖区',
          },
        ];
  },
  components:{
  
  },
  

}
</script>

<style>

</style>