forked from nsjcy/frontEnd/nsjcy

liuwh
2020-04-27 4e44bc1fd7806a6c1611302120882b91d96640b5
SunshineLnsMinApp/app.js
@@ -12,9 +12,9 @@
    pageData: {},
    //url: 'https://nsjcy.hugeinfo.com.cn/nsjc-charge',
    // url: 'http://1p885086k1.iok.la/nsjc-charge',
     url: 'http://localhost:6060/nsjc-charge',
    //  url: 'http://localhost:6060/nsjc-charge',
    imgUrl: 'https://nsjcy.hugeinfo.com.cn/nsjc-charge',
    // url: 'http://nsjc.vaiwan.com/nsjc-charge',
    url: 'http://nsjc.vaiwan.com/nsjc-charge',
    // imgUrl: 'http://nsjc.vaiwan.com/nsjc-charge'
  },
  // 过滤数组
@@ -272,6 +272,63 @@
      }
      return age;
    }
  },
  getPermission: function(url) {
    wx.getLocation({
      success: function(res) {
        wx.navigateTo({
          url,
        })
      },
      fail: function() {
        wx.getSetting({
          success: function(res) {
            var statu = res.authSetting;
            if (!statu['scope.userLocation']) {
              wx.showModal({
                title: '是否授权当前位置',
                content: '需要获取您的地理位置,请确认授权,否则地图功能将无法使用',
                success: function(tip) {
                  if (tip.confirm) {
                    wx.openSetting({
                      success: function(data) {
                        if (data.authSetting["scope.userLocation"] === true) {
                          wx.showToast({
                            title: '授权成功',
                            icon: 'success',
                            duration: 1000
                          })
                          //授权成功之后,再调用chooseLocation选择地方
                          wx.getLocation({
                            success: function(res) {
                              wx.navigateTo({
                                url,
                              })
                            },
                          })
                        } else {
                          wx.showToast({
                            title: '授权失败',
                            icon: 'success',
                            duration: 1000
                          })
  }
                      }
                    })
                  }
                }
              })
            }
          },
          fail: function(res) {
            wx.showToast({
              title: '调用授权窗口失败',
              icon: 'success',
              duration: 1000
            })
          }
        })
      }
    })
  }
})