diff --git a/pages/index/index.css b/pages/index/index.css index 884f465e..e0b663e3 100644 --- a/pages/index/index.css +++ b/pages/index/index.css @@ -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; } diff --git a/pages/index/index.vue b/pages/index/index.vue index 224eff8a..c95ae492 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -4,6 +4,7 @@ 404 当前城市暂未开通服务 + @@ -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) {