my-address.vue
3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<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>