address.js
1.32 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
import address from '@/api/address'
import {AddressList, Col, Icon, NavBar, Row, Toast} from 'vant'
import storage from '@/utils/storage'
export default {
components: {
[AddressList.name]: AddressList,
[Toast.name]: Toast,
[Row.name]: Row,
[Col.name]: Col,
[Icon.name]: Icon,
[NavBar.name]: NavBar
},
data() {
return {
activeFooter: 3,
chosenAddressId: 0,
list: [
]
}
},
mounted(){
this.init()
},
methods: {
init(){
address.queryByUser().then( response => {
this.list = response.data
for(const index in this.list){
if(this.list[index].isDefault === true){
this.chosenAddressId= this.list[index].id
}
}
}).catch( err => {
Toast(err.response.data.message)
})
},
onAdd() {
Toast('新增地址');
this.$router.push('address/edit')
},
onEdit(item, index) {
this.$router.push({path:'address/edit',query:{id:item.id}})
},
onClickLeft() {
storage.set('chosenAddressId',this.chosenAddressId)
this.$router.go(-1)
}
}
}