|
|
@ -3,15 +3,15 @@ |
|
|
|
<div class="selfCity flex flex-center2 p-12 flex-end"> |
|
|
|
<div class="flex flex-center2 flex-1"> |
|
|
|
<img src="@/assets/images/icons/homeBlue.png" alt="" @click="getAgency" /> |
|
|
|
<span style="color: #666666;" v-if="!selfCity">请选择您所在城市</span> |
|
|
|
<span v-else class="flex"> |
|
|
|
<!-- <span style="color: #666666;" v-if="!selfCity && district">请选择您所在城市</span> --> |
|
|
|
<span class="flex"> |
|
|
|
<div v-for="(item, index) in selfCity"> |
|
|
|
<span @click="handelClickAgencyName(item,index)"> {{ item.label }}</span> |
|
|
|
<span @click="handelClickAgencyNav(item, index)"> {{ item.label }}</span> |
|
|
|
<span v-if="index != selfCity.length - 1">,</span> |
|
|
|
</div> |
|
|
|
</span> |
|
|
|
</div> |
|
|
|
<van-button type="info" size="small" round class="m-right10">手动选择</van-button> |
|
|
|
<van-button type="info" size="small" round class="m-right10" @click="restAddress">手动选择</van-button> |
|
|
|
</div> |
|
|
|
<div class="container"> |
|
|
|
<van-list finished-text="没有更多了" class="selectAgency"> |
|
|
@ -24,25 +24,78 @@ |
|
|
|
|
|
|
|
<script> |
|
|
|
import { editUser, getAllOrgTreeList } from "@/api/user"; |
|
|
|
import { setConfig } from '@/utils/jweixin' |
|
|
|
export default { |
|
|
|
data() { |
|
|
|
return { |
|
|
|
cityJson: [], |
|
|
|
selfCity: [], |
|
|
|
address: null, |
|
|
|
district: null, |
|
|
|
show:true |
|
|
|
}; |
|
|
|
}, |
|
|
|
created() { |
|
|
|
this.getAgency() |
|
|
|
}, |
|
|
|
mounted() { |
|
|
|
setConfig(['checkJsApi', 'openLocation', 'getLocation', 'updateAppMessageShareData', 'updateTimelineShareData']) |
|
|
|
this.signWX() |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
async getAgency() { |
|
|
|
this.selfCity = []; |
|
|
|
let res = await getAllOrgTreeList({organizationName:''}) |
|
|
|
restAddress() { |
|
|
|
this.district = null; |
|
|
|
this.selfCity = null; |
|
|
|
this.getAgency(); |
|
|
|
}, |
|
|
|
signWX() { |
|
|
|
let _this = this |
|
|
|
wx.checkJsApi({ |
|
|
|
jsApiList: ['getLocation'], |
|
|
|
success: function (res) { |
|
|
|
// alert(JSON.stringify(res)); |
|
|
|
if (res.checkResult.getLocation === false) { |
|
|
|
alert('你的微信版本太低,不支持微信JS接口,请升级到最新的微信版本!') |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
wx.ready(function () { |
|
|
|
wx.getLocation({ |
|
|
|
type: 'gcj02', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02' |
|
|
|
success: function (res) { |
|
|
|
var latLng = new qq.maps.LatLng(res.latitude, res.longitude) |
|
|
|
getAddr.getAddress(latLng) |
|
|
|
}, |
|
|
|
cancel: function (res) { |
|
|
|
alert('用户拒绝授权获取地理位置') |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
wx.error(function (res) { |
|
|
|
console.log('微信js-sdk 配置失败000' + res.errMsg) |
|
|
|
}) |
|
|
|
// 调取腾讯地图 |
|
|
|
var getAddr = new qq.maps.Geocoder({ |
|
|
|
complete: function (res) { |
|
|
|
_this.address = res.detail |
|
|
|
var allAddress = res.detail.addressComponents |
|
|
|
var address = res.detail.address |
|
|
|
console.log('地址:', address, allAddress.province, allAddress.city, allAddress.district) |
|
|
|
_this.district = allAddress.district; |
|
|
|
_this.getAgency(true) |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
async getAgency(type) { |
|
|
|
let res = await getAllOrgTreeList({ organizationName: this.district }) |
|
|
|
if (res) { |
|
|
|
if (type) { |
|
|
|
this.selfCity.push({ label: this.district, children: res }) |
|
|
|
} |
|
|
|
this.cityJson = res; |
|
|
|
} |
|
|
|
}, |
|
|
|
handelClickAgencyName(item,index){ |
|
|
|
handelClickAgencyNav(item, index) { |
|
|
|
if (item.id === this.selfCity[this.selfCity.length - 1].id) return |
|
|
|
this.selfCity.splice(index + 1); |
|
|
|
this.cityJson = item.children; |
|
|
@ -58,7 +111,8 @@ export default { |
|
|
|
this.$router.replace('/') |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.cityJson = item.children |
|
|
|
this.district = item.label; |
|
|
|
this.getAgency() |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|