deming/components/mine/address-block/address-item.vue

175 lines
3.6 KiB
Vue
Raw Normal View History

2020-06-02 11:42:13 +08:00
<template>
2020-06-22 17:45:17 +08:00
<view class="items">
2020-07-16 17:39:06 +08:00
<view class="item-top" @click="choiceAddress">
2020-06-22 17:45:17 +08:00
<view class="user-info">
<view class="user-name">{{ item.address_realname }}</view>
2020-06-23 17:21:01 +08:00
<view class="user-pnone">{{ item.address_mob_phone | phoneFormat }}</view>
2020-06-22 17:45:17 +08:00
</view>
<view class="user-address u-line-2">{{ $u.trim(item.area_info + item.address_detail, 'all') }}</view>
</view>
<view class="item-bottom">
<view class="item-default">
<u-radio
:name="item.address_id"
shape="circle"
label-size="22"
2020-06-23 17:21:01 +08:00
:disabled="false"
2020-06-22 17:45:17 +08:00
>
<view :class="[item.address_is_default == '0' ? 'radio-others' : 'radio-default']">
{{ item.address_is_default == '0' ? '设为默认' : '已设为默认' }}
2020-06-02 11:42:13 +08:00
</view>
2020-06-22 17:45:17 +08:00
</u-radio>
</view>
<view class="address-operate">
<view @click="editAddress">
<image src="@/pageE/static/mine/24.png"></image>
<view>编辑</view>
2020-06-02 11:42:13 +08:00
</view>
2020-06-23 17:21:01 +08:00
<view @click="deleteAddress">
2020-06-22 17:45:17 +08:00
<image src="@/pageE/static/mine/25.png"></image>
<view>删除</view>
2020-06-02 11:42:13 +08:00
</view>
</view>
2020-06-23 17:21:01 +08:00
<u-toast ref="uToast" />
2020-06-22 17:45:17 +08:00
</view>
2020-06-02 11:42:13 +08:00
</view>
</template>
<script>
2020-07-16 17:39:06 +08:00
/**
* address
* @description 地址
* @property {Object} item 地址信息
* @property {String} state 是否选择地址 choise
*/
2020-06-02 11:42:13 +08:00
export default {
2020-06-02 15:35:19 +08:00
name: 'address-item',
2020-07-16 17:39:06 +08:00
props: ['item', 'current', 'state'],
2020-06-23 17:21:01 +08:00
filters: {
phoneFormat(value) {
return value.replace(/^(\d{3})\d*(\d{4})$/, '$1****$2');
}
2020-06-02 15:35:19 +08:00
},
methods: {
editAddress() {
2020-06-23 17:21:01 +08:00
this.$u.route({
2020-06-30 18:06:50 +08:00
type: 'redirect',
2020-06-23 17:21:01 +08:00
url: '/pageE/more/EditAddress',
params: {
item: JSON.stringify(this.item)
}
})
},
deleteAddress() {
// console.log(this.item.address_id);
this.$u.api.deleteAddress({
address_id: this.item.address_id
}).then((res)=>{
if(res.errCode == 0) {
this.showToast(res.message, 'success');
this.$emit('getAddressList');
} else {
2020-06-30 18:06:50 +08:00
this.showToast(res.message, 'error');
2020-06-23 17:21:01 +08:00
}
})
},
2020-07-16 17:39:06 +08:00
choiceAddress() {
if(this.state) {
this.$store.commit('updateAddress', this.item);
this.$u.route({
type: 'navigateBack',
url: '/pageC/cart/ConfirmOrder',
})
}
},
2020-06-23 17:21:01 +08:00
showToast(message, type) {
this.$refs.uToast.show({
title: message,
type: type,
})
2020-06-02 15:35:19 +08:00
},
},
2020-06-02 11:42:13 +08:00
}
</script>
<style lang="scss" scoped>
2020-06-22 17:45:17 +08:00
.items {
padding: 1rpx 0 0;
.item-top {
position: relative;
padding-bottom: 30rpx;
&::after {
content: "";
position: absolute;
width: 690rpx;
height: 2rpx;
background: rgba(241,241,241,1);
bottom: 0;
left: 50%;
transform: translate(-50%,0);
}
.user-info {
display: flex;
align-items: center;
margin-bottom: 30rpx;
.user-name {
font-size: 32rpx;
font-weight: 500;
color: rgba(51,51,51,1);
margin-right: 13rpx;
}
.user-pnone {
font-size: 28rpx;
color: rgba(51,51,51,1);
}
}
.user-address {
font-size: 26rpx;
color: rgba(51,51,51,1);
line-height: 32rpx;
}
}
.item-bottom {
padding-top: 30rpx;
display: flex;
align-items: center;
justify-content: space-between;
.item-default {
display: flex;
align-items: center;
font-size: 22rpx;
.radio-default {
color: rgba(255,119,15,1);
2020-06-02 15:35:19 +08:00
}
2020-06-22 17:45:17 +08:00
.radio-others {
color:rgba(153,153,153,1);
}
}
.address-operate {
display: flex;
font-size: 24rpx;
color: rgba(152,152,152,1);
> view {
2020-06-02 15:35:19 +08:00
display: flex;
2020-06-22 17:45:17 +08:00
&:not(:last-child) {
margin-right: 30rpx;
}
> image {
margin-right: 15rpx;
flex-shrink: 0;
}
&:first-child {
> image {
width: 23rpx;
height: 23rpx;
2020-06-02 15:35:19 +08:00
}
2020-06-04 08:21:34 +08:00
}
2020-06-22 17:45:17 +08:00
&:nth-child(2) {
> image {
width: 17rpx;
height: 21rpx;
2020-06-02 15:35:19 +08:00
}
}
}
2020-06-02 11:42:13 +08:00
}
}
}
</style>