修改样式

This commit is contained in:
zhouyanli
2026-04-29 09:07:18 +08:00
parent e3e74a1be0
commit 46c9f6dacc
6 changed files with 53 additions and 109 deletions

View File

@@ -105,107 +105,45 @@ const chooseImg = () => {
// 重新定位
// 定位并获取具体地点名称
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
// 调用微信原生选择位置接口(自带地址解析,无调用上限)
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' });
},
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: (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();
}
},
fail: (geoErr) => {
uni.hideLoading();
// 接口请求失败,降级显示经纬度
location.value = `${locRes.longitude},${locRes.latitude}`;
uni.showToast({ title: '定位成功,地址解析失败', icon: 'none' });
console.error('地址解析失败:', geoErr);
}
});
},
fail: (locErr) => {
}
}
});
} else {
uni.hideLoading();
uni.showToast({ title: '定位失败,请检查权限', icon: 'none' });
console.error('定位失败:', locErr);
uni.showToast({ title: '定位失败,请重试', icon: 'none' });
console.error('定位失败:', err);
}
}
});
};
// 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 () => {
if (imgList.value.length === 0) return [];

View File

@@ -68,7 +68,7 @@ const confirmSelect = () => {
display: flex;
flex-direction: column;
justify-content: space-between;
background: #fff;
background: #f9f9f9;
}
.house-list {
flex: 1;
@@ -78,13 +78,14 @@ const confirmSelect = () => {
justify-content: flex-start;
align-items: center;
padding: 15px 10px;
border: 1px solid #eee;
background-color: #fff;
border-radius: 8px;
margin-bottom: 10px;
}
.house-item.active {
border-color: #007aff;
background: #f0f8ff;
border: 1px solid #2F77FD;
}
.house-name {
font-size: 16px;
@@ -108,7 +109,8 @@ const confirmSelect = () => {
background: #007aff;
color: #fff;
border-radius: 8px;
font-size: 16px;
font-size: 28rpx;
margin-top: 20px;
margin-bottom: 20rpx;
}
</style>

View File

@@ -112,6 +112,8 @@ const sendToFriend = () => {
color: #fff;
border-radius: 8rpx;
height: 88rpx;
font-size: 32rpx;
font-size: 28rpx;
line-height: 88rpx;
}
</style>

View File

@@ -470,7 +470,7 @@ const resetForm = () => {
.submit-btn {
background-color: #007aff;
color: #fff;
font-size: 32rpx;
font-size: 28rpx;
height: 80rpx;
line-height: 80rpx;
border-radius: 8rpx;

View File

@@ -167,6 +167,7 @@ const goToQrcode = () => {
color: #fff;
border-radius: 8rpx;
height: 88rpx;
font-size: 32rpx;
font-size: 28rpx;
line-height: 88rpx
}
</style>

View File

@@ -73,8 +73,8 @@
<!-- 新增邀请按钮 -->
<view class="add-btn" @click="addInvitation">
<uni-icons type="plus" size="18" color="#fff"></uni-icons>
<text class="add-text">新增邀请</text>
<!-- <uni-icons type="plus" size="18" color="#fff"></uni-icons> -->
<text class="add-text">新增邀请+</text>
</view>
</view>
</template>
@@ -332,5 +332,6 @@ const addInvitation = () => {
}
.add-text {
margin-left: 5px;
font-size: 28rpx;
}
</style>