2025-04-01 16:37:21 +08:00
|
|
|
<template>
|
|
|
|
<view class="addr-box">
|
2025-04-07 13:53:10 +08:00
|
|
|
<navigation-bar-vue title="地址管理" style="width: 100%;" background-color="#ffffff"
|
|
|
|
title-color="#000000"></navigation-bar-vue>
|
2025-04-10 16:25:23 +08:00
|
|
|
<view class="opt-box" v-if="!ifChoose">
|
2025-04-01 16:37:21 +08:00
|
|
|
<view v-if="!ifEdit" class="item-dom" @click="manager(true)"><uni-icons type="bars" color="#FC1F3E"
|
|
|
|
size="16"></uni-icons><text>管理</text></view>
|
|
|
|
<view v-if="!ifEdit" class="item-dom" @click="addNew()">
|
|
|
|
<uni-icons type="plusempty" color="#FC1F3E" size="16"></uni-icons>
|
|
|
|
<text>新增地址</text>
|
|
|
|
</view>
|
|
|
|
<view v-if="ifEdit" class="item-dom" @click="manager(false)"><uni-icons type="closeempty" color="#FC1F3E"
|
|
|
|
size="16"></uni-icons><text>退出管理</text></view>
|
|
|
|
</view>
|
2025-04-10 16:25:23 +08:00
|
|
|
<view :class="['addr-list-box',ifChoose?'choose-height':'']">
|
2025-04-07 13:53:10 +08:00
|
|
|
<view v-for="(item,index) in dataList" class="addr-item-box">
|
|
|
|
<view class="addr-item-top">
|
|
|
|
<view class="item-info">
|
|
|
|
<view class="text little-1">{{ item.cityName }}</view>
|
|
|
|
<view class="text">{{ item.detail }}</view>
|
|
|
|
<view class="text little-2 item-flex">
|
|
|
|
{{ item.name }} {{ item.tel }}
|
|
|
|
<view v-if="item.isDefault=='1'" class="item-icon">默认</view>
|
2025-04-01 16:37:21 +08:00
|
|
|
</view>
|
|
|
|
</view>
|
2025-04-10 16:25:23 +08:00
|
|
|
<view v-if="!ifChoose" class="item-opt" @click="toEdit(item.id)">
|
2025-04-07 13:53:10 +08:00
|
|
|
<uni-icons type="compose" color="#565656" size="16"></uni-icons><text>编辑</text>
|
2025-04-01 16:37:21 +08:00
|
|
|
</view>
|
2025-04-14 14:24:40 +08:00
|
|
|
<view v-if="ifChoose" class="item-opt" @click="chooseItem(item)">
|
2025-04-10 16:25:23 +08:00
|
|
|
<uni-icons type="paperplane" color="#565656" size="16"></uni-icons><text>选择</text>
|
|
|
|
</view>
|
2025-04-01 16:37:21 +08:00
|
|
|
</view>
|
2025-04-07 13:53:10 +08:00
|
|
|
<view class="addr-item-opt" v-if="ifEdit">
|
|
|
|
<view class="opt-button choose" @click="setDefaultCity(item.id)" v-if="item.isDefault!='1'">设为默认
|
|
|
|
</view>
|
|
|
|
<view class="opt-button" @click="toCopy(item.id)">复制</view>
|
|
|
|
<view class="opt-button" @click="remove(item.id)">删除</view>
|
2025-04-01 16:37:21 +08:00
|
|
|
</view>
|
2025-04-07 13:53:10 +08:00
|
|
|
</view>
|
|
|
|
<view style="text-align: center" v-if="dataList.length==0">
|
|
|
|
<image class="" src="@/static/images/nothing.png"></image>
|
|
|
|
</view>
|
2025-04-01 16:37:21 +08:00
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2025-04-07 13:53:10 +08:00
|
|
|
import navigationBarVue from '@/components/navigation/navigationBar.vue';
|
2025-04-02 17:35:06 +08:00
|
|
|
import {
|
2025-04-07 13:53:10 +08:00
|
|
|
getUserAddress,
|
|
|
|
setDefault,
|
|
|
|
removeAddress
|
2025-04-02 17:35:06 +08:00
|
|
|
} from '@/api/business/member.js'
|
2025-04-01 16:37:21 +08:00
|
|
|
export default {
|
2025-04-07 13:53:10 +08:00
|
|
|
components: {
|
|
|
|
navigationBarVue
|
|
|
|
},
|
2025-04-01 16:37:21 +08:00
|
|
|
data() {
|
|
|
|
return {
|
2025-04-07 13:53:10 +08:00
|
|
|
|
2025-04-01 16:37:21 +08:00
|
|
|
ifEdit: false,
|
|
|
|
queryParams: {
|
|
|
|
pageNum: 1,
|
|
|
|
pageSize: 10
|
|
|
|
},
|
|
|
|
total: 0,
|
|
|
|
//下来刷新状态
|
|
|
|
isTriggered: false,
|
2025-04-10 16:25:23 +08:00
|
|
|
dataList: [],
|
|
|
|
//是否是选择模式
|
2025-04-14 14:24:40 +08:00
|
|
|
ifChoose: false,
|
2025-04-01 16:37:21 +08:00
|
|
|
}
|
|
|
|
},
|
2025-04-03 11:47:29 +08:00
|
|
|
|
2025-04-07 13:53:10 +08:00
|
|
|
onShow() {
|
|
|
|
this.initData();
|
|
|
|
},
|
2025-04-01 16:37:21 +08:00
|
|
|
methods: {
|
2025-04-07 13:53:10 +08:00
|
|
|
/**初始化数据*/
|
2025-04-02 17:35:06 +08:00
|
|
|
initData() {
|
|
|
|
getUserAddress().then(res => {
|
|
|
|
this.dataList = res.data
|
|
|
|
}).catch((e) => {
|
|
|
|
uni.showToast({
|
|
|
|
icon: 'error',
|
|
|
|
duration: 2000,
|
|
|
|
title: e
|
|
|
|
});
|
|
|
|
})
|
|
|
|
},
|
2025-04-07 13:53:10 +08:00
|
|
|
/**设为默认方法*/
|
|
|
|
setDefaultCity(id) {
|
|
|
|
setDefault({
|
|
|
|
id: id
|
|
|
|
}).then(res => {
|
|
|
|
uni.showToast({
|
|
|
|
icon: 'success',
|
|
|
|
duration: 2000,
|
|
|
|
title: '设置成功'
|
|
|
|
});
|
|
|
|
this.ifEdit = false
|
|
|
|
this.initData()
|
|
|
|
}).catch((e) => {
|
|
|
|
uni.showToast({
|
|
|
|
icon: 'error',
|
|
|
|
duration: 2000,
|
|
|
|
title: e
|
|
|
|
});
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
/**删除地址*/
|
|
|
|
remove(id) {
|
|
|
|
removeAddress({
|
|
|
|
id: id
|
|
|
|
}).then(res => {
|
|
|
|
uni.showToast({
|
|
|
|
icon: 'success',
|
|
|
|
duration: 2000,
|
|
|
|
title: '删除成功'
|
|
|
|
});
|
|
|
|
this.ifEdit = false
|
|
|
|
this.initData()
|
|
|
|
}).catch((e) => {
|
|
|
|
uni.showToast({
|
|
|
|
icon: 'error',
|
|
|
|
duration: 2000,
|
|
|
|
title: e
|
|
|
|
});
|
|
|
|
})
|
|
|
|
},
|
|
|
|
/**新增页面*/
|
2025-04-01 16:37:21 +08:00
|
|
|
addNew() {
|
|
|
|
this.$tab.navigateTo(`/pages/mine/addr/addr-detail`)
|
|
|
|
},
|
2025-04-07 13:53:10 +08:00
|
|
|
/**编辑页面*/
|
|
|
|
toEdit(id) {
|
|
|
|
this.$tab.navigateTo(`/pages/mine/addr/addr-detail?id=` + id)
|
|
|
|
},
|
2025-04-10 16:25:23 +08:00
|
|
|
/**
|
|
|
|
* 选择地址
|
|
|
|
* @param {Object} id
|
|
|
|
*/
|
2025-04-14 14:24:40 +08:00
|
|
|
chooseItem(item) {
|
|
|
|
uni.$emit('updateAddr', item)
|
|
|
|
uni.navigateBack()
|
|
|
|
},
|
2025-04-07 13:53:10 +08:00
|
|
|
/**复制*/
|
|
|
|
toCopy(id) {
|
|
|
|
this.$tab.navigateTo(`/pages/mine/addr/addr-detail?id=` + id + `&isCopy=1`)
|
|
|
|
},
|
2025-04-03 11:47:29 +08:00
|
|
|
|
2025-04-01 16:37:21 +08:00
|
|
|
/**
|
|
|
|
* 进入管理
|
|
|
|
*/
|
|
|
|
manager(flag) {
|
|
|
|
this.ifEdit = flag
|
|
|
|
},
|
2025-04-03 11:47:29 +08:00
|
|
|
|
2025-04-01 16:37:21 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
.addr-box {
|
2025-04-07 13:53:10 +08:00
|
|
|
padding-top: calc(90rpx + var(--status-bar-height));
|
2025-04-01 16:37:21 +08:00
|
|
|
background-color: white;
|
|
|
|
width: 100%;
|
|
|
|
color: #363636;
|
|
|
|
font-size: 32rpx;
|
|
|
|
height: 100%;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
align-items: self-start;
|
|
|
|
justify-content: center;
|
|
|
|
position: relative;
|
|
|
|
|
|
|
|
.opt-box {
|
|
|
|
width: 100%;
|
|
|
|
display: flex;
|
|
|
|
color: #FC1F3E;
|
|
|
|
padding: 25rpx;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
2025-04-07 13:53:10 +08:00
|
|
|
border-top: 1rpx solid #F2F2F2;
|
2025-04-01 16:37:21 +08:00
|
|
|
border-bottom: 1rpx solid #F2F2F2;
|
|
|
|
|
|
|
|
.item-dom {
|
|
|
|
flex: 1;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
|
|
|
|
text {
|
|
|
|
margin-left: 10rpx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-04-10 16:25:23 +08:00
|
|
|
.choose-height {
|
|
|
|
height: calc(100vh - var(--status-bar-height) - var(--window-bottom) - 91rpx) !important;
|
|
|
|
}
|
|
|
|
|
2025-04-01 16:37:21 +08:00
|
|
|
.addr-list-box {
|
2025-04-10 16:25:23 +08:00
|
|
|
border-top: 1rpx solid #F2F2F2;
|
2025-04-07 13:53:10 +08:00
|
|
|
height: calc(100vh - var(--status-bar-height) - var(--window-bottom) - 191rpx);
|
|
|
|
overflow-y: scroll;
|
2025-04-01 16:37:21 +08:00
|
|
|
padding: 0 30rpx;
|
|
|
|
width: 100%;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
align-items: center;
|
2025-04-03 11:47:29 +08:00
|
|
|
justify-content: start;
|
2025-04-01 16:37:21 +08:00
|
|
|
|
|
|
|
.addr-item-box {
|
|
|
|
width: 100%;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
padding: 20rpx 0;
|
|
|
|
border-bottom: 1rpx solid #F2F2F2;
|
|
|
|
|
|
|
|
.addr-item-top {
|
|
|
|
width: 100%;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
|
|
|
|
.item-info {
|
|
|
|
flex: 1;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
align-items: self-start;
|
|
|
|
justify-content: center;
|
|
|
|
|
|
|
|
.text {
|
|
|
|
padding: 5rpx;
|
|
|
|
}
|
|
|
|
|
|
|
|
.little-1 {
|
|
|
|
color: #929292;
|
|
|
|
font-size: 24rpx;
|
|
|
|
}
|
|
|
|
|
|
|
|
.little-2 {
|
|
|
|
color: #363636;
|
|
|
|
font-size: 24rpx;
|
|
|
|
}
|
|
|
|
|
|
|
|
.item-flex {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
|
|
|
|
.item-icon {
|
|
|
|
font-size: 18rpx;
|
|
|
|
margin-left: 10rpx;
|
|
|
|
border-radius: 10rpx;
|
|
|
|
padding: 3rpx 18rpx;
|
|
|
|
background-color: #FEE8EB;
|
|
|
|
color: #FC3753;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.item-opt {
|
|
|
|
font-size: 26rpx;
|
|
|
|
width: 100rpx;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
|
|
|
|
text {
|
|
|
|
padding-left: 5rpx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.addr-item-opt {
|
|
|
|
width: 100%;
|
|
|
|
padding-top: 20rpx;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: flex-end;
|
|
|
|
|
|
|
|
.opt-button {
|
|
|
|
margin: 0 15rpx;
|
|
|
|
font-size: 26rpx;
|
|
|
|
color: #363636;
|
|
|
|
background-color: #E2E2E2;
|
|
|
|
border-radius: 20rpx;
|
|
|
|
padding: 10rpx 30rpx;
|
|
|
|
}
|
|
|
|
|
|
|
|
.choose {
|
|
|
|
background-color: #FEE8EB;
|
|
|
|
color: #FC3753;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2025-04-14 14:24:40 +08:00
|
|
|
</style>
|