获取权限管理,以“微信步数计数”为例,直接上代码
注意步骤:
1、先判断scope.werun的权限是否打开
2、当开启权限还未拿到数据时,检查是否关注了“微信运动”公众号
wx.getSetting({
success: function (res) {
console.log(res);
if (!res.authSetting['scope.werun']) {
wx.showModal({
title: '提示',
content: '获取微信运动步数,需要开启计步权限',
success: function (res) {
if (res.confirm) {
wx.openSetting({
success: function (res) {
}
})
} else {
}
}
})
} else {
wx.getWeRunData({
success: function (res) {
console.log(res);
},
fail: function (res) {
wx.showModal({
title: '提示',
content: '开发者未开通微信运动,请关注“微信运动”公众号后重试',
showCancel: false,
confirmText: '知道了'
})
}
})
}
}
})
宁波微整医院http://www.iyestar.com/wzx/zscz/
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37