|
|
|
@ -1,15 +1,23 @@
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { deleteMemberAddressByIdAPI, getMemberAddressAPI } from '@/services/address'
|
|
|
|
|
import { deleteMemberAddressAPI, getMemberAddressAPI } from '@/services/address'
|
|
|
|
|
import { useAddressStore } from '@/stores/modules/address'
|
|
|
|
|
import type { AddressItem } from '@/types/address'
|
|
|
|
|
import { onShow } from '@dcloudio/uni-app'
|
|
|
|
|
import { useMemberStore } from '@/stores'
|
|
|
|
|
import { ref } from 'vue'
|
|
|
|
|
|
|
|
|
|
// 获取收货地址列表数据
|
|
|
|
|
const addressList = ref<AddressItem[]>([])
|
|
|
|
|
const memberStore = useMemberStore()
|
|
|
|
|
const storage_staffId = uni.getStorageSync('storage_userInfo').id
|
|
|
|
|
const staffId = memberStore.profile?.id || storage_staffId
|
|
|
|
|
|
|
|
|
|
const getMemberAddressData = async () => {
|
|
|
|
|
const res = await getMemberAddressAPI()
|
|
|
|
|
addressList.value = res.result
|
|
|
|
|
const params = {
|
|
|
|
|
clientId: staffId,
|
|
|
|
|
}
|
|
|
|
|
const res = await getMemberAddressAPI(params)
|
|
|
|
|
addressList.value = res.data
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 初始化调用(页面显示)
|
|
|
|
@ -26,7 +34,10 @@ const onDeleteAddress = (id: string) => {
|
|
|
|
|
success: async (res) => {
|
|
|
|
|
if (res.confirm) {
|
|
|
|
|
// 根据id删除收货地址
|
|
|
|
|
await deleteMemberAddressByIdAPI(id)
|
|
|
|
|
const params = {
|
|
|
|
|
addressId: id,
|
|
|
|
|
}
|
|
|
|
|
await deleteMemberAddressAPI(params)
|
|
|
|
|
// 重新获取收货地址列表
|
|
|
|
|
getMemberAddressData()
|
|
|
|
|
}
|
|
|
|
@ -54,16 +65,15 @@ const onChangeAddress = (item: AddressItem) => {
|
|
|
|
|
<uni-swipe-action-item class="item" v-for="item in addressList" :key="item.id">
|
|
|
|
|
<view class="item-content" @tap="onChangeAddress(item)">
|
|
|
|
|
<view class="user">
|
|
|
|
|
{{ item.receiver }}
|
|
|
|
|
<text class="contact">{{ item.contact }}</text>
|
|
|
|
|
{{ item.receiveUserName }}
|
|
|
|
|
<text class="contact">{{ item.receiveMobilePhone }}</text>
|
|
|
|
|
<text v-if="item.isDefault" class="badge">默认</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="locate">{{ item.fullLocation }} {{ item.address }}</view>
|
|
|
|
|
<!-- H5 端需添加 .prevent 阻止链接的默认行为 -->
|
|
|
|
|
<view class="locate">{{ item.receiveStreet }}</view>
|
|
|
|
|
<navigator
|
|
|
|
|
class="edit"
|
|
|
|
|
hover-class="none"
|
|
|
|
|
:url="`/pagesMember/address-form/address-form?id=${item.id}`"
|
|
|
|
|
:url="`/pagesMember/address-form/address-form?info=${JSON.stringify(item)}`"
|
|
|
|
|
@tap.stop="() => {}"
|
|
|
|
|
@tap.prevent="() => {}"
|
|
|
|
|
>
|
|
|
|
@ -191,4 +201,5 @@ page {
|
|
|
|
|
font-size: 30rpx;
|
|
|
|
|
background-color: #3775F6;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
</style>import type { stringify } from 'querystring'
|
|
|
|
|
|
|
|
|
|