Files
suke-mp/src/pages/mine/subs/address/index.vue
2024-04-13 00:57:24 +08:00

53 lines
1.2 KiB
Vue

<template>
<view class='content'>
<scroll-view :scroll-y='true'>
<item v-for='(item,index) in addressList' :key='index' :item='item'
@on-checked='onChecked(item)'
@on-edit='args => goPath(`create?bean=${encodeURIComponent(JSON.stringify(args))}`)'
@on-delete='args => {addressDelete(args?.addrid);fetchAddressList}' />
</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 { addressDelete, getAddressList } from '@/api/user';
import { useUserStore } from '@/store';
const userStore = useUserStore();
const addressList = ref<{
name: string,
mobile: string,
addr: string,
status: number,
defaultstatus: number,
}[]>([]);
onLoad((e) => {
// fetchAddressList();
});
onShow(() => {
fetchAddressList();
});
const fetchAddressList = async () => {
addressList.value = await getAddressList();
};
const onChecked = (e: any) => {
uni.navigateBack();
userStore.setDeliveryAddress(e);
};
</script>
<style lang='scss' scoped>
</style>