对接活动实况接口;注掉登录接口代码

This commit is contained in:
zhouyanli
2026-04-27 13:38:24 +08:00
parent ae9465cc0e
commit d52cbbd51b
8 changed files with 256 additions and 115 deletions

View File

@@ -98,29 +98,113 @@ const chooseImg = () => {
};
// 删除图片
const deleteImg = (index) => {
imgList.value.splice(index, 1);
};
const deleteImg = (index) => {
imgList.value.splice(index, 1);
};
// 重新定位
const reLocate = () => {
uni.showLoading({ title: '定位中...' });
uni.getLocation({
type: 'gcj02',
success: (res) => {
uni.hideLoading();
longitude.value = res.longitude;
latitude.value = res.latitude;
location.value = `${res.longitude},${res.latitude}`;
uni.showToast({ title: '定位成功', icon: 'success' });
},
fail: (err) => {
uni.hideLoading();
uni.showToast({ title: '定位失败,请检查权限', icon: 'none' });
console.error('定位失败:', err);
}
});
};
// 重新定位
// 定位并获取具体地点名称
const reLocate = () => {
uni.showLoading({ title: '定位中...' });
// 第一步:获取经纬度
uni.getLocation({
type: 'gcj02', // 微信地图专用坐标系,必须用这个
success: (locRes) => {
// 第二步:通过经纬度逆解析为具体地址
uni.request({
url: 'https://apis.map.qq.com/ws/geocoder/v1/', // 腾讯地图逆地理编码接口(免费)
data: {
location: `${locRes.latitude},${locRes.longitude}`, // 纬度,经度
key: 'XCNBZ-TJ46B-BCJUZ-JBMIM-LZWRJ-SBBWW', // 替换成你自己的Key下面教你怎么获取
get_poi: 0 // 0=只返回基础地址1=返回周边POI
},
success: (geoRes) => {
uni.hideLoading();
if (geoRes.data.status === 0) {
// 解析成功,获取具体地址
const address = geoRes.data.result.address; // 完整地址北京市海淀区中关村南大街5号
const formattedAddress = geoRes.data.result.formatted_addresses.recommend; // 推荐地址(更简洁)
const province = geoRes.data.result.address_component.province; // 省
const city = geoRes.data.result.address_component.city; // 市
const district = geoRes.data.result.address_component.district; // 区
const street = geoRes.data.result.address_component.street; // 街道
// 保存数据(按需选择)
longitude.value = locRes.longitude;
latitude.value = locRes.latitude;
location.value = address; // 把location改为存储具体地址而非经纬度
// 也可以自定义格式location.value = `${city}${district}${street}`;
// 提示定位成功并显示地址
uni.showToast({ title: `定位成功:${formattedAddress}`, icon: 'success', duration: 2000 });
console.log('完整地址:', address);
console.log('省市区:', province, city, district);
} else {
// 解析地址失败,降级显示经纬度
location.value = `${locRes.longitude},${locRes.latitude}`;
uni.showToast({ title: '定位成功,但无法解析地址', icon: 'none' });
}
},
fail: (geoErr) => {
uni.hideLoading();
// 接口请求失败,降级显示经纬度
location.value = `${locRes.longitude},${locRes.latitude}`;
uni.showToast({ title: '定位成功,地址解析失败', icon: 'none' });
console.error('地址解析失败:', geoErr);
}
});
},
fail: (locErr) => {
uni.hideLoading();
uni.showToast({ title: '定位失败,请检查权限', icon: 'none' });
console.error('定位失败:', locErr);
}
});
};
// const reLocate = () => {
// // 调用微信原生选择位置接口(自带地址解析,无调用上限)
// uni.chooseLocation({
// success: (res) => {
// // res.address = 具体地址XX市XX区XX街道XX小区
// // res.name = 地点名称XX小区
// longitude.value = res.longitude;
// latitude.value = res.latitude;
// location.value = res.address; // 显示具体地址
// uni.showToast({ title: `定位成功:${res.name}`, icon: 'success' });
// },
// fail: (err) => {
// // 处理权限拒绝/定位失败
// if (err.errMsg.includes('auth deny')) {
// uni.showModal({
// title: '需要定位权限',
// content: '请允许获取位置信息以显示具体地点',
// confirmText: '去设置',
// success: (modalRes) => {
// if (modalRes.confirm) {
// uni.openSetting({
// success: (settingRes) => {
// // 用户开启权限后重新定位
// if (settingRes.authSetting['scope.userLocation']) {
// reLocate();
// }
// }
// });
// }
// }
// });
// } else {
// uni.hideLoading();
// uni.showToast({ title: '定位失败,请重试', icon: 'none' });
// console.error('定位失败:', err);
// }
// }
// });
// };
// 上传所有图片
const uploadAllImages = async () => {