//获取微信步数
getWalkCounts:function(){
var that = this;
wx.login({
success(res) {
wx.getWeRunData({
success(res1) {
console.log(res1)
if (res1.errMsg == 'getWeRunData:ok') {
wx.request({
url: app.globalData.host + '/api/step/GetWeixinRun',
data: {
code: res.code,
encryptedData: res1.encryptedData,
iv: res1.iv
},
method: 'post',
success: function (ret) {
console.log("ret:"+JSON.stringify(ret));
var length = ret.data.data.stepInfoList.length;
that.timeStamp(ret.data.data.stepInfoList[length - 1].timestamp);
that.setData({
step_number: ret.data.data.stepInfoList[length - 1].step,
})
}
})
}
// 拿 encryptedData 到开发者后台解密开放数据
const encryptedData = res.encryptedData
// 或拿 cloudID 通过云调用直接获取开放数据
const cloudID = res.cloudID
console.log(cloudID)
}
})
}
})
},
timeStamp(timeStart) {
var date = new Date(parseInt(1562256000) * 1000).toLocaleString().replace(/:\d{1,2}$/, ' ');
console.log(date)
return date; //最后得到的是2018:12:03:14:08 2018年12月3日14点08分
}