赞
踩
- <view class="map" @tap="getLocation">
- <u-icon name="map" size="26" color="red"></u-icon>
- </view>
- getLocation() {
- const _this = this
- uni.getSystemInfo({
- success(res) {
- let locationEnabled = res.locationEnabled; //判断手机定位服务是否开启
- let locationAuthorized = res.locationAuthorized; //判断定位服务是否允许微信授权
- if (locationEnabled == false || locationAuthorized == false) {
- //手机定位服务(GPS)未授权
- uni.showModal({
- title:'授权',
- content:'获取授权失败,是否前往授权?',
- success:function(result){
- if(result.confirm){
- uni.openAppAuthorizeSetting()
- }
- },
- fail:function(){
- uni.showToast({
- title:'请前往设置中授权位置信息',
- icon:'none'
- })
- }
- })
- }else{
- uni.chooseLocation({
- success:function(response){
- console.log('位置名称:',response);
- _this.detailed = response.address
- }
- })
- }
- }
- })
- },

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。