deming/pageE/more/Address.vue
2020-06-22 17:45:17 +08:00

76 lines
1.6 KiB
Vue

<template>
<view class="address">
<u-radio-group v-model="current" @change="changeDefault" size="29" active-color="#FF780F">
<view v-for="(item, index) in addressList" :key="index" class="address-item">
<AddressItem :item="item" :current='current'></AddressItem>
</view>
</u-radio-group>
<view class="address-btn" @click="addAddress">添加地址</view>
</view>
</template>
<script>
import AddressItem from '@/components/mine/address-block/address-item'
export default {
data() {
return {
current: 0,
addressList: []
}
},
components: {
AddressItem
},
onLoad() {
this.getAddressList();
},
methods: {
getAddressList() {
this.$u.api.getAddressList().then((res)=>{
if (res.errCode == 0) {
this.addressList = res.data.addressList;
let defaultAddress = this.addressList.filter(item => {
return item.address_is_default == '1';
})
this.current = defaultAddress[0].address_id;
}
})
},
addAddress() {
uni.navigateTo({
url: '/pageE/more/AddAddress'
});
},
changeDefault(event) {
console.log(event)
// this.current = event
},
},
}
</script>
<style lang="scss" scoped>
.address {
min-height: calc(100vh - var(--window-top));
background-color: #ECECEC;
padding: 1rpx 0 40rpx;
box-sizing: border-box;
.u-radio-group {
display: block;
.address-item {
background-color: #ffffff;
margin-bottom: 20rpx;
padding: 30rpx;
}
}
.address-btn {
margin: 322rpx auto 0;
width: 690rpx;
height: 98rpx;
background: rgba(255,119,15,1);
border-radius: 49rpx;
font-size: 36rpx;
color: rgba(255,255,255,1);
line-height: 98rpx;
text-align: center;
}
}
</style>