添加首页不是衡水市时重新定位按钮

This commit is contained in:
赵毅 2025-09-09 18:00:49 +08:00
parent e13cf87f87
commit 7b656c7a9f
2 changed files with 73 additions and 1 deletions

View File

@ -18,6 +18,21 @@
color: #000;
}
.not_found_button {
width: 200rpx;
height: 50rpx;
background-color: #f6f7fb;
border-radius: 20rpx;
margin-right: 170rpx;
display: flex;
box-sizing: border-box;
align-items: center;
justify-content: center;
padding: 0 20rpx;
font-size: 26rpx;
margin: 30rpx auto 0;
}
.container {
background-color: #f9f9f9;
}

View File

@ -4,6 +4,7 @@
<view class="not_found_404">
<text class="not_found_text">404</text>
<text class="not_found_desc">当前城市暂未开通服务</text>
<button class="not_found_button" @click="obtainLocation">重新定位</button>
</view>
</view>
<view v-else>
@ -503,9 +504,41 @@ export default {
uni.hideLoading();
},
fail(err) {
console.log(err);
console.log('地图API解析地址失败:', err);
uni.showToast({
title: '定位失败,请检查网络',
icon: 'none'
});
uni.hideLoading();
}
});
},
fail(err) {
console.log('获取位置信息失败:', err);
if (err.errMsg.indexOf('auth deny') >= 0) {
uni.showModal({
title: '提示',
content: '需要您授权位置信息才能使用此功能',
confirmText: '去授权',
success: (res) => {
if (res.confirm) {
// #ifdef MP-WEIXIN
wx.openSetting();
// #endif
// #ifdef APP-PLUS
uni.openSetting();
// #endif
}
uni.hideLoading();
}
});
} else {
uni.showToast({
title: '定位失败,请重试',
icon: 'none'
});
uni.hideLoading();
}
}
});
},
@ -1037,6 +1070,30 @@ export default {
selectCategoryFromDropdown(id) {
this.switchCategory(id);
this.showDropdown = false;
},
//
obtainLocation() {
//
uni.showLoading({
title: '定位中...',
mask: true
});
//
uni.removeStorageSync('location');
//
try {
this.getUserLocation();
} catch (error) {
console.error('定位失败:', error);
uni.showToast({
title: '定位失败,请重试',
icon: 'none'
});
uni.hideLoading();
}
}
},
onLoad(options) {