<template>
  <view>
    <view class="midbox">
        <scroll-view :scroll-y="true" class="scroll-Y" @scroll="scroll" @click.stop="a">
      <view v-for="(i,j) in list" :key="j" @click="xz(j,i.id)" :data-addrid="i.id" @longtap='del'>
        <chooseaddrInfo
          :name="i.uname"
          :address="i.address"
          :phone="i.phone"
          :defined="i.status"
          :aid="i.id"
          @addid="addid(j)"
  
        ></chooseaddrInfo>
      </view>
        </scroll-view>
    </view>

    <view class="btn">
      <!-- <chooseaddrBtn class="btn1"></chooseaddrBtn> -->
      <view @click="tianjia">
      <chooseaddrBtn1 ifadd="true"></chooseaddrBtn1>
      </view>
    </view>
  </view>
</template>
<script>
import chooseaddrInfo from "../../components/chooseaddr/chooseaddr-info";
import chooseaddrBtn from "../../components/chooseaddr/chooseaddr-btn";
import chooseaddrBtn1 from "../../components/chooseaddr/chooseaddr-btn1";
import { requestP } from "../../static/js/request";
export default {
  components: {
    chooseaddrInfo,
    chooseaddrBtn,
    chooseaddrBtn1
  },
  data() {
    return {
      list: [],
      addrid: 0,
      canshu: {}
    };
  },
  mounted() {
    requestP({
      url: "user/get_user_address"
    }).then(res => {
      console.log(res.data.data[0].id);
      this.list = res.data.data;
    });
  },
  onLoad(e) {
    console.log(e, 7945455);
    this.canshu = e;
  },
  methods: {
    a(){},
    scroll(){},
    xz(a,b) {
      console.log(a)
      console.log(b);
      this.addrid = b
      
      uni.navigateTo({
        url:
          "/pages/order-sub/order-sub?addrid=" +
          this.addrid +
          "&guige=" +
          this.canshu.guige +
          "&num=" +
          this.canshu.num +
          "&shopid=" +
          this.canshu.shopid +
          "&shoptype=" +
          this.canshu.shoptype +
          "&msid=" +
          this.canshu.msid+"&addrkey="+a
      });
    },
    del(e){
      console.log(e,"long") 
    },
    addid(e){
      uni.setStorageSync("address",this.list[e])
      uni.navigateTo({
        url:"../addr-add/addr-add?id=" + 1
      })
      
    },
    tianjia(){
      uni.navigateTo({
        url:"../addr-add/addr-add"
      })
    }
  }
};
</script>
<style lang="scss">
.midbox{
  height:1100upx;
}
.scroll-Y{
  height: 90%;
}
.btn {
  position: fixed;
  bottom: 14upx;
  left: 29upx;
  .btn1 {
    position: relative;
    bottom: 27upx;
  }
}
</style>