purchase-let/pagesOrder/addressList/addressList.vue

159 lines
3.8 KiB
Vue
Raw Normal View History

2024-04-27 18:02:43 +08:00
<template>
<view class="list">
2024-04-28 18:08:57 +08:00
<view class="address-card" v-for="(item, index) in addressList" :key="index">
2024-04-27 18:02:43 +08:00
<view class="address-info">
<view class="top">
2024-04-28 18:08:57 +08:00
<view class="name">收货人{{item.real_name}}</view>
<view class="phone">{{item.phone}}</view>
2024-04-27 18:02:43 +08:00
</view>
<view class="bottom">
2024-04-28 18:08:57 +08:00
{{item.detail}}
2024-04-27 18:02:43 +08:00
</view>
</view>
<view class="btn-box">
<view class="left">
<image v-if="false" src="@/static/icon/check.png"></image>
<image v-else src="@/static/icon/n-check.png"></image>
<view>设为默认</view>
</view>
<view class="right">
<view class="btn" @click="showDelete(item)">
<up-icon name="trash"></up-icon>
删除
</view>
<view class="btn" @click="navTo('/pagesOrder/addressEdit/addressEdit?mode=edit')">
<up-icon name="edit-pen"></up-icon>
编辑
</view>
</view>
</view>
</view>
<view style="width: 100%;height: 150rpx;"></view>
<view class="bottom-fixed">
<up-button color="#20B128" shape="circle" @click="navTo('/pagesOrder/addressEdit/addressEdit')">新增地址</up-button>
</view>
<modal :show="show" title="确认删除吗" content="删除后不可恢复" @close="show=false" @change="deleteAddress"></modal>
</view>
</template>
<script setup>
import { ref } from "vue"
import modal from "@/components/modal.vue";
2024-04-28 18:08:57 +08:00
import { addressListsApi } from "@/api/user.js"
2024-04-27 18:02:43 +08:00
const navTo = (url)=>{
uni.navigateTo({
url: url
})
}
const show = ref(false);
const deleteInfo = ref({});
const showDelete = (item)=>{
deleteInfo.value = item;
show.value = true;
}
const deleteAddress = ()=>{
console.log(deleteInfo.value);
show.value = false;
}
2024-04-28 18:08:57 +08:00
const addressList = ref([]);
const getAddressLists = ()=>{
addressListsApi().then(res=>{
addressList.value = res.data.lists;
console.log(addressList);
})
}
getAddressLists();
2024-04-27 18:02:43 +08:00
</script>
<style lang="scss">
.address-card {
margin: 20rpx;
background-color: #fff;
border-radius: 14rpx;
box-sizing: border-box;
padding: 20rpx;
color: #444;
.address-info {
padding-bottom: 20rpx;
2024-04-28 18:08:57 +08:00
border-bottom: 1rpx solid #f6f6f6;
2024-04-27 18:02:43 +08:00
margin-bottom: 20rpx;
.top {
display: flex;
justify-content: space-between;
font-size: 28rpx;
.name {
color: #000;
}
}
.bottom {
font-size: 26rpx;
margin-top: 10rpx;
}
}
.btn-box {
display: flex;
justify-content: space-between;
font-size: 26rpx;
.left{
display: flex;
align-items: center;
image{
width: 40rpx;
height: 40rpx;
margin-right: 6rpx;
}
}
.right {
display: flex;
color: #7a7a7a;
align-items: center;
.btn {
display: flex;
margin-left: 20rpx;
&:active {
color: rgba(#7a7a7a, 0.8);
transition: background-color 0.5s;
animation: disappear 0.5s 0.5s forwards;
}
}
}
}
}
.bottom-fixed{
position: fixed;
bottom: 0;
left: 0;
height: 120rpx;
height: calc(constant(safe-area-inset-bottom) + 120rpx); /* 适用于iOS设备 */
height: calc(env(safe-area-inset-bottom) + 120rpx); /* 适用于Android设备 */
width: 100%;
box-sizing: border-box;
background-color: #fff;
padding: 20rpx;
padding-bottom: calc(constant(safe-area-inset-bottom) + 20rpx); /* 适用于iOS设备 */
padding-bottom: calc(env(safe-area-inset-bottom) + 20rpx); /* 适用于Android设备 */
}
@keyframes disappear {
to {
opacity: 0;
/* 渐隐 */
transform: scale(0);
/* 缩小 */
}
}
</style>