微信小程序权限被禁后怎么重新调起


// 导航
  navigation() {
    var that = this;
    var qqmapsdk = new amapFile({
      key: 'key值'
    });
    let name = this.data.address
    let address = this.data.address
    qqmapsdk.geocoder({
      address: address,
      success: function (res) {
        // 经度lng  	纬度lat
        let latitude = res.result.location.lat
        let longitude = res.result.location.lng
        // console.log(res,'res')
        wx.getLocation({ //获取当前经纬度
          type: 'wgs84', //返回可以用于wx.openLocation的经纬度,官方提示bug: iOS 6.3.30 type 参数不生效,只会返回 wgs84 类型的坐标信息  
          success: function (res) {
            // console.log(res,'res2')
            // console.log(latitude,'latitude')
            // console.log(longitude,'longitude')
            wx.openLocation({ //​使用微信内置地图查看位置。
              latitude: latitude, //要去的纬度-地址
              longitude: longitude, //要去的经度-地址
              name: name,
              address: address,
              scale: 18
            })
          },
          fail:function(res){
            if(res.errMsg=="getLocation:fail auth deny"){
              that.showSettingToast()
            }
          }
        })
      },
      complete: res => {
        // console.log(res.result.location)
      }
    })
  },
  showSettingToast: function(e) {
    // console.log("1")
    wx.showModal({
     title: '提示!',
     showCancel: true,
     content: '未开启定位,是否去设置',
     success: function(res) {
      //  console.log(res,'res')
      if (res.confirm) {
       wx.navigateTo({
        url: '../setting/setting',
       })
      }
     }
    })
   },

setting页的代码

<view class="tips">请配置微信设置功能</view>
<button open-type="openSetting" type="primary">
    <view class="img">
        <image src="../../images/setting.png">
        </image>
    </view>设置
</button>
/* pages/setting/setting.wxss */
.tips{
    font-size:32rpx;
    color: #666666;
    padding: 24rpx 48rpx 120rpx;
}
button{
    padding: 0;
    width:420rpx !important;
    height:76rpx !important;
    /* line-height: 76rpx; */
    background:#0DAABF !important;
    border-radius:18rpx !important; 
    display: flex;
    align-items: center;
    justify-content: center;
}
.img{
    
    width: 34rpx;
    height: 34rpx;
    margin-right: 18rpx;
}
image{
    width: 100%;
    height: 100%;
    vertical-align: top;
    /* margin-top: 20rpx !important; */
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值