const wxLoginInfo = await wxLogin();
wx.getWeRunData({
success: async (weRunData) => {
console.log('------------------------------------');
console.log(weRunData);
console.log('------------------------------------');
const res = await wx.api.setWechatSteps({
code: wxLoginInfo.code,
encryptedData: weRunData.encryptedData,
iv: weRunData.iv
});
if (res.cd == 0) {
this.setData({
wxSteps: res.data.step || 0
});
} else {
wx.showToast({
title: res.msg || res.data,
icon: 'none',
duration: 2000
});
}
},
fail: (err) => {
wx.getSetting().then((res) => {
if (!res.authSetting['scope.werun']) {
if (flag) return;
wx.showModal({
title: '',
content: '请先开启微信运动步数权限',
success(res) {
if (res.confirm) {
wx.openSetting();
}
}
});
} else {
console.log(err);
wx.showToast({
title: '获取微信步数失败',
icon: 'none',
duration: 2000
});
}
});
}
});
https://developers.weixin.qq.com/miniprogram/dev/framework/performance/api-frequency.html