|
|
@@ -257,28 +257,10 @@ export default {
|
|
|
return;
|
|
|
}
|
|
|
try {
|
|
|
- const amapKey = '5457092e6c62b83c1b2e45dbe973d858';
|
|
|
- const url = `https://restapi.amap.com/v3/geocode/regeo?key=${amapKey}&location=${longitude},${latitude}`;
|
|
|
- const res = await uni.request({
|
|
|
- url: url,
|
|
|
- method: 'GET',
|
|
|
- });
|
|
|
- if (!res.data || !res.data.regeocode || !res.data.regeocode.addressComponent) {
|
|
|
- console.error('获取城市信息失败:响应数据格式错误');
|
|
|
- return;
|
|
|
- }
|
|
|
- const city = res.data.regeocode.addressComponent.city;
|
|
|
- if (!city) {
|
|
|
- console.error('获取城市信息失败:未找到城市名称');
|
|
|
- return;
|
|
|
- }
|
|
|
- uni.setStorageSync('selectCity', city);
|
|
|
- const resquery = await getCityCode({name: city});
|
|
|
- if (!resquery || !resquery.data || !resquery.data.data) {
|
|
|
- console.error('获取城市代码失败:响应数据格式错误');
|
|
|
- return;
|
|
|
- }
|
|
|
- uni.setStorageSync('selectCitycode', resquery.data.data);
|
|
|
+ const resquery = await getCityCode({longitude: longitude,latitude:latitude});
|
|
|
+ console.log(resquery);
|
|
|
+ uni.setStorageSync('selectCity', resquery.data.data.cityName);
|
|
|
+ uni.setStorageSync('selectCitycode', resquery.data.data.cityCode);
|
|
|
} catch (error) {
|
|
|
console.error('获取城市信息失败:', error);
|
|
|
}
|