jiuyiUniapp/jiuyi/pages/mine/components/jy-address/index.vue

185 lines
5.3 KiB
Vue
Raw Normal View History

2024-12-18 15:46:27 +08:00
<template>
<view class="page-wrapper">
<view v-for="addressItem in addressData" :key="addressItem.id" class="address-item"
@click="emit('choose', addressItem)">
<view class="top-area">
<text class="name">{{ addressItem.name }}</text>
<text class="phone">
<!-- <text class="iconfont icon-dianhua" style="margin-right: 5rpx"></text> -->
{{ addressItem.phone }}</text>
<!-- <text class="default-tag" v-if="addressItem.isDefault">默认</text>
<text class="default-tag" v-if="addressItem.isCompany">公司</text>
<text class="default-tag home-tag" v-if="addressItem.isHome"></text> -->
</view>
<view class="address-text">{{ addressItem.address }}</view>
<view class="bottom-area">
<label>
<checkbox @click.stop="emit('setDefault', addressItem)" color="#f60" disabled
style="transform:scale(0.8)" :class="[addressItem.isDefault && 'isDefault']"
:checked="addressItem.isDefault" />
<text @click.stop="emit('setDefault', addressItem)" class="set-def-text">设为默认</text>
</label>
<view class="operation-btns">
<uni-tag class="mlr10" @click.stop="emit('edit', addressItem)" :inverted="true" text="复制"
type="warning" size="small"></uni-tag>
<uni-tag class="mlr1" @click.stop="copyText(addressItem)" :inverted="true" text="修改" type="warning"
size="small"></uni-tag>
</view>
</view>
<text class="delete" @click.stop="emit('delete', addressItem)">×</text>
</view>
</view>
</template>
<script setup>
import { ref } from 'vue'
const emit = defineEmits(['setDefault', 'delete', 'edit', 'choose'])
const props = defineProps({
addressData: {
type: Array,
default: () => ({})
},
addBtnStyles: {
type: Object,
default: () => ({})
}
})
console.log('====================================');
console.log(props.addressData);
console.log('====================================');
const copyText = (item) => {
uni.setClipboardData({
data: item.address,
success: () => {
uni.showToast({
title: '复制成功',
icon: 'success'
});
},
fail: () => {
uni.showToast({
title: '复制失败',
icon: 'none'
});
}
});
}
</script>
<style lang="scss" scoped>
$text-color1: #333333;
$text-color2: #666;
::v-deep .uni-checkbox-input-disabled {
border-radius: 50% !important;
background-color: #ffffff !important;
}
::v-deep .isDefault {
.uni-checkbox-input {
background-color: #F8BA4D !important;
border-color: #F8BA4D !important;
}
path {
fill: #fff;
}
}
.page-wrapper {
// padding: 20rpx;
overflow-y: scroll;
height: calc(100vh - 200rpx - 110rpx);
.address-item {
width: 100%;
height: 220rpx;
padding: 15rpx;
box-sizing: border-box;
background-color: #fff;
// border-radius: 20rpx;
margin-bottom: 20rpx;
position: relative;
.delete {
position: absolute;
top: 15rpx;
right: 15rpx;
width: 26rpx;
height: 26rpx;
}
.top-area {
font-weight: bold;
font-size: 28rpx;
margin: 10rpx 0;
.name {
margin-right: 20rpx;
}
text {
color: #333333;
font-size: 28rpx;
}
// .default-tag {
// position: relative;
// left: 15rpx;
// top: -5rpx;
// font-size: 10px;
// color: rgb(58, 152, 218);
// display: inline-block;
// padding: 1px 3px;
// border: 1px solid rgb(58, 152, 218);
// margin-right: 15rpx;
// }
// .home-tag {
// border: 1px solid #f60;
// color: #f60;
// }
}
.address-text {
padding: 0 0 15rpx 0;
width: 90vw;
color: $text-color1;
white-space: nowrap;
/* 禁止换行 */
overflow: hidden;
/* 隐藏溢出部分 */
text-overflow: ellipsis;
/* 使用省略号替代溢出部分 */
}
.bottom-area {
display: flex;
padding-right: 0rpx;
justify-content: space-between;
justify-items: center;
.set-def-text {
font-size: 14px;
color: $text-color2;
}
}
}
.add-address-btn {
position: fixed;
z-index: 99;
bottom: 120rpx;
width: calc(100% - 30rpx);
margin: auto;
height: 80rpx;
border-radius: 15rpx;
background-color: #f60;
color: #fff;
font-size: 22px;
text-align: center;
line-height: 80rpx;
letter-spacing: 4rpx;
}
}
</style>