收藏
回答

频繁调用 wx.getWeRunData 后端会一直返回运动数据为0的情况,这个怎么回事?

 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
                        });
                    }
                });
            }
        });
回答关注问题邀请回答
收藏

2 个回答

登录 后发表内容