2025-10-16 17:23:57 +08:00
|
|
|
<template>
|
|
|
|
|
<view class="shipping-container">
|
2025-10-17 14:10:49 +08:00
|
|
|
<u-navbar id="uNavbarId" back-text="收货地址" :back-text-style="navBarTitle"
|
|
|
|
|
:background="{background: 'transparent' }" :border-bottom="false" back-icon-color="#000" title-color="#000">
|
2025-10-16 17:23:57 +08:00
|
|
|
<template v-slot:right>
|
|
|
|
|
<view class="right-menu">
|
2025-10-17 14:10:49 +08:00
|
|
|
<view @click="handleManage">
|
|
|
|
|
{{isManage?'取消':'管理'}}
|
|
|
|
|
</view>
|
|
|
|
|
<view v-if="isManage" class="u-m-l-10 del-text" @click="showDelModel">
|
|
|
|
|
删除
|
2025-10-16 17:23:57 +08:00
|
|
|
</view>
|
|
|
|
|
<view class="u-m-l-10 add-text">
|
|
|
|
|
新增地址
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
</u-navbar>
|
2025-10-17 14:10:49 +08:00
|
|
|
<scroll-view scroll-y="true" :style="'height:'+scrollHeight+'px'" @scrolltolower="loadData">
|
|
|
|
|
<view class="data-list">
|
|
|
|
|
<view class="data-item" v-for="item in dataList" @click="handleClick(item)">
|
|
|
|
|
<view class="item-text">
|
|
|
|
|
<view class="address u-m-b-18">
|
|
|
|
|
{{item.province + item.city + item.district}}
|
|
|
|
|
</view>
|
|
|
|
|
<view class="specific-address u-m-b-18">
|
|
|
|
|
{{item.detailed_address}}
|
|
|
|
|
</view>
|
|
|
|
|
<view class="info">
|
|
|
|
|
<div class="u-m-r-20">{{item.receiver_name}}</div>
|
|
|
|
|
<div class="u-m-r-20">{{item.receiver_phone}}</div>
|
|
|
|
|
<span v-if="item.is_default" class="u-m-r-10">默认</span>
|
|
|
|
|
<span class="u-m-r-10">{{item.label}}</span>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="item-icon">
|
|
|
|
|
<image v-if="!isManage" style="width: 100%;height: 100%;" src="/static/icon/Edit.png" mode="">
|
|
|
|
|
</image>
|
|
|
|
|
<template v-else>
|
|
|
|
|
<image v-if="!isIncludeId(item.id)" style="width: 100%;height: 100%;"
|
|
|
|
|
src="/static/icon/chose.png" mode=""></image>
|
|
|
|
|
<image v-else style="width: 100%;height: 100%;" src="/static/icon/chose-active.png" mode="">
|
|
|
|
|
</image>
|
|
|
|
|
</template>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<u-loadmore :status="status" />
|
|
|
|
|
</view>
|
2025-10-16 17:23:57 +08:00
|
|
|
</scroll-view>
|
2025-10-17 14:10:49 +08:00
|
|
|
|
|
|
|
|
<!-- 确认是否删除 -->
|
|
|
|
|
<u-modal v-model="showDel" content="是否删除选中的地址" :show-cancel-button="true" @confirm="handleDel"></u-modal>
|
2025-10-16 17:23:57 +08:00
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2025-10-17 14:10:49 +08:00
|
|
|
import { computed, getCurrentInstance, onMounted, ref } from 'vue'
|
2025-10-17 14:45:21 +08:00
|
|
|
import { addressAPI } from '../../api/address'
|
2025-10-17 14:10:49 +08:00
|
|
|
|
2025-10-16 17:23:57 +08:00
|
|
|
const navBarTitle = {
|
|
|
|
|
fontWeight: '510',
|
|
|
|
|
fontStyle: 'Medium',
|
|
|
|
|
fontSize: '40rpx',
|
|
|
|
|
lineHeight: '52px'
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-17 14:10:49 +08:00
|
|
|
const isManage = ref(false)
|
|
|
|
|
const showDel = ref(false)
|
|
|
|
|
|
|
|
|
|
const handleManage = () => {
|
|
|
|
|
if (isManage.value) {
|
|
|
|
|
ids.value = []
|
|
|
|
|
}
|
|
|
|
|
isManage.value = !isManage.value
|
|
|
|
|
}
|
|
|
|
|
const showDelModel = () => {
|
|
|
|
|
showDel.value = true
|
|
|
|
|
}
|
|
|
|
|
const handleDel = () => {
|
|
|
|
|
// TODO 删除
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-16 17:23:57 +08:00
|
|
|
const scrollHeight = ref(0)
|
|
|
|
|
const instance = getCurrentInstance();
|
|
|
|
|
const loadHeight = () => {
|
|
|
|
|
uni.getSystemInfo({
|
|
|
|
|
success(res) {
|
|
|
|
|
let screenHeight = res.screenHeight
|
|
|
|
|
uni.createSelectorQuery().in(instance.proxy).select("#uNavbarId").boundingClientRect((data : any) => {
|
|
|
|
|
scrollHeight.value = screenHeight - data.height
|
|
|
|
|
}).exec()
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-17 14:10:49 +08:00
|
|
|
const defaultSize = 10
|
|
|
|
|
const params = ref({
|
|
|
|
|
page: 1,
|
|
|
|
|
size: defaultSize,
|
|
|
|
|
keyword: ''
|
|
|
|
|
})
|
|
|
|
|
const status = ref('loadmore')
|
|
|
|
|
const maxPage = ref()
|
2025-10-17 14:45:21 +08:00
|
|
|
const dataList = ref([])
|
2025-10-17 14:10:49 +08:00
|
|
|
const loadData = () => {
|
|
|
|
|
if (status.value == 'nomore') return
|
2025-10-17 14:45:21 +08:00
|
|
|
addressAPI.getList(params.value).then(res => {
|
|
|
|
|
console.log(res);
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
uni.stopPullDownRefresh()
|
|
|
|
|
})
|
2025-10-17 14:10:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ids = ref([])
|
|
|
|
|
const handleClick = (item : any) => {
|
|
|
|
|
if (isManage.value) { // 开始管理
|
|
|
|
|
ids.value.push(item.id)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const isIncludeId = (id : any) => {
|
|
|
|
|
return ids.value.includes(id);
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-16 17:23:57 +08:00
|
|
|
onMounted(() => {
|
|
|
|
|
loadHeight()
|
2025-10-17 14:10:49 +08:00
|
|
|
loadData()
|
2025-10-16 17:23:57 +08:00
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
.shipping-container {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100vh;
|
2025-10-17 14:10:49 +08:00
|
|
|
background: #E5ECFD;
|
|
|
|
|
|
2025-10-16 17:23:57 +08:00
|
|
|
|
|
|
|
|
.right-menu {
|
|
|
|
|
display: flex;
|
|
|
|
|
margin-right: 24rpx;
|
|
|
|
|
font-family: Work Sans;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
font-style: Medium;
|
|
|
|
|
font-size: 32rpx;
|
|
|
|
|
leading-trim: NONE;
|
|
|
|
|
line-height: 100%;
|
|
|
|
|
letter-spacing: -2%;
|
2025-10-17 14:10:49 +08:00
|
|
|
|
|
|
|
|
.del-text {
|
|
|
|
|
color: red;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.add-text {
|
2025-10-16 17:23:57 +08:00
|
|
|
color: #305DEF;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-10-17 14:10:49 +08:00
|
|
|
|
|
|
|
|
.data-list {
|
|
|
|
|
.data-item {
|
|
|
|
|
width: 100%;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
padding: 28rpx 22rpx;
|
|
|
|
|
background: #F5F8FF;
|
|
|
|
|
margin-bottom: 4rpx;
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
|
|
.item-text {
|
|
|
|
|
font-weight: 400;
|
|
|
|
|
line-height: 100%;
|
|
|
|
|
|
|
|
|
|
.address {
|
|
|
|
|
font-size: 20rpx;
|
|
|
|
|
color: #7B7E8F;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.specific-address {
|
|
|
|
|
font-size: 26rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.info {
|
|
|
|
|
font-size: 24rpx;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
|
|
span {
|
|
|
|
|
padding: 2rpx 8rpx;
|
|
|
|
|
font-size: 16rpx;
|
|
|
|
|
background: #DADDEA;
|
|
|
|
|
color: #305DEF;
|
|
|
|
|
border-radius: 2rpx;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.item-icon {
|
|
|
|
|
width: 40rpx;
|
|
|
|
|
height: 40rpx;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-10-16 17:23:57 +08:00
|
|
|
}
|
|
|
|
|
</style>
|