2025-01-10 15:49:19 +08:00
|
|
|
<template>
|
|
|
|
|
<view class="address-list">
|
|
|
|
|
<Navbar title="我的地址" :showRightText="true" :isBack="false" :text="'新增地址'" @clickIcon="addAddress"/>
|
|
|
|
|
<view
|
|
|
|
|
v-for="(item, index) in addressList"
|
|
|
|
|
:key="index"
|
|
|
|
|
class="address-item"
|
2025-02-19 18:58:59 +08:00
|
|
|
@click="handleEdit(item)"
|
2025-01-10 15:49:19 +08:00
|
|
|
>
|
|
|
|
|
<view class="address-info">
|
|
|
|
|
<text class="address-text">{{ item.address }}</text>
|
|
|
|
|
<view class="contact-info">
|
|
|
|
|
<text class="contact-text">{{ item.name }}</text>
|
|
|
|
|
<text class="contact-text">{{ item.phone }}</text>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2025-02-19 18:58:59 +08:00
|
|
|
<span size="10">{{item.ifDefault=="1"?"默认":""}}</span>
|
2025-01-10 15:49:19 +08:00
|
|
|
<u-icon name="edit-pen-fill" color="#c8c9cc" size="22"></u-icon>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2025-02-19 18:58:59 +08:00
|
|
|
import { queryCustAddrApi } from '@/api/mine/information.js';
|
2025-01-10 15:49:19 +08:00
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
addressList: [
|
|
|
|
|
{
|
|
|
|
|
address: '府前西街与站前北街交叉口南200米',
|
2025-02-19 18:58:59 +08:00
|
|
|
name: '冯先生1',id: '1',
|
|
|
|
|
phone: '153****5876',
|
|
|
|
|
ifDefault:"1"
|
2025-01-10 15:49:19 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
address: '怡馨家园30号楼(近达人街商城)',
|
2025-02-19 18:58:59 +08:00
|
|
|
name: '冯先生',id: '2',ifDefault:"0",
|
2025-01-10 15:49:19 +08:00
|
|
|
phone: '153****5876'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
address: '西辛南区46号楼2单元101室',
|
2025-02-19 18:58:59 +08:00
|
|
|
name: '冯先生',id: '3',ifDefault:"0",
|
2025-01-10 15:49:19 +08:00
|
|
|
phone: '153****5876'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
},
|
2025-02-19 18:58:59 +08:00
|
|
|
onLoad() {
|
|
|
|
|
this.queryCustAddrList()
|
|
|
|
|
},
|
2025-01-10 15:49:19 +08:00
|
|
|
methods: {
|
2025-02-19 18:58:59 +08:00
|
|
|
async queryCustAddrList() {
|
|
|
|
|
try {
|
|
|
|
|
let param = {
|
|
|
|
|
"custId":uni.getStorageSync('custId'),
|
|
|
|
|
}
|
|
|
|
|
const res = await queryCustAddrApi(param)
|
|
|
|
|
console.log('🚀 ~ getList ~ res:', res)
|
|
|
|
|
this.addressList = res.data;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.log(error)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
async updateDefaultAddr() {
|
|
|
|
|
try {
|
|
|
|
|
let param = {
|
|
|
|
|
"custId":uni.getStorageSync('custId'),
|
|
|
|
|
}
|
|
|
|
|
const res = await updateDefaultAddrApi(param)
|
|
|
|
|
console.log('🚀 ~ getList ~ res:', res)
|
|
|
|
|
if(res.code==200){
|
|
|
|
|
uni.$u.toast(`操作成功!`)
|
|
|
|
|
}else{
|
|
|
|
|
uni.$u.toast(`操作成功!`)
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.log(error)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
handleEdit(address) {
|
2025-01-10 15:49:19 +08:00
|
|
|
// 处理编辑事件
|
2025-02-19 18:58:59 +08:00
|
|
|
// uni.$u.toast(`编辑第${index + 1}个地址`)
|
|
|
|
|
console.log('🚀 ==='+address)
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: `/pages/mine/me/upAddress?address=${encodeURIComponent(JSON.stringify(address))}`
|
|
|
|
|
})
|
2025-01-10 15:49:19 +08:00
|
|
|
},
|
|
|
|
|
addAddress() {
|
2025-02-19 18:58:59 +08:00
|
|
|
uni.navigateTo({
|
|
|
|
|
url: `/pages/mine/me/upAddress`
|
|
|
|
|
})
|
2025-01-10 15:49:19 +08:00
|
|
|
},
|
2025-02-19 18:58:59 +08:00
|
|
|
|
2025-01-10 15:49:19 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.address-list {
|
|
|
|
|
min-height: 100vh;
|
|
|
|
|
background-color: #f8f8f8;
|
|
|
|
|
padding: 30rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.address-item {
|
|
|
|
|
background-color: #ffffff;
|
|
|
|
|
border-radius: 8rpx;
|
|
|
|
|
padding: 30rpx;
|
|
|
|
|
margin-bottom: 20rpx;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
align-items: center;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.address-info {
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
|
|
|
|
.address-text {
|
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
color: #333333;
|
|
|
|
|
line-height: 1.5;
|
|
|
|
|
margin-bottom: 8rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.contact-info {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
|
|
.contact-text {
|
|
|
|
|
font-size: 26rpx;
|
|
|
|
|
color: #999999;
|
|
|
|
|
|
|
|
|
|
&:first-child {
|
|
|
|
|
margin-right: 20rpx;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|