可以通过微信接口:wx.getWeRunData 获取用户过去三十天的微信运动步数。
前提:
使用这个接口有两个前提:
1. 需先调用wx.login接口进行登录 步数信息会在用户主动进入小程序时更新。
2. 调用前需要用户授权scope.werun
Page({
data: {
runData:[],
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
//1、调用小程序API:wx.login获取code和sessionKey;
var that = this;
wx.login({
success: function (resLogin) {
if (resLogin.code) {
wx.request({
url: 'http://localhost:9281/wxapp/onlogin',
data: { //传给后台参数code
code: resLogin.code
},
success: function (resSession) {
&n