my-address.vue 3.4 KB
<template>
	<view class="content">
		<view class="item" v-for="(item,index) in list" :key="index">
			<view class="topInfo">
				<view class="nameBox">
					{{item.consignee}}
					<text class="phone">{{item.phone}}</text>
				</view>
				<view class="addressBox">
					<view class="" style="flex: 1;">
						{{item.province_name}}{{item.city_name}}{{item.area_name}}{{item.address}}
					</view>
					<view class="" style="width: 70rpx;text-align: right;" @click="editAddress(item.id)">
						<image src="../../static/ic_42@2x.png" mode="" style="width: 32rpx;height: 32rpx;"></image>
					</view>
				</view>
			</view>
			<view class="handle">
				<view class="defalutBox">
					<image src="../../static/ic_37@2x.png" mode="" v-if="item.is_default==1"></image>
					<image src="../../static/ic_38_1@2x.png" mode="" v-else></image>
					默认地址
				</view>
				<view class="delBtn" @click="delAddress(item.id,index)">
					删除
				</view>
			</view>
		</view>
		<view class="bottomBtn">
			<view class="btn" @click="address">
				+新增收货地址
			</view>
		</view>
	</view>
</template>

<script>
	import request from '../../utils/request.js'
	export default {
		data() {
			return {
				list: [{
					name: '张筱雨',
					phone: '12345678912',
					address: '福建省三明市梅列区列西街道17幢福建省三明市梅列区列西街道17幢'
				}, {
					name: '张筱雨',
					phone: '12345678912',
					address: '福建省三明市梅列区列西街道17幢福建省三明市梅列区列西街道17幢'
				}]
			}
		},
		onShow() {
			this.getList()
		},
		methods:{
			//添加地址
			address(){
				uni.navigateTo({
					url:'/pages/me/add-address'
				})
			},
			//删除地址
			delAddress(ids,index){
				request.post('/api/address/del',{id:ids}).then(res=>{
					if(res.code==1){
						this.list.splice(index,1)
					}
				}).catch(err=>{
					
				})
			},
			getList(){
				request.get('/api/address/index',{}).then(res=>{
					this.list=res.data
				}).catch(err=>{})
			},
			
		}
	}
</script>

<style>
	.content {
		min-height: 100vh;
		background-color: #F7F8FA;
		padding: 32rpx;
		box-sizing: border-box;
	}

	.item {
		background-color: #fff;
		margin-bottom: 32rpx;
		border-radius: 24rpx;
		padding: 32rpx;
		box-sizing: border-box;
		padding-bottom: 0;
	}

	.topInfo {
		border-bottom: 2rpx solid #ebedf0;
	}

	.nameBox {
		color: #323233;
		font-size: 32rpx;
	}

	.phone {
		color: #969799;
		font-size: 24rpx;
		padding-right: 16rpx;
	}

	.addressBox {
		display: flex;
		justify-content: space-between;
		/* align-items: center; */
		color: #323233;
		font-size: 24rpx;
		padding: 32rpx 0;
		box-sizing: border-box;
	}

	.handle {
		padding: 32rpx 0;
		box-sizing: border-box;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.defalutBox {
		display: flex;
		align-items: center;
		color: #ff2f2f;
		font-size: 26rpx;
	}

	.defalutBox image {
		width: 38rpx;
		height: 38rpx;
		margin-right: 6rpx;
	}

	.delBtn {
		width: 104rpx;
		height: 40rpx;
		background: #f2f3f5;
		border-radius: 96rpx;
		color: #646566;
		font-size: 24rpx;
		line-height: 40rpx;
		text-align: center;
	}

	.bottomBtn {
		width: 100%;
		background-color: #fff;
		padding: 26rpx 32rpx;
		box-sizing: border-box;
		position: fixed;
		bottom: 0;
		left: 0;
	}
	.btn{
		width: 100%;
		height: 80rpx;
		background-color:#ff2f2f;
		line-height: 80rpx;
		color: #ffffff;
		font-size: 32rpx;
		text-align: center;
	}
</style>