<template>
  <view class='content'>
    <scroll-view :scroll-y='true'>
      <address-item v-for='(item,index) in addressList' :key='index' :item='item' />
    </scroll-view>

    <view class='bottom-button-view'>
      <button class='primary-button' @click.stop='goPath("add-address")'>+新增地址</button>
    </view>
  </view>
</template>

<script lang='ts' setup>

import AddressItem from './components/address-item.vue';
import { goPath } from '@/utils';
import { getAddressList } from '@/api/user';

const addressList = ref<{
  name: string,
  mobile: string,
  address: string,
  status: number
}[]>([{
  name: '黄先生',
  mobile: '13xxxxxx8900',
  status: 1
}, {
  name: '李先生',
  mobile: '13xxxxxx8900',
  status: 0
}]);

onLoad((e) => {
  fetchAddressList();
});

const fetchAddressList = async () => {
  const { data } = await getAddressList();
  addressList.value = data;
};
</script>

<style lang='scss' scoped>
</style>
