<template>
  <view class='content'>
    <scroll-view :scroll-y='true'>
      <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("create")'>+新增地址</button>
    </view>
  </view>
</template>

<script lang='ts' setup>

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

const addressList = ref<{
  name: string,
  mobile: string,
  address: string,
  status: number
}[]>([]);

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

onShow(() => {
  fetchAddressList();
});

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

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