wx.getWeRunData({
success: async function (res) {
const { encryptedData, iv } = res
try {
const pc = new WXBizDataCrypt(appid, session_key)
const data = pc.decryptData(encryptedData, iv)
func(data)
} catch (e) {
console.log('session_key 失效,重新登录', e)
try {
const newSessionKey = await getWXSessionKey()
const pc = new WXBizDataCrypt(appid, newSessionKey)
const data = pc.decryptData(encryptedData, iv)
func(data)
} catch (err) {
func({ isFail: true })
}
}
},
fail (res) {
let day = uni.getStorageSync('noOpenRun')
let toDay = new Date().getDay()
if (day !== toDay) {
uni.setStorageSync('noOpenRun', toDay)
wx.showModal({
title: '提示',
content: '获取微信运动步数,需要微信步数权限',
success: function (res) {
if (res.confirm) {
wx.openSetting({})
}
}
})
}
func({ isFail: true })
}
})
没有和官方一样的
麻烦解答下
