|
|
@@ -32,6 +32,8 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import { getProvinces, getStreetChildren, getStreetPath } from '@/utils/api.js'
|
|
|
+
|
|
|
export default {
|
|
|
name: 'AddressPicker',
|
|
|
props: {
|
|
|
@@ -76,7 +78,7 @@ export default {
|
|
|
methods: {
|
|
|
async loadProvinces() {
|
|
|
try {
|
|
|
- const res = await this.$http.get('/api/streets/provinces')
|
|
|
+ const res = await getProvinces()
|
|
|
this.provinces = res.data || []
|
|
|
} catch (e) {
|
|
|
console.error('加载省份失败', e)
|
|
|
@@ -85,7 +87,7 @@ export default {
|
|
|
|
|
|
async loadCities(provinceId) {
|
|
|
try {
|
|
|
- const res = await this.$http.get(`/api/streets/children/${provinceId}`)
|
|
|
+ const res = await getStreetChildren(provinceId)
|
|
|
this.cities = res.data || []
|
|
|
} catch (e) {
|
|
|
console.error('加载城市失败', e)
|
|
|
@@ -94,7 +96,7 @@ export default {
|
|
|
|
|
|
async loadDistricts(cityId) {
|
|
|
try {
|
|
|
- const res = await this.$http.get(`/api/streets/children/${cityId}`)
|
|
|
+ const res = await getStreetChildren(cityId)
|
|
|
this.districts = res.data || []
|
|
|
} catch (e) {
|
|
|
console.error('加载区县失败', e)
|
|
|
@@ -103,7 +105,7 @@ export default {
|
|
|
|
|
|
async loadStreets(districtId) {
|
|
|
try {
|
|
|
- const res = await this.$http.get(`/api/streets/children/${districtId}`)
|
|
|
+ const res = await getStreetChildren(districtId)
|
|
|
this.streets = res.data || []
|
|
|
} catch (e) {
|
|
|
console.error('加载街道失败', e)
|
|
|
@@ -112,7 +114,7 @@ export default {
|
|
|
|
|
|
async loadAddressById(streetId) {
|
|
|
try {
|
|
|
- const res = await this.$http.get(`/api/streets/${streetId}/path`)
|
|
|
+ const res = await getStreetPath(streetId)
|
|
|
const path = res.data || []
|
|
|
|
|
|
if (path.length >= 1) this.selectedProvince = path[0]
|