|
|
@ -3,9 +3,9 @@ |
|
|
|
<!-- 地址列表 --> |
|
|
|
<scroll-view enable-back-to-top class="scroll-view" scroll-y> |
|
|
|
<view v-if="addressList.length" class="address"> |
|
|
|
<uni-swipe-action class="address-list"> |
|
|
|
<!-- 收货地址项 --> |
|
|
|
<uni-swipe-action-item class="item" v-for="item in addressList" :key="item.id"> |
|
|
|
<view class="address-list"> |
|
|
|
<!-- 收获地址项 --> |
|
|
|
<view class="item" v-for="item in addressList" :key="item.id"> |
|
|
|
<view class="item-content" @tap="onChangeAddress(item)"> |
|
|
|
<view class="user"> |
|
|
|
{{ item.receiver }} |
|
|
@ -13,6 +13,13 @@ |
|
|
|
<text v-if="item.isDefault" class="badge">默认</text> |
|
|
|
</view> |
|
|
|
<view class="locate">{{ item.fullLocation }} {{ item.address }}</view> |
|
|
|
<text |
|
|
|
class="delete" |
|
|
|
@tap.stop="onDeleteAddress(item.id)" |
|
|
|
@tap.prevent="onDeleteAddress(item.id)" |
|
|
|
> |
|
|
|
删除 |
|
|
|
</text> |
|
|
|
<!-- H5 端需添加 .prevent 阻止链接的默认行为 --> |
|
|
|
<navigator |
|
|
|
class="edit" |
|
|
@ -24,12 +31,8 @@ |
|
|
|
修改 |
|
|
|
</navigator> |
|
|
|
</view> |
|
|
|
<!-- 右侧插槽 --> |
|
|
|
<template #right> |
|
|
|
<button @tap="onDeleteAddress(item.id)" class="delete-button">删除</button> |
|
|
|
</template> |
|
|
|
</uni-swipe-action-item> |
|
|
|
</uni-swipe-action> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view v-else class="blank">暂无收货地址</view> |
|
|
|
</scroll-view> |
|
|
@ -43,7 +46,7 @@ |
|
|
|
</template> |
|
|
|
|
|
|
|
<script setup lang="ts"> |
|
|
|
import { deleteMemberAddressByIdAPI, getMemberAddressAPI } from '@/services/address' |
|
|
|
import { getMemberAddressAPI, deleteMemberAddressByIdAPI } from '@/services/address' |
|
|
|
import { useAddressStore } from '@/stores/modules/address' |
|
|
|
import type { AddressItem } from '@/types/address' |
|
|
|
import { onShow } from '@dcloudio/uni-app' |
|
|
@ -56,11 +59,6 @@ const getMemberAddressData = async () => { |
|
|
|
addressList.value = res.result |
|
|
|
} |
|
|
|
|
|
|
|
// 初始化调用(页面显示) |
|
|
|
onShow(() => { |
|
|
|
getMemberAddressData() |
|
|
|
}) |
|
|
|
|
|
|
|
// 删除收货地址 |
|
|
|
const onDeleteAddress = (id: string) => { |
|
|
|
// 二次确认 |
|
|
@ -86,6 +84,11 @@ const onChangeAddress = (item: AddressItem) => { |
|
|
|
// 返回上一页 |
|
|
|
uni.navigateBack() |
|
|
|
} |
|
|
|
|
|
|
|
// 初始化调用(页面显示) |
|
|
|
onShow(() => { |
|
|
|
getMemberAddressData() |
|
|
|
}) |
|
|
|
</script> |
|
|
|
|
|
|
|
<style lang="scss"> |
|
|
@ -94,20 +97,6 @@ page { |
|
|
|
overflow: hidden; |
|
|
|
} |
|
|
|
|
|
|
|
/* 删除按钮 */ |
|
|
|
.delete-button { |
|
|
|
display: flex; |
|
|
|
justify-content: center; |
|
|
|
align-items: center; |
|
|
|
width: 50px; |
|
|
|
height: 100%; |
|
|
|
font-size: 28rpx; |
|
|
|
color: #fff; |
|
|
|
border-radius: 0; |
|
|
|
padding: 0; |
|
|
|
background-color: #cf4444; |
|
|
|
} |
|
|
|
|
|
|
|
.viewport { |
|
|
|
display: flex; |
|
|
|
flex-direction: column; |
|
|
@ -141,6 +130,16 @@ page { |
|
|
|
color: #666; |
|
|
|
line-height: 1; |
|
|
|
} |
|
|
|
|
|
|
|
.delete { |
|
|
|
position: absolute; |
|
|
|
top: 38rpx; |
|
|
|
right: 100rpx; |
|
|
|
font-size: 26rpx; |
|
|
|
color: #ff3b30; |
|
|
|
line-height: 1; |
|
|
|
padding-right: 20rpx; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.item:last-child .item-content { |
|
|
|