添加首页不是衡水市时重新定位按钮
This commit is contained in:
parent
e13cf87f87
commit
7b656c7a9f
@ -18,6 +18,21 @@
|
|||||||
color: #000;
|
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 {
|
.container {
|
||||||
background-color: #f9f9f9;
|
background-color: #f9f9f9;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
<view class="not_found_404">
|
<view class="not_found_404">
|
||||||
<text class="not_found_text">404</text>
|
<text class="not_found_text">404</text>
|
||||||
<text class="not_found_desc">当前城市暂未开通服务</text>
|
<text class="not_found_desc">当前城市暂未开通服务</text>
|
||||||
|
<button class="not_found_button" @click="obtainLocation">重新定位</button>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view v-else>
|
<view v-else>
|
||||||
@ -503,9 +504,41 @@ export default {
|
|||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
},
|
},
|
||||||
fail(err) {
|
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) {
|
selectCategoryFromDropdown(id) {
|
||||||
this.switchCategory(id);
|
this.switchCategory(id);
|
||||||
this.showDropdown = false;
|
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) {
|
onLoad(options) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user