|
@@ -2,29 +2,23 @@
|
|
|
<view class="map-popup-box">
|
|
|
<view class="icon-title-navBar-box">
|
|
|
<view @click="goUpPage" class="nav-bar-icon"></view>
|
|
|
- <text @click="aaaa" class="nav-bar-title">选择地址</text>
|
|
|
+ <text class="nav-bar-title">选择地址</text>
|
|
|
</view>
|
|
|
-
|
|
|
- <!-- <view class="city-picker-box">
|
|
|
- <picker mode="region" @change="handleCityChange">
|
|
|
- <view class="city-picker">
|
|
|
- <text>{{ selectedCity }}</text>
|
|
|
- <uni-icons type="arrowdown" size="16" color="#666"></uni-icons>
|
|
|
- </view>
|
|
|
- </picker>
|
|
|
- </view> -->
|
|
|
<uni-popup ref="filterPopup" type="top" :animation="false" :is-mask-click="false"
|
|
|
- mask-background-color="rgba(0, 0, 0, 0.4)">
|
|
|
- <view class="white-popup">
|
|
|
- <view class="icon-title-navBar-box">
|
|
|
- <view @click="goUpPage2" class="nav-bar-icon"></view>
|
|
|
- <text class="nav-bar-title">返回</text>
|
|
|
- </view>
|
|
|
- <t-index-address @select="select"></t-index-address>
|
|
|
- </view>
|
|
|
+ mask-background-color="rgba(0, 0, 0, 0.4)">
|
|
|
+ <view class="white-popup">
|
|
|
+ <view class="icon-title-navBar-box">
|
|
|
+ <view @click="closePop" class="nav-bar-icon"></view>
|
|
|
+ <text class="nav-bar-title">选择城市</text>
|
|
|
+ </view>
|
|
|
+ <t-index-address @select="select"></t-index-address>
|
|
|
+ </view>
|
|
|
</uni-popup>
|
|
|
<!-- 查询职业 -->
|
|
|
<view class="phone-search-box">
|
|
|
+ <view @click="openPopup">
|
|
|
+ {{currentCity}}
|
|
|
+ </view>
|
|
|
<input class="search-input" placeholder="请输入地址" v-model="data.keyword" />
|
|
|
<view class="search-icon" @click="handleClick">
|
|
|
<uni-icons type="search" size="24" color="#fff"></uni-icons>
|
|
@@ -78,29 +72,33 @@
|
|
|
const {
|
|
|
getPositionSearchByKeyword
|
|
|
} = useCustomMap();
|
|
|
-
|
|
|
+
|
|
|
const result = ref(null);
|
|
|
const filterPopup = ref(null);
|
|
|
- const selectedCity = ref('选择城市'); // 默认显示“选择城市”
|
|
|
- function select(data){
|
|
|
- console.log('data',data);
|
|
|
- }
|
|
|
- function goUpPage2(data){
|
|
|
- console.log('data',data);
|
|
|
+ let currentCity = ref('选择城市');
|
|
|
+ function select(data) {
|
|
|
+ console.log('data', data);
|
|
|
+ currentCity.value = data.name; // 更新当前城市
|
|
|
+ filterPopup.value.close()
|
|
|
+ getCityLocation(data.name);
|
|
|
}
|
|
|
- function aaaa(data){
|
|
|
- console.log('data',data);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ function openPopup(data) {
|
|
|
+ console.log('data', data);
|
|
|
filterPopup.value.open("top")
|
|
|
}
|
|
|
-
|
|
|
- function handleCityChange(e) {
|
|
|
- //const city = e.detail.value[1]; // 获取选择的城市
|
|
|
- // selectedCity.value = city;
|
|
|
- // 根据选择的城市更新地图中心点
|
|
|
- getCityLocation("北京");
|
|
|
+
|
|
|
+ function closePop(data) {
|
|
|
+ console.log('data', data);
|
|
|
+ filterPopup.value.close()
|
|
|
}
|
|
|
- function getCityLocation(city) {
|
|
|
+
|
|
|
+
|
|
|
+ function getCityLocation(city) {
|
|
|
console.log('222222');
|
|
|
+ console.log('city',city);
|
|
|
const Key = `KBYBZ-FS3KZ-U2FXR-7VPDX-L7J46-23F55`
|
|
|
const url = `https://apis.map.qq.com/ws/geocoder/v1/?address=${city}&key=${Key}`;
|
|
|
|
|
@@ -224,7 +222,35 @@
|
|
|
height: 30
|
|
|
}]
|
|
|
})
|
|
|
+ function getCityName(latitude, longitude) {
|
|
|
+ const Key = `KBYBZ-FS3KZ-U2FXR-7VPDX-L7J46-23F55`
|
|
|
+ const url = `https://apis.map.qq.com/ws/geocoder/v1/?location=${latitude},${longitude}&key=${Key}`;
|
|
|
|
|
|
+ uni.request({
|
|
|
+ url: url,
|
|
|
+ success: (res) => {
|
|
|
+ if (res.data.status === 0) {
|
|
|
+ console.log('当前城市:', res);
|
|
|
+ const city = res.data.result.address_component.city;
|
|
|
+ currentCity.value = city; // 更新当前城市
|
|
|
+ console.log('当前城市:', city);
|
|
|
+ } else {
|
|
|
+ console.error('逆地理编码失败:', res.data.message);
|
|
|
+ uni.showToast({
|
|
|
+ title: '获取城市信息失败',
|
|
|
+ icon: 'none',
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail: (err) => {
|
|
|
+ console.error('请求失败:', err);
|
|
|
+ uni.showToast({
|
|
|
+ title: '请求失败',
|
|
|
+ icon: 'none',
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
// 初始化
|
|
|
function initLocation() {
|
|
|
console.log('init')
|
|
@@ -238,6 +264,7 @@
|
|
|
data.covers[0].latitude = res.latitude;
|
|
|
console.log('当前位置的经度:' + res.longitude);
|
|
|
console.log('当前位置的纬度:' + res.latitude);
|
|
|
+ getCityName(res.latitude, res.longitude)
|
|
|
// 获取当前位置附近的数据
|
|
|
getPositionSearchByKeyword('公司', `nearby(${res.latitude},${res.longitude},1000)`, onSuccess,
|
|
|
onError, {
|