You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

208 lines
4.7 KiB

<template>
<view>
<view class="address_item" v-for="(item,index) in list" :key="index" @click="selectAddress(item)">
<view class="address_info">
<view class="address_info_title">
<view class="info_title_span">{{item.consignee}}</view>
<text>{{item.mobile}}</text>
</view>
<view class="address_info_content">
<view class="info_content_left" style="width: 60%;">
<view>{{item.sign_building}} </view>
<text>{{item.country_name}} {{item.province_name}} {{item.city_name}} {{item.address}} {{item.mobile}}</text>
</view>
<image src="../../static/img/update.png" mode="" @click.stop="updateAddress(item)"></image>
</view>
</view>
<view class="address_default">
<view class="address_default_left">
<image src="../../static/img/select4.png" mode="" v-if="item.default_address_id==item.address_id"></image>
<image src="../../static/img/select2.png" mode="" v-else @click.stop="setDefault(item.address_id)"></image>
<text>Default address</text>
</view>
<text @click.stop="deleteAddress(item.address_id)">Delete</text>
</view>
</view>
<view class="empty_item" v-if="!list">
<view class="empty_item_img">
<image src = "../../static/img/map.png" mode=""></image>
</view>
<view>No harvest address!</view>
<view><navigator url="/pages/account/addAddress" >
<button>To add</button>
</navigator></view>
</view>
<view class="address_foot" v-if="list">
<navigator url="/pages/account/addAddress" >
<button>ADD ADDRESS</button>
</navigator>
</view>
<uni-popup ref="alertDialog" type="dialog">
<uni-popup-dialog type="error" cancelText="Close" confirmText="Delete" title="Tips" content="Whether to delete the address?"
@confirm="dialogConfirm" ></uni-popup-dialog>
</uni-popup>
</view>
</template>
<script>
import {defaultRequest,defaultRequest2} from '../../api/index.js'
export default {
data() {
return {
list:[],
address_id:'',
type:0
}
},
methods:{
//确认订单选择地址
selectAddress(item){
if(this.type==1){
uni.$emit('query' , {consignee : item,type:'address'});
uni.navigateBack()
}
},
// 修改地址
updateAddress(item){
uni.navigateTo({
url:'./addAddress?type=1&data='+JSON.stringify(item)
})
},
// 删除地址
deleteAddress(id){
this.address_id=id
this.$refs.alertDialog.open()
},
dialogConfirm(){
let data={_action:'dropconsignee',address_id:this.address_id}
defaultRequest2(data).then(res=>{
console.info(res)
if(res.error==0){
uni.showToast({
icon:'none',
title:res.message
})
this.getList()
}
})
},
// 设置默认地址
setDefault(id){
let data={_action:'setdefaultconsignee',address_id:id}
defaultRequest2(data).then(res=>{
console.info(res)
if(res.error==0){
this.getList()
}
})
},
getList(){
let data={_action:'getconsignees'}
defaultRequest(data).then(res=>{
console.info(res)
if(res.error==0){
this.list=res.data
}
})
}
},
onShow() {
this.getList()
},
onLoad(e) {
if(e.type==1){
this.type=1
}
}
}
</script>
<style>
page{
background-color: #F6F5FA;
padding-bottom: 160rpx;
}
</style>
<style lang="scss" scoped>
.address_foot{
padding: 42rpx 24rpx;
background-color: white;
border-top: #E2E2E2 solid 1px;
position: fixed;
bottom: 0;
width: 100%;
box-sizing: border-box;
button{
color: white;
height: 84rpx;
line-height: 84rpx;
background-color: black;
font-size: 26.67rpx;
font-weight: bold;
bottom: 10rpx;
}
}
.address_item{
margin-top: 17.33rpx;
width: 100%;
background-color: white;
padding-top: 32rpx;
font-size: 26rpx;
color: #666666;
font-weight: bold;
.address_info{
padding: 0 26.67rpx;
padding-bottom: 33.33rpx;
border-bottom: 1px solid #E2E2E2;
.address_info_title{
display: flex;
align-items: center;
margin-bottom: 37.33rpx;
.info_title_span{
font-size: 32rpx;
color: black;
margin-right: 38.67rpx;
}
}
.address_info_content{
display: flex;
align-items: center;
width: 100%;
.info_content_left{
padding-right: 38.67rpx;
margin-right: 34rpx;
min-width: 80%;
border-right: 1px solid #E2E2E2;
}
image{
width: 34.67rpx;
height: 34.67rpx;
}
}
}
.address_default{
padding: 29.33rpx 0;
padding-left: 26.67rpx;
padding-right: 52.67rpx;
display: flex;
align-items: center;
justify-content: space-between;
.address_default_left{
display: flex;
align-items: center;
image{
width: 25.33rpx;
height: 25.33rpx;
margin-right: 13.33rpx;
}
}
}
}
</style>